refactor: remove the wallet folder if the restore fails

This commit is contained in:
w0xlt
2021-12-14 20:49:11 -03:00
parent abbb7eccef
commit 62fa61fa4a
2 changed files with 24 additions and 1 deletions

View File

@ -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