<p>Despite the name, the <code>MAX_MONEY</code> constant is not used in determining the total maximum number of coins.  Rather, it is used only for a sanity check: any transaction output larger than <code>MAX_MONEY</code> is automatically rejected as invalid.  They simply set this new constant equal to the eventual maximum number of Bitcoins, since that is a value that certainly should never be exceeded by any output.  This was part of the fix to <a href="https://en.bitcoin.it/wiki/Value_overflow_incident" rel="nofollow noreferrer">an early bug</a> where only the sum of all outputs for a transaction was checked, leading to the possibility that the addition might overflow.  </p>

<p>The block subsidy (aka reward) is computed in the 
<code>GetBlockSubsidy</code> function in <code>validation.cpp</code>.</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>Here you can see the initial block reward of 50 coins is hard coded.  The halving interval <code>consensusParams.nSubsidyHalvingInterval</code> is set in <code>chainparams.cpp</code> in the constructors for <code>CMainParams</code>, <code>CTestNetParams</code> and <code>CRegTestParams</code> respectively (the respective default values are 210000, 210000, 150).  Note that <code>MAX_MONEY</code> does not appear.</p>

<p>So in order to change your coin's total money supply, you'll need to do a little math to decide what the initial block reward and halving interval should be, and modify them accordingly.  If you want the reward adjusted by any other mechanism than "continue halving until the reward reaches zero", then you'll have to rewrite the 
<code>GetBlockSubsidy</code> function.  (And you should <em>also</em> change <code>MAX_MONEY</code> to an appropriate value that should never be exceeded by any transaction output.)</p>

CC BY-SA 3.0
2015-09-20T19:56:21.593Z
2018-04-11T13:57:35.423Z
2018-04-11T13:57:35.423Z
Nate Eldredge
<p>I've changed <a href="https://github.com/bitcoin/bitcoin/blob/f914f1a746d7f91951c1da262a4a749dd3ebfa71/src/amount.h#L20" rel="nofollow">MAX_MONEY</a> to decrease the number of coins issued in my altcoin, but it's not working.</p>

<p>Why?</p>

CC BY-SA 3.0
2015-03-27T19:01:42.760Z
Check where MAX_MONEY is used, and you'll see it does not affect subsidy. It only limits the values being allowed in transactions.
Pieter Wuille
<altcoin-development>
Why doesn't changing MAX_MONEY change the maximum number of coins?
Nick ODell
# Why doesn't changing MAX_MONEY change the maximum number of coins?

(Asked by: username_0 on 2015-03-27)

I've changed [MAX\_MONEY](https://github.com/bitcoin/bitcoin/blob/f914f1a746d7f91951c1da262a4a749dd3ebfa71/src/amount.h#L20) to decrease the number of coins issued in my altcoin, but it's not working.

Why?

**Tags:** altcoin-development

> **Comments:**
> **username_1**: Check where MAX_MONEY is used, and you'll see it does not affect subsidy. It only limits the values being allowed in transactions.  

---

## 1 answers

### Answer by username_2 on 2015-09-20. Score: 4 | Accepted answer

Despite the name, the `MAX_MONEY` constant is not used in determining the total maximum number of coins. Rather, it is used only for a sanity check: any transaction output larger than `MAX_MONEY` is automatically rejected as invalid. They simply set this new constant equal to the eventual maximum number of Bitcoins, since that is a value that certainly should never be exceeded by any output. This was part of the fix to [an early bug](https://en.bitcoin.it/wiki/Value_overflow_incident) where only the sum of all outputs for a transaction was checked, leading to the possibility that the addition might overflow.

The block subsidy (aka reward) is computed in the
`GetBlockSubsidy` function in `validation.cpp`.

```
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;
}

```

Here you can see the initial block reward of 50 coins is hard coded. The halving interval `consensusParams.nSubsidyHalvingInterval` is set in `chainparams.cpp` in the constructors for `CMainParams`, `CTestNetParams` and `CRegTestParams` respectively (the respective default values are 210000, 210000, 150). Note that `MAX_MONEY` does not appear.

So in order to change your coin's total money supply, you'll need to do a little math to decide what the initial block reward and halving interval should be, and modify them accordingly. If you want the reward adjusted by any other mechanism than "continue halving until the reward reaches zero", then you'll have to rewrite the
`GetBlockSubsidy` function. (And you should *also* change `MAX_MONEY` to an appropriate value that should never be exceeded by any transaction output.)


---

