diff options
author | furszy <matiasfurszyfer@protonmail.com> | 2022-04-27 11:04:31 -0300 |
---|---|---|
committer | furszy <matiasfurszyfer@protonmail.com> | 2022-06-08 11:22:40 -0300 |
commit | 4b83bf8dbcf6b8b1c1293575391e90ac7e21b0e0 (patch) | |
tree | 4ac5a5f92709ae76159429c885834570527eecb0 /src | |
parent | 3d8a2822570e3cf4d1bc4f9d59b5dcb0145920ad (diff) | |
download | bitcoin-4b83bf8dbcf6b8b1c1293575391e90ac7e21b0e0.tar.xz |
wallet: avoid extra IsSpentKey -> GetWalletTx lookups
Diffstat (limited to 'src')
-rw-r--r-- | src/wallet/receive.cpp | 4 | ||||
-rw-r--r-- | src/wallet/rpc/coins.cpp | 2 | ||||
-rw-r--r-- | src/wallet/spend.cpp | 2 |
3 files changed, 4 insertions, 4 deletions
diff --git a/src/wallet/receive.cpp b/src/wallet/receive.cpp index 39d4574def..8de4017371 100644 --- a/src/wallet/receive.cpp +++ b/src/wallet/receive.cpp @@ -205,8 +205,8 @@ CAmount CachedTxGetAvailableCredit(const CWallet& wallet, const CWalletTx& wtx, CAmount nCredit = 0; uint256 hashTx = wtx.GetHash(); 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]; + const CTxOut& txout = wtx.tx->vout[i]; + if (!wallet.IsSpent(COutPoint(hashTx, i)) && (allow_used_addresses || !wallet.IsSpentKey(txout.scriptPubKey))) { nCredit += OutputGetCredit(wallet, txout, filter); if (!MoneyRange(nCredit)) throw std::runtime_error(std::string(__func__) + " : value out of range"); diff --git a/src/wallet/rpc/coins.cpp b/src/wallet/rpc/coins.cpp index 3eea03ff78..ad59cc94ff 100644 --- a/src/wallet/rpc/coins.cpp +++ b/src/wallet/rpc/coins.cpp @@ -649,7 +649,7 @@ RPCHelpMan listunspent() CTxDestination address; const CScript& scriptPubKey = out.txout.scriptPubKey; bool fValidAddress = ExtractDestination(scriptPubKey, address); - bool reused = avoid_reuse && pwallet->IsSpentKey(out.outpoint.hash, out.outpoint.n); + bool reused = avoid_reuse && pwallet->IsSpentKey(scriptPubKey); if (destinations.size() && (!fValidAddress || !destinations.count(address))) continue; diff --git a/src/wallet/spend.cpp b/src/wallet/spend.cpp index d178358048..c598f2c925 100644 --- a/src/wallet/spend.cpp +++ b/src/wallet/spend.cpp @@ -191,7 +191,7 @@ CoinsResult AvailableCoins(const CWallet& wallet, continue; } - if (!allow_used_addresses && wallet.IsSpentKey(wtxid, i)) { + if (!allow_used_addresses && wallet.IsSpentKey(output.scriptPubKey)) { continue; } |