17 const std::vector<std::string> &wallet_files) {
19 fs::path wallet_dir =
gArgs.
GetArg(
"-walletdir",
"");
20 boost::system::error_code
error;
23 fs::path canonical_wallet_dir = fs::canonical(wallet_dir, error);
24 if (error || !fs::exists(wallet_dir)) {
26 strprintf(
_(
"Specified -walletdir \"%s\" does not exist"),
27 wallet_dir.string()));
29 }
else if (!fs::is_directory(wallet_dir)) {
31 strprintf(
_(
"Specified -walletdir \"%s\" is not a directory"),
32 wallet_dir.string()));
36 }
else if (!wallet_dir.is_absolute()) {
38 strprintf(
_(
"Specified -walletdir \"%s\" is a relative path"),
39 wallet_dir.string()));
47 chain.
initMessage(
_(
"Verifying wallet(s)...").translated);
50 std::set<fs::path> wallet_paths;
52 for (
const auto &wallet_file : wallet_files) {
55 if (!wallet_paths.insert(location.
GetPath()).second) {
57 "-wallet filename specified."),
63 std::vector<bilingual_str> warnings;
65 error_string, warnings);
66 if (!warnings.empty()) {
69 if (!verify_success) {
79 const std::vector<std::string> &wallet_files) {
81 for (
const std::string &walletFile : wallet_files) {
83 std::vector<bilingual_str> warnings;
87 if (!warnings.empty()) {
97 }
catch (
const std::runtime_error &e) {
104 for (
const std::shared_ptr<CWallet> &pwallet :
GetWallets()) {
105 pwallet->postInitProcess();
115 std::chrono::milliseconds{500});
122 std::chrono::milliseconds{1000});
126 for (
const std::shared_ptr<CWallet> &pwallet :
GetWallets()) {
127 pwallet->Flush(
false);
132 for (
const std::shared_ptr<CWallet> &pwallet :
GetWallets()) {
133 pwallet->Flush(
true);
139 while (!wallets.empty()) {
140 auto wallet = wallets.back();
const fs::path & GetPath() const
Get wallet absolute path.
bool IsArgSet(const std::string &strArg) const
Return true if the given argument has been manually set.
std::vector< std::shared_ptr< CWallet > > GetWallets()
void UnloadWallet(std::shared_ptr< CWallet > &&wallet)
Explicitly unload and delete the wallet.
auto Join(const std::vector< T > &list, const BaseType &separator, UnaryOp unary_op) -> decltype(unary_op(list.at(0)))
Join a list of items.
bool AddWallet(const std::shared_ptr< CWallet > &wallet)
bilingual_str Untranslated(std::string original)
Mark a bilingual_str as untranslated.
static void LogPrintf(const char *fmt, const Args &... args)
CChainParams defines various tweakable parameters of a given instance of the Bitcoin system...
void MaybeResendWalletTxs()
Called periodically by the schedule thread.
bool GetBoolArg(const std::string &strArg, bool fDefault) const
Return boolean argument or default value.
void ForceSetArg(const std::string &strArg, const std::string &strValue)
static bool Verify(const CChainParams &chainParams, interfaces::Chain &chain, const WalletLocation &location, bilingual_str &error_string, std::vector< bilingual_str > &warnings)
Verify wallet naming and perform salvage on the wallet if required.
void StopWallets()
Stop all wallets. Wallets will be flushed first.
bool LoadWallets(const CChainParams &chainParams, interfaces::Chain &chain, const std::vector< std::string > &wallet_files)
Load wallet databases.
static std::shared_ptr< CWallet > CreateWalletFromFile(const CChainParams &chainParams, interfaces::Chain &chain, const WalletLocation &location, bilingual_str &error, std::vector< bilingual_str > &warnings, uint64_t wallet_creation_flags=0)
Initializes the wallet, returns a new CWallet instance or a null pointer in case of an error...
bilingual_str _(const char *psz)
Translation function.
void scheduleEvery(Predicate p, std::chrono::milliseconds delta)
Repeat p until it return false.
void MaybeCompactWalletDB()
Compacts BDB state so that wallet.dat is self-contained (if there are changes)
bool VerifyWallets(const CChainParams &chainParams, interfaces::Chain &chain, const std::vector< std::string > &wallet_files)
Responsible for reading and validating the -wallet arguments and verifying the wallet database...
void FlushWallets()
Flush all wallets in preparation for shutdown.
virtual void initWarning(const bilingual_str &message)=0
Send init warning.
Interface giving clients (wallet processes, maybe other analysis tools in the future) ability to acce...
std::string GetArg(const std::string &strArg, const std::string &strDefault) const
Return string argument or default value.
static const bool DEFAULT_FLUSHWALLET
Overview of wallet database classes:
virtual void initMessage(const std::string &message)=0
Send init message.
bool RemoveWallet(const std::shared_ptr< CWallet > &wallet)
fs::path GetWalletDir()
Get the path of the wallet directory.
The WalletLocation class provides wallet information.
void UnloadWallets()
Close all wallets.
virtual void initError(const bilingual_str &message)=0
Send init error.
bool error(const char *fmt, const Args &... args)
void StartWallets(CScheduler &scheduler, const ArgsManager &args)
Complete startup of wallets.