@@ -591,16 +591,15 @@ static UniValue gettxoutproof(const JSONRPCRequest& request)
591
591
}.Check (request);
592
592
593
593
std::set<uint256> setTxids;
594
- uint256 oneTxid;
595
594
UniValue txids = request.params [0 ].get_array ();
595
+ if (txids.empty ()) {
596
+ throw JSONRPCError (RPC_INVALID_PARAMETER, " Parameter 'txids' cannot be empty" );
597
+ }
596
598
for (unsigned int idx = 0 ; idx < txids.size (); idx++) {
597
- const UniValue& txid = txids[idx];
598
- uint256 hash (ParseHashV (txid, " txid" ));
599
- if (setTxids.count (hash)) {
600
- throw JSONRPCError (RPC_INVALID_PARAMETER, std::string (" Invalid parameter, duplicated txid: " )+txid.get_str ());
599
+ auto ret = setTxids.insert (ParseHashV (txids[idx], " txid" ));
600
+ if (!ret.second ) {
601
+ throw JSONRPCError (RPC_INVALID_PARAMETER, std::string (" Invalid parameter, duplicated txid: " ) + txids[idx].get_str ());
601
602
}
602
- setTxids.insert (hash);
603
- oneTxid = hash;
604
603
}
605
604
606
605
CBlockIndex* pblockindex = nullptr ;
@@ -636,7 +635,7 @@ static UniValue gettxoutproof(const JSONRPCRequest& request)
636
635
LOCK (cs_main);
637
636
638
637
if (pblockindex == nullptr ) {
639
- const CTransactionRef tx = GetTransaction (/* block_index */ nullptr , /* mempool */ nullptr , oneTxid , Params ().GetConsensus (), hashBlock);
638
+ const CTransactionRef tx = GetTransaction (/* block_index */ nullptr , /* mempool */ nullptr , *setTxids. begin () , Params ().GetConsensus (), hashBlock);
640
639
if (!tx || hashBlock.IsNull ()) {
641
640
throw JSONRPCError (RPC_INVALID_ADDRESS_OR_KEY, " Transaction not yet in block" );
642
641
}
0 commit comments