From 62fa61fa4a33ff4d108a65d656ffe2cac4330824 Mon Sep 17 00:00:00 2001 From: w0xlt <94266259+w0xlt@users.noreply.github.com> Date: Tue, 14 Dec 2021 20:49:11 -0300 Subject: refactor: remove the wallet folder if the restore fails --- src/wallet/wallet.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index f2d1acb71f..1c61d7e981 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -379,7 +379,14 @@ std::shared_ptr RestoreWallet(WalletContext& context, const std::string auto wallet_file = wallet_path / "wallet.dat"; fs::copy_file(backup_file, wallet_file, fs::copy_option::fail_if_exists); - return LoadWallet(context, wallet_name, load_on_start, options, status, error, warnings); + auto wallet = LoadWallet(context, wallet_name, load_on_start, options, status, error, warnings); + + if (!wallet) { + fs::remove(wallet_file); + fs::remove(wallet_path); + } + + return wallet; } /** @defgroup mapWallet -- cgit v1.2.3