diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 1d31658637..d4cb379eda 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -324,6 +324,12 @@ std::shared_ptr CreateWallet(interfaces::Chain& chain, const std::strin wallet->m_spk_man->NewKeyPool(); // end TODO + // backup the wallet we just encrypted + if (!wallet->AutoBackupWallet("", error, warnings) && !error.original.empty()) { + status = DatabaseStatus::FAILED_ENCRYPT; + return nullptr; + } + // Relock the wallet wallet->Lock(); } @@ -4637,11 +4643,16 @@ bool CWallet::AutoBackupWallet(const fs::path& wallet_path, bilingual_str& error strWalletName = "wallet.dat"; } - if (!IsBDBFile(BDBDataFile(wallet_path))) { + if (!wallet_path.empty() && !IsBDBFile(BDBDataFile(wallet_path))) { WalletLogPrintf("Automatic wallet backups are currently only supported with Berkeley DB!\n"); return false; } + if (IsWalletFlagSet(WALLET_FLAG_BLANK_WALLET)) { + WalletLogPrintf("Wallet is blank, won't create new backup for it!\n"); + return false; + } + if (nWalletBackups <= 0) { WalletLogPrintf("Automatic wallet backups are disabled!\n"); return false;