<p>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:</p>

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

<p><a href="https://github.com/bitcoin/bitcoin/blob/master/src/main.cpp#L1672">Source</a></p>

<p>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.</p>

CC BY-SA 3.0
2013-04-18T21:33:49.453Z
Beat me by a second in posting this.
David Ogren
CC BY-SA 3.0
2013-04-18T21:37:09.480Z
@DavidOgren We've all been there at one point or another. :|
Nick ODell
CC BY-SA 3.0
2013-04-18T22:03:04.440Z
Yours was more detailed in the explanation than mine anyway.
David Ogren
CC BY-SA 3.0
2013-04-18T21:32:04.720Z
2013-04-18T21:32:04.720Z
Nick ODell
<p><strong>Which fragment of the Satoshi client is verifying if announced block has a valid reward?</strong></p>

<p>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?</p>

<p>So where is this fragment of the code?</p>

<p>I know where is the <a href="https://github.com/bitcoin/bitcoin/blob/master/src/main.cpp#L1053" rel="nofollow">code which limits BTC supply to 21 million</a>:</p>

<pre><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 &gt;&gt;= (nHeight / 210000);

        return nSubsidy + nFees;
    }
</code></pre>

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

CC BY-SA 4.0
2019-09-10T17:07:42.327Z
Just a note that the relevant code resides here now: https://github.com/bitcoin/bitcoin/blob/0d20c42a014ff95aab1447a92605c3a194cfeecc/src/validation.cpp#L1080-L1091 (it's also link that should work forever ).
meeDamian
<bitcoin-core-development><money-supply><coinbase-transaction>
Where, in the code, in the Satoshi client is 21 million cap implemented?
UserPioneer
# Where, in the code, in the Satoshi client is 21 million cap implemented?

(Asked by: username_0 on 2013-04-18)

**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](https://github.com/bitcoin/bitcoin/blob/master/src/main.cpp#L1053):

```
    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.

**Tags:** bitcoin-core-development, money-supply, coinbase-transaction

> **Comments:**
> **username_1**: Just a note that the relevant code resides here now: https://github.com/bitcoin/bitcoin/blob/0d20c42a014ff95aab1447a92605c3a194cfeecc/src/validation.cpp#L1080-L1091 (it's also link that should work forever ).  

---

## 1 answers

### Answer by username_2 on 2013-04-18. Score: 7 | Accepted answer

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)));

```

[Source](https://github.com/bitcoin/bitcoin/blob/master/src/main.cpp#L1672)

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.

> **Comments:**
> **username_3**: Beat me by a second in posting this.  
> **username_2**: @username_3 We've all been there at one point or another. :|  
> **username_3**: Yours was more detailed in the explanation than mine anyway.  

---

