Skip to content

Commit fc0c410

Browse files
committed
rpc: Improve scantxoutset response and help message
1 parent 332c613 commit fc0c410

File tree

1 file changed

+19
-10
lines changed

1 file changed

+19
-10
lines changed

src/rpc/blockchain.cpp

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2199,17 +2199,21 @@ UniValue scantxoutset(const JSONRPCRequest& request)
21992199
},
22002200
RPCResult{
22012201
"{\n"
2202+
" \"success\": true|false, (boolean) Whether the scan was completed\n"
2203+
" \"txouts\": n, (numeric) The number of unspent transaction outputs scanned\n"
2204+
" \"height\": n, (numeric) The current block height (index)\n"
2205+
" \"bestblock\": \"hex\", (string) The hash of the block at the tip of the chain\n"
22022206
" \"unspents\": [\n"
2203-
" {\n"
2204-
" \"txid\" : \"transactionid\", (string) The transaction id\n"
2205-
" \"vout\": n, (numeric) the vout value\n"
2206-
" \"scriptPubKey\" : \"script\", (string) the script key\n"
2207-
" \"desc\" : \"descriptor\", (string) A specialized descriptor for the matched scriptPubKey\n"
2208-
" \"amount\" : x.xxx, (numeric) The total amount in " + CURRENCY_UNIT + " of the unspent output\n"
2209-
" \"height\" : n, (numeric) Height of the unspent transaction output\n"
2207+
" {\n"
2208+
" \"txid\": \"hash\", (string) The transaction id\n"
2209+
" \"vout\": n, (numeric) The vout value\n"
2210+
" \"scriptPubKey\": \"script\", (string) The script key\n"
2211+
" \"desc\": \"descriptor\", (string) A specialized descriptor for the matched scriptPubKey\n"
2212+
" \"amount\": x.xxx, (numeric) The total amount in " + CURRENCY_UNIT + " of the unspent output\n"
2213+
" \"height\": n, (numeric) Height of the unspent transaction output\n"
22102214
" }\n"
2211-
" ,...], \n"
2212-
" \"total_amount\" : x.xxx, (numeric) The total amount of all found unspent outputs in " + CURRENCY_UNIT + "\n"
2215+
" ,...],\n"
2216+
" \"total_amount\": x.xxx, (numeric) The total amount of all found unspent outputs in " + CURRENCY_UNIT + "\n"
22132217
"]\n"
22142218
},
22152219
RPCExamples{""},
@@ -2293,15 +2297,20 @@ UniValue scantxoutset(const JSONRPCRequest& request)
22932297
g_scan_progress = 0;
22942298
int64_t count = 0;
22952299
std::unique_ptr<CCoinsViewCursor> pcursor;
2300+
CBlockIndex* tip;
22962301
{
22972302
LOCK(cs_main);
22982303
::ChainstateActive().ForceFlushStateToDisk();
22992304
pcursor = std::unique_ptr<CCoinsViewCursor>(pcoinsdbview->Cursor());
23002305
assert(pcursor);
2306+
tip = ::ChainActive().Tip();
2307+
assert(tip);
23012308
}
23022309
bool res = FindScriptPubKey(g_scan_progress, g_should_abort_scan, count, pcursor.get(), needles, coins);
23032310
result.pushKV("success", res);
2304-
result.pushKV("searched_items", count);
2311+
result.pushKV("txouts", count);
2312+
result.pushKV("height", tip->nHeight);
2313+
result.pushKV("bestblock", tip->GetBlockHash().GetHex());
23052314

23062315
for (const auto& it : coins) {
23072316
const COutPoint& outpoint = it.first;

0 commit comments

Comments
 (0)