Skip to content

Commit 8dea74a

Browse files
committed
refactor: use GetWalletTx in SelectCoins instead of access mapWallet
1 parent b4e2d4d commit 8dea74a

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

src/wallet/spend.cpp

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -441,15 +441,14 @@ std::optional<SelectionResult> SelectCoins(const CWallet& wallet, const std::vec
441441
for (const COutPoint& outpoint : vPresetInputs) {
442442
int input_bytes = -1;
443443
CTxOut txout;
444-
std::map<uint256, CWalletTx>::const_iterator it = wallet.mapWallet.find(outpoint.hash);
445-
if (it != wallet.mapWallet.end()) {
446-
const CWalletTx& wtx = it->second;
444+
auto ptr_wtx = wallet.GetWalletTx(outpoint.hash);
445+
if (ptr_wtx) {
447446
// Clearly invalid input, fail
448-
if (wtx.tx->vout.size() <= outpoint.n) {
447+
if (ptr_wtx->tx->vout.size() <= outpoint.n) {
449448
return std::nullopt;
450449
}
451-
input_bytes = GetTxSpendSize(wallet, wtx, outpoint.n, false);
452-
txout = wtx.tx->vout.at(outpoint.n);
450+
input_bytes = GetTxSpendSize(wallet, *ptr_wtx, outpoint.n, false);
451+
txout = ptr_wtx->tx->vout.at(outpoint.n);
453452
} else {
454453
// The input is external. We did not find the tx in mapWallet.
455454
if (!coin_control.GetExternalOutput(outpoint, txout)) {

0 commit comments

Comments
 (0)