mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-06-13 10:21:34 +02:00
rpc: Reject empty txids in gettxoutproof
This commit is contained in:
parent
73dc19a330
commit
52fc39917f
@ -245,6 +245,9 @@ static RPCHelpMan gettxoutproof()
|
|||||||
{
|
{
|
||||||
std::set<uint256> setTxids;
|
std::set<uint256> setTxids;
|
||||||
UniValue txids = request.params[0].get_array();
|
UniValue txids = request.params[0].get_array();
|
||||||
|
if (txids.empty()) {
|
||||||
|
throw JSONRPCError(RPC_INVALID_PARAMETER, "Parameter 'txids' cannot be empty");
|
||||||
|
}
|
||||||
for (unsigned int idx = 0; idx < txids.size(); idx++) {
|
for (unsigned int idx = 0; idx < txids.size(); idx++) {
|
||||||
auto ret = setTxids.insert(ParseHashV(txids[idx], "txid"));
|
auto ret = setTxids.insert(ParseHashV(txids[idx], "txid"));
|
||||||
if (!ret.second) {
|
if (!ret.second) {
|
||||||
|
@ -78,7 +78,7 @@ class MerkleBlockTest(BitcoinTestFramework):
|
|||||||
# We can't get a proof if we specify transactions from different blocks
|
# We can't get a proof if we specify transactions from different blocks
|
||||||
assert_raises_rpc_error(-5, "Not all transactions found in specified or retrieved block", self.nodes[0].gettxoutproof, [txid1, txid3])
|
assert_raises_rpc_error(-5, "Not all transactions found in specified or retrieved block", self.nodes[0].gettxoutproof, [txid1, txid3])
|
||||||
# Test empty list
|
# Test empty list
|
||||||
assert_raises_rpc_error(-5, "Transaction not yet in block", self.nodes[0].gettxoutproof, [])
|
assert_raises_rpc_error(-8, "Parameter 'txids' cannot be empty", self.nodes[0].gettxoutproof, [])
|
||||||
# Test duplicate txid
|
# Test duplicate txid
|
||||||
assert_raises_rpc_error(-8, 'Invalid parameter, duplicated txid', self.nodes[0].gettxoutproof, [txid1, txid1])
|
assert_raises_rpc_error(-8, 'Invalid parameter, duplicated txid', self.nodes[0].gettxoutproof, [txid1, txid1])
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user