How Bitcoin's Source Code Defines Its 21 Million Supply Cap

·

Bitcoin's 21 million supply cap is a cornerstone of its monetary policy, yet critics often question how this limit is enforced within the code. While the cap isn't stated in plain language, the rules governing bitcoin's issuance are mathematically verifiable through its open-source protocol.

The Foundation: Block Subsidies and Halvings

All new bitcoin enters circulation via block subsidies, which are part of the block reward miners receive for validating transactions. These subsidies follow a strict schedule defined in Bitcoin's source code, ensuring predictable scarcity.

Key Components:

Verifying the Supply Cap

1. The GetBlockSubsidy Function

This critical function calculates mining rewards by:

  1. Determining the current halving epoch
  2. Applying bitwise right-shift operations to cut subsidies
  3. Returning the adjusted reward amount
CAmount GetBlockSubsidy(int nHeight, const Consensus::Params& consensusParams) {
    int halvings = nHeight / consensusParams.nSubsidyHalvingInterval;
    if (halvings >= 64) return 0;
    CAmount nSubsidy = 50 * COIN;
    nSubsidy >>= halvings;
    return nSubsidy;
}

How it works:

2. Binary Arithmetic in Action

Each right-shift operation truncates the binary representation of the subsidy:

HalvingBinary ValueBTC Reward
010010101000000101111100100000000050.00000000
11001010100000010111110010000000025.00000000
31001010100000010111110010000006.25000000
3310.00000001

👉 Explore Bitcoin's halving schedule in depth

The Path to 21 Million

Calculating the total supply involves summing all possible block subsidies:

  1. 210,000 blocks per epoch
  2. 33 halvings until subsidy reaches 1 satoshi
  3. Final epoch: 6,930,000 blocks (33 × 210,000) produce remaining coins

Total Supply Calculation:

(210,000 × 50) + (210,000 × 25) + ... + (210,000 × 0.00000001) 
= 20,999,999.9769 BTC

Adjusting for unspendable genesis coins and early bugs, the actual circulating supply is approximately 20,999,817 BTC.

FAQ: Addressing Common Questions

Q: Could Bitcoin's code be changed to increase the 21M cap?
A: Such a change would require near-unanimous consensus among users, miners, and nodes—effectively impossible without abandoning Bitcoin's core value proposition.

Q: Why does Bitcoin use binary shifts instead of simple division?
A: Bitwise operations are computationally efficient and prevent floating-point rounding errors in the code's integer-based system.

Q: What happens when all 21 million are mined?
A: Miners will earn income solely from transaction fees, with the last bitcoin expected around 2140.

Q: How accurate is the 21M prediction?
A: The actual total will be slightly less due to lost coins and early protocol quirks.

For those interested in Bitcoin's monetary policy, understanding these technical safeguards reinforces confidence in its predictable scarcity. 👉 Learn more about Bitcoin's economic design