mirror of
https://github.com/bitcoinbook/bitcoinbook
synced 2024-11-25 09:28:25 +00:00
17 lines
474 B
Python
17 lines
474 B
Python
|
from bitcoin.rpc import RawProxy
|
||
|
|
||
|
p = RawProxy()
|
||
|
|
||
|
# Alice's transaction ID
|
||
|
txid = "0627052b6f28912f2703066a912ea577f2ce4da4caa5a5fbd8a57286c345c2f2"
|
||
|
|
||
|
# First, retrieve the raw transaction in hex
|
||
|
raw_tx = p.getrawtransaction(txid)
|
||
|
|
||
|
# Decode the transaction hex into a JSON object
|
||
|
decoded_tx = p.decoderawtransaction(raw_tx)
|
||
|
|
||
|
# Retrieve each of the outputs from the transaction
|
||
|
for output in decoded_tx['vout']:
|
||
|
print(output['scriptPubKey']['addresses'], output['value'])
|