Skip to content

Commit 52fc399

Browse files
committed
rpc: Reject empty txids in gettxoutproof
1 parent 73dc19a commit 52fc399

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

src/rpc/rawtransaction.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,9 @@ static RPCHelpMan gettxoutproof()
245245
{
246246
std::set<uint256> setTxids;
247247
UniValue txids = request.params[0].get_array();
248+
if (txids.empty()) {
249+
throw JSONRPCError(RPC_INVALID_PARAMETER, "Parameter 'txids' cannot be empty");
250+
}
248251
for (unsigned int idx = 0; idx < txids.size(); idx++) {
249252
auto ret = setTxids.insert(ParseHashV(txids[idx], "txid"));
250253
if (!ret.second) {

test/functional/rpc_txoutproof.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ def run_test(self):
7878
# We can't get a proof if we specify transactions from different blocks
7979
assert_raises_rpc_error(-5, "Not all transactions found in specified or retrieved block", self.nodes[0].gettxoutproof, [txid1, txid3])
8080
# Test empty list
81-
assert_raises_rpc_error(-5, "Transaction not yet in block", self.nodes[0].gettxoutproof, [])
81+
assert_raises_rpc_error(-8, "Parameter 'txids' cannot be empty", self.nodes[0].gettxoutproof, [])
8282
# Test duplicate txid
8383
assert_raises_rpc_error(-8, 'Invalid parameter, duplicated txid', self.nodes[0].gettxoutproof, [txid1, txid1])
8484

0 commit comments

Comments
 (0)