THAMER
Sovereign Bitcoin Wallet

WALLET AI BITCOIN

Your Bitcoin Wallet. Your Keys. Your Engine.

Self-hosted Bitcoin software built for developers, applications, and AI agents.

CREATE WALLET

Bitcoin Block Validation Explained: Headers, Transactions, and Consensus Checks

permalink THAMER
#bitcoin-block-validation#block-checks#consensus-rules#proof-of-work

A Bitcoin full node does not accept a block simply because a miner announces it. It independently checks the block against consensus rules and the history of the chain it considers valid. This distinction is essential: proof of work orders candidate histories, but does not waive validation.

Header checks come first

A block header commits to a previous block hash, a Merkle root, a timestamp, an encoded target (nBits), a nonce, and a version. The node checks the proof-of-work hash against the decoded target, verifies that the target is permitted for that height and network, and checks contextual header rules. A header can be valid while its block body is invalid or unavailable.

Block structure and commitments

The block body must have the correct transaction structure, including exactly one coinbase transaction in the first position. The transaction identifiers must match the header Merkle root. Where SegWit applies, the witness commitment must also be consistent with the witness data. Duplicate inputs, malformed transactions, invalid amounts, and other consensus failures can invalidate the block.

Contextual transaction validation

The node checks each transaction against the UTXO set as updated in block order. Every spent outpoint must exist and be unspent; the unlocking data must satisfy the relevant Script and signature rules. A transaction cannot spend an output twice, whether within its own inputs or across the same block. Input value must cover output value, and outputs must remain within the monetary range.

Subsidy and coinbase accounting

The coinbase may claim no more than the permitted block subsidy plus fees from included transactions. The subsidy follows the halving schedule. Coinbase outputs must mature for 100 blocks before being spent, under consensus rules. These checks prevent miners from inventing extra spendable coins.

Validity is not the same as relay policy

Mempool admission may reject transactions for policy reasons, including minimum relay fees or nonstandard scripts. Such policy rejection does not automatically mean a transaction is invalid inside a block. Conversely, a transaction that once sat in a mempool can become invalid when a conflicting spend is confirmed.

Example validation sequence

  1. Receive a candidate header and check proof of work and chain context.
  1. Obtain the full block and verify structure and commitments.
  1. Validate each transaction, its inputs, scripts, and values.
  1. Check coinbase subsidy plus total fees.
  1. Connect the block to chainstate only after all required checks succeed.

This is a conceptual sequence; implementations optimize and reorder safe checks. Nodes can also maintain headers for competing chains without accepting their blocks as valid.

Primary references

Bitcoin Developer Reference — Block Chain: https://developer.bitcoin.org/reference/block_chain.html
Bitcoin Core validation source: https://github.com/bitcoin/bitcoin/blob/master/src/validation.cpp
BIP141 — Segregated Witness: https://github.com/bitcoin/bips/blob/master/bip-0141.mediawiki

Questions & Answers

Explore all questions →

Latest from the Lab

THAMER illustrated developer portrait and signature

ABOUT THE DEVELOPER

Independent Software Developer specializing in Bitcoin Script, Golang, and AI Agents.

Software engineering · Independent research · Open-source projects