How the 21 Million Bitcoin Cap Is Defined and Enforced

·

Most people familiar with Bitcoin know its supply is predictable and will never exceed 21 million BTC. Strictly speaking, since the protocol operates in the smallest monetary unit (satoshis), the cap is 2,099,999,976,900,000 sats.

But how is this limit defined? And how is it guaranteed to remain unbroken?

Some might first look for answers in the Bitcoin whitepaper, but it’s not there (along with many other protocol details!).

As one expert notes: “Bitcoin whitpaper fundamentalists should know the following aren’t in the whitepaper: multisig, mining pools, the 21 million BTC cap, GPU/ASIC mining, 10-minute block intervals, HD wallets, the chain with the most proof-of-work being the best—not the longest, etc.”

You might also search the Bitcoin Core codebase for “21000000.” You’ll find a MAX_MONEY constant, but it’s not directly related to the total supply!

A note in the code clarifies: “Note that this constant is not the total money supply… In the current Bitcoin protocol, the total money supply is actually slightly less than 21 million BTC for several reasons. This constant is more of a sanity check. Since it’s used in consensus-critical validation code, the exact value of MAX_MONEY is also consensus-critical. In rare scenarios, like an overflow bug allowing currency creation, this constant could cause a fork.”

So how is the cap actually enforced? It might be less direct than you think.

An Implicit, Not Explicit, Limit

A common misconception is that Bitcoin regularly checks whether the total supply is below 21 million. In reality, Bitcoin Core has no such explicit check. Why? Summing over 75 million UTXOs would be computationally intensive. The 21 million cap is implicit, not explicit.

Instead of thinking of Bitcoin’s supply as a point-in-time check, view it as a geometric series with a moving cap. We don’t need to know the exact number of bitcoins in existence—we only care that it’s less than the expected amount. The series describing this upper limit can be expressed with this equation:

As illustrated:

50 * 210,000
+ 25 * 210,000
+ 12.5 * 210,000
…
+ 0.00000002 * 210,000
+ 0.00000001 * 210,000
= 20,999,999.9769

The Bitcoin implementation controls issuance by verifying that each new block doesn’t create more than the allowed block reward. Code in the validation logic sums the output denominations of the coinbase transaction—the first transaction in a block and the only one that can mint new coins.

You might notice it also accounts for transaction fees. Why? Because fees aren’t newly created bitcoin—they already exist and are paid by users to miners. Similarly, it’s correct to check that the coinbase output sum minus the block’s fees is less than or equal to the allowed reward.

So how is Bitcoin’s emission curve defined in the protocol? It’s just five lines of code. Two lines cover an edge case that won’t occur until around block height 13,440,000 (approximately the year 2265). You can learn about the logic behind line 1157 in BIP-42.

For any block height, we can easily calculate its position on the emission curve/geometric series. We only need to know how many halvings have occurred (line 1155), then multiply the original block reward (50 BTC) by (1/2) to the power of that number—which is what the fancy bit-shift operation on line 1162 does.

Besides checking block rewards, we must also prevent unexpected currency creation outside coinbase transactions.

The first method ensures every transaction input exists and is spendable. You’ll find this check in Bitcoin Core’s CheckTxInputs function.

This is also the most basic check in the Bitcoin protocol—preventing double-spending. If money could be spent twice, it could inflate the supply arbitrarily.

We also perform sanity checks on input values to ensure they aren’t negative and don’t overflow. Both scenarios could create new currency, and early Bitcoin history actually had an overflow incident!

Another critical validation is that for every non-coinbase transaction, the sum of output denominations must be less than or equal to the sum of input denominations. A higher output would mean new currency was created out of thin air. The same validation function performs this check.

These are all key checks preventing arbitrary inflation of Bitcoin’s money supply. Additionally, mechanisms like difficulty adjustment control inflation on a human timescale. 👉 Explore more about Bitcoin's protocol mechanics

Explicit Verification

As noted, summing all bitcoin holdings every time we want to verify supply rules would be resource-intensive. But a more explicit verification is still possible—you simply sum the denominations of all UTXOs.

Bitcoin Core provides a convenient function for this total supply audit: gettxoutsetinfo.

At the time of writing, the Bitcoin network has about 80 million UTXOs, so running this function may take one to two minutes, depending on your hardware.

My node powers the statoshi.info dashboard, which automatically calls this function after each new block. The returned currency amount is stored in a database and used to generate this chart.

That’s it! Bitcoin’s money supply is both broadly predictable and verifiable. The preceding explanation is essentially a detailed description of just a few dozen lines of code.

Frequently Asked Questions

People often have additional questions about Bitcoin’s supply limit.

Can the 21 million cap be changed?

Technically, yes. But it’s also a governance and incentive problem. Anyone can change the cap in their own node—the hard part is convincing everyone else to use the same rules.

Why 21 million and not some other number?

As one developer put it: “Q: Why did Satoshi choose 21 million as the cap? A: The constraining factor is the maximum value a 64-bit integer can represent (18,446,744,073,709,551,615), and 21,000,000 BTC would be represented as 2,100,000,000,000,000 sats.”

What happens after all 21 million BTC are mined?

Miners simply won’t mint new coins anymore—they can continue collecting transaction fees. That’s why new currency is called the “block subsidy”—it helped bootstrap the system when transaction volume was low. As Bitcoin adoption grows, demand for limited block space will increase, and so will fees.

How many bitcoins actually exist or are lost?

Counting existing UTXOs is easy, but deeper analysis shows some coins will never be used, some are provably unspendable, and others are possibly unspendable (but uncertain). One analysis suggested 182 BTC are possibly lost and 1.5 million are surely lost (as of block height 600,000).