@@ -244,16 +244,15 @@ static RPCHelpMan gettxoutproof()
244
244
[&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
245
245
{
246
246
std::set<uint256> setTxids;
247
- uint256 oneTxid;
248
247
UniValue txids = request.params [0 ].get_array ();
248
+ if (txids.empty ()) {
249
+ throw JSONRPCError (RPC_INVALID_PARAMETER, " Parameter 'txids' cannot be empty" );
250
+ }
249
251
for (unsigned int idx = 0 ; idx < txids.size (); idx++) {
250
- const UniValue& txid = txids[idx];
251
- uint256 hash (ParseHashV (txid, " txid" ));
252
- if (setTxids.count (hash)) {
253
- throw JSONRPCError (RPC_INVALID_PARAMETER, std::string (" Invalid parameter, duplicated txid: " ) + txid.get_str ());
252
+ auto ret = setTxids.insert (ParseHashV (txids[idx], " txid" ));
253
+ if (!ret.second ) {
254
+ throw JSONRPCError (RPC_INVALID_PARAMETER, std::string (" Invalid parameter, duplicated txid: " ) + txids[idx].get_str ());
254
255
}
255
- setTxids.insert (hash);
256
- oneTxid = hash;
257
256
}
258
257
259
258
CBlockIndex* pblockindex = nullptr ;
@@ -287,7 +286,7 @@ static RPCHelpMan gettxoutproof()
287
286
LOCK (cs_main);
288
287
289
288
if (pblockindex == nullptr ) {
290
- const CTransactionRef tx = GetTransaction (/* block_index */ nullptr , /* mempool */ nullptr , oneTxid , Params ().GetConsensus (), hashBlock);
289
+ const CTransactionRef tx = GetTransaction (/* block_index */ nullptr , /* mempool */ nullptr , *setTxids. begin () , Params ().GetConsensus (), hashBlock);
291
290
if (!tx || hashBlock.IsNull ()) {
292
291
throw JSONRPCError (RPC_INVALID_ADDRESS_OR_KEY, " Transaction not yet in block" );
293
292
}
0 commit comments