Many people already know that bitcoin total supply will be 21 millions. But do you know how bitcoin supply is managed and regulated by the Bitcoin consensus rules? Here we understand how.
How the total supply is calculated?
You may think that somewhere in Bitcoin core code there is a 21mio value as constant and this would be enforced while issuing new Bitcoin. But that’s wrong. This is not how this is managed by the code.
The number of 21mio Bitcoin is occurring as a calculation based on total number of blocks created since the genesis block. So let’s see how the block subsidy (the number of total Bitcoin issued per block) is calculated and enforced by consensus rules.
First of all the number of elapsed blocks since the genesis block is calculated for the current block.
Then we shall divide this number by 210’000. Bear in mind that 210’000 is the number of blocks between two halvings. This happens each about 4 years (that is the aproximate time necessary for creating 210’000 blocks). 4 years is because each block needs about 10 minutes to be discovered (this is due to the balancing between hash power on the network and difficulty).
Now with above informations it’s possible to calculate how many halvings have been happened from the beginning. Therefore we can know how is the subsidy of the current block.
How this value is enforced?
So we know that all the nodes running Bitcoin core are able to calculate how many Bitcoin shall be issued in the current block, by executing the above computations from the genesis block.
Every Bitcoin full node in the network must enforce the consensus rules. For doing that, every node must verify that the current block’s subsidy is correct. This check is made not only by miners, but by all the nodes on the network and it is part of Bitcoin security enforcement.
By those calculations each node is verifying that the reward to the miner is the Bitcoin current subsidy + the fees generated by all the transactions added to the current block. If this is not the case, the block would be invalid and it will be rejected.
What happens if the issuance is modified?
So what happens if a node is running a manipulated software in which the Bitcoin core has been changed to accept blocks with higher subsidy? Simply those blocks will be accepted by manipulated nodes but rejected by all the remaining network, creating a fork in the blockchain.
Nobody will join the corrupted Bitcoin forked network and therefore there will be an abandoned fork with no consequences for Bitcoin. For these reasons all the miners are incentivized to keep honest in order to receive the Bitcoin reward.