Merge bitcoin/bitcoin#23634: rpc: add missing scantxoutset examples

1ed5681407 rpc: add missing scantxoutset examples (Sebastian Falbesoner)

Pull request description:

  The scantxoutset RPC and its help text was at last improved in #16285, but it's still missing examples (see https://github.com/bitcoin/bitcoin/pull/16285#issuecomment-529313781).

  ~Note that the example descriptor used doesn't follow the developer guideline of using invalid bech32 addresses, as the RPC is not wallet-related and it's use-case is merely to look up state information (i.e. there is no danger of sending funds to a wrong address).~ For the sake of simplicity, the raw descriptor for an early coinbase payout address (block 9) is taken, i.e. it yields results even at an early stage of IBD. Happy to change that though if there are other suggestions.

ACKs for top commit:
  shaavan:
    reACK 1ed5681407

Tree-SHA512: 057ad9ac0d019035bee2332440128de0ef08580bbeae80182ff74771beead3555c4bf7008071a97bbb6a8d85fb85d0f0754fb7941db2c5b755eae1ac9aa65318
This commit is contained in:
W. J. van der Laan 2021-12-07 12:21:43 +01:00
commit 6ac8c4f700
No known key found for this signature in database
GPG key ID: 1E4AED62986CD25D

View file

@ -2298,6 +2298,9 @@ public:
static RPCHelpMan scantxoutset()
{
// scriptPubKey corresponding to mainnet address 12cbQLTFMXRnSzktFkuoG3eHoMeFtpTu3S
const std::string EXAMPLE_DESCRIPTOR_RAW = "raw(76a91411b366edfc0a8b66feebae5c2e25a7b6a5d1cf3188ac)#fm24fxxy";
return RPCHelpMan{"scantxoutset",
"\nScans the unspent transaction output set for entries that match certain output descriptors.\n"
"Examples of output descriptors are:\n"
@ -2355,7 +2358,14 @@ static RPCHelpMan scantxoutset()
{RPCResult::Type::STR_AMOUNT, "total_amount", "The total amount of all found unspent outputs in " + CURRENCY_UNIT},
}},
},
RPCExamples{""},
RPCExamples{
HelpExampleCli("scantxoutset", "start \'[\"" + EXAMPLE_DESCRIPTOR_RAW + "\"]\'") +
HelpExampleCli("scantxoutset", "status") +
HelpExampleCli("scantxoutset", "abort") +
HelpExampleRpc("scantxoutset", "\"start\", [\"" + EXAMPLE_DESCRIPTOR_RAW + "\"]") +
HelpExampleRpc("scantxoutset", "\"status\"") +
HelpExampleRpc("scantxoutset", "\"abort\"")
},
[&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
{
RPCTypeCheck(request.params, {UniValue::VSTR, UniValue::VARR});