Skip to content

Instantly share code, notes, and snippets.

@miohtama
Created April 11, 2014 14:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save miohtama/10474410 to your computer and use it in GitHub Desktop.
Save miohtama/10474410 to your computer and use it in GitHub Desktop.
Extract receiving addresses from a Bitcoin transaction.
"""
Utils for extracting information about bitcoin transactions.
"""
import json
from django_bitcoin.utils import bitcoind
def get_output_address(txid):
""" Extract receiving addresses from a Bitcoin transaction.
"""
raw = bitcoind.bitcoind_api.getrawtransaction(txid)
#print raw.keys()
#print raw
txdata_raw = bitcoind.bitcoind_api.decoderawtransaction(raw)
#print txdata_raw
#for itx in txdata_raw["vin"]:
# print itx
print txdata_raw.keys()
print
print txdata_raw
print
for output in txdata_raw["vout"]:
print output
scriptPubKey = output.get("scriptPubKey", None)
if scriptPubKey:
for address in scriptPubKey.get("addresses", []):
print address
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment