Longest chain
The bitcoin longest chain rule means nodes follow the chain with the most work, not the most blocks. See how work is counted and why it matters.
By Dimitar Zurnov · Updated 4 Nov 2026
Adapted from Learn Me a Bitcoin by Greg Walker.
Nodes call the chain with the most work the longest chain, and they treat it as the valid history of bitcoin. Shorter or weaker chains are ignored. "Work" means the expected number of hashes it took to find each block. The total is called chainwork.
What makes a chain the longest?
Each block takes energy to mine, so each block adds some work to the chain. A chain's chainwork is the sum of the work in all of its blocks. The chain with the most chainwork wins, and that is the chain nodes keep.
A block's work depends on its target. A lower target is harder to hit, so it takes more hashes on average. The expected number of hashes for one block is 2^256 divided by the target plus one. Bitcoin Core's chain code uses this same measure of work.
To find the target, a node reads the bits value from the header. Bits is the target in a compact form, with one byte for an exponent and three bytes for a mantissa. The target is the mantissa times 256 to the power of the exponent minus 3.
How much work does one block carry?
The first 2,016 blocks all used the genesis target, so each one carried the same work. The genesis target is 0x00000000ffff0000000000000000000000000000000000000000000000000000. Dividing 2^256 by that target plus one gives:
2^256 / (target + 1) = 4,295,032,833 = 0x100010001
So one genesis-era block carries about 4.3 billion expected hashes. Four blocks in that period carry four times as much:
4 x 0x100010001 = 17,180,131,332 = 0x400040004
A simple way to picture the average: if you need a 1 on a 20-sided die, you expect to roll about 20 times. The same reasoning applies to a block, where the target is the winning range. A smaller range means more rolls on average.
Does the chain with the most blocks always win?
Usually it is, but not always. Difficulty changes, so one block can carry more work than another. Every block in one difficulty period carries the same work. When difficulty rises, the blocks in the new period each carry more work.
A chain with fewer blocks at a higher difficulty can hold more total work than a longer chain at a lower difficulty. Nodes follow the chain with the most work. A chain built with artificially low difficulty can have many blocks and still lose.
Early versions of the software compared chains by block count. That was easy to abuse, because anyone could make a chain long by setting the difficulty low. The rule was later changed to compare work.
Why do nodes follow the chain with the most work?
When every node follows the same rule, independent computers can agree on one history. Suppose two blocks are found at nearly the same time. Each node keeps the first one it sees. The next block to be found settles the question, because it extends one side and makes it the heaviest chain. Nodes on the other side switch to it in a chain reorganization.
The rule also protects old blocks. To rewrite a block, someone must build a chain with more work than the honest network has added since that block. The deeper a block sits, the more work a rewrite takes. That is why a 51% attack gets harder with depth.
Miners have a reason to follow the rule too. A block that ends up off the chain takes its reward with it. The reward also cannot be spent until the block has 100 blocks built on top of it, so miners want their block on the chain that everyone follows.
What happens to transactions outside the longest chain?
A transaction in a block that is not on the longest chain is not confirmed. Its outputs cannot be spent on the chain your node follows. Your node will not accept a new transaction that spends them, and it will not mine one. The confirmation page explains how to tell whether a transaction has been confirmed.
How many confirmations should you wait for?
Most reorgs reach only the top block or two. Waiting for a few blocks on top of your transaction makes it much safer. It does not make it final in an absolute sense, because a deeper reorg is possible in principle. The chain reorganization page explains where the six-confirmation rule of thumb comes from.
How do you check the chainwork?
With Bitcoin Core, bitcoin-cli getblockchaininfo shows the chainwork of your best chain in its chainwork field. bitcoin-cli getblock with a block hash shows the chainwork up to that block. The value is a long hexadecimal number. Compare chains by this number, not by block count.
bitcoin-cli getblockchaininfo
bitcoin-cli getblock <blockhash>
Summary
The longest chain is the chain with the most work, which is usually the one with the most blocks. Nodes follow it, so a network agrees on one history without trusting any single party. Because rewriting a block means outworking everyone who builds on it, the rule makes recent blocks easy to confirm and old blocks hard to replace.
In this section: Blockchain
Something look wrong? Tell us