mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-12 15:09:59 +01:00
IsUsedDestination should count any known single-key address
This commit is contained in:
@@ -719,17 +719,33 @@ void CWallet::SetUsedDestinationState(WalletBatch& batch, const uint256& hash, u
|
||||
}
|
||||
}
|
||||
|
||||
bool CWallet::IsUsedDestination(const CTxDestination& dst) const
|
||||
{
|
||||
LOCK(cs_wallet);
|
||||
return IsMine(dst) && GetDestData(dst, "used", nullptr);
|
||||
}
|
||||
|
||||
bool CWallet::IsUsedDestination(const uint256& hash, unsigned int n) const
|
||||
{
|
||||
AssertLockHeld(cs_wallet);
|
||||
CTxDestination dst;
|
||||
const CWalletTx* srctx = GetWalletTx(hash);
|
||||
return srctx && ExtractDestination(srctx->tx->vout[n].scriptPubKey, dst) && IsUsedDestination(dst);
|
||||
if (srctx) {
|
||||
assert(srctx->tx->vout.size() > n);
|
||||
LegacyScriptPubKeyMan* spk_man = GetLegacyScriptPubKeyMan();
|
||||
// When descriptor wallets arrive, these additional checks are
|
||||
// likely superfluous and can be optimized out
|
||||
assert(spk_man != nullptr);
|
||||
for (const auto& keyid : GetAffectedKeys(srctx->tx->vout[n].scriptPubKey, *spk_man)) {
|
||||
WitnessV0KeyHash wpkh_dest(keyid);
|
||||
if (GetDestData(wpkh_dest, "used", nullptr)) {
|
||||
return true;
|
||||
}
|
||||
ScriptHash sh_wpkh_dest(wpkh_dest);
|
||||
if (GetDestData(sh_wpkh_dest, "used", nullptr)) {
|
||||
return true;
|
||||
}
|
||||
PKHash pkh_dest(keyid);
|
||||
if (GetDestData(pkh_dest, "used", nullptr)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CWallet::AddToWallet(const CWalletTx& wtxIn, bool fFlushOnClose)
|
||||
|
||||
Reference in New Issue
Block a user