@@ -3498,6 +3498,11 @@ LegacyScriptPubKeyMan* CWallet::GetOrCreateLegacyScriptPubKeyMan()
3498
3498
return GetLegacyScriptPubKeyMan ();
3499
3499
}
3500
3500
3501
+ void CWallet::AddScriptPubKeyMan (const uint256& id, std::unique_ptr<ScriptPubKeyMan> spkm_man)
3502
+ {
3503
+ m_spk_managers[id] = std::move (spkm_man);
3504
+ }
3505
+
3501
3506
void CWallet::SetupLegacyScriptPubKeyMan ()
3502
3507
{
3503
3508
if (!m_internal_spk_managers.empty () || !m_external_spk_managers.empty () || !m_spk_managers.empty () || IsWalletFlagSet (WALLET_FLAG_DESCRIPTORS)) {
@@ -3509,7 +3514,8 @@ void CWallet::SetupLegacyScriptPubKeyMan()
3509
3514
m_internal_spk_managers[type] = spk_manager.get ();
3510
3515
m_external_spk_managers[type] = spk_manager.get ();
3511
3516
}
3512
- m_spk_managers[spk_manager->GetID ()] = std::move (spk_manager);
3517
+ uint256 id = spk_manager->GetID ();
3518
+ AddScriptPubKeyMan (id, std::move (spk_manager));
3513
3519
}
3514
3520
3515
3521
const CKeyingMaterial& CWallet::GetEncryptionKey () const
@@ -3534,10 +3540,10 @@ void CWallet::LoadDescriptorScriptPubKeyMan(uint256 id, WalletDescriptor& desc)
3534
3540
{
3535
3541
if (IsWalletFlagSet (WALLET_FLAG_EXTERNAL_SIGNER)) {
3536
3542
auto spk_manager = std::unique_ptr<ScriptPubKeyMan>(new ExternalSignerScriptPubKeyMan (*this , desc, m_keypool_size));
3537
- m_spk_managers[id] = std::move (spk_manager);
3543
+ AddScriptPubKeyMan (id, std::move (spk_manager) );
3538
3544
} else {
3539
3545
auto spk_manager = std::unique_ptr<ScriptPubKeyMan>(new DescriptorScriptPubKeyMan (*this , desc, m_keypool_size));
3540
- m_spk_managers[id] = std::move (spk_manager);
3546
+ AddScriptPubKeyMan (id, std::move (spk_manager) );
3541
3547
}
3542
3548
}
3543
3549
@@ -3558,7 +3564,7 @@ void CWallet::SetupDescriptorScriptPubKeyMans(const CExtKey& master_key)
3558
3564
}
3559
3565
spk_manager->SetupDescriptorGeneration (master_key, t, internal);
3560
3566
uint256 id = spk_manager->GetID ();
3561
- m_spk_managers[id] = std::move (spk_manager);
3567
+ AddScriptPubKeyMan (id, std::move (spk_manager) );
3562
3568
AddActiveScriptPubKeyMan (id, t, internal);
3563
3569
}
3564
3570
}
@@ -3606,7 +3612,7 @@ void CWallet::SetupDescriptorScriptPubKeyMans()
3606
3612
auto spk_manager = std::unique_ptr<ExternalSignerScriptPubKeyMan>(new ExternalSignerScriptPubKeyMan (*this , m_keypool_size));
3607
3613
spk_manager->SetupDescriptor (std::move (desc));
3608
3614
uint256 id = spk_manager->GetID ();
3609
- m_spk_managers[id] = std::move (spk_manager);
3615
+ AddScriptPubKeyMan (id, std::move (spk_manager) );
3610
3616
AddActiveScriptPubKeyMan (id, t, internal);
3611
3617
}
3612
3618
}
@@ -3723,7 +3729,8 @@ ScriptPubKeyMan* CWallet::AddWalletDescriptor(WalletDescriptor& desc, const Flat
3723
3729
spk_man = new_spk_man.get ();
3724
3730
3725
3731
// Save the descriptor to memory
3726
- m_spk_managers[new_spk_man->GetID ()] = std::move (new_spk_man);
3732
+ uint256 id = new_spk_man->GetID ();
3733
+ AddScriptPubKeyMan (id, std::move (new_spk_man));
3727
3734
}
3728
3735
3729
3736
// Add the private keys to the descriptor
@@ -3866,7 +3873,8 @@ bool CWallet::ApplyMigrationData(MigrationData& data, bilingual_str& error)
3866
3873
error = _ (" Error: Duplicate descriptors created during migration. Your wallet may be corrupted." );
3867
3874
return false ;
3868
3875
}
3869
- m_spk_managers[desc_spkm->GetID ()] = std::move (desc_spkm);
3876
+ uint256 id = desc_spkm->GetID ();
3877
+ AddScriptPubKeyMan (id, std::move (desc_spkm));
3870
3878
}
3871
3879
3872
3880
// Remove the LegacyScriptPubKeyMan from disk
0 commit comments