mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-02-02 14:37:42 -03:00
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:
parent
79a35663f0
commit
933a550af5
1 changed files with 4 additions and 10 deletions
|
@ -1593,16 +1593,10 @@ void CWallet::BlockUntilSyncedToCurrentChain() const {
|
|||
// and a not-"is mine" (according to the filter) input.
|
||||
CAmount CWallet::GetDebit(const CTxIn &txin, const isminefilter& filter) const
|
||||
{
|
||||
{
|
||||
LOCK(cs_wallet);
|
||||
const auto mi = mapWallet.find(txin.prevout.hash);
|
||||
if (mi != mapWallet.end())
|
||||
{
|
||||
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;
|
||||
}
|
||||
LOCK(cs_wallet);
|
||||
auto txo = GetTXO(txin.prevout);
|
||||
if (txo && (txo->GetIsMine() & filter)) {
|
||||
return txo->GetTxOut().nValue;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue