<p>You are looking for the method <a href="https://github.com/bitcoin/bitcoin/blob/v22.0/src/validation.cpp#L1186-L1197" rel="nofollow noreferrer"><code>CAmount GetBlockSubsidy(int nHeight, const Consensus::Params&amp; consensusParams)</code> in <code>validation.cpp</code></a>.</p>
<pre><code>CAmount GetBlockSubsidy(int nHeight, const Consensus::Params&amp; consensusParams)
{
    int halvings = nHeight / consensusParams.nSubsidyHalvingInterval;
    // Force block reward to zero when right shift is undefined.
    if (halvings &gt;= 64)
        return 0;

    CAmount nSubsidy = 50 * COIN;
    // Subsidy is cut in half every 210,000 blocks which will occur approximately every 4 years.
    nSubsidy &gt;&gt;= halvings;
    return nSubsidy;
}
</code></pre>
<p>The variables in this code snippet stand for:</p>
<ul>
<li><code>nHeight</code> is the number of blocks that have been found.</li>
<li><code>consensusParams.nSubsidyHalvingInterval</code> is 210000 blocks, the duration of reward epochs and the interval between the halvings</li>
<li><code>COIN</code> is 10<sup>8</sup>, the number of satoshis in one bitcoin</li>
<li><code>nSubsidy</code> finally gives the number of satoshis that may be generated per block</li>
</ul>

CC BY-SA 4.0
2015-12-23T08:35:42.863Z
2021-10-21T14:36:20.743Z
2021-10-21T14:36:20.743Z
Murch
<p>As per Bitcoin documentation, new coins are generated and brought into circulation when miner receive the reward. 
I am not talking about existing coins that are collected at the time of mining.</p>

<p>Can somebody guide me, where exactly this generation of new coins takes place?</p>

<bitcoin-core-development><mining-reward><coinbase-transaction><reward-schedule>
Where is the source code that allows new coins to be generated?
Vinay Chitale
# Where is the source code that allows new coins to be generated?

(Asked by: username_0 on 2015-12-23)

As per Bitcoin documentation, new coins are generated and brought into circulation when miner receive the reward.
I am not talking about existing coins that are collected at the time of mining.

Can somebody guide me, where exactly this generation of new coins takes place?

**Tags:** bitcoin-core-development, mining-reward, coinbase-transaction, reward-schedule


---

## 1 answers

### Answer by username_1 on 2015-12-23. Score: 4

You are looking for the method [`CAmount GetBlockSubsidy(int nHeight, const Consensus::Params& consensusParams)` in `validation.cpp`](https://github.com/bitcoin/bitcoin/blob/v22.0/src/validation.cpp#L1186-L1197).

```
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;
    // Subsidy is cut in half every 210,000 blocks which will occur approximately every 4 years.
    nSubsidy >>= halvings;
    return nSubsidy;
}

```

The variables in this code snippet stand for:

* `nHeight` is the number of blocks that have been found.
* `consensusParams.nSubsidyHalvingInterval` is 210000 blocks, the duration of reward epochs and the interval between the halvings
* `COIN` is 108, the number of satoshis in one bitcoin
* `nSubsidy` finally gives the number of satoshis that may be generated per block


---

