mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-06-23 07:13:33 +02:00
wallet: avoid extra IsSpentKey -> GetWalletTx lookups
This commit is contained in:
parent
3d8a282257
commit
4b83bf8dbc
@ -205,8 +205,8 @@ CAmount CachedTxGetAvailableCredit(const CWallet& wallet, const CWalletTx& wtx,
|
|||||||
CAmount nCredit = 0;
|
CAmount nCredit = 0;
|
||||||
uint256 hashTx = wtx.GetHash();
|
uint256 hashTx = wtx.GetHash();
|
||||||
for (unsigned int i = 0; i < wtx.tx->vout.size(); 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];
|
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);
|
nCredit += OutputGetCredit(wallet, txout, filter);
|
||||||
if (!MoneyRange(nCredit))
|
if (!MoneyRange(nCredit))
|
||||||
throw std::runtime_error(std::string(__func__) + " : value out of range");
|
throw std::runtime_error(std::string(__func__) + " : value out of range");
|
||||||
|
@ -649,7 +649,7 @@ RPCHelpMan listunspent()
|
|||||||
CTxDestination address;
|
CTxDestination address;
|
||||||
const CScript& scriptPubKey = out.txout.scriptPubKey;
|
const CScript& scriptPubKey = out.txout.scriptPubKey;
|
||||||
bool fValidAddress = ExtractDestination(scriptPubKey, address);
|
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)))
|
if (destinations.size() && (!fValidAddress || !destinations.count(address)))
|
||||||
continue;
|
continue;
|
||||||
|
@ -191,7 +191,7 @@ CoinsResult AvailableCoins(const CWallet& wallet,
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!allow_used_addresses && wallet.IsSpentKey(wtxid, i)) {
|
if (!allow_used_addresses && wallet.IsSpentKey(output.scriptPubKey)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user