4

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 in 2016, but the internal miner was "removed" in v0.13.0. Looking at the code, it's unclear to me whether it's still possible; 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?

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. – Luca Blight May 23 at 13:15
6

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).

2
  • 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 May 24 at 3:49
  • 1
    I believe it still could, but I'd need to think harder about all the changes since then to know for sure. – Pieter Wuille May 24 at 3:51
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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.