Skip to content

Commit d8ea7be

Browse files
committed
add 2fa token support for sending BTC
1 parent 7cf13bc commit d8ea7be

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

coinbase/__init__.py

+7-1
Original file line numberDiff line numberDiff line change
@@ -384,7 +384,8 @@ def request(self, from_email, amount, notes=''):
384384
return CoinbaseTransaction \
385385
.from_coinbase_dict(response_parsed['transaction'])
386386

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

432+
if token_2fa is not None:
433+
self.session.headers.update({'CB-2FA-Token': token_2fa})
434+
429435
response = self.session.post(url=url, data=json.dumps(request_data))
430436
response_parsed = response.json()
431437

0 commit comments

Comments
 (0)