mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-04-29 23:09:44 -04:00
wallet: fix, detect blank legacy wallets in IsLegacy
Blank legacy wallets do not have active SPKM. They can only be detected by checking the descriptors' flag or the db format. This enables the migration of blank legacy wallets in the GUI.
This commit is contained in:
parent
c2d15d993e
commit
6ed424f2db
1 changed files with 24 additions and 24 deletions
|
@ -1037,22 +1037,22 @@ bool CWallet::IsSpentKey(const CScript& scriptPubKey) const
|
||||||
if (IsAddressPreviouslySpent(dest)) {
|
if (IsAddressPreviouslySpent(dest)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (IsLegacy()) {
|
|
||||||
LegacyScriptPubKeyMan* spk_man = GetLegacyScriptPubKeyMan();
|
LegacyScriptPubKeyMan* spk_man = GetLegacyScriptPubKeyMan();
|
||||||
assert(spk_man != nullptr);
|
if (!spk_man) return false;
|
||||||
for (const auto& keyid : GetAffectedKeys(scriptPubKey, *spk_man)) {
|
|
||||||
WitnessV0KeyHash wpkh_dest(keyid);
|
for (const auto& keyid : GetAffectedKeys(scriptPubKey, *spk_man)) {
|
||||||
if (IsAddressPreviouslySpent(wpkh_dest)) {
|
WitnessV0KeyHash wpkh_dest(keyid);
|
||||||
return true;
|
if (IsAddressPreviouslySpent(wpkh_dest)) {
|
||||||
}
|
return true;
|
||||||
ScriptHash sh_wpkh_dest(GetScriptForDestination(wpkh_dest));
|
}
|
||||||
if (IsAddressPreviouslySpent(sh_wpkh_dest)) {
|
ScriptHash sh_wpkh_dest(GetScriptForDestination(wpkh_dest));
|
||||||
return true;
|
if (IsAddressPreviouslySpent(sh_wpkh_dest)) {
|
||||||
}
|
return true;
|
||||||
PKHash pkh_dest(keyid);
|
}
|
||||||
if (IsAddressPreviouslySpent(pkh_dest)) {
|
PKHash pkh_dest(keyid);
|
||||||
return true;
|
if (IsAddressPreviouslySpent(pkh_dest)) {
|
||||||
}
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
@ -1625,7 +1625,9 @@ isminetype CWallet::IsMine(const CScript& script) const
|
||||||
}
|
}
|
||||||
|
|
||||||
// Legacy wallet
|
// Legacy wallet
|
||||||
if (IsLegacy()) return GetLegacyScriptPubKeyMan()->IsMine(script);
|
if (LegacyScriptPubKeyMan* spkm = GetLegacyScriptPubKeyMan()) {
|
||||||
|
return spkm->IsMine(script);
|
||||||
|
}
|
||||||
|
|
||||||
return ISMINE_NO;
|
return ISMINE_NO;
|
||||||
}
|
}
|
||||||
|
@ -3558,7 +3560,8 @@ std::set<ScriptPubKeyMan*> CWallet::GetScriptPubKeyMans(const CScript& script) c
|
||||||
Assume(std::all_of(spk_mans.begin(), spk_mans.end(), [&script, &sigdata](ScriptPubKeyMan* spkm) { return spkm->CanProvide(script, sigdata); }));
|
Assume(std::all_of(spk_mans.begin(), spk_mans.end(), [&script, &sigdata](ScriptPubKeyMan* spkm) { return spkm->CanProvide(script, sigdata); }));
|
||||||
|
|
||||||
// Legacy wallet
|
// Legacy wallet
|
||||||
if (IsLegacy() && GetLegacyScriptPubKeyMan()->CanProvide(script, sigdata)) spk_mans.insert(GetLegacyScriptPubKeyMan());
|
LegacyScriptPubKeyMan* spkm = GetLegacyScriptPubKeyMan();
|
||||||
|
if (spkm && spkm->CanProvide(script, sigdata)) spk_mans.insert(spkm);
|
||||||
|
|
||||||
return spk_mans;
|
return spk_mans;
|
||||||
}
|
}
|
||||||
|
@ -3588,7 +3591,8 @@ std::unique_ptr<SigningProvider> CWallet::GetSolvingProvider(const CScript& scri
|
||||||
}
|
}
|
||||||
|
|
||||||
// Legacy wallet
|
// Legacy wallet
|
||||||
if (IsLegacy() && GetLegacyScriptPubKeyMan()->CanProvide(script, sigdata)) return GetLegacyScriptPubKeyMan()->GetSolvingProvider(script);
|
LegacyScriptPubKeyMan* spkm = GetLegacyScriptPubKeyMan();
|
||||||
|
if (spkm && spkm->CanProvide(script, sigdata)) return spkm->GetSolvingProvider(script);
|
||||||
|
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
@ -3845,11 +3849,7 @@ void CWallet::DeactivateScriptPubKeyMan(uint256 id, OutputType type, bool intern
|
||||||
|
|
||||||
bool CWallet::IsLegacy() const
|
bool CWallet::IsLegacy() const
|
||||||
{
|
{
|
||||||
if (m_internal_spk_managers.count(OutputType::LEGACY) == 0) {
|
return !IsWalletFlagSet(WALLET_FLAG_DESCRIPTORS);
|
||||||
return false;
|
|
||||||
}
|
|
||||||
auto spk_man = dynamic_cast<LegacyScriptPubKeyMan*>(m_internal_spk_managers.at(OutputType::LEGACY));
|
|
||||||
return spk_man != nullptr;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
DescriptorScriptPubKeyMan* CWallet::GetDescriptorScriptPubKeyMan(const WalletDescriptor& desc) const
|
DescriptorScriptPubKeyMan* CWallet::GetDescriptorScriptPubKeyMan(const WalletDescriptor& desc) const
|
||||||
|
|
Loading…
Add table
Reference in a new issue