@@ -3433,6 +3433,29 @@ void CWallet::LoadDescriptorScriptPubKeyMan(uint256 id, WalletDescriptor& desc)
34333433 }
34343434}
34353435
3436+ void CWallet::SetupDescriptorScriptPubKeyMans (const CExtKey& master_key)
3437+ {
3438+ AssertLockHeld (cs_wallet);
3439+
3440+ for (bool internal : {false , true }) {
3441+ for (OutputType t : OUTPUT_TYPES) {
3442+ auto spk_manager = std::unique_ptr<DescriptorScriptPubKeyMan>(new DescriptorScriptPubKeyMan (*this ));
3443+ if (IsCrypted ()) {
3444+ if (IsLocked ()) {
3445+ throw std::runtime_error (std::string (__func__) + " : Wallet is locked, cannot setup new descriptors" );
3446+ }
3447+ if (!spk_manager->CheckDecryptionKey (vMasterKey) && !spk_manager->Encrypt (vMasterKey, nullptr )) {
3448+ throw std::runtime_error (std::string (__func__) + " : Could not encrypt new descriptors" );
3449+ }
3450+ }
3451+ spk_manager->SetupDescriptorGeneration (master_key, t, internal);
3452+ uint256 id = spk_manager->GetID ();
3453+ m_spk_managers[id] = std::move (spk_manager);
3454+ AddActiveScriptPubKeyMan (id, t, internal);
3455+ }
3456+ }
3457+ }
3458+
34363459void CWallet::SetupDescriptorScriptPubKeyMans ()
34373460{
34383461 AssertLockHeld (cs_wallet);
@@ -3448,23 +3471,7 @@ void CWallet::SetupDescriptorScriptPubKeyMans()
34483471 CExtKey master_key;
34493472 master_key.SetSeed (seed_key);
34503473
3451- for (bool internal : {false , true }) {
3452- for (OutputType t : OUTPUT_TYPES) {
3453- auto spk_manager = std::unique_ptr<DescriptorScriptPubKeyMan>(new DescriptorScriptPubKeyMan (*this ));
3454- if (IsCrypted ()) {
3455- if (IsLocked ()) {
3456- throw std::runtime_error (std::string (__func__) + " : Wallet is locked, cannot setup new descriptors" );
3457- }
3458- if (!spk_manager->CheckDecryptionKey (vMasterKey) && !spk_manager->Encrypt (vMasterKey, nullptr )) {
3459- throw std::runtime_error (std::string (__func__) + " : Could not encrypt new descriptors" );
3460- }
3461- }
3462- spk_manager->SetupDescriptorGeneration (master_key, t, internal);
3463- uint256 id = spk_manager->GetID ();
3464- m_spk_managers[id] = std::move (spk_manager);
3465- AddActiveScriptPubKeyMan (id, t, internal);
3466- }
3467- }
3474+ SetupDescriptorScriptPubKeyMans (master_key);
34683475 } else {
34693476 ExternalSigner signer = ExternalSignerScriptPubKeyMan::GetExternalSigner ();
34703477
0 commit comments