@@ -244,16 +244,12 @@ 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 ();
249
248
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 ());
249
+ auto ret = setTxids.insert (ParseHashV (txids[idx], " txid" ));
250
+ if (!ret.second ) {
251
+ throw JSONRPCError (RPC_INVALID_PARAMETER, std::string (" Invalid parameter, duplicated txid: " ) + txids[idx].get_str ());
254
252
}
255
- setTxids.insert (hash);
256
- oneTxid = hash;
257
253
}
258
254
259
255
CBlockIndex* pblockindex = nullptr ;
@@ -287,7 +283,7 @@ static RPCHelpMan gettxoutproof()
287
283
LOCK (cs_main);
288
284
289
285
if (pblockindex == nullptr ) {
290
- const CTransactionRef tx = GetTransaction (/* block_index */ nullptr , /* mempool */ nullptr , oneTxid , Params ().GetConsensus (), hashBlock);
286
+ const CTransactionRef tx = GetTransaction (/* block_index */ nullptr , /* mempool */ nullptr , *setTxids. begin () , Params ().GetConsensus (), hashBlock);
291
287
if (!tx || hashBlock.IsNull ()) {
292
288
throw JSONRPCError (RPC_INVALID_ADDRESS_OR_KEY, " Transaction not yet in block" );
293
289
}
0 commit comments