aboutsummaryrefslogtreecommitdiff
path: root/src/wallet/wallet.cpp
diff options
context:
space:
mode:
authorJoão Barbosa <joao.paulo.barbosa@gmail.com>2020-03-28 02:14:08 +0000
committerJoão Barbosa <joao.paulo.barbosa@gmail.com>2020-03-31 14:23:43 +0100
commitee9e88ba2734b81d0ffe23fd45c4f69a970c6494 (patch)
treeaffa697c956cbb96973091937b68e80995b04930 /src/wallet/wallet.cpp
parent9a2b5f22c1f603a6e3abc16dbf074c8d33a8d01f (diff)
wallet: Handle duplicate fileid exception
Diffstat (limited to 'src/wallet/wallet.cpp')
-rw-r--r--src/wallet/wallet.cpp25
1 files changed, 15 insertions, 10 deletions
diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp
index 98f308f927..bc9f84a11d 100644
--- a/src/wallet/wallet.cpp
+++ b/src/wallet/wallet.cpp
@@ -148,19 +148,24 @@ void UnloadWallet(std::shared_ptr<CWallet>&& wallet)
std::shared_ptr<CWallet> LoadWallet(interfaces::Chain& chain, const WalletLocation& location, std::string& error, std::vector<std::string>& warnings)
{
- if (!CWallet::Verify(chain, location, false, error, warnings)) {
- error = "Wallet file verification failed: " + error;
- return nullptr;
- }
+ try {
+ if (!CWallet::Verify(chain, location, false, error, warnings)) {
+ error = "Wallet file verification failed: " + error;
+ return nullptr;
+ }
- std::shared_ptr<CWallet> wallet = CWallet::CreateWalletFromFile(chain, location, error, warnings);
- if (!wallet) {
- error = "Wallet loading failed: " + error;
+ std::shared_ptr<CWallet> wallet = CWallet::CreateWalletFromFile(chain, location, error, warnings);
+ if (!wallet) {
+ error = "Wallet loading failed: " + error;
+ return nullptr;
+ }
+ AddWallet(wallet);
+ wallet->postInitProcess();
+ return wallet;
+ } catch (const std::runtime_error& e) {
+ error = e.what();
return nullptr;
}
- AddWallet(wallet);
- wallet->postInitProcess();
- return wallet;
}
std::shared_ptr<CWallet> LoadWallet(interfaces::Chain& chain, const std::string& name, std::string& error, std::vector<std::string>& warnings)