1

Is there an RPC command which would allow me to generate blocks under a given difficulty? For instance, I would like to do something like this:

bitcoind -daemon -regtest
bitcoin-cli -regtest setdifficulty 100
bitcoin-cli -regtest generatetoaddress 101 bcrt1qlckxrvk56kezy35xuw3tk5w5gkvnmjl0cahw3u
bitcoin-cli -regtest setdifficulty 1
bitcoin-cli -regtest generatetoaddress 101 bcrt1qlckxrvk56kezy35xuw3tk5w5gkvnmjl0cahw3u

I am aware that it would result in an invalid blockchain, since it would not match the expected target recalculation of the Bitcoin protocol. This "detail" aside, is there any way to use bitcoind/bitcoin-cli to perform something like this?

1 Answer 1

1

No there isn't. Regtest is not designed to test mining ASICs and the motivation for such a RPC seems limited given regtest is for local testing.

However, if you want to experiment with mining on a network with limited network hash rate you could either try mining on the default Signet administered by Kalle Alm and AJ Towns or you could set up your own custom Signet network and then use the Signet mining utility in this PR (19937) to mine blocks. AJ Towns lays out some examples in a PR comment.

e.g.

Generate blocks indefinitely, at 10 minute intervals, paying block reward to the given address, using bitcoin-util to do multi-threaded proof-of-work:

./contrib/signet/generate.py --cli='./bitcoin-cli' generate 10 --block-time=600 --address="tb1..." --grind-cmd='./bitcoin-util grind'

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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