<p>Testnet has a special rule, which makes it easy to mine in particular circumstances. If there are no blocks found for more than 20 minutes, the difficulty drops and you can easily mine a testnet block with a normal CPU. Obviously your luck depends on if other powerful miners are mining or not, so sometimes you will find more blocks in a week, sometimes no block for months.</p>
<p>Heck, you can even mine with bitcoin-cli:</p>
<pre><code>while [ 1 ]
do
    bitcoin-cli generatetoaddress 1 &quot;2N5fJkfCv4cF6vsa5QQJnsazBKWNXynn9zp&quot; 10000000
done
</code></pre>
<p>For example, I found <a href="https://mempool.space/testnet/address/2N5fJkfCv4cF6vsa5QQJnsazBKWNXynn9zp" rel="nofollow noreferrer">6 blocks</a> in less than 2.5 months, but your luck depends on the activity of other miners.</p>

CC BY-SA 4.0
2024-03-01T04:45:10.867Z
2024-03-01T04:45:10.867Z
DaWe
<p>Even on testnet the difficulty is sufficiently high that it will take you a long time to mine anything using cpu. (Lots of people testing ASICs, presumably.)</p>

<p>Your best bet is probably <a href="https://github.com/freewil/bitcoin-testnet-box" rel="noreferrer">Testnet in a box</a>. Then you can cpu mine just by using ´setgenerate true´ in Bitcoin Core.</p>

CC BY-SA 3.0
2014-08-01T06:44:59.360Z
I thought setgenerate true option was removed. Thanks.
Emre K.
CC BY-SA 3.0
2014-08-01T08:51:11.823Z
This worked for me.
Emre K.
CC BY-SA 3.0
2015-08-28T18:04:51.480Z
There is now `regtest` mode in plain `bitcoind`, you don't need any additional dependency. Using regtest you have a private blockchain and using `generate` method you mine instantly.
jangorecki
CC BY-SA 3.0
2016-04-25T18:38:57.433Z
@jangorecki: That comment should rather be an answer. :)
Murch
CC BY-SA 3.0
2014-07-31T22:53:46.773Z
2014-07-31T22:53:46.773Z
Nate Eldredge
<p>I'm trying to do cpu mining on testnet to debug coinbase transactions in my application.</p>

<p>Tried running GUI miner, I get the below output:</p>

<pre><code>2014-07-31 11:31:51: Running command: poclbm.exe testnetuser:test123456@localhost:18332 --device=0 --platform=0 --verbose -r1
2014-07-31 11:31:51: Listener for "Default" started
2014-07-31 11:31:53: Listener for "Default": No PyOpenCL
2014-07-31 11:31:53: Listener for "Default": Not using OpenCL
2014-07-31 11:31:53: Listener for "Default": Nothing to mine on, exiting
</code></pre>

<p>I tried UFASoft miner, set the listening port to 18332 but nothing happens.</p>

<p>What is the easiest way to do cpu mining on testnet?</p>

<p>Is there another way of getting coinbase transactions in my testnet wallet?</p>

<miner-configuration><testnet><cpu-mining><regtest>
How can I do CPU mining on testnet?
Emre K.
# How can I do CPU mining on testnet?

(Asked by: username_0 on 2014-07-31)

I'm trying to do cpu mining on testnet to debug coinbase transactions in my application.

Tried running GUI miner, I get the below output:

```
2014-07-31 11:31:51: Running command: poclbm.exe testnetuser:test123456@localhost:18332 --device=0 --platform=0 --verbose -r1
2014-07-31 11:31:51: Listener for "Default" started
2014-07-31 11:31:53: Listener for "Default": No PyOpenCL
2014-07-31 11:31:53: Listener for "Default": Not using OpenCL
2014-07-31 11:31:53: Listener for "Default": Nothing to mine on, exiting

```

I tried UFASoft miner, set the listening port to 18332 but nothing happens.

What is the easiest way to do cpu mining on testnet?

Is there another way of getting coinbase transactions in my testnet wallet?

**Tags:** miner-configuration, testnet, cpu-mining, regtest


---

## 2 answers

### Answer by username_2 on 2014-07-31. Score: 5 | Accepted answer

Even on testnet the difficulty is sufficiently high that it will take you a long time to mine anything using cpu. (Lots of people testing ASICs, presumably.)

Your best bet is probably [Testnet in a box](https://github.com/freewil/bitcoin-testnet-box). Then you can cpu mine just by using ´setgenerate true´ in Bitcoin Core.

> **Comments:**
> **username_0**: I thought setgenerate true option was removed. Thanks.  
> **username_0**: This worked for me.  
> **username_3**: There is now `regtest` mode in plain `bitcoind`, you don't need any additional dependency. Using regtest you have a private blockchain and using `generate` method you mine instantly.  
> **username_4**: @username_3: That comment should rather be an answer. :)  

---

### Answer by username_1 on 2024-03-01. Score: 2

Testnet has a special rule, which makes it easy to mine in particular circumstances. If there are no blocks found for more than 20 minutes, the difficulty drops and you can easily mine a testnet block with a normal CPU. Obviously your luck depends on if other powerful miners are mining or not, so sometimes you will find more blocks in a week, sometimes no block for months.

Heck, you can even mine with bitcoin-cli:

```
while [ 1 ]
do
    bitcoin-cli generatetoaddress 1 "2N5fJkfCv4cF6vsa5QQJnsazBKWNXynn9zp" 10000000
done

```

For example, I found [6 blocks](https://mempool.space/testnet/address/2N5fJkfCv4cF6vsa5QQJnsazBKWNXynn9zp) in less than 2.5 months, but your luck depends on the activity of other miners.


---

