Skip to content

Commit df2f166

Browse files
author
MacroFake
committed
Merge bitcoin/bitcoin#26508: RPC/Blockchain: Minor improvements for scanblocks & scantxoutset docs/errors
f986984 RPC/blockchain: scan{blocks,txoutset>: Further doc improvements (Luke Dashjr) 54b45e1 RPC/Blockchain: Clarify invalid-action error in scanblocks & scantxoutset (Luke Dashjr) Pull request description: * Clarify invalid-action error in scanblocks & scantxoutset * Mention action=='start' only returns after scan completes (already in scantxoutset) * Document `relevant_blocks` ACKs for top commit: kristapsk: utACK f986984 aureleoules: ACK f986984 MarnixCroes: ACK f986984 Tree-SHA512: a37c9cc8a9a2f59376e8d8ed7dbf5e140eb3fefb4b7c19a23fc8190f3aef060bda1f0d5d06dc81cd7dca9e871d65f6c8094bab6e8d42e0bcef0fc7ffd2342d09
2 parents 295f617 + f986984 commit df2f166

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

src/rpc/blockchain.cpp

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2205,7 +2205,7 @@ static RPCHelpMan scantxoutset()
22052205
result.pushKV("unspents", unspents);
22062206
result.pushKV("total_amount", ValueFromAmount(total_in));
22072207
} else {
2208-
throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid command");
2208+
throw JSONRPCError(RPC_INVALID_PARAMETER, strprintf("Invalid action '%s'", request.params[0].get_str()));
22092209
}
22102210
return result;
22112211
},
@@ -2254,12 +2254,13 @@ static RPCHelpMan scanblocks()
22542254
},
22552255
{
22562256
scan_result_status_none,
2257-
RPCResult{"When action=='start'", RPCResult::Type::OBJ, "", "", {
2257+
RPCResult{"When action=='start'; only returns after scan completes", RPCResult::Type::OBJ, "", "", {
22582258
{RPCResult::Type::NUM, "from_height", "The height we started the scan from"},
22592259
{RPCResult::Type::NUM, "to_height", "The height we ended the scan at"},
2260-
{RPCResult::Type::ARR, "relevant_blocks", "", {{RPCResult::Type::STR_HEX, "blockhash", "A relevant blockhash"},}},
2261-
},
2262-
},
2260+
{RPCResult::Type::ARR, "relevant_blocks", "Blocks that may have matched a scanobject.", {
2261+
{RPCResult::Type::STR_HEX, "blockhash", "A relevant blockhash"},
2262+
}},
2263+
}},
22632264
RPCResult{"when action=='status' and a scan is currently in progress", RPCResult::Type::OBJ, "", "", {
22642265
{RPCResult::Type::NUM, "progress", "Approximate percent complete"},
22652266
{RPCResult::Type::NUM, "current_height", "Height of the block currently being scanned"},
@@ -2402,7 +2403,7 @@ static RPCHelpMan scanblocks()
24022403
ret.pushKV("relevant_blocks", blocks);
24032404
}
24042405
else {
2405-
throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid command");
2406+
throw JSONRPCError(RPC_INVALID_PARAMETER, strprintf("Invalid action '%s'", request.params[0].get_str()));
24062407
}
24072408
return ret;
24082409
},

test/functional/rpc_scanblocks.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ def run_test(self):
122122
assert_equal(node.scanblocks("abort"), False)
123123

124124
# test invalid command
125-
assert_raises_rpc_error(-8, "Invalid command", node.scanblocks, "foobar")
125+
assert_raises_rpc_error(-8, "Invalid action 'foobar'", node.scanblocks, "foobar")
126126

127127

128128
if __name__ == '__main__':

0 commit comments

Comments
 (0)