Changeset View
Changeset View
Standalone View
Standalone View
src/rpc/mining.cpp
Show First 20 Lines • Show All 305 Lines • ▼ Show 20 Lines | RPCHelpMan{ | ||||
"\nGenerate 11 blocks to myaddress\n" + | "\nGenerate 11 blocks to myaddress\n" + | ||||
HelpExampleCli("generatetoaddress", "11 \"myaddress\"") + | HelpExampleCli("generatetoaddress", "11 \"myaddress\"") + | ||||
"If you are using the " PACKAGE_NAME " wallet, you can " | "If you are using the " PACKAGE_NAME " wallet, you can " | ||||
"get a new address to send the newly generated bitcoin to with:\n" + | "get a new address to send the newly generated bitcoin to with:\n" + | ||||
HelpExampleCli("getnewaddress", "")}, | HelpExampleCli("getnewaddress", "")}, | ||||
} | } | ||||
.Check(request); | .Check(request); | ||||
int nGenerate = request.params[0].get_int(); | const int num_blocks{request.params[0].get_int()}; | ||||
uint64_t nMaxTries{DEFAULT_MAX_TRIES}; | const uint64_t max_tries{request.params[2].isNull() | ||||
if (!request.params[2].isNull()) { | ? DEFAULT_MAX_TRIES | ||||
nMaxTries = request.params[2].get_int64(); | : request.params[2].get_int64()}; | ||||
} | |||||
CTxDestination destination = | CTxDestination destination = | ||||
DecodeDestination(request.params[1].get_str(), config.GetChainParams()); | DecodeDestination(request.params[1].get_str(), config.GetChainParams()); | ||||
if (!IsValidDestination(destination)) { | if (!IsValidDestination(destination)) { | ||||
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, | throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, | ||||
"Error: Invalid address"); | "Error: Invalid address"); | ||||
} | } | ||||
const CTxMemPool &mempool = EnsureMemPool(request.context); | const CTxMemPool &mempool = EnsureMemPool(request.context); | ||||
ChainstateManager &chainman = EnsureChainman(request.context); | ChainstateManager &chainman = EnsureChainman(request.context); | ||||
CScript coinbase_script = GetScriptForDestination(destination); | CScript coinbase_script = GetScriptForDestination(destination); | ||||
return generateBlocks(config, chainman, mempool, coinbase_script, nGenerate, | return generateBlocks(config, chainman, mempool, coinbase_script, | ||||
nMaxTries); | num_blocks, max_tries); | ||||
} | } | ||||
static UniValue generateblock(const Config &config, | static UniValue generateblock(const Config &config, | ||||
const JSONRPCRequest &request) { | const JSONRPCRequest &request) { | ||||
RPCHelpMan{ | RPCHelpMan{ | ||||
"generateblock", | "generateblock", | ||||
"\nMine a block with a set of ordered transactions immediately to a " | "\nMine a block with a set of ordered transactions immediately to a " | ||||
"specified address or descriptor (before the RPC call returns)\n", | "specified address or descriptor (before the RPC call returns)\n", | ||||
▲ Show 20 Lines • Show All 834 Lines • Show Last 20 Lines |