Skip to content

Commit 27c8056

Browse files
committed
rpc: Disallow gettxoutsetinfo queries for a specific block with use_index=false
by returning an RPC error where previously a NonFatalError would be thrown.
1 parent 1da1c0d commit 27c8056

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/rpc/blockchain.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -845,7 +845,7 @@ static RPCHelpMan gettxoutsetinfo()
845845
"Note this call may take some time if you are not using coinstatsindex.\n",
846846
{
847847
{"hash_type", RPCArg::Type::STR, RPCArg::Default{"hash_serialized_2"}, "Which UTXO set hash should be calculated. Options: 'hash_serialized_2' (the legacy algorithm), 'muhash', 'none'."},
848-
{"hash_or_height", RPCArg::Type::NUM, RPCArg::Optional::OMITTED_NAMED_ARG, "The block hash or height of the target height (only available with coinstatsindex).", "", {"", "string or numeric"}},
848+
{"hash_or_height", RPCArg::Type::NUM, RPCArg::DefaultHint{"the current best block"}, "The block hash or height of the target height (only available with coinstatsindex).", "", {"", "string or numeric"}},
849849
{"use_index", RPCArg::Type::BOOL, RPCArg::Default{true}, "Use coinstatsindex, if available."},
850850
},
851851
RPCResult{
@@ -881,6 +881,7 @@ static RPCHelpMan gettxoutsetinfo()
881881
HelpExampleCli("gettxoutsetinfo", R"("none")") +
882882
HelpExampleCli("gettxoutsetinfo", R"("none" 1000)") +
883883
HelpExampleCli("gettxoutsetinfo", R"("none" '"00000000c937983704a73af28acdec37b049d214adbda81d7e2a3dd146f6ed09"')") +
884+
HelpExampleCli("-named gettxoutsetinfo", R"(hash_type='muhash' use_index='false')") +
884885
HelpExampleRpc("gettxoutsetinfo", "") +
885886
HelpExampleRpc("gettxoutsetinfo", R"("none")") +
886887
HelpExampleRpc("gettxoutsetinfo", R"("none", 1000)") +
@@ -917,6 +918,9 @@ static RPCHelpMan gettxoutsetinfo()
917918
throw JSONRPCError(RPC_INVALID_PARAMETER, "hash_serialized_2 hash type cannot be queried for a specific block");
918919
}
919920

921+
if (!index_requested) {
922+
throw JSONRPCError(RPC_INVALID_PARAMETER, "Cannot set use_index to false when querying for a specific block");
923+
}
920924
pindex = ParseHashOrHeight(request.params[1], chainman);
921925
}
922926

0 commit comments

Comments
 (0)