Module 6: Blocks and Blockchain State
Learning Objectives
By the end of this module, you will:
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:
Retrieve full block data using the hash:
To get just the header:
This includes:
Height
Timestamp
Version
Merkle root
Previous block hash
Nonce
Chainwork
Get block hash by height:
Example:
Using getchaintips and Understanding Chain Re-orgs
The command getchaintips returns all known tips of the blockchain:
This is useful in regtest when you're simulating chain reorganizations. For example, if you invalidate a block:
Then generate a longer competing chain (replace <miner_address> with your mining address):
Your node will adopt the longer chain tip, causing a re-org. This is how Bitcoin resolves consensus forks.
Understanding Confirmations and Depth
A transaction's confirmation count is equal to the number of blocks on top of the block that includes it.
To see how many confirmations a transaction has (replace <txid> with an actual transaction ID):
You’ll see:
confirmations: number of blocks since inclusion
blockhash: which block it was mined in
Alternatively, use :
To simulate confirmations in regtest, simply mine more blocks (replace <miner_address> with your mining address):
This simulates time passing and increases confirmation depth instantly.
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:
Get details of a specific mempool transaction (replace <txid> with an actual transaction ID):
This shows:
Fee
Size
Ancestor/descendant count
Time in pool
You can clear the mempool by restarting the node or by mining a block that confirms the pending transactions.
Activity
Generate five blocks and get the latest block hash
Use getblock and getblockheader ti 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