1

can anyone explain what are this rpc methods used for:
1.generate
https://bitcoincore.org/en/doc/0.16.3/rpc/generating/generate/
from the introduction of generate mehod:

Mine up to nblocks blocks immediately

but how? bitcoin is hard to mine, how can this method mine nblocks immediately?

generate nblocks ( maxtries )

Mine up to nblocks blocks immediately (before the RPC call returns) to an address in the wallet.

Arguments:
1. nblocks      (numeric, required) How many blocks are generated immediately.
2. maxtries     (numeric, optional) How many iterations to try (default = 1000000).

Result:
[ blockhashes ]     (array) hashes of blocks generated

Examples:

Generate 11 blocks
> bitcoin-cli generate 11

2.generatetoaddress
https://bitcoincore.org/en/doc/0.16.3/rpc/generating/generatetoaddress/

the same question as generate method

generatetoaddress nblocks address (maxtries)

Mine blocks immediately to a specified address (before the RPC call returns)

Arguments:
1. nblocks      (numeric, required) How many blocks are generated immediately.
2. address      (string, required) The address to send the newly generated bitcoin to.
3. maxtries     (numeric, optional) How many iterations to try (default = 1000000).

Result:
[ blockhashes ]     (array) hashes of blocks generated

Examples:

Generate 11 blocks to myaddress
> bitcoin-cli generatetoaddress 11 "myaddress"
1

but how? bitcoin is hard to mine, how can this method mine nblocks immediately?

generate is only used on the regtest network, where blocks can be mined instantly.

  • thank you, how about the maxtries param in input, what it is used for? – huahuayu Nov 12 '18 at 5:44
  • @huahuayu Maximum nonce perhaps? – KappaDev Nov 12 '18 at 6:16

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.