Bitcoin Block Validation: Headers, Chainwork, and Consensus Checks
Bitcoin nodes use proof of work to compare competing histories, but they do not accept a chain merely because its headers claim substantial work. A fully validating node checks headers and blocks against consensus rules and tracks accumulated work on valid candidates.
Header-level checks
Headers link to predecessor hashes, encode a target through nBits, and must satisfy proof of work and applicable difficulty and timestamp constraints. Header-first synchronization can identify candidate chains before all associated block data has arrived.
What is chainwork?
Chainwork represents the cumulative expected work associated with a chain of headers. It is derived from proof-of-work targets, not from the raw number of blocks alone. A chain with more blocks does not necessarily represent more total work.
Block and transaction validation
After obtaining full block data, a node checks matters such as block structure, transaction syntax, coinbase rules, input availability, prevention of double spending, script and witness validity, value conservation, and applicable locktime and resource limits. The precise rules depend on the block's height and active consensus upgrades.
Valid chain selection
The relevant principle is selection of the valid chain with the most accumulated proof of work, not blind acceptance of the longest sequence of headers. If a higher-work candidate contains an invalid block, it cannot become the node's accepted valid chain merely by adding more work.
Reorganizations
When a competing valid branch accumulates more work, a node may reorganize its active chain. Transactions from disconnected blocks can return to the mempool if still eligible, or become conflicted. This is why applications distinguish mempool observation, block inclusion, and subsequent confirmations.
Why this matters to developers
A wallet, explorer, or payment processor should not treat an unverified header as equivalent to a fully validated block. APIs should expose the distinction between a peer's claim, local node validation, and confirmation depth. Correct trust boundaries matter as much as raw speed.
Primary references
Bitcoin Developer Guide — Block Chain: https://developer.bitcoin.org/devguide/block_chain.html
Bitcoin Core source: https://github.com/bitcoin/bitcoin
Bitcoin whitepaper: https://bitcoin.org/bitcoin.pdf
