@@ -3628,6 +3628,26 @@ DescriptorScriptPubKeyMan& CWallet::LoadDescriptorScriptPubKeyMan(uint256 id, Wa
3628
3628
return *spk_manager;
3629
3629
}
3630
3630
3631
+ DescriptorScriptPubKeyMan& CWallet::SetupDescriptorScriptPubKeyMan (WalletBatch& batch, const CExtKey& master_key, const OutputType& output_type, bool internal)
3632
+ {
3633
+ AssertLockHeld (cs_wallet);
3634
+ auto spk_manager = std::unique_ptr<DescriptorScriptPubKeyMan>(new DescriptorScriptPubKeyMan (*this , m_keypool_size));
3635
+ if (IsCrypted ()) {
3636
+ if (IsLocked ()) {
3637
+ throw std::runtime_error (std::string (__func__) + " : Wallet is locked, cannot setup new descriptors" );
3638
+ }
3639
+ if (!spk_manager->CheckDecryptionKey (vMasterKey) && !spk_manager->Encrypt (vMasterKey, &batch)) {
3640
+ throw std::runtime_error (std::string (__func__) + " : Could not encrypt new descriptors" );
3641
+ }
3642
+ }
3643
+ spk_manager->SetupDescriptorGeneration (batch, master_key, output_type, internal);
3644
+ DescriptorScriptPubKeyMan* out = spk_manager.get ();
3645
+ uint256 id = spk_manager->GetID ();
3646
+ AddScriptPubKeyMan (id, std::move (spk_manager));
3647
+ AddActiveScriptPubKeyManWithDb (batch, id, output_type, internal);
3648
+ return *out;
3649
+ }
3650
+
3631
3651
void CWallet::SetupDescriptorScriptPubKeyMans (const CExtKey& master_key)
3632
3652
{
3633
3653
AssertLockHeld (cs_wallet);
@@ -3638,19 +3658,7 @@ void CWallet::SetupDescriptorScriptPubKeyMans(const CExtKey& master_key)
3638
3658
3639
3659
for (bool internal : {false , true }) {
3640
3660
for (OutputType t : OUTPUT_TYPES) {
3641
- auto spk_manager = std::unique_ptr<DescriptorScriptPubKeyMan>(new DescriptorScriptPubKeyMan (*this , m_keypool_size));
3642
- if (IsCrypted ()) {
3643
- if (IsLocked ()) {
3644
- throw std::runtime_error (std::string (__func__) + " : Wallet is locked, cannot setup new descriptors" );
3645
- }
3646
- if (!spk_manager->CheckDecryptionKey (vMasterKey) && !spk_manager->Encrypt (vMasterKey, &batch)) {
3647
- throw std::runtime_error (std::string (__func__) + " : Could not encrypt new descriptors" );
3648
- }
3649
- }
3650
- spk_manager->SetupDescriptorGeneration (batch, master_key, t, internal);
3651
- uint256 id = spk_manager->GetID ();
3652
- AddScriptPubKeyMan (id, std::move (spk_manager));
3653
- AddActiveScriptPubKeyManWithDb (batch, id, t, internal);
3661
+ SetupDescriptorScriptPubKeyMan (batch, master_key, t, internal);
3654
3662
}
3655
3663
}
3656
3664
0 commit comments