wallet: Handle duplicate fileid exception

This commit is contained in:
João Barbosa
2020-03-28 02:14:08 +00:00
parent 9a2b5f22c1
commit ee9e88ba27
3 changed files with 32 additions and 23 deletions

View File

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