version details:
- Ubuntu 18.04
- Python
2.73.6.7- library
- python-bitcoinlib
- sudo apt-get install libssl-dev
pip install python-bitcoinlibor or pip3 install python-bitcoinlib
- pycoin
- python-bitcoinlib
- library
- Bitcoin Core 0.16.3
- code
- rpc_block.py
- rpc_transaction.py
- code
- Text Editor
Nano 2.5.3- Leafpad
- Sublime or equivalent
libssl-dev is needed to handle SSL and TLS cryptographic protocols
The best way to learn coding is to review examples available on the internet and referencing syntax to the official documentation – python-bitcoinlib Documentation
Let’s review 2 methods:
- getblockhash(height)
- Return hash of block in best-block-chain at height.
- Raises IndexError if height is not valid.
- getrawtransaction(txid, verbose=False)
- Return transaction with hash txid
- Raises IndexError if transaction not found.
- verbose – If true a dict is returned instead with additional information on the transaction.
- Note that if all txouts are spent and the transaction index is not enabled the transaction may not be available
- Exercise #1:
- design a GUI allowing for the
- input of the blockheight
- output of the corresponding total output (BTC)
- GUI to have Label, grid, messagebox
- use tkinter, bitcoin.rpc/RawProxy
- design a GUI allowing for the
The idea is to extract a list of all transaction IDs in the block. Next, to iterate through each transaction ID in the block for txid and drill down to the output.
Like so …

- Exercise #2a:
- design a GUI / command line interface (bitcoin-cli) to understand the following methods
- getblockchaininfo
- bestblockhash
- getwalletinfo
- getblockhash
- getrawtransaction txid
- decoderawtransaction
- getblockchaininfo
- GUI to have
- Label, grid, messagebox
- tkinter, bitcoin.rpc/RawPro
- design a GUI / command line interface (bitcoin-cli) to understand the following methods
- Exercise #2b:
- design a GUI / command line interface (bitcoin-cli) to trace the history of a particular transaction through its txid
- determine its blockid
- run node with txindex=1 in the configuration
- bitcoind -reindex
- obtain blockhash
(use an example from the internet and verify the data points programmatically for consistency)- bitcoin-cli getrawtransaction [txid]
1
- bitcoin-cli getrawtransaction [txid]
alternatively, obtain its hash by manually obtaining blockid from the internetbitcoin-cli getblockhash[blockid]- bitcoin-cli getrawtransaction [txid] 1
- it is equivalent to decoderawtransaction
- get block details
- bitcoin-cli [blockhash]
- validate / search for a txid is recorded in the list (tx) the said block
- verify whether the hash of the said transaction is also its txid
- run node with txindex=1 in the configuration
- obain raw transaction of txid
- bitcoin-cli getrawtransaction [txid]
- decode the raw transaction
- bitcoin-cli decoderawtransaction [ ]
- bitcoin-cli decoderawtransaction [ ]
- view and interpret the details
- txid
- hash
- vin
- txid (previous transaction)
- vout
- can have more than 1 output
- for this exercise the txid example has only 1 previous output
scripSig
- vout
- value
- n
scripPubKey- address
- tie in the values
- Input = Outputs + Mining Fees
- GUI to have
- Label, grid, messagebox
- tkinter, bitcoin.rpc/RawPro
- Label, grid, messagebox
Like so …
