<p>An updated answer.</p>
<p>First, check out the block subsidy calculation: <a href="https://github.com/bitcoin/bitcoin/blob/v23.0/src/validation.cpp#L1417" rel="nofollow noreferrer">https://github.com/bitcoin/bitcoin/blob/v23.0/src/validation.cpp#L1417</a></p>
<pre><code>CAmount GetBlockSubsidy(int nHeight, const Consensus::Params&amp; consensusParams)
{
    int halvings = nHeight / consensusParams.nSubsidyHalvingInterval;
    // Force block reward to zero when right shift is undefined.
    if (halvings &gt;= 64)
        return 0;

    CAmount nSubsidy = 50 * COIN;
    // Subsidy is cut in half every 210,000 blocks which will occur approximately every 4 years.
    nSubsidy &gt;&gt;= halvings;
    return nSubsidy;
}
</code></pre>
<p>An important constant: <code>consensus.nSubsidyHalvingInterval = 210000</code> comes from this file here:
<a href="https://github.com/bitcoin/bitcoin/blob/v23.0/src/chainparams.cpp#L67" rel="nofollow noreferrer">https://github.com/bitcoin/bitcoin/blob/v23.0/src/chainparams.cpp#L67</a></p>
<p>Right now the current block height is 704673 (you can look it up here if you like: <a href="https://blockexplorer.one/bitcoin/mainnet" rel="nofollow noreferrer">https://blockexplorer.one/bitcoin/mainnet</a>)</p>
<p><code>halvings = int(704673 / 210000) == 3</code></p>
<p>So the current reward <code>50 &gt;&gt; 3 == 6.25</code></p>
<p>The sum of a series that halves like that is <code>a/(1-r)</code>, where a is the first value (50) and r is the ratio (0.5). See: <a href="https://en.wikipedia.org/wiki/Geometric_series" rel="nofollow noreferrer">https://en.wikipedia.org/wiki/Geometric_series</a> for more info.</p>
<p>Thus <code>50 + 25 + 12.5 + 6.25 + 3.125 + 1.5625 + … + 0.000000001 = 100</code></p>
<p>Since the same amount is given per block, you need only multiply that by the total number of blocks issued per halving:  210000</p>
<p><code>210,000 * 100 == 21,000,000</code></p>
<p>Bitcoin is an open source consensus protocol.  It's not a company, there is no &quot;foundation&quot;, and the code can be reviewed by anyone with about a high school level of knowledge of math.</p>

CC BY-SA 4.0
2021-10-12T13:24:01.613Z
2022-07-11T18:10:22.653Z
2022-07-11T18:10:22.653Z
Erik Aronesty
<p>The software in the bitcoin client verifies that each transaction follows the algorithm that is part of the protocol.</p>

<p>Now even if the developers of the client were to somehow conclude that increasing the limit was a good idea and were to then push that client out for distribution, those holding bitcoins would likely not accept the new client.  There would then be a fork in the blockchain as the limit increase would devalue the currency already issued and therefore it would be rational to those holding bitcoins already would protect the value of their currency by not accepting transactions from the new fork.</p>

<p>So to change the limit you not only need to get the developers to make the changes that fork the blockchain but also you need to get exchanges and merchants to accept transactions using the fork -- something that, in this case, is irrational.</p>

CC BY-SA 3.0
2013-04-12T08:26:50.687Z
Bitcoin source code: https://github.com/bitcoin/bitcoin/blob/master/src/main.cpp#L1053
Stephen Gornick
CC BY-SA 3.0
2014-07-22T22:21:57.023Z
@StephenGornick In order to see the code that limits bitcoin to 21 million, am I supposed to read down from line 1053?  Is there an english translation of the code anywhere for non-coders? thanks
Alex Millar
CC BY-SA 3.0
2014-07-23T15:24:53.163Z
Well, the source code is continually changing, so a pointer to a specific line of code in "tip" (the latest code that exist) will be obsolete in a short amount of time.
Stephen Gornick
CC BY-SA 3.0
2014-07-23T15:30:27.997Z
The code to look at is the GetBlockValue function.    

The block subsidy started out at 50 but is halved every 210,000 blocks.  So the english translation basically is "if block 1 through 210,000 then award 50 XBT per-block, if block is 210,001 through 420,000 then award 25 XBT per-block, if block is 420,001 through 630,000 then award 12.5 XBT, etc.   Eventually (like a hundred some years from now) the reward is so small, there is no block award remaining to issue.
Stephen Gornick
CC BY-SA 3.0
2012-01-27T00:47:16.913Z
2012-01-27T00:47:16.913Z
user479
<p>Every node in the Bitcoin network checks every block it receives and validates any transactions in it. As coin generation is a transaction that is included in the block, it is also checked. Same as a node would not accept a transaction that does not balance its inputs and outputs (for example, by spending more coins than it has), neither would it accept a block reward different, than the one that is scheduled to occur (50 coins currently, half of that for some number of blocks, and then other fractions of that amount). The nodes know what rewards to expect based on the block number, as it is set to half based on that number.</p>

<p>To change it you would have to (convince people to) change all the clients, exactly like any other protocol change.</p>

CC BY-SA 3.0
2012-01-26T18:31:00.250Z
2012-02-13T14:05:24.407Z
2012-02-13T14:05:24.407Z
ThePiachu
<p>Just to check what would take for that limit to be changed. (not that I want to be changed, quite the opposite). I know the total number of bitcoin reward is halved every 4 years.</p>

<p>So does the verifying nodes check if the number of rewarded bitcoins match the distribution schedule?</p>

<protocol><reward-schedule>
How is the bitcoin 21 million cap implemented?
Bernardo Kyotoku
# How is the bitcoin 21 million cap implemented?

(Asked by: username_0 on 2012-01-26)

Just to check what would take for that limit to be changed. (not that I want to be changed, quite the opposite). I know the total number of bitcoin reward is halved every 4 years.

So does the verifying nodes check if the number of rewarded bitcoins match the distribution schedule?

**Tags:** protocol, reward-schedule


---

## 3 answers

### Answer by username_5 on 2012-01-26. Score: 10 | Accepted answer

Every node in the Bitcoin network checks every block it receives and validates any transactions in it. As coin generation is a transaction that is included in the block, it is also checked. Same as a node would not accept a transaction that does not balance its inputs and outputs (for example, by spending more coins than it has), neither would it accept a block reward different, than the one that is scheduled to occur (50 coins currently, half of that for some number of blocks, and then other fractions of that amount). The nodes know what rewards to expect based on the block number, as it is set to half based on that number.

To change it you would have to (convince people to) change all the clients, exactly like any other protocol change.


---

### Answer by username_1 on 2021-10-12. Score: 5

An updated answer.
First, check out the block subsidy calculation: https://github.com/bitcoin/bitcoin/blob/v23.0/src/validation.cpp#L1417
CAmount GetBlockSubsidy(int nHeight, const Consensus::Params& consensusParams)
{
    int halvings = nHeight / consensusParams.nSubsidyHalvingInterval;
    // Force block reward to zero when right shift is undefined.
    if (halvings >= 64)
        return 0;

    CAmount nSubsidy = 50 * COIN;
    // Subsidy is cut in half every 210,000 blocks which will occur approximately every 4 years.
    nSubsidy >>= halvings;
    return nSubsidy;
}

An important constant: consensus.nSubsidyHalvingInterval = 210000 comes from this file here:
https://github.com/bitcoin/bitcoin/blob/v23.0/src/chainparams.cpp#L67
Right now the current block height is 704673 (you can look it up here if you like: https://blockexplorer.one/bitcoin/mainnet)
halvings = int(704673 / 210000) == 3
So the current reward 50 >> 3 == 6.25
The sum of a series that halves like that is a/(1-r), where a is the first value (50) and r is the ratio (0.5). See: https://en.wikipedia.org/wiki/Geometric_series for more info.
Thus 50 + 25 + 12.5 + 6.25 + 3.125 + 1.5625 + … + 0.000000001 = 100
Since the same amount is given per block, you need only multiply that by the total number of blocks issued per halving:  210000
210,000 * 100 == 21,000,000
Bitcoin is an open source consensus protocol.  It's not a company, there is no "foundation", and the code can be reviewed by anyone with about a high school level of knowledge of math.


---

### Answer by username_2 on 2012-01-27. Score: 5

The software in the bitcoin client verifies that each transaction follows the algorithm that is part of the protocol.

Now even if the developers of the client were to somehow conclude that increasing the limit was a good idea and were to then push that client out for distribution, those holding bitcoins would likely not accept the new client. There would then be a fork in the blockchain as the limit increase would devalue the currency already issued and therefore it would be rational to those holding bitcoins already would protect the value of their currency by not accepting transactions from the new fork.

So to change the limit you not only need to get the developers to make the changes that fork the blockchain but also you need to get exchanges and merchants to accept transactions using the fork -- something that, in this case, is irrational.

> **Comments:**
> **username_3**: Bitcoin source code: https://github.com/bitcoin/bitcoin/blob/master/src/main.cpp#L1053  
> **username_4**: @StephenGornick In order to see the code that limits bitcoin to 21 million, am I supposed to read down from line 1053?  Is there an english translation of the code anywhere for non-coders? thanks  
> **username_3**: Well, the source code is continually changing, so a pointer to a specific line of code in "tip" (the latest code that exist) will be obsolete in a short amount of time.  
> **username_3**: The code to look at is the GetBlockValue function.      The block subsidy started out at 50 but is halved every 210,000 blocks.  So the english translation basically is "if block 1 through 210,000 then award 50 XBT per-block, if block is 210,001 through 420,000 then award 25 XBT per-block, if block is 420,001 through 630,000 then award 12.5 XBT, etc.   Eventually (like a hundred some years from now) the reward is so small, there is no block award remaining to issue.  

---

