Bitcoin Forum

Other => Beginners & Help => Topic started by: pysiak on November 11, 2013, 07:16:10 PM



Title: main.h: MAX_MONEY = 21000000
Post by: pysiak on November 11, 2013, 07:16:10 PM
I saw this question on zerohedge today. The guy was looking at https://github.com/bitcoin/bitcoin/blob/master/src/main.h and saying it's possible that this constant is changed in the future. I think he meant the whole network would be forced to accept a supply change.

This made me raise some questions:
- what happens if somebody runs a node or a pool with this variable different and we're reaching said supply?
- what if there was consensus in the whole community to increase this value, could that be done?
- if it were done and was adopted by all upgraded nodes, would that affect the mining curve and make new bitcoins's probability of getting mined different than it is now?
- wouldn't that invalidate the previously mined bitcoins worth?

Just thinking and wondering if anybody has had thougths around this.
Thanks


Title: Re: main.h: MAX_MONEY = 21000000
Post by: Foxpup on November 12, 2013, 01:06:08 AM
He clearly doesn't understand the code, then. MAX_MONEY is only used as a sanity check to prevent "impossible" transactions and integer overflows (any transaction sending more than MAX_MONEY is invalid, regardless of all other factors). The actual limit is enforced in this function in main.cpp:
Code:
int64 static GetBlockValue(int nHeight, int64 nFees)
{
    int64 nSubsidy = 50 * COIN;

    // Subsidy is cut in half every 210000 blocks, which will occur approximately every 4 years
    nSubsidy >>= (nHeight / 210000);

    return nSubsidy + nFees;
}

The result of this code is the first 210,000 blocks are worth BTC50 each, the next 210,000 blocks are worth BTC25 each, and so on (any block created with a greater value (eg, by modified or faulty mining software) will be rejected as invalid by all other nodes). This is a convergent infinite series with a limit of BTC21,000,000. However, due to rounding errors, the series is actually finite, and reaches a limit of BTC20,999,999.97690000 after 6,930,000 blocks.