aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorw0xlt <94266259+w0xlt@users.noreply.github.com>2021-12-14 20:49:11 -0300
committerw0xlt <94266259+w0xlt@users.noreply.github.com>2021-12-15 18:41:40 -0300
commit62fa61fa4a33ff4d108a65d656ffe2cac4330824 (patch)
tree1ba573882ef6bce71e536396e971eae16326f940 /src
parentabbb7eccef3fc1c36f34756458d2792f6661e29f (diff)
refactor: remove the wallet folder if the restore fails
Diffstat (limited to 'src')
-rw-r--r--src/wallet/wallet.cpp9
1 files changed, 8 insertions, 1 deletions
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<CWallet> 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