22 fs::path wallet_dir =
gArgs.
GetArg(
"-walletdir",
"");
23 boost::system::error_code
error;
25 fs::path canonical_wallet_dir = fs::canonical(wallet_dir,
error);
26 if (
error || !fs::exists(wallet_dir)) {
27 chain.
initError(
strprintf(
_(
"Specified -walletdir \"%s\" does not exist"), wallet_dir.string()));
29 }
else if (!fs::is_directory(wallet_dir)) {
30 chain.
initError(
strprintf(
_(
"Specified -walletdir \"%s\" is not a directory"), wallet_dir.string()));
33 }
else if (!wallet_dir.is_absolute()) {
34 chain.
initError(
strprintf(
_(
"Specified -walletdir \"%s\" is a relative path"), wallet_dir.string()));
42 chain.
initMessage(
_(
"Verifying wallet(s)...").translated);
62 std::set<fs::path> wallet_paths;
64 for (
const auto& wallet_file :
gArgs.
GetArgs(
"-wallet")) {
65 const fs::path path = fs::absolute(wallet_file,
GetWalletDir());
67 if (!wallet_paths.insert(path).second) {
93 std::set<fs::path> wallet_paths;
95 if (!wallet_paths.insert(
name).second) {
103 std::vector<bilingual_str> warnings;
117 }
catch (
const std::runtime_error& e) {
125 for (
const std::shared_ptr<CWallet>& pwallet :
GetWallets()) {
126 pwallet->postInitProcess();
138 for (
const std::shared_ptr<CWallet>& pwallet :
GetWallets()) {
145 for (
const std::shared_ptr<CWallet>& pwallet :
GetWallets()) {
153 while (!wallets.empty()) {
154 auto wallet = wallets.back();
156 std::vector<bilingual_str> warnings;
void ForceSetArg(const std::string &strArg, const std::string &strValue)
std::vector< std::string > GetArgs(const std::string &strArg) const
Return a vector of strings of the given argument.
void LockSettings(Fn &&fn)
Access settings with lock held.
bool IsArgSet(const std::string &strArg) const
Return true if the given argument has been manually set.
std::string GetArg(const std::string &strArg, const std::string &strDefault) const
Return string argument or default value.
bool GetBoolArg(const std::string &strArg, bool fDefault) const
Return boolean argument or default value.
Simple class for background tasks that should be run periodically or once "after a while".
void scheduleEvery(Function f, std::chrono::milliseconds delta)
Repeat f until the scheduler is stopped.
static std::shared_ptr< CWallet > Create(interfaces::Chain &chain, const std::string &name, std::unique_ptr< WalletDatabase > database, uint64_t wallet_creation_flags, bilingual_str &error, std::vector< bilingual_str > &warnings)
bool push_back(const UniValue &val)
Interface giving clients (wallet processes, maybe other analysis tools in the future) ability to acce...
virtual void initMessage(const std::string &message)=0
Send init message.
virtual void initError(const bilingual_str &message)=0
Send init error.
virtual void initWarning(const bilingual_str &message)=0
Send init warning.
void StartWallets(CScheduler &scheduler, const ArgsManager &args)
Complete startup of wallets.
bool VerifyWallets(interfaces::Chain &chain)
Responsible for reading and validating the -wallet arguments and verifying the wallet database.
void UnloadWallets()
Close all wallets.
void FlushWallets()
Flush all wallets in preparation for shutdown.
void StopWallets()
Stop all wallets. Wallets will be flushed first.
bool LoadWallets(interfaces::Chain &chain)
Load wallet databases.
static void LogPrintf(const char *fmt, const Args &... args)
static auto & nullopt
Substitute for C++17 std::nullopt.
auto Join(const std::vector< T > &list, const BaseType &separator, UnaryOp unary_op) -> decltype(unary_op(list.at(0)))
Join a list of items.
std::map< std::string, SettingsValue > rw_settings
Map of setting name to read-write file setting value.
bool error(const char *fmt, const Args &... args)
bilingual_str _(const char *psz)
Translation function.
bilingual_str Untranslated(std::string original)
Mark a bilingual_str as untranslated.
void MaybeResendWalletTxs()
Called periodically by the schedule thread.
bool RemoveWallet(const std::shared_ptr< CWallet > &wallet, Optional< bool > load_on_start, std::vector< bilingual_str > &warnings)
void UnloadWallet(std::shared_ptr< CWallet > &&wallet)
Explicitly unload and delete the wallet.
std::unique_ptr< WalletDatabase > MakeWalletDatabase(const std::string &name, const DatabaseOptions &options, DatabaseStatus &status, bilingual_str &error_string)
std::vector< std::shared_ptr< CWallet > > GetWallets()
bool AddWallet(const std::shared_ptr< CWallet > &wallet)
void MaybeCompactWalletDB()
Compacts BDB state so that wallet.dat is self-contained (if there are changes)
static const bool DEFAULT_FLUSHWALLET
Overview of wallet database classes:
fs::path GetWalletDir()
Get the path of the wallet directory.