@@ -210,9 +210,14 @@ WalletCreationStatus CreateWallet(interfaces::Chain& chain, const SecureString&
210
210
}
211
211
212
212
// Set a seed for the wallet
213
- CPubKey master_pub_key = wallet->m_spk_man ->GenerateNewSeed ();
214
- wallet->m_spk_man ->SetHDSeed (master_pub_key);
215
- wallet->m_spk_man ->NewKeyPool ();
213
+ {
214
+ if (auto spk_man = wallet->m_spk_man .get ()) {
215
+ if (!spk_man->SetupGeneration ()) {
216
+ error = " Unable to generate initial keys" ;
217
+ return WalletCreationStatus::CREATION_FAILED;
218
+ }
219
+ }
220
+ }
216
221
217
222
// Relock the wallet
218
223
wallet->Lock ();
@@ -565,11 +570,11 @@ bool CWallet::EncryptWallet(const SecureString& strWalletPassphrase)
565
570
Unlock (strWalletPassphrase);
566
571
567
572
// if we are using HD, replace the HD seed with a new one
568
- if (m_spk_man->IsHDEnabled ()) {
569
- m_spk_man->SetHDSeed (m_spk_man->GenerateNewSeed ());
573
+ if (auto spk_man = m_spk_man.get ()) {
574
+ if (spk_man->IsHDEnabled ()) {
575
+ spk_man->SetupGeneration (true );
576
+ }
570
577
}
571
-
572
- m_spk_man->NewKeyPool ();
573
578
Lock ();
574
579
575
580
// Need to completely rewrite the wallet file; if we don't, bdb might keep
@@ -3630,15 +3635,12 @@ std::shared_ptr<CWallet> CWallet::CreateWalletFromFile(interfaces::Chain& chain,
3630
3635
3631
3636
walletInstance->SetWalletFlags (wallet_creation_flags, false );
3632
3637
if (!(wallet_creation_flags & (WALLET_FLAG_DISABLE_PRIVATE_KEYS | WALLET_FLAG_BLANK_WALLET))) {
3633
- // generate a new seed
3634
- CPubKey seed = walletInstance->m_spk_man ->GenerateNewSeed ();
3635
- walletInstance->m_spk_man ->SetHDSeed (seed);
3636
- }
3637
-
3638
- // Top up the keypool
3639
- if (walletInstance->m_spk_man ->CanGenerateKeys () && !walletInstance->m_spk_man ->TopUp ()) {
3640
- error = _ (" Unable to generate initial keys" ).translated ;
3641
- return nullptr ;
3638
+ if (auto spk_man = walletInstance->m_spk_man .get ()) {
3639
+ if (!spk_man->SetupGeneration ()) {
3640
+ error = _ (" Unable to generate initial keys" ).translated ;
3641
+ return nullptr ;
3642
+ }
3643
+ }
3642
3644
}
3643
3645
3644
3646
auto locked_chain = chain.lock ();
0 commit comments