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.
This commit is contained in:
1 parent
17d453cb3a
commit
49675de035
1 file changed
+3
-9
@@ -1542,17 +1542,11 @@ void CWallet::BlockUntilSyncedToCurrentChain() const {
|
|||||||
// Note that this function doesn't distinguish between a 0-valued input,
|
// Note that this function doesn't distinguish between a 0-valued input,
|
||||||
// and a not-"is mine" (according to the filter) input.
|
// and a not-"is mine" (according to the filter) input.
|
||||||
CAmount CWallet::GetDebit(const CTxIn &txin, const isminefilter& filter) const
|
CAmount CWallet::GetDebit(const CTxIn &txin, const isminefilter& filter) const
|
||||||
{
|
|
||||||
{
|
{
|
||||||
LOCK(cs_wallet);
|
LOCK(cs_wallet);
|
||||||
const auto mi = mapWallet.find(txin.prevout.hash);
|
auto txo = GetTXO(txin.prevout);
|
||||||
if (mi != mapWallet.end())
|
if (txo && (txo->GetIsMine() & filter)) {
|
||||||
{
|
return txo->GetTxOut().nValue;
|
||||||
const CWalletTx& prev = (*mi).second;
|
|
||||||
if (txin.prevout.n < prev.tx->vout.size())
|
|
||||||
if (IsMine(prev.tx->vout[txin.prevout.n]) & filter)
|
|
||||||
return prev.tx->vout[txin.prevout.n].nValue;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user