TeachMeBitcoin

The Anatomy of a Block: Headers, Transactions, and Witnesses

From TeachMeBitcoin, the free encyclopedia Reading time: 2 min

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

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."



☕ Help support TeachMeBitcoin

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:

Ethereum: 0x578417C51783663D8A6A811B3544E1f779D39A85
Bitcoin: bc1q77k9e95rn669kpzyjr8ke9w95zhk7pa5s63qzz
Solana: 4ycT2ayqeMucixj3wS8Ay8Tq9NRDYRPKYbj3UGESyQ4J
Address copied to clipboard!