Skip to content

Instantly share code, notes, and snippets.

@leto
Last active August 2, 2020 08:31
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save leto/a8818202ca4298cc3df5cb80b0aeaf82 to your computer and use it in GitHub Desktop.
Save leto/a8818202ca4298cc3df5cb80b0aeaf82 to your computer and use it in GitHub Desktop.
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