<p>With <code>setgenerate true</code> you can't.</p>
<p>But yes, it's possible, just you need to configure your <code>Bitcoin.conf</code> to receive <code>RPC command</code>, then you can communicate with your bitcoin client to get information from and send information to when you find a valid block for exemple</p>

CC BY-SA 4.0
2021-05-23T13:58:01.067Z
2021-05-23T13:58:01.067Z
Hamita
<p>The <code>setgenerate</code> built-in background miner was removed.</p>
<p>There is however still a test-only on-demand miner, which will try to mine N blocks whenever requested by RPC (see <code>generatetoaddress</code> /<code>generatetodescriptor</code>/<code>generateblock</code> RPCs in recent Bitcoin Core versions). It is many times less efficient than even the built-in CPU miner was. Its only purpose is in functional tests (which use the &quot;regtest&quot; network that is permanently at very low difficulty).</p>
<p>The code you see in miner.cpp is additionally used as a backend for the <code>getblocktemplate</code> RPC, which is how pools and external miners communicate with bitcoind. It doesn't actually do any mining (as in hashing) itself, but provides block templates for others to do so, based on transactions in the mempool and the chain's tip block hash.</p>
<p>The <code>-generate</code> option to bitcoin-cli is just a wrapper around the internal <code>generatetoaddress</code> RPC, which is slightly more convenient (it requests an address from the wallet, and then miner to it). It is in theory usable on mainnet, but it obviously won't ever actually find anything (except with extremely small probability).</p>

CC BY-SA 4.0
2021-05-24T03:49:31.010Z
Thanks Pieter, appreciate your response. Just for my curiosity, if someone was still running Bitcoin Core v0.12.1 (the last version with setgenerate), and they ran setgenerate, could the software still theoretically mine a block (again, theoretically; I'm aware the chance is effectively zero), or is that version of the software too old to mine blocks for the current blockchain?
nbduckman
CC BY-SA 4.0
2021-05-24T03:51:11.527Z
I believe it still could, but I'd need to think harder about all the changes since then to know for sure.
Pieter Wuille
CC BY-SA 4.0
2021-05-23T14:33:06.420Z
2021-05-23T14:33:06.420Z
Pieter Wuille
<p>Before you tell me, yes, I'm aware CPU mining is dead in 2021 and attempting to do so will likely just burn CPU time for no good reason.</p>
<p>However, my question is not whether mining is feasible, but whether it is <em>possible</em> with the (currently) latest version of Bitcoin Core, v0.21.1. From my understanding, it <a href="https://bitcoin.stackexchange.com/a/42792/121631">was possible</a> in 2016, but the internal miner was &quot;<a href="https://bitcoin.org/en/release/v0.13.0#removal-of-internal-miner" rel="noreferrer">removed</a>&quot; in v0.13.0. Looking at the code, it's unclear to me whether it's still possible; <a href="https://github.com/bitcoin/bitcoin/blob/master/src/miner.cpp" rel="noreferrer">miner.cpp</a> is still present, for example. All that seems to remain is the &quot;-generate&quot; option. Does this option actually allow mining on mainnet?</p>
<p>If the answer is no: Isn't Bitcoin Core meant to be the reference implementation of Bitcoin? And given that, isn't it a bit odd that the reference implementation does contain one of the core components of Bitcoin, that is, the mining system? I understand it's pointless to do so, but as the reference implementation, shouldn't Bitcoin Core provide this feature regardless?</p>

CC BY-SA 4.0
2021-05-23T13:15:07.157Z
I heard once the native mining feature on Bitcoin Core was removed in some of the previous versions, so right now the native mining is not supported anymore.
Luca Blight
<bitcoin-core><miner-configuration>
Is it possible (not feasible) to mine bitcoins with Bitcoin Core v0.21.1?
nbduckman
# Is it possible (not feasible) to mine bitcoins with Bitcoin Core v0.21.1?

(Asked by: username_0 on 2021-05-23)

Before you tell me, yes, I'm aware CPU mining is dead in 2021 and attempting to do so will likely just burn CPU time for no good reason.

However, my question is not whether mining is feasible, but whether it is *possible* with the (currently) latest version of Bitcoin Core, v0.21.1. From my understanding, it [was possible](https://bitcoin.stackexchange.com/a/42792/121631) in 2016, but the internal miner was "[removed](https://bitcoin.org/en/release/v0.13.0#removal-of-internal-miner)" in v0.13.0. Looking at the code, it's unclear to me whether it's still possible; [miner.cpp](https://github.com/bitcoin/bitcoin/blob/master/src/miner.cpp) is still present, for example. All that seems to remain is the "-generate" option. Does this option actually allow mining on mainnet?

If the answer is no: Isn't Bitcoin Core meant to be the reference implementation of Bitcoin? And given that, isn't it a bit odd that the reference implementation does contain one of the core components of Bitcoin, that is, the mining system? I understand it's pointless to do so, but as the reference implementation, shouldn't Bitcoin Core provide this feature regardless?

**Tags:** bitcoin-core, miner-configuration

> **Comments:**
> **username_1**: I heard once the native mining feature on Bitcoin Core was removed in some of the previous versions, so right now the native mining is not supported anymore.  

---

## 2 answers

### Answer by username_3 on 2021-05-23. Score: 8 | Accepted answer

The `setgenerate` built-in background miner was removed.

There is however still a test-only on-demand miner, which will try to mine N blocks whenever requested by RPC (see `generatetoaddress` /`generatetodescriptor`/`generateblock` RPCs in recent Bitcoin Core versions). It is many times less efficient than even the built-in CPU miner was. Its only purpose is in functional tests (which use the "regtest" network that is permanently at very low difficulty).

The code you see in miner.cpp is additionally used as a backend for the `getblocktemplate` RPC, which is how pools and external miners communicate with bitcoind. It doesn't actually do any mining (as in hashing) itself, but provides block templates for others to do so, based on transactions in the mempool and the chain's tip block hash.

The `-generate` option to bitcoin-cli is just a wrapper around the internal `generatetoaddress` RPC, which is slightly more convenient (it requests an address from the wallet, and then miner to it). It is in theory usable on mainnet, but it obviously won't ever actually find anything (except with extremely small probability).

> **Comments:**
> **username_0**: Thanks Pieter, appreciate your response. Just for my curiosity, if someone was still running Bitcoin Core v0.12.1 (the last version with setgenerate), and they ran setgenerate, could the software still theoretically mine a block (again, theoretically; I'm aware the chance is effectively zero), or is that version of the software too old to mine blocks for the current blockchain?  
> **username_3**: I believe it still could, but I'd need to think harder about all the changes since then to know for sure.  

---

### Answer by username_2 on 2021-05-23. Score: 0

With `setgenerate true` you can't.

But yes, it's possible, just you need to configure your `Bitcoin.conf` to receive `RPC command`, then you can communicate with your bitcoin client to get information from and send information to when you find a valid block for exemple


---

