diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 3263d24e3f..4f883853e7 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -336,6 +336,12 @@ std::shared_ptr CreateWallet(interfaces::Chain& chain, const std::strin } // 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(); } @@ -4864,11 +4870,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;