Post
Topic
Board Development & Technical Discussion
Merits 1 from 1 user
Topic OP
How to add premine in the bitcoin source
by
vanshtah
on 04/02/2020, 01:02:38 UTC
⭐ Merited by Quickseller (1)
Hello all, I am learning about bitcoin development, a created a new genesis, I compiled it and i got the windows, Linux and mac wallet running pretty well. Now I also want to add premine to the source code and with some searches in the google I found a solution to it.

In validation.cpp #L1041

Code:
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;
    if(nHeight == 4) 
    {
        nSubsidy = 1000000000 * COIN;
        return nSubsidy;
    }
    // Subsidy is cut in half every 210,000 blocks which will occur approximately every 4 years.
    nSubsidy >>= halvings;
    return nSubsidy;
}

I start the mining I got the coins but I cannot spend it, do anyone has a solution to it