Which fragment of the Satoshi client is verifying if announced block has a valid reward?

I mean, we now live in the 25 BTC reward period. I guess client after receiving a newly minted block, does verifications, like checking if inputs and outputs are balancing for example, and, I guess, if the reward is 25 BTC, right?

So where is this fragment of the code?

I know where is the code which limits BTC supply to 21 million:

    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;

...and I am looking for somebody to point me to the right place, where the verification is done.


1 Answer 1


There are 3 places where GetBlockValue is called. One is on incoming blocks, one is on blocks we're mining, and one is an error message. This is the one for incoming blocks:

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


This looks at the first transaction (the coinbase transaction) and checks the value. If it is larger than the subsidy plus the fees, then the block is rejected and the node that sent the block is blacklisted.

  • Beat me by a second in posting this. Apr 18, 2013 at 21:33
  • @DavidOgren We've all been there at one point or another. :|
    – Nick ODell
    Apr 18, 2013 at 21:37
  • Yours was more detailed in the explanation than mine anyway. Apr 18, 2013 at 22:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.