How Bitcoin Halving Works

The code behind Bitcoin's deflationary economics

The Core Mechanism

Bitcoin's halving is a protocol-level mechanism that reduces the reward miners receive for adding new blocks to the blockchain. This reduction occurs every 210,000 blocks, which is approximately every four years at Bitcoin's target rate of one block every 10 minutes.

          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;
            }
        

This function calculates how many bitcoins miners receive as a reward, cutting the amount in half every 210,000 blocks.

How It Works

Calculate Halvings

The code divides the current block height by the halving interval (210,000) to determine how many halvings have occurred.

At block 840,000 (April 2024): 840,000 ÷ 210,000 = 4 halvings

Apply Right Shift

The bitwise right-shift operation (>>=) divides the initial subsidy by 2 for each halving that has occurred.

50 BTC >> 4 = 3.125 BTC (current reward)

Current Status

Reward Schedule

  • 2009-2012: 50 BTC
  • 2012-2016: 25 BTC
  • 2016-2020: 12.5 BTC
  • 2020-2024: 6.25 BTC
  • 2024-2028: 3.125 BTC (current)
  • 2028-2032: 1.5625 BTC (next)

Economic Impact

Each halving reduces the rate of new Bitcoin creation, increasing scarcity and historically leading to price appreciation.

By 2140, all 21 million bitcoins will have been mined, and miners will be sustained solely by transaction fees.