diff --git a/src/rpc/budget.cpp b/src/rpc/budget.cpp index 9e6f900f97fda..74c7bd3a9d525 100644 --- a/src/rpc/budget.cpp +++ b/src/rpc/budget.cpp @@ -162,8 +162,9 @@ UniValue preparebudget(const JSONRPCRequest& request) throw JSONRPCError(RPC_WALLET_ERROR, res.ToString()); // Store proposal name as a comment - assert(pwallet->mapWallet.count(wtx->GetHash())); - pwallet->mapWallet.at(wtx->GetHash()).SetComment("Proposal: " + strProposalName); + auto it = pwallet->mapWallet.find(wtx->GetHash()); + assert(it != pwallet->mapWallet.end()); + it->second.SetComment("Proposal: " + strProposalName); return wtx->GetHash().ToString(); } diff --git a/src/sapling/saplingscriptpubkeyman.cpp b/src/sapling/saplingscriptpubkeyman.cpp index 75f371951d7d2..1b2593314f372 100644 --- a/src/sapling/saplingscriptpubkeyman.cpp +++ b/src/sapling/saplingscriptpubkeyman.cpp @@ -37,10 +37,9 @@ void SaplingScriptPubKeyMan::UpdateSaplingNullifierNoteMapForBlock(const CBlock LOCK(wallet->cs_wallet); for (const auto& tx : pblock->vtx) { - const uint256& hash = tx->GetHash(); - bool txIsOurs = wallet->mapWallet.count(hash); - if (txIsOurs) { - UpdateSaplingNullifierNoteMapWithTx(wallet->mapWallet.at(hash)); + auto it = wallet->mapWallet.find(tx->GetHash()); + if (it != wallet->mapWallet.end()) { + UpdateSaplingNullifierNoteMapWithTx(it->second); } } } @@ -746,8 +745,9 @@ CAmount SaplingScriptPubKeyMan::GetDebit(const CTransaction& tx, const isminefil // If we have the spend nullifier, it means that this input is ours. // The transaction (and decrypted note data) has been added to the wallet. const SaplingOutPoint& op = it->second; - assert(wallet->mapWallet.count(op.hash)); - const auto& wtx = wallet->mapWallet.at(op.hash); + auto wit = wallet->mapWallet.find(op.hash); + assert(wit != wallet->mapWallet.end()); + const auto& wtx = wit->second; assert(wtx.mapSaplingNoteData.count(op)); const auto& nd = wtx.mapSaplingNoteData.at(op); assert(nd.IsMyNote()); // todo: Add watch only check. @@ -820,10 +820,11 @@ void SaplingScriptPubKeyMan::GetSaplingNoteWitnesses(const std::vector rt; int i = 0; for (SaplingOutPoint note : notes) { - if (wallet->mapWallet.count(note.hash) && - wallet->mapWallet.at(note.hash).mapSaplingNoteData.count(note) && - wallet->mapWallet.at(note.hash).mapSaplingNoteData[note].witnesses.size() > 0) { - witnesses[i] = wallet->mapWallet.at(note.hash).mapSaplingNoteData[note].witnesses.front(); + auto it = wallet->mapWallet.find(note.hash); + if (it != wallet->mapWallet.end() && + it->second.mapSaplingNoteData.count(note) && + it->second.mapSaplingNoteData[note].witnesses.size() > 0) { + witnesses[i] = it->second.mapSaplingNoteData[note].witnesses.front(); if (!rt) { rt = witnesses[i]->root(); } else { diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index d90b68a97be9f..4d0501ff61cf3 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -1094,12 +1094,13 @@ static UniValue ShieldSendManyTo(CWallet * const pwallet, // add comments const uint256& txHash = uint256S(txid); - assert(pwallet->mapWallet.count(txHash)); + auto it = pwallet->mapWallet.find(txHash); + assert(it != pwallet->mapWallet.end()); if (!commentStr.empty()) { - pwallet->mapWallet.at(txHash).mapValue["comment"] = commentStr; + it->second.mapValue["comment"] = commentStr; } if (!toStr.empty()) { - pwallet->mapWallet.at(txHash).mapValue["to"] = toStr; + it->second.mapValue["to"] = toStr; } return txid; @@ -1532,9 +1533,10 @@ UniValue viewshieldtransaction(const JSONRPCRequest& request) hash.SetHex(request.params[0].get_str()); UniValue entry(UniValue::VOBJ); - if (!pwallet->mapWallet.count(hash)) + auto it = pwallet->mapWallet.find(hash); + if (it == pwallet->mapWallet.end()) throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid or non-wallet transaction id"); - const CWalletTx& wtx = pwallet->mapWallet.at(hash); + const CWalletTx& wtx = it->second; if (!wtx.tx->IsShieldedTx()) { throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid transaction, no shield data available"); @@ -2807,8 +2809,9 @@ UniValue listreceivedbyshieldaddress(const JSONRPCRequest& request) int index = -1; int64_t time = 0; - if (pwallet->mapWallet.count(entry.op.hash)) { - const CWalletTx& wtx = pwallet->mapWallet.at(entry.op.hash); + auto it = pwallet->mapWallet.find(entry.op.hash); + if (it != pwallet->mapWallet.end()) { + const CWalletTx& wtx = it->second; if (!wtx.m_confirm.hashBlock.IsNull()) height = mapBlockIndex[wtx.m_confirm.hashBlock]->nHeight; index = wtx.m_confirm.nIndex;