Skip to content

Commit 16209b1

Browse files
committed
Merge #20556: rpc: Properly document return values (submitblock, gettxout, getblocktemplate, scantxoutset)
fa7ff07 rpc: Properly document submitblock return value (MarcoFalke) fae542c rpc: Properly document getblocktemplate return value (MarcoFalke) fabaccf rpc: Properly document scantxoutset return value (MarcoFalke) faa2059 rpc: Properly document gettxout return value (MarcoFalke) Pull request description: Currently a few return values are undocumented. This is causing confusion at the least. See for example #18476 ACKs for top commit: fjahr: utACK fa7ff07 amitiuttarwar: tACK fa7ff07 Tree-SHA512: 933cb8f003163d93dbedb302d4c162514c2698ec6d58dbb9a053da8b8b9a4459b0701a3d9e830ecdabd7f278a46b7a07a3af49ec60703a80fcd75390877294ea
2 parents d42078e + fa7ff07 commit 16209b1

File tree

2 files changed

+160
-152
lines changed

2 files changed

+160
-152
lines changed

src/rpc/blockchain.cpp

Lines changed: 77 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -1100,30 +1100,29 @@ static RPCHelpMan gettxoutsetinfo()
11001100
static RPCHelpMan gettxout()
11011101
{
11021102
return RPCHelpMan{"gettxout",
1103-
"\nReturns details about an unspent transaction output.\n",
1104-
{
1105-
{"txid", RPCArg::Type::STR, RPCArg::Optional::NO, "The transaction id"},
1106-
{"n", RPCArg::Type::NUM, RPCArg::Optional::NO, "vout number"},
1107-
{"include_mempool", RPCArg::Type::BOOL, /* default */ "true", "Whether to include the mempool. Note that an unspent output that is spent in the mempool won't appear."},
1108-
},
1109-
RPCResult{
1110-
RPCResult::Type::OBJ, "", "",
1111-
{
1112-
{RPCResult::Type::STR_HEX, "bestblock", "The hash of the block at the tip of the chain"},
1113-
{RPCResult::Type::NUM, "confirmations", "The number of confirmations"},
1114-
{RPCResult::Type::STR_AMOUNT, "value", "The transaction value in " + CURRENCY_UNIT},
1115-
{RPCResult::Type::OBJ, "scriptPubKey", "",
1116-
{
1117-
{RPCResult::Type::STR_HEX, "asm", ""},
1118-
{RPCResult::Type::STR_HEX, "hex", ""},
1119-
{RPCResult::Type::NUM, "reqSigs", "Number of required signatures"},
1120-
{RPCResult::Type::STR_HEX, "type", "The type, eg pubkeyhash"},
1121-
{RPCResult::Type::ARR, "addresses", "array of bitcoin addresses",
1122-
{{RPCResult::Type::STR, "address", "bitcoin address"}}},
1123-
}},
1124-
{RPCResult::Type::BOOL, "coinbase", "Coinbase or not"},
1125-
}},
1126-
RPCExamples{
1103+
"\nReturns details about an unspent transaction output.\n",
1104+
{
1105+
{"txid", RPCArg::Type::STR, RPCArg::Optional::NO, "The transaction id"},
1106+
{"n", RPCArg::Type::NUM, RPCArg::Optional::NO, "vout number"},
1107+
{"include_mempool", RPCArg::Type::BOOL, /* default */ "true", "Whether to include the mempool. Note that an unspent output that is spent in the mempool won't appear."},
1108+
},
1109+
{
1110+
RPCResult{"If the UTXO was not found", RPCResult::Type::NONE, "", ""},
1111+
RPCResult{"Otherwise", RPCResult::Type::OBJ, "", "", {
1112+
{RPCResult::Type::STR_HEX, "bestblock", "The hash of the block at the tip of the chain"},
1113+
{RPCResult::Type::NUM, "confirmations", "The number of confirmations"},
1114+
{RPCResult::Type::STR_AMOUNT, "value", "The transaction value in " + CURRENCY_UNIT},
1115+
{RPCResult::Type::OBJ, "scriptPubKey", "", {
1116+
{RPCResult::Type::STR_HEX, "asm", ""},
1117+
{RPCResult::Type::STR_HEX, "hex", ""},
1118+
{RPCResult::Type::NUM, "reqSigs", "Number of required signatures"},
1119+
{RPCResult::Type::STR_HEX, "type", "The type, eg pubkeyhash"},
1120+
{RPCResult::Type::ARR, "addresses", "array of bitcoin addresses", {{RPCResult::Type::STR, "address", "bitcoin address"}}},
1121+
}},
1122+
{RPCResult::Type::BOOL, "coinbase", "Coinbase or not"},
1123+
}},
1124+
},
1125+
RPCExamples{
11271126
"\nGet unspent transactions\n"
11281127
+ HelpExampleCli("listunspent", "") +
11291128
"\nView the details\n"
@@ -2137,59 +2136,64 @@ class CoinsViewScanReserver
21372136
static RPCHelpMan scantxoutset()
21382137
{
21392138
return RPCHelpMan{"scantxoutset",
2140-
"\nEXPERIMENTAL warning: this call may be removed or changed in future releases.\n"
2141-
"\nScans the unspent transaction output set for entries that match certain output descriptors.\n"
2142-
"Examples of output descriptors are:\n"
2143-
" addr(<address>) Outputs whose scriptPubKey corresponds to the specified address (does not include P2PK)\n"
2144-
" raw(<hex script>) Outputs whose scriptPubKey equals the specified hex scripts\n"
2145-
" combo(<pubkey>) P2PK, P2PKH, P2WPKH, and P2SH-P2WPKH outputs for the given pubkey\n"
2146-
" pkh(<pubkey>) P2PKH outputs for the given pubkey\n"
2147-
" sh(multi(<n>,<pubkey>,<pubkey>,...)) P2SH-multisig outputs for the given threshold and pubkeys\n"
2148-
"\nIn the above, <pubkey> either refers to a fixed public key in hexadecimal notation, or to an xpub/xprv optionally followed by one\n"
2149-
"or more path elements separated by \"/\", and optionally ending in \"/*\" (unhardened), or \"/*'\" or \"/*h\" (hardened) to specify all\n"
2150-
"unhardened or hardened child keys.\n"
2151-
"In the latter case, a range needs to be specified by below if different from 1000.\n"
2152-
"For more information on output descriptors, see the documentation in the doc/descriptors.md file.\n",
2139+
"\nEXPERIMENTAL warning: this call may be removed or changed in future releases.\n"
2140+
"\nScans the unspent transaction output set for entries that match certain output descriptors.\n"
2141+
"Examples of output descriptors are:\n"
2142+
" addr(<address>) Outputs whose scriptPubKey corresponds to the specified address (does not include P2PK)\n"
2143+
" raw(<hex script>) Outputs whose scriptPubKey equals the specified hex scripts\n"
2144+
" combo(<pubkey>) P2PK, P2PKH, P2WPKH, and P2SH-P2WPKH outputs for the given pubkey\n"
2145+
" pkh(<pubkey>) P2PKH outputs for the given pubkey\n"
2146+
" sh(multi(<n>,<pubkey>,<pubkey>,...)) P2SH-multisig outputs for the given threshold and pubkeys\n"
2147+
"\nIn the above, <pubkey> either refers to a fixed public key in hexadecimal notation, or to an xpub/xprv optionally followed by one\n"
2148+
"or more path elements separated by \"/\", and optionally ending in \"/*\" (unhardened), or \"/*'\" or \"/*h\" (hardened) to specify all\n"
2149+
"unhardened or hardened child keys.\n"
2150+
"In the latter case, a range needs to be specified by below if different from 1000.\n"
2151+
"For more information on output descriptors, see the documentation in the doc/descriptors.md file.\n",
2152+
{
2153+
{"action", RPCArg::Type::STR, RPCArg::Optional::NO, "The action to execute\n"
2154+
"\"start\" for starting a scan\n"
2155+
"\"abort\" for aborting the current scan (returns true when abort was successful)\n"
2156+
"\"status\" for progress report (in %) of the current scan"},
2157+
{"scanobjects", RPCArg::Type::ARR, RPCArg::Optional::OMITTED, "Array of scan objects. Required for \"start\" action\n"
2158+
"Every scan object is either a string descriptor or an object:",
2159+
{
2160+
{"descriptor", RPCArg::Type::STR, RPCArg::Optional::OMITTED, "An output descriptor"},
2161+
{"", RPCArg::Type::OBJ, RPCArg::Optional::OMITTED, "An object with output descriptor and metadata",
21532162
{
2154-
{"action", RPCArg::Type::STR, RPCArg::Optional::NO, "The action to execute\n"
2155-
" \"start\" for starting a scan\n"
2156-
" \"abort\" for aborting the current scan (returns true when abort was successful)\n"
2157-
" \"status\" for progress report (in %) of the current scan"},
2158-
{"scanobjects", RPCArg::Type::ARR, RPCArg::Optional::OMITTED, "Array of scan objects. Required for \"start\" action\n"
2159-
" Every scan object is either a string descriptor or an object:",
2160-
{
2161-
{"descriptor", RPCArg::Type::STR, RPCArg::Optional::OMITTED, "An output descriptor"},
2162-
{"", RPCArg::Type::OBJ, RPCArg::Optional::OMITTED, "An object with output descriptor and metadata",
2163-
{
2164-
{"desc", RPCArg::Type::STR, RPCArg::Optional::NO, "An output descriptor"},
2165-
{"range", RPCArg::Type::RANGE, /* default */ "1000", "The range of HD chain indexes to explore (either end or [begin,end])"},
2166-
},
2167-
},
2168-
},
2163+
{"desc", RPCArg::Type::STR, RPCArg::Optional::NO, "An output descriptor"},
2164+
{"range", RPCArg::Type::RANGE, /* default */ "1000", "The range of HD chain indexes to explore (either end or [begin,end])"},
2165+
}},
2166+
},
21692167
"[scanobjects,...]"},
2170-
},
2171-
RPCResult{
2172-
RPCResult::Type::OBJ, "", "",
2168+
},
2169+
{
2170+
RPCResult{"When action=='abort'", RPCResult::Type::BOOL, "", ""},
2171+
RPCResult{"When action=='status' and no scan is in progress", RPCResult::Type::NONE, "", ""},
2172+
RPCResult{"When action=='status' and scan is in progress", RPCResult::Type::OBJ, "", "",
2173+
{
2174+
{RPCResult::Type::NUM, "progress", "The scan progress"},
2175+
}},
2176+
RPCResult{"When action=='start'", RPCResult::Type::OBJ, "", "", {
2177+
{RPCResult::Type::BOOL, "success", "Whether the scan was completed"},
2178+
{RPCResult::Type::NUM, "txouts", "The number of unspent transaction outputs scanned"},
2179+
{RPCResult::Type::NUM, "height", "The current block height (index)"},
2180+
{RPCResult::Type::STR_HEX, "bestblock", "The hash of the block at the tip of the chain"},
2181+
{RPCResult::Type::ARR, "unspents", "",
2182+
{
2183+
{RPCResult::Type::OBJ, "", "",
21732184
{
2174-
{RPCResult::Type::BOOL, "success", "Whether the scan was completed"},
2175-
{RPCResult::Type::NUM, "txouts", "The number of unspent transaction outputs scanned"},
2176-
{RPCResult::Type::NUM, "height", "The current block height (index)"},
2177-
{RPCResult::Type::STR_HEX, "bestblock", "The hash of the block at the tip of the chain"},
2178-
{RPCResult::Type::ARR, "unspents", "",
2179-
{
2180-
{RPCResult::Type::OBJ, "", "",
2181-
{
2182-
{RPCResult::Type::STR_HEX, "txid", "The transaction id"},
2183-
{RPCResult::Type::NUM, "vout", "The vout value"},
2184-
{RPCResult::Type::STR_HEX, "scriptPubKey", "The script key"},
2185-
{RPCResult::Type::STR, "desc", "A specialized descriptor for the matched scriptPubKey"},
2186-
{RPCResult::Type::STR_AMOUNT, "amount", "The total amount in " + CURRENCY_UNIT + " of the unspent output"},
2187-
{RPCResult::Type::NUM, "height", "Height of the unspent transaction output"},
2188-
}},
2189-
}},
2190-
{RPCResult::Type::STR_AMOUNT, "total_amount", "The total amount of all found unspent outputs in " + CURRENCY_UNIT},
2185+
{RPCResult::Type::STR_HEX, "txid", "The transaction id"},
2186+
{RPCResult::Type::NUM, "vout", "The vout value"},
2187+
{RPCResult::Type::STR_HEX, "scriptPubKey", "The script key"},
2188+
{RPCResult::Type::STR, "desc", "A specialized descriptor for the matched scriptPubKey"},
2189+
{RPCResult::Type::STR_AMOUNT, "amount", "The total amount in " + CURRENCY_UNIT + " of the unspent output"},
2190+
{RPCResult::Type::NUM, "height", "Height of the unspent transaction output"},
21912191
}},
2192-
RPCExamples{""},
2192+
}},
2193+
{RPCResult::Type::STR_AMOUNT, "total_amount", "The total amount of all found unspent outputs in " + CURRENCY_UNIT},
2194+
}},
2195+
},
2196+
RPCExamples{""},
21932197
[&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
21942198
{
21952199
RPCTypeCheck(request.params, {UniValue::VSTR, UniValue::VARR});

0 commit comments

Comments
 (0)