<p>It looks like the produced block does not follow the <a href="https://github.com/bitcoin/bips/blob/master/bip-0034.mediawiki" rel="nofollow noreferrer">BIP34</a> rule that every coinbase input has to start with the height of the block it's in.</p>
<p>CPUMiner probably predates regtest by several years, and might not be aware of all the rules that are enforced on regtest. It's much easier to use Bitcoin Core's built in functionality for constructing regtest blocks (e.g. <code>generatetoaddress</code> RPC). It has no optimized mining code, but given regtest's low difficulty this is hardly an issue.</p>

CC BY-SA 4.0
2024-07-05T12:26:31.853Z
Thank you so much! I looked up BIP34 rule and I think I can now grasp what the problem is.
paranoid
CC BY-SA 4.0
2024-07-05T11:42:08.997Z
2024-07-05T11:42:08.997Z
Pieter Wuille
<p>The genesis block that is hardcoded in src/kernel/chainparams.cpp file doesn't follow the BIP34 rule. I guess this is the source of the issue. After generating just one single block using the <code>generatetoaddress</code> RPC method, the mining works without any issues.</p>

CC BY-SA 4.0
2024-07-18T09:31:05.443Z
2024-07-18T09:31:05.443Z
paranoid
<p>I downloaded CPUminer and tried mining on regtest. Not a single block has been mined and I can see the following error messages. (I modified the difficulty level though) I can't find any pages who have dealt with a relevant problem like this. Can somebody tell me what the issue is?</p>
<p>=&gt; bitcoind debug.log file...</p>
<pre><code>2024-07-05T05:37:33Z CreateNewBlock(): block weight: 800 txs: 0 fees: 0 sigops 400
2024-07-05T05:43:51Z Saw new header hash=00000000ab2d84fe5fdb9e250838c5e7c2751a2cbbec90e23fe75e4e923c8a23 height=1
2024-07-05T05:43:51Z [error] AcceptBlock: bad-cb-height, block height mismatch in coinbase
2024-07-05T05:43:51Z [error] ProcessNewBlock: AcceptBlock FAILED (bad-cb-height, block height mismatch in coinbase)
</code></pre>
<p>=&gt; CPUminer terminal log messages...</p>
<pre><code>[2024-07-05 14:43:51] DEBUG: hash &lt;= target
Hash:   00000000ab2d84fe5fdb9e250838c5e7c2751a2cbbec90e23fe75e4e923c8a23
Target: 00000000ffff0000000000000000000000000000000000000000000000000000
[2024-07-05 14:43:51] accepted: 0/1 (0.00%), 4953 khash/s (booooo)
[2024-07-05 14:43:51] DEBUG: reject reason: bad-cb-height
</code></pre>
<pre><code>$ ./bitcoin-cli -conf=configuration_file.conf getblockchaininfo
{
  &quot;chain&quot;: &quot;regtest&quot;,
  &quot;blocks&quot;: 0,
  &quot;headers&quot;: 1,
  &quot;bestblockhash&quot;: &quot;0f9188f13cb7b2c71f2a335e3a4fc328bf5beb436012afca590b1a11466e2206&quot;,
  &quot;difficulty&quot;: 1,
  &quot;time&quot;: 1296688602,
  &quot;mediantime&quot;: 1296688602,
  &quot;verificationprogress&quot;: 1,
  &quot;initialblockdownload&quot;: false,
  &quot;chainwork&quot;: &quot;0000000000000000000000000000000000000000000000000000000100010001&quot;,
  &quot;size_on_disk&quot;: 293,
  &quot;pruned&quot;: false,
  &quot;warnings&quot;: [
    &quot;This is a pre-release test build - use at your own risk - do not use for mining or merchant applications&quot;
  ]
}
</code></pre>

<coinbase-transaction><regtest><cpuminer>
Bitcoin regtest CPUminer not even starting
paranoid
# Bitcoin regtest CPUminer not even starting

(Asked by: username_0 on 2024-07-05)

I downloaded CPUminer and tried mining on regtest. Not a single block has been mined and I can see the following error messages. (I modified the difficulty level though) I can't find any pages who have dealt with a relevant problem like this. Can somebody tell me what the issue is?

=> bitcoind debug.log file...

```
2024-07-05T05:37:33Z CreateNewBlock(): block weight: 800 txs: 0 fees: 0 sigops 400
2024-07-05T05:43:51Z Saw new header hash=00000000ab2d84fe5fdb9e250838c5e7c2751a2cbbec90e23fe75e4e923c8a23 height=1
2024-07-05T05:43:51Z [error] AcceptBlock: bad-cb-height, block height mismatch in coinbase
2024-07-05T05:43:51Z [error] ProcessNewBlock: AcceptBlock FAILED (bad-cb-height, block height mismatch in coinbase)

```

=> CPUminer terminal log messages...

```
[2024-07-05 14:43:51] DEBUG: hash <= target
Hash:   00000000ab2d84fe5fdb9e250838c5e7c2751a2cbbec90e23fe75e4e923c8a23
Target: 00000000ffff0000000000000000000000000000000000000000000000000000
[2024-07-05 14:43:51] accepted: 0/1 (0.00%), 4953 khash/s (booooo)
[2024-07-05 14:43:51] DEBUG: reject reason: bad-cb-height

```

```
$ ./bitcoin-cli -conf=configuration_file.conf getblockchaininfo
{
  "chain": "regtest",
  "blocks": 0,
  "headers": 1,
  "bestblockhash": "0f9188f13cb7b2c71f2a335e3a4fc328bf5beb436012afca590b1a11466e2206",
  "difficulty": 1,
  "time": 1296688602,
  "mediantime": 1296688602,
  "verificationprogress": 1,
  "initialblockdownload": false,
  "chainwork": "0000000000000000000000000000000000000000000000000000000100010001",
  "size_on_disk": 293,
  "pruned": false,
  "warnings": [
    "This is a pre-release test build - use at your own risk - do not use for mining or merchant applications"
  ]
}

```

**Tags:** coinbase-transaction, regtest, cpuminer


---

## 2 answers

### Answer by username_1 on 2024-07-05. Score: 4

It looks like the produced block does not follow the [BIP34](https://github.com/bitcoin/bips/blob/master/bip-0034.mediawiki) rule that every coinbase input has to start with the height of the block it's in.

CPUMiner probably predates regtest by several years, and might not be aware of all the rules that are enforced on regtest. It's much easier to use Bitcoin Core's built in functionality for constructing regtest blocks (e.g. `generatetoaddress` RPC). It has no optimized mining code, but given regtest's low difficulty this is hardly an issue.

> **Comments:**
> **username_0**: Thank you so much! I looked up BIP34 rule and I think I can now grasp what the problem is.  

---

### Answer by username_0 on 2024-07-18. Score: 1

The genesis block that is hardcoded in src/kernel/chainparams.cpp file doesn't follow the BIP34 rule. I guess this is the source of the issue. After generating just one single block using the `generatetoaddress` RPC method, the mining works without any issues.


---

