diff options
author | furszy <matiasfurszyfer@protonmail.com> | 2022-05-19 09:59:28 -0300 |
---|---|---|
committer | furszy <matiasfurszyfer@protonmail.com> | 2022-06-19 20:32:51 -0300 |
commit | 8dea74a8ff8f5d3fdf6602c0eaa0fcc5877fc569 (patch) | |
tree | de930a69181c40c263bb3af421b6d5ee38d80867 /src | |
parent | b4e2d4d4eea5f53aeb3124f966157222ea91106b (diff) |
refactor: use GetWalletTx in SelectCoins instead of access mapWallet
Diffstat (limited to 'src')
-rw-r--r-- | src/wallet/spend.cpp | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/src/wallet/spend.cpp b/src/wallet/spend.cpp index 0d3107e063..6119a047d6 100644 --- a/src/wallet/spend.cpp +++ b/src/wallet/spend.cpp @@ -441,15 +441,14 @@ std::optional<SelectionResult> SelectCoins(const CWallet& wallet, const std::vec for (const COutPoint& outpoint : vPresetInputs) { int input_bytes = -1; CTxOut txout; - std::map<uint256, CWalletTx>::const_iterator it = wallet.mapWallet.find(outpoint.hash); - if (it != wallet.mapWallet.end()) { - const CWalletTx& wtx = it->second; + auto ptr_wtx = wallet.GetWalletTx(outpoint.hash); + if (ptr_wtx) { // Clearly invalid input, fail - if (wtx.tx->vout.size() <= outpoint.n) { + if (ptr_wtx->tx->vout.size() <= outpoint.n) { return std::nullopt; } - input_bytes = GetTxSpendSize(wallet, wtx, outpoint.n, false); - txout = wtx.tx->vout.at(outpoint.n); + input_bytes = GetTxSpendSize(wallet, *ptr_wtx, outpoint.n, false); + txout = ptr_wtx->tx->vout.at(outpoint.n); } else { // The input is external. We did not find the tx in mapWallet. if (!coin_control.GetExternalOutput(outpoint, txout)) { |