Skip to content

Instantly share code, notes, and snippets.

@leto
Last active Aug 2, 2020
Embed
What would you like to do?
Bitcoin Halving Calculations

Bitcoin Halving Is Not Every Four Years!

It's close, but not exactly! Let's discover why.

Block Time

Bitcoin has a block time of 600 seconds (10 minutes).

Halving Interval

The internals of Bitcoin uses the concept of blocks, not calendar years or timestamps. The halving interval of Bitcoin is actually defined as every 210,000 blocks. 210,000 blocks of 600 seconds gives us exactly 126,000,000 seconds per halving.

This is called nSubsidyHalvingInterval on line 66 of src/chainparams.cpp

consensus.nSubsidyHalvingInterval = 210000;

Seconds in a year

The number of seconds in a year is 60*60*24*365=31,536,000. Multiplying by four gives 126,144,000 seconds in four years, ignoring leap years and leap seconds.

Bitcoin Halving is 3.9954 yrs

Dividing 126,144,000 by 31,536,000 seconds gives us the exact value of the Bitcoin halving interval, which is 3.9954 years! That is about 1.6 days shorter than 4 years, so you don't have to wait as long for the next one 😃

Leap Years

Leap years add an extra 86400 seconds, making the deviation larger, not smaller.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment