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.

Murch
  • 75,206
  • 34
  • 186
  • 622
Shubham Saxena
  • 139
  • 1
  • 8

1 Answers1

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.

Murch
  • 75,206
  • 34
  • 186
  • 622
0xb10c
  • 1,430
  • 7
  • 22