TeachMeBitcoin

The Skeleton of Truth: Exploring `getblockheader`

From TeachMeBitcoin, the free encyclopedia Reading time: 2 min

The Skeleton of Truth: Exploring getblockheader

Sometimes you don't need the whole book; you just need to see the cover. In Bitcoin, the cover of a block is called the Header. It is a tiny, 80-byte piece of data that contains all the cryptographic proof needed to verify the block. The command for this is getblockheader. It is the "Skeleton of Truth," the "Lightweight Protocol of the Bridge."

Analyzing the "Skeleton Retrieval" Code

In the source code (src/rpc/blockchain.cpp), the getblockheader command fast because it only reads from the node's memory-based index.

/**
 * This function retrieves ONLY the "Skeleton" (the header) of a block.
 */
static RPCMethod getblockheader()
{
 return RPCMethod{
 "getblockheader",
 "Returns an Object with information about blockheader.\n",
 {
 {"blockhash", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, "The block hash"},
 {"verbose", RPCArg::Type::BOOL, RPCArg::Default{true}, "true for JSON, false for hex bytes"},
 },
 // ... (Example omitted)
 [](const RPCMethod& self, const JSONRPCRequest& request) -> UniValue
{
 uint256 hash(ParseHashV(request.params[0], "hash"));
 ChainstateManager& chainman = EnsureAnyChainman(request.context);
 const CBlockIndex* pblockindex = WITH_LOCK(cs_main, return chainman.m_blockman.LookupBlockIndex(hash));

 if (!pblockindex) throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Block not found");

 return blockheaderToJSON(*chainman.ActiveChain().Tip(), *pblockindex, chainman.GetConsensus().powLimit);
}

Explaining the Logic to a Non-Coder

The Power of the Header

The header is what makes Bitcoin "Scale." Because it is so small, even a mobile phone can download all the headers in history and verify the chain without needing 500GB of space. This is SPV (Simplified Payment Verification). The header is the "Concentrated Essence" of Bitcoin's security. It is the "Unbreakable Link" between the past and the present.


☕ 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!