比特币源码阅读(0.16)(二十一)

mining.cpp::generatetoaddress

挖nblocks个区块,并将挖矿收入存入address指定的地址中。可以用来CPU挖矿,不过目前比特币的计算量,已经不可能挖出来了。

参数:

  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).

结果:
区块的hash值

样例:

挖11个区块到myaddress中

1
> bitcoin-cli generatetoaddress 11 "myaddress"

顺序图