How is block reward set in time?

3

1

Many coins have dynamic block reward over the time, for example Bitcoin was 50BTC/block years ago and now 25BTC. My question is how is it defined in the source code ? I searched in Litecoin's source code but found nothing... Is it done manually by releasing a new version each xxxx blocks ?

DevAnaly

Posted 2014-01-02T18:31:19.437

Reputation: 33

Answers

4

The relevant function in the current latest git revision:

int64_t GetBlockValue(int nHeight, int64_t nFees)
{
    int64_t nSubsidy = 50 * COIN;

    // Subsidy is cut in half every 210,000 blocks which will occur approximately every 4 years.
    nSubsidy >>= (nHeight / Params().SubsidyHalvingInterval());

    return nSubsidy + nFees;
}

Which is used later in ConnectBlock(), as follows :

 if (block.vtx[0].GetValueOut() > GetBlockValue(pindex->nHeight, nFees))
        return state.DoS(100,
                         error("ConnectBlock() : coinbase pays too much (actual=%"PRId64" vs limit=%"PRId64")",
                               block.vtx[0].GetValueOut(), GetBlockValue(pindex->nHeight, nFees)),
                         REJECT_INVALID, "coinbase too large");

Stéphane Gimenez

Posted 2014-01-02T18:31:19.437

Reputation: 4 746