<p>When you generate a new block, its corresponding block reward needs to mature first for 100 blocks until it is spendable. In your case, it should show up as immature if you run <code>getbalances</code> (note the extra <code>s</code>).</p>
<pre><code>$ bitcoin-cli -regtest -rpcwallet=minerwallet getbalances
&gt; {
    &quot;mine&quot;: {
    &quot;trusted&quot;: 0.00000000,
    &quot;untrusted_pending&quot;: 0.00000000,
    &quot;immature&quot;: 50.00000000
  },
...
</code></pre>
<p>This also explains why the balance of your &quot;mywallet&quot; shows as 89.99977500: After having received the block reward of 101 blocks, the first block reward is mature (50 BTC). You then subtract the 10 BTC you sent to your other address, and a small transaction fee. After that, you generate another block to the <code>$MINER_ADDR</code>, which makes the second block reward for &quot;mywallet&quot; mature, adding another 50 BTC to the wallet's balance.</p>

CC BY-SA 4.0
2024-01-14T16:17:45.267Z
2024-01-14T16:17:45.267Z
TheCharlatan
<p>I am running the ruimarinho/bitcoin-core docker image and trying to understand why the block reward is going to the wrong btc address.</p>
<p>I have the following scenario:</p>
<pre class="lang-bash prettyprint-override"><code>$ bitcoin-cli -regtest createwallet mywallet
{
  &quot;name&quot;: &quot;mywallet&quot;,
  &quot;warning&quot;: &quot;&quot;
}
$ bitcoin-cli -regtest createwallet minerwallet
{
  &quot;name&quot;: &quot;minerwallet&quot;,
  &quot;warning&quot;: &quot;&quot;
}

$ ADDR=$(bitcoin-cli -regtest -rpcwallet=mywallet getnewaddress mywallet legacy) 
$ MINER_ADDR=$(bitcoin-cli -regtest -rpcwallet=minerwallet getnewaddress minerwallet legacy)

$ echo $ADDR $MINER_ADDR
muHrQQbYfhzVH4GCTZh4ZnKZvWBHVcqg66 mz3QWUnL94q2RdRxFtPq747SngoBu5uQMi

$ bitcoin-cli -regtest generatetoaddress 101 $ADDR # generate 100 blocks which will add bitcoin to 'mywallet'

$ TXID=$(bitcoin-cli -regtest -rpcwallet=mywallet sendtoaddress) &quot;mtuFXC3oACRqVMMqN32L5VG7ZCbaE7aZxi&quot; 10 # send 10 btc to random addr

$ bitcoin-cli -regtest -rpcwallet=minerwallet generateblock $MINER_ADDR &quot;[\&quot;$TXID\&quot;]&quot; # mine the transaction

$ bitcoin-cli -regtest -rpcwallet=mywallet getbalance
89.99977500
$ bitcoin-cli -regtest -rpcwallet=minerwallet getbalance
0.00000000
</code></pre>
<p>Why is the minerwallet not getting the block reward of 50 btc? I was expecting this output:</p>
<pre class="lang-bash prettyprint-override"><code>$ bitcoin-cli -regtest -rpcwallet=mywallet getbalance
39.999775
$ bitcoin-cli -regtest -rpcwallet=minerwallet getbalance
50.000000
</code></pre>

<mining-reward><regtest><immature-coins>
Mine blocks to specified address in regtest mode
Kevin
# Mine blocks to specified address in regtest mode

(Asked by: username_0 on 2024-01-14)

I am running the ruimarinho/bitcoin-core docker image and trying to understand why the block reward is going to the wrong btc address.
I have the following scenario:
$ bitcoin-cli -regtest createwallet mywallet
{
  "name": "mywallet",
  "warning": ""
}
$ bitcoin-cli -regtest createwallet minerwallet
{
  "name": "minerwallet",
  "warning": ""
}

$ ADDR=$(bitcoin-cli -regtest -rpcwallet=mywallet getnewaddress mywallet legacy) 
$ MINER_ADDR=$(bitcoin-cli -regtest -rpcwallet=minerwallet getnewaddress minerwallet legacy)

$ echo $ADDR $MINER_ADDR
muHrQQbYfhzVH4GCTZh4ZnKZvWBHVcqg66 mz3QWUnL94q2RdRxFtPq747SngoBu5uQMi

$ bitcoin-cli -regtest generatetoaddress 101 $ADDR # generate 100 blocks which will add bitcoin to 'mywallet'

$ TXID=$(bitcoin-cli -regtest -rpcwallet=mywallet sendtoaddress) "mtuFXC3oACRqVMMqN32L5VG7ZCbaE7aZxi" 10 # send 10 btc to random addr

$ bitcoin-cli -regtest -rpcwallet=minerwallet generateblock $MINER_ADDR "[\"$TXID\"]" # mine the transaction

$ bitcoin-cli -regtest -rpcwallet=mywallet getbalance
89.99977500
$ bitcoin-cli -regtest -rpcwallet=minerwallet getbalance
0.00000000

Why is the minerwallet not getting the block reward of 50 btc? I was expecting this output:
$ bitcoin-cli -regtest -rpcwallet=mywallet getbalance
39.999775
$ bitcoin-cli -regtest -rpcwallet=minerwallet getbalance
50.000000

**Tags:** mining-reward, regtest, immature-coins


---

## 1 answers

### Answer by username_1 on 2024-01-14. Score: 3 | Accepted answer

When you generate a new block, its corresponding block reward needs to mature first for 100 blocks until it is spendable. In your case, it should show up as immature if you run getbalances (note the extra s).
$ bitcoin-cli -regtest -rpcwallet=minerwallet getbalances
> {
    "mine": {
    "trusted": 0.00000000,
    "untrusted_pending": 0.00000000,
    "immature": 50.00000000
  },
...

This also explains why the balance of your "mywallet" shows as 89.99977500: After having received the block reward of 101 blocks, the first block reward is mature (50 BTC). You then subtract the 10 BTC you sent to your other address, and a small transaction fee. After that, you generate another block to the $MINER_ADDR, which makes the second block reward for "mywallet" mature, adding another 50 BTC to the wallet's balance.


---

