From 42ece51026d815a0bf249671391ab2e7d6c53645 Mon Sep 17 00:00:00 2001 From: Muneeb Ali Date: Fri, 4 Nov 2016 16:39:06 -0400 Subject: [PATCH 1/2] include API token in broadcast tx --- pybitcoin/services/blockcypher.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/pybitcoin/services/blockcypher.py b/pybitcoin/services/blockcypher.py index 7d486d7..0db4268 100644 --- a/pybitcoin/services/blockcypher.py +++ b/pybitcoin/services/blockcypher.py @@ -1,4 +1,4 @@ -# -*- coding: utf-8 -*- +=# -*- coding: utf-8 -*- """ pybitcoin ~~~~~ @@ -69,12 +69,17 @@ def get_unspents(address, blockchain_client=BlockcypherClient()): def broadcast_transaction(hex_tx, blockchain_client): """ Dispatch a raw hex transaction to the network. """ + if not isinstance(blockchain_client, BlockcypherClient): raise Exception('A BlockcypherClient object is required') url = '%s/txs/push' % (BLOCKCYPHER_BASE_URL) - payload = json.dumps({'tx': hex_tx}) - r = requests.post(url, data=payload) + payload = {'tx': hex_tx} + + if blockchain_client.auth: + payload['token'] = blockchain_client.auth[0] + + r = requests.post(url, data=json.dumps(payload)) try: data = r.json() From f4bc327c7824e8dd95893892b9c56f3cf326df4c Mon Sep 17 00:00:00 2001 From: Muneeb Ali Date: Fri, 4 Nov 2016 16:41:35 -0400 Subject: [PATCH 2/2] remove typo --- pybitcoin/services/blockcypher.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pybitcoin/services/blockcypher.py b/pybitcoin/services/blockcypher.py index 0db4268..04dd5b6 100644 --- a/pybitcoin/services/blockcypher.py +++ b/pybitcoin/services/blockcypher.py @@ -1,4 +1,4 @@ -=# -*- coding: utf-8 -*- +# -*- coding: utf-8 -*- """ pybitcoin ~~~~~