Created
April 11, 2014 14:41
-
-
Save miohtama/10474410 to your computer and use it in GitHub Desktop.
Extract receiving addresses from a Bitcoin transaction.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
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 txdata_raw | |
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