Skip to content
This repository was archived by the owner on Mar 26, 2025. It is now read-only.

include API token in broadcast tx #57

Open
wants to merge 2 commits 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
9 changes: 7 additions & 2 deletions pybitcoin/services/blockcypher.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down