2

I am fairly new to bitcoin and was attempting to setup a local test network in my machine. I am using the regtest network to create the local network. Is there a way in which I can initialize the nodes (using a genesis block or something) to hold bitcoins (without mining)? I was going through the developer docs but I could not figure it out. Pardon me if it is a simple solution as I am fairly new to bitcoin. Something like an initialfreecoins=10000000 in the elements/lightning network.

1 Answer 1

4

No, there does not such thing as initialfreecoins=10000000. However mining on regtest is not resource hungry and nearly instant. It's the only way to get coins.

To get coins on regtest you first need a address to mine those coins to. An address can be created with bitcoin-cli -regtest getnewaddress.

To mine and payout to this address use with <address> being the output of the first step and <nblock> the number of blocks you want to mine. A good number would be for example 101 to get 50 coins (because coins need 100 confirmations to be spendable).

bitcoin-cli -regtest generatetoaddress <nblocks> <address>

You can repeat generatetoaddress or set a higher value for <nblock> to get more coins.

2
  • So if i set the value of nblocks to a higher value say 500 then the mined fee would also be higher? Commented Jul 27, 2019 at 5:50
  • No, you'd mine 500 blocks.
    – 0xb10c
    Commented Jul 27, 2019 at 8:37

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.