@@ -1037,22 +1037,22 @@ bool CWallet::IsSpentKey(const CScript& scriptPubKey) const
1037
1037
if (IsAddressPreviouslySpent (dest)) {
1038
1038
return true ;
1039
1039
}
1040
- if ( IsLegacy ()) {
1041
- LegacyScriptPubKeyMan* spk_man = GetLegacyScriptPubKeyMan ();
1042
- assert ( spk_man != nullptr ) ;
1043
- for ( const auto & keyid : GetAffectedKeys (scriptPubKey, *spk_man)) {
1044
- WitnessV0KeyHash wpkh_dest (keyid);
1045
- if ( IsAddressPreviouslySpent ( wpkh_dest)) {
1046
- return true ;
1047
- }
1048
- ScriptHash sh_wpkh_dest ( GetScriptForDestination (wpkh_dest));
1049
- if ( IsAddressPreviouslySpent (sh_wpkh_dest)) {
1050
- return true ;
1051
- }
1052
- PKHash pkh_dest (keyid);
1053
- if ( IsAddressPreviouslySpent ( pkh_dest)) {
1054
- return true ;
1055
- }
1040
+
1041
+ LegacyScriptPubKeyMan* spk_man = GetLegacyScriptPubKeyMan ();
1042
+ if (! spk_man) return false ;
1043
+
1044
+ for ( const auto & keyid : GetAffectedKeys (scriptPubKey, *spk_man)) {
1045
+ WitnessV0KeyHash wpkh_dest (keyid);
1046
+ if ( IsAddressPreviouslySpent (wpkh_dest)) {
1047
+ return true ;
1048
+ }
1049
+ ScriptHash sh_wpkh_dest ( GetScriptForDestination (wpkh_dest));
1050
+ if ( IsAddressPreviouslySpent (sh_wpkh_dest)) {
1051
+ return true ;
1052
+ }
1053
+ PKHash pkh_dest (keyid);
1054
+ if ( IsAddressPreviouslySpent (pkh_dest)) {
1055
+ return true ;
1056
1056
}
1057
1057
}
1058
1058
return false ;
@@ -1625,7 +1625,9 @@ isminetype CWallet::IsMine(const CScript& script) const
1625
1625
}
1626
1626
1627
1627
// Legacy wallet
1628
- if (IsLegacy ()) return GetLegacyScriptPubKeyMan ()->IsMine (script);
1628
+ if (LegacyScriptPubKeyMan* spkm = GetLegacyScriptPubKeyMan ()) {
1629
+ return spkm->IsMine (script);
1630
+ }
1629
1631
1630
1632
return ISMINE_NO;
1631
1633
}
@@ -3558,7 +3560,8 @@ std::set<ScriptPubKeyMan*> CWallet::GetScriptPubKeyMans(const CScript& script) c
3558
3560
Assume (std::all_of (spk_mans.begin (), spk_mans.end (), [&script, &sigdata](ScriptPubKeyMan* spkm) { return spkm->CanProvide (script, sigdata); }));
3559
3561
3560
3562
// Legacy wallet
3561
- if (IsLegacy () && GetLegacyScriptPubKeyMan ()->CanProvide (script, sigdata)) spk_mans.insert (GetLegacyScriptPubKeyMan ());
3563
+ LegacyScriptPubKeyMan* spkm = GetLegacyScriptPubKeyMan ();
3564
+ if (spkm && spkm->CanProvide (script, sigdata)) spk_mans.insert (spkm);
3562
3565
3563
3566
return spk_mans;
3564
3567
}
@@ -3588,7 +3591,8 @@ std::unique_ptr<SigningProvider> CWallet::GetSolvingProvider(const CScript& scri
3588
3591
}
3589
3592
3590
3593
// Legacy wallet
3591
- if (IsLegacy () && GetLegacyScriptPubKeyMan ()->CanProvide (script, sigdata)) return GetLegacyScriptPubKeyMan ()->GetSolvingProvider (script);
3594
+ LegacyScriptPubKeyMan* spkm = GetLegacyScriptPubKeyMan ();
3595
+ if (spkm && spkm->CanProvide (script, sigdata)) return spkm->GetSolvingProvider (script);
3592
3596
3593
3597
return nullptr ;
3594
3598
}
@@ -3845,11 +3849,7 @@ void CWallet::DeactivateScriptPubKeyMan(uint256 id, OutputType type, bool intern
3845
3849
3846
3850
bool CWallet::IsLegacy () const
3847
3851
{
3848
- if (m_internal_spk_managers.count (OutputType::LEGACY) == 0 ) {
3849
- return false ;
3850
- }
3851
- auto spk_man = dynamic_cast <LegacyScriptPubKeyMan*>(m_internal_spk_managers.at (OutputType::LEGACY));
3852
- return spk_man != nullptr ;
3852
+ return !IsWalletFlagSet (WALLET_FLAG_DESCRIPTORS);
3853
3853
}
3854
3854
3855
3855
DescriptorScriptPubKeyMan* CWallet::GetDescriptorScriptPubKeyMan (const WalletDescriptor& desc) const
0 commit comments