Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add 2fa token support for sending BTC #20

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion coinbase/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,8 @@ def request(self, from_email, amount, notes=''):
return CoinbaseTransaction \
.from_coinbase_dict(response_parsed['transaction'])

def send(self, to_address, amount, notes='', user_fee=None, idem=None):
def send(self, to_address, amount, notes='', user_fee=None, idem=None,
token_2fa=None):
"""
Send BitCoin from this account to either an email address or a BTC
address
Expand All @@ -398,6 +399,8 @@ def send(self, to_address, amount, notes='', user_fee=None, idem=None):
transaction with the same idem parameter already exists for this
sender, that previous transaction will be returned and a new one will
not be created. Max length 100 characters.
:param token_2fa: Optional two factor token which might be necessary
depending on user permissions
:return: CoinbaseTransaction with status and details
:raise: CoinbaseError with the error list received from Coinbase on
failure
Expand Down Expand Up @@ -426,6 +429,9 @@ def send(self, to_address, amount, notes='', user_fee=None, idem=None):
if idem is not None:
request_data['transaction']['idem'] = str(idem)

if token_2fa is not None:
self.session.headers.update({'CB-2FA-Token': token_2fa})

response = self.session.post(url=url, data=json.dumps(request_data))
response_parsed = response.json()

Expand Down