The Anatomy of a Block: Headers, Transactions, and Witnesses
The Anatomy of a Block: Headers, Transactions, and Witnesses
To truly understand the blockchain, we must look at how a block is "Built." A block is composed of three parts: the Header, the Transaction List, and the Witness Data. This structure is the result of the SegWit upgrade. It is the "Engineering Mastery" of the Bitcoin bridge.
Analyzing the "Dissection" Logic
In the function blockToJSON (found in src/rpc/blockchain.cpp), we see how the node calculates the different "Weights" of the block.
/**
* This function is the "Block Dissector."
*/
UniValue blockToJSON(BlockManager& blockman, const CBlock& block, const CBlockIndex& tip, const CBlockIndex& blockindex, TxVerbosity verbosity, const uint256 pow_limit)
{
UniValue result = blockheaderToJSON(tip, blockindex, pow_limit);
// Physical Size
result.pushKV("size", ::GetSerializeSize(TX_WITH_WITNESS(block)));
// Economic Weight (SegWit Metric)
result.pushKV("weight", ::GetBlockWeight(block));
// Transaction IDs
UniValue txs(UniValue::VARR);
for (const auto& tx : block.vtx) txs.push_back(tx->GetHash().GetHex());
result.pushKV("tx", std::move(txs));
return result;
}
Explaining the Anatomy to a Non-Coder
-
weight: Imagine a block is a truck. Before 2017, the truck had a limit of 1 Megabyte. After SegWit, we changed the rules to measure "Weight" instead. This allowed us to carry more data (the witness signatures) without making the truck physically bigger for old observers. It is the "Capacity Optimization of the Core." -
tx: This is the "List of Events." Each transaction is a transfer of value. The bridge lists their IDs so you can go and investigate them individually. It is the "Inventory of the Block."
The Unforgeable Record
The anatomy of a block is designed for "Total Verification." The header links to the previous block, the merkle root links to the transactions, and the witness data links to the signatures. It is a "Web of Proof" where no single thread can be changed without breaking the whole thing. It is the "Biological Reality of the Ledger."
TeachMeBitcoin is an ad-free, open-source educational repository curated by a passionate team of Bitcoin researchers and educators for public benefit. If you found our articles helpful, please consider supporting our hosting and ongoing content updates with a clean donation: