aboutsummaryrefslogtreecommitdiff
path: root/src/wallet/load.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/load.cpp
parent9a2b5f22c1f603a6e3abc16dbf074c8d33a8d01f (diff)
wallet: Handle duplicate fileid exception
Diffstat (limited to 'src/wallet/load.cpp')
-rw-r--r--src/wallet/load.cpp26
1 files changed, 15 insertions, 11 deletions
diff --git a/src/wallet/load.cpp b/src/wallet/load.cpp
index 3e92c07d64..d6e44c7be5 100644
--- a/src/wallet/load.cpp
+++ b/src/wallet/load.cpp
@@ -66,19 +66,23 @@ bool VerifyWallets(interfaces::Chain& chain, const std::vector<std::string>& wal
bool LoadWallets(interfaces::Chain& chain, const std::vector<std::string>& wallet_files)
{
- for (const std::string& walletFile : wallet_files) {
- std::string error;
- std::vector<std::string> warnings;
- std::shared_ptr<CWallet> pwallet = CWallet::CreateWalletFromFile(chain, WalletLocation(walletFile), error, warnings);
- if (!warnings.empty()) chain.initWarning(Join(warnings, "\n"));
- if (!pwallet) {
- chain.initError(error);
- return false;
+ try {
+ for (const std::string& walletFile : wallet_files) {
+ std::string error;
+ std::vector<std::string> warnings;
+ std::shared_ptr<CWallet> pwallet = CWallet::CreateWalletFromFile(chain, WalletLocation(walletFile), error, warnings);
+ if (!warnings.empty()) chain.initWarning(Join(warnings, "\n"));
+ if (!pwallet) {
+ chain.initError(error);
+ return false;
+ }
+ AddWallet(pwallet);
}
- AddWallet(pwallet);
+ return true;
+ } catch (const std::runtime_error& e) {
+ chain.initError(e.what());
+ return false;
}
-
- return true;
}
void StartWallets(CScheduler& scheduler)