diff options
author | furszy <matiasfurszyfer@protonmail.com> | 2022-04-27 10:52:30 -0300 |
---|---|---|
committer | furszy <matiasfurszyfer@protonmail.com> | 2022-06-08 11:22:39 -0300 |
commit | a06fa94ff81e2bccef0316ea5ec4eca0f4de5071 (patch) | |
tree | 2539c545d00292374270690795d78a91b92fee6c /src/wallet/receive.cpp | |
parent | 91902b77202fc636edb3db587cb6e87d9fb9b60a (diff) |
wallet: IsSpent, 'COutPoint' arg instead of (hash, index)
Diffstat (limited to 'src/wallet/receive.cpp')
-rw-r--r-- | src/wallet/receive.cpp | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/src/wallet/receive.cpp b/src/wallet/receive.cpp index 8cce07b921..39d4574def 100644 --- a/src/wallet/receive.cpp +++ b/src/wallet/receive.cpp @@ -204,9 +204,8 @@ CAmount CachedTxGetAvailableCredit(const CWallet& wallet, const CWalletTx& wtx, bool allow_used_addresses = (filter & ISMINE_USED) || !wallet.IsWalletFlagSet(WALLET_FLAG_AVOID_REUSE); CAmount nCredit = 0; uint256 hashTx = wtx.GetHash(); - for (unsigned int i = 0; i < wtx.tx->vout.size(); i++) - { - if (!wallet.IsSpent(hashTx, i) && (allow_used_addresses || !wallet.IsSpentKey(hashTx, i))) { + for (unsigned int i = 0; i < wtx.tx->vout.size(); i++) { + if (!wallet.IsSpent(COutPoint(hashTx, i)) && (allow_used_addresses || !wallet.IsSpentKey(hashTx, i))) { const CTxOut &txout = wtx.tx->vout[i]; nCredit += OutputGetCredit(wallet, txout, filter); if (!MoneyRange(nCredit)) @@ -371,15 +370,15 @@ std::map<CTxDestination, CAmount> GetAddressBalances(const CWallet& wallet) if (nDepth < (CachedTxIsFromMe(wallet, wtx, ISMINE_ALL) ? 0 : 1)) continue; - for (unsigned int i = 0; i < wtx.tx->vout.size(); i++) - { + for (unsigned int i = 0; i < wtx.tx->vout.size(); i++) { + const auto& output = wtx.tx->vout[i]; CTxDestination addr; - if (!wallet.IsMine(wtx.tx->vout[i])) + if (!wallet.IsMine(output)) continue; - if(!ExtractDestination(wtx.tx->vout[i].scriptPubKey, addr)) + if(!ExtractDestination(output.scriptPubKey, addr)) continue; - CAmount n = wallet.IsSpent(walletEntry.first, i) ? 0 : wtx.tx->vout[i].nValue; + CAmount n = wallet.IsSpent(COutPoint(walletEntry.first, i)) ? 0 : output.nValue; balances[addr] += n; } } |