mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-06-08 22:20:00 +02:00
Implement CWallet::IsSpentKey for non-LegacySPKMans
This commit is contained in:
parent
3c19fdd2a2
commit
886e0d75f5
@ -754,9 +754,15 @@ bool CWallet::IsSpentKey(const uint256& hash, unsigned int n) const
|
|||||||
const CWalletTx* srctx = GetWalletTx(hash);
|
const CWalletTx* srctx = GetWalletTx(hash);
|
||||||
if (srctx) {
|
if (srctx) {
|
||||||
assert(srctx->tx->vout.size() > n);
|
assert(srctx->tx->vout.size() > n);
|
||||||
|
CTxDestination dest;
|
||||||
|
if (!ExtractDestination(srctx->tx->vout[n].scriptPubKey, dest)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (GetDestData(dest, "used", nullptr)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (IsLegacy()) {
|
||||||
LegacyScriptPubKeyMan* spk_man = GetLegacyScriptPubKeyMan();
|
LegacyScriptPubKeyMan* spk_man = GetLegacyScriptPubKeyMan();
|
||||||
// When descriptor wallets arrive, these additional checks are
|
|
||||||
// likely superfluous and can be optimized out
|
|
||||||
assert(spk_man != nullptr);
|
assert(spk_man != nullptr);
|
||||||
for (const auto& keyid : GetAffectedKeys(srctx->tx->vout[n].scriptPubKey, *spk_man)) {
|
for (const auto& keyid : GetAffectedKeys(srctx->tx->vout[n].scriptPubKey, *spk_man)) {
|
||||||
WitnessV0KeyHash wpkh_dest(keyid);
|
WitnessV0KeyHash wpkh_dest(keyid);
|
||||||
@ -773,6 +779,7 @@ bool CWallet::IsSpentKey(const uint256& hash, unsigned int n) const
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user