Skip to content

Commit 49675de

Browse files
committed
wallet: Have GetDebit use the wallet's TXO set
Instead of looking up the previous tx in mapWallet, and then calling IsMine on the specified output, use the TXO set and its cached IsMine value.
1 parent 17d453c commit 49675de

File tree

1 file changed

+4
-10
lines changed

1 file changed

+4
-10
lines changed

src/wallet/wallet.cpp

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1543,16 +1543,10 @@ void CWallet::BlockUntilSyncedToCurrentChain() const {
15431543
// and a not-"is mine" (according to the filter) input.
15441544
CAmount CWallet::GetDebit(const CTxIn &txin, const isminefilter& filter) const
15451545
{
1546-
{
1547-
LOCK(cs_wallet);
1548-
const auto mi = mapWallet.find(txin.prevout.hash);
1549-
if (mi != mapWallet.end())
1550-
{
1551-
const CWalletTx& prev = (*mi).second;
1552-
if (txin.prevout.n < prev.tx->vout.size())
1553-
if (IsMine(prev.tx->vout[txin.prevout.n]) & filter)
1554-
return prev.tx->vout[txin.prevout.n].nValue;
1555-
}
1546+
LOCK(cs_wallet);
1547+
auto txo = GetTXO(txin.prevout);
1548+
if (txo && (txo->GetIsMine() & filter)) {
1549+
return txo->GetTxOut().nValue;
15561550
}
15571551
return 0;
15581552
}

0 commit comments

Comments
 (0)