MCPcopy Create free account
hub / github.com/ElementsProject/elements / generatetodescriptor

Function generatetodescriptor

src/rpc/mining.cpp:236–272  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

234}
235
236static RPCHelpMan generatetodescriptor()
237{
238 return RPCHelpMan{
239 "generatetodescriptor",
240 "Mine to a specified descriptor and return the block hashes.",
241 {
242 {"num_blocks", RPCArg::Type::NUM, RPCArg::Optional::NO, "How many blocks are generated."},
243 {"descriptor", RPCArg::Type::STR, RPCArg::Optional::NO, "The descriptor to send the newly generated bitcoin to."},
244 {"maxtries", RPCArg::Type::NUM, RPCArg::Default{DEFAULT_MAX_TRIES}, "How many iterations to try."},
245 },
246 RPCResult{
247 RPCResult::Type::ARR, "", "hashes of blocks generated",
248 {
249 {RPCResult::Type::STR_HEX, "", "blockhash"},
250 }
251 },
252 RPCExamples{
253 "\nGenerate 11 blocks to mydesc\n" + HelpExampleCli("generatetodescriptor", "11 \"mydesc\"")},
254 [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
255{
256 const int num_blocks{request.params[0].get_int()};
257 const uint64_t max_tries{request.params[2].isNull() ? DEFAULT_MAX_TRIES : request.params[2].get_int()};
258
259 CScript coinbase_script;
260 std::string error;
261 if (!getScriptFromDescriptor(request.params[1].get_str(), coinbase_script, error)) {
262 throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, error);
263 }
264
265 NodeContext& node = EnsureAnyNodeContext(request.context);
266 const CTxMemPool& mempool = EnsureMemPool(node);
267 ChainstateManager& chainman = EnsureChainman(node);
268
269 return generateBlocks(chainman, mempool, coinbase_script, num_blocks, max_tries);
270},
271 };
272}
273
274static RPCHelpMan generate()
275{

Callers

nothing calls this directly

Calls 6

HelpExampleCliFunction · 0.85
getScriptFromDescriptorFunction · 0.85
JSONRPCErrorFunction · 0.85
generateBlocksFunction · 0.85
get_intMethod · 0.80
isNullMethod · 0.45

Tested by

no test coverage detected