Learning objectives
- Read and interpret block and chain data using Bitcoin Core commands
- Understand chain tips and how re-orgs occur in regtest
- Track transaction confirmations and understand depth
- Inspect the mempool for unconfirmed transactions
Reading block data
After mining blocks in regtest or syncing a mainnet/testnet node, you can inspect block data using several bitcoin-cli commands. Get the hash of the most recent block:- Height
- Timestamp
- Version
- Merkle root
- Previous block hash
- Nonce
- Chainwork
Using getchaintips and understanding chain re-orgs
The command getchaintips returns all known tips of the blockchain:Understanding confirmations and depth
A transaction’s confirmation count is the block that includes it plus every block on top of that block. To see how many confirmations a transaction has (replace <txid> with an actual transaction ID):- confirmations: number of blocks since inclusion, counting the block it was mined in
- blockhash: which block it was mined in
Inspecting mempool transactions
The mempool holds transactions waiting to be mined. In regtest, it’s typically empty unless you send a transaction before mining. List all mempool transactions:- Fee
- Size
- Ancestor/descendant count
- Time in pool
-persistmempool=0. A plain restart keeps it, because the node saves the mempool to mempool.dat.
Activity
- Generate five blocks and get the latest block hash
- Use getblock and getblockheader to inspect the block
- Send a transaction and observe it in the mempool before mining.
- Mine one block and check the transaction’s confirmation count.
- Invalidate the block using invalidateblock , then, inspect with getchaintips