Changeset View
Changeset View
Standalone View
Standalone View
src/wallet/load.cpp
// Copyright (c) 2009-2010 Satoshi Nakamoto | // Copyright (c) 2009-2010 Satoshi Nakamoto | ||||
// Copyright (c) 2009-2018 The Bitcoin Core developers | // Copyright (c) 2009-2018 The Bitcoin Core developers | ||||
// Distributed under the MIT software license, see the accompanying | // Distributed under the MIT software license, see the accompanying | ||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php. | // file COPYING or http://www.opensource.org/licenses/mit-license.php. | ||||
#include <wallet/load.h> | #include <wallet/load.h> | ||||
#include <interfaces/chain.h> | #include <interfaces/chain.h> | ||||
#include <scheduler.h> | #include <scheduler.h> | ||||
#include <util/string.h> | |||||
#include <util/system.h> | #include <util/system.h> | ||||
#include <util/translation.h> | #include <util/translation.h> | ||||
#include <wallet/wallet.h> | #include <wallet/wallet.h> | ||||
bool VerifyWallets(const CChainParams &chainParams, interfaces::Chain &chain, | bool VerifyWallets(const CChainParams &chainParams, interfaces::Chain &chain, | ||||
const std::vector<std::string> &wallet_files) { | const std::vector<std::string> &wallet_files) { | ||||
if (gArgs.IsArgSet("-walletdir")) { | if (gArgs.IsArgSet("-walletdir")) { | ||||
fs::path wallet_dir = gArgs.GetArg("-walletdir", ""); | fs::path wallet_dir = gArgs.GetArg("-walletdir", ""); | ||||
▲ Show 20 Lines • Show All 42 Lines • ▼ Show 20 Lines | for (const auto &wallet_file : wallet_files) { | ||||
chain.initError(strprintf(_("Error loading wallet %s. Duplicate " | chain.initError(strprintf(_("Error loading wallet %s. Duplicate " | ||||
"-wallet filename specified.") | "-wallet filename specified.") | ||||
.translated, | .translated, | ||||
wallet_file)); | wallet_file)); | ||||
return false; | return false; | ||||
} | } | ||||
std::string error_string; | std::string error_string; | ||||
std::string warning_string; | std::vector<std::string> warnings; | ||||
bool verify_success = | bool verify_success = | ||||
CWallet::Verify(chainParams, chain, location, salvage_wallet, | CWallet::Verify(chainParams, chain, location, salvage_wallet, | ||||
error_string, warning_string); | error_string, warnings); | ||||
if (!error_string.empty()) { | if (!error_string.empty()) { | ||||
chain.initError(error_string); | chain.initError(error_string); | ||||
} | } | ||||
if (!warning_string.empty()) { | if (!warnings.empty()) { | ||||
chain.initWarning(warning_string); | chain.initWarning(Join(warnings, "\n")); | ||||
} | } | ||||
if (!verify_success) { | if (!verify_success) { | ||||
return false; | return false; | ||||
} | } | ||||
} | } | ||||
return true; | return true; | ||||
} | } | ||||
bool LoadWallets(const CChainParams &chainParams, interfaces::Chain &chain, | bool LoadWallets(const CChainParams &chainParams, interfaces::Chain &chain, | ||||
const std::vector<std::string> &wallet_files) { | const std::vector<std::string> &wallet_files) { | ||||
for (const std::string &walletFile : wallet_files) { | for (const std::string &walletFile : wallet_files) { | ||||
std::string error; | |||||
std::vector<std::string> warnings; | |||||
std::shared_ptr<CWallet> pwallet = CWallet::CreateWalletFromFile( | std::shared_ptr<CWallet> pwallet = CWallet::CreateWalletFromFile( | ||||
chainParams, chain, WalletLocation(walletFile)); | chainParams, chain, WalletLocation(walletFile), error, warnings); | ||||
if (!warnings.empty()) { | |||||
chain.initWarning(Join(warnings, "\n")); | |||||
} | |||||
if (!pwallet) { | if (!pwallet) { | ||||
chain.initError(error); | |||||
return false; | return false; | ||||
} | } | ||||
AddWallet(pwallet); | AddWallet(pwallet); | ||||
} | } | ||||
return true; | return true; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 41 Lines • Show Last 20 Lines |