Protocol & Mining
How a node verifies a transaction
Protocol referenceSource: Bitcoin Developer Guide, P2P Network and Block ChainDescribes the reference implementation's validation path; individual node policies vary.
From mempool to block
A transaction begins as a message. A wallet signs it and hands it to one or more nodes, and those nodes pass it on to their peers. A node that receives a transaction it has not seen before runs a set of checks before deciding whether to keep it and relay it onward. If the transaction passes, it is held in the node's mempool, a temporary store of transactions that are valid but not yet confirmed. If it fails, it is dropped, and the node does not tell the network about it.
The checks at this stage are of two kinds, and the difference matters more than any individual rule. Some checks are consensus rules: the transaction must spend outputs that exist and are unspent, its signature must satisfy the spending condition, and the total value of its outputs must not exceed the total value of its inputs. A transaction that breaks one of these rules can never be valid in any block, on any node, ever. Other checks are policy: whether the transaction's fee rate is high enough to be worth relaying, whether it is too large, whether it uses a script form the node considers standard. A transaction that fails a policy check is not invalid. It is merely unwelcome at this particular node.
The second pass happens when a block arrives. A node that receives a candidate block does not trust the miner who produced it. It re-validates every transaction in the block from scratch, against the state of the chain as the node understands it, and it checks the block's own header: that the proof of work meets the difficulty target, that the previous block hash matches the tip the node already has, and that the coinbase transaction claims no more than the current subsidy plus the fees of the transactions included. Only if all of that holds does the node accept the block and build on it.
Consensus rules and node policy
A consensus rule is a rule whose violation makes a block invalid. The block subsidy may not exceed the scheduled amount. A transaction may not spend an output that does not exist or has already been spent. A block's proof of work must meet the target set by the difficulty adjustment. These rules are enforced identically by every node, and a node that accepted a block breaking one of them would compute a different chain from everyone else and be ignored. Consensus rules are what make the network a network rather than a collection of opinions.
Policy is everything else. A node's mempool is its own; it decides what it will hold and relay, and different nodes decide differently. The default policy in Bitcoin Core sets a minimum fee rate below which a transaction will not be relayed, limits on the size and standardness of scripts, and rules about how many unconfirmed ancestors a transaction may have. These settings are not part of the protocol and can be changed by anyone running a node. A transaction that one node refuses to relay may be perfectly acceptable to another, and a miner is free to include it in a block regardless.
The practical consequence is that policy shapes what most transactions experience without ever being able to make a valid transaction impossible. A very low fee transaction may sit unrelayed for a long time, but it is not invalid, and if a miner chooses to include it the network will accept the block. This is why fee estimation is a matter of local judgement rather than a protocol constant, and why the mempool page describes a node-local structure rather than a global pool.
Why every node checks everything
The design choice that makes this work is that validation is not delegated. A node does not ask a trusted server whether a block is valid, and it does not accept a block because most other nodes seem to have accepted it. It checks the block itself, using rules it enforces independently, and it will reject a block that the rest of the network has accepted if that block breaks a rule it knows. The cost is that every node does the same work, which is wasteful in the narrow sense. The benefit is that no participant has to trust any other participant's word about the state of the ledger.
This is what people mean when they say that running a node is how you verify your own money. A wallet that queries someone else's server is trusting that server to report the chain honestly. A node that validates for itself is not. The two arrangements look similar from the outside and are quite different underneath, and the difference is entirely a matter of who performs the checks described above.
The block size and weight page explains the limits a block must respect, and the Script page covers the language a node evaluates when it checks a spending condition.
Sources
- Bitcoin Developer Guide, P2P Network — transaction relay and the mempool.
- Bitcoin Developer Guide, Block Chain — block validation and the consensus rules a block must satisfy.
- Bitcoin Core, policy documentation — the relay policy that is deliberately not consensus.
Related reading
- Protocol, Transactions & MiningThe supply schedule, transaction mechanics and mining economics behind the price.
- Proof of WorkThe hash puzzle, the target and nonce, and why accumulated work secures the chain.
- Difficulty AdjustmentThe 2,016-block retarget, its caps, and the ten-minute target it defends.
- HashrateWhat hashrate measures, why it is estimated, and how it differs from difficulty.
- Mining PoolsPooled hash rate, share accounting, payout schemes and centralisation.
- Miner RevenueThe block subsidy plus fees, and how the mix changes across subsidy epochs.