Bitcoin Halving: A Technical Deep Dive – hackernoon.com

Bitcoin Halving: A Technical Deep Dive – hackernoon.com

Author profile picture

Today (11 may 2020) it’s a very important day for Bitcoin. Today we will have the halving!

The halving is a recurrent event, every 4 years the reward that the miner gets to resolve the Proof of Work is being cut in half.

More precisely: the reward is being cut in half every 210.000 blocks. A block is mined every 10 minutes. That’s why 210.000 blocks are equivalent to 1458 days, that are equivalent to 3.99 years!

At this very moment, the blockchain has 629.992 blocks. When a miner will find a new block with the height 630.000, 12 years will pass from the genesis block, and the reward will be 6.25 bitcoins per block instead of 12.5 bitcoins.

We can reproduce the same behavior in the regtest enviroment.

Please note: in regtest the halving occurred on different height. We need to mine 449 blocks in order to have the same scenario as the mainnet. At the block with height 449, the reward is 12.5 bitcoins, when we mining another block, the reward will be 6.25 bitcoins.

In Action

First of all, we need to use the regtest environment with no blocks.

$ bitcoin-cli getblockchaininfo
{ "chain": "regtest", "blocks": 0, "headers": 0, "bestblockhash": "0f9188f13cb7b2c71f2a335e3a4fc328bf5beb436012afca590b1a11466e2206", "difficulty": 4.656542373906925e-10, "mediantime": 1296688602, "verificationprogress": 1, "initialblockdownload": true, "chainwork": "0000000000000000000000000000000000000000000000000000000000000002",
....

We can mine 449 blocks using the
Source…