diff options
Diffstat (limited to 'src/wallet/load.cpp')
-rw-r--r-- | src/wallet/load.cpp | 30 |
1 files changed, 17 insertions, 13 deletions
diff --git a/src/wallet/load.cpp b/src/wallet/load.cpp index 071befaebf..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) @@ -88,8 +92,8 @@ void StartWallets(CScheduler& scheduler) } // Schedule periodic wallet flushes and tx rebroadcasts - scheduler.scheduleEvery(MaybeCompactWalletDB, 500); - scheduler.scheduleEvery(MaybeResendWalletTxs, 1000); + scheduler.scheduleEvery(MaybeCompactWalletDB, std::chrono::milliseconds{500}); + scheduler.scheduleEvery(MaybeResendWalletTxs, std::chrono::milliseconds{1000}); } void FlushWallets() |