generate/generatetoaddress what are this two rpc methods used for?

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"

huahuayu

Posted 2018-11-12T04:00:57.467

Reputation: 11

Answers

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.

Anonymous

Posted 2018-11-12T04:00:57.467

Reputation: 10 054

thank you, how about the maxtries param in input, what it is used for?huahuayu 2018-11-12T05:44:32.837

@huahuayu Maximum nonce perhaps?KappaDev 2018-11-12T06:16:20.593