diff options
Diffstat (limited to 'src/wallet/wallet.cpp')
-rw-r--r-- | src/wallet/wallet.cpp | 25 |
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) |