2

Assuming that there is a magical mineblocks RPC command that can mine X blocks on demand, what is the complete set of command line commands to start a client, mine my coins to a specific address, see the mined blocks, get the reward and send them to an address XXX?

rmac
  • 21
  • 2

2 Answers2

1
  1. Put your client into regtest mode. This allows you to mine an arbitrary amount of blocks very quickly. Add this to your bitcoin.conf

    regtest=1
    daemon=1
    
  2. Generate the blocks. Run

    bitcoin-cli setgenerate true <number of blocks>
    

    where X is the number of block you want. You'll want at least 101 blocks.

  3. See the mined blocks. Run

    bitcoin-cli getblockhash <index>
    

    to get the hash of block number <index>. Then take that hash and run

    bitcoin-cli getblock <hash>
    
  4. Repeat Step 3 for each block you want.

  5. Send the Bitcoins to a new address. Run

    bitcoin-cli getbalance
    

    to find out your balance. Run

    bitcoin-cli sendtoaddress <address> <amount>
    

If you don't need to see the contents of the block, you can skip steps 3 and 4.

Nick ODell
  • 29,396
  • 11
  • 72
  • 130
0

setgenerate has been removed. and now you can use generatetoaddress to mine.

# generatetoaddress
generatetoaddress 1 2NDyXhf4i44Vqpy9FvPHXkw8ccA2WtMkTe3