21#include <system_error>
26 std::error_code
error;
32 strprintf(
_(
"Specified -walletdir \"%s\" does not exist"),
37 strprintf(
_(
"Specified -walletdir \"%s\" is not a directory"),
44 strprintf(
_(
"Specified -walletdir \"%s\" is a relative path"),
53 chain.
initMessage(
_(
"Verifying wallet(s)...").translated);
95 strprintf(
"Skipping -wallet path that doesn't exist. %s\n",
121 std::vector<bilingual_str>
warnings;
122 std::unique_ptr<WalletDatabase> database =
127 std::shared_ptr<CWallet> pwallet =
143 }
catch (
const std::runtime_error &
e) {
150 for (
const std::shared_ptr<CWallet> &pwallet :
GetWallets()) {
151 pwallet->postInitProcess();
161 std::chrono::milliseconds{500});
168 std::chrono::milliseconds{1000});
172 for (
const std::shared_ptr<CWallet> &pwallet :
GetWallets()) {
178 for (
const std::shared_ptr<CWallet> &pwallet :
GetWallets()) {
188 std::vector<bilingual_str>
warnings;
void ForceSetArg(const std::string &strArg, const std::string &strValue)
bool IsArgSet(const std::string &strArg) const
Return true if the given argument has been manually set.
bool GetBoolArg(const std::string &strArg, bool fDefault) const
Return boolean argument or default value.
fs::path GetPathArg(std::string arg, const fs::path &default_value={}) const
Return path argument or default value.
Simple class for background tasks that should be run periodically or once "after a while".
void scheduleEvery(Predicate p, std::chrono::milliseconds delta) EXCLUSIVE_LOCKS_REQUIRED(!newTaskMutex)
Repeat p until it return false.
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)
Initializes the wallet, returns a new CWallet instance or a null pointer in case of an error.
Path class wrapper to block calls to the fs::path(std::string) implicit constructor and the fs::path:...
Interface giving clients (wallet processes, maybe other analysis tools in the future) ability to acce...
virtual bool updateRwSetting(const std::string &name, const util::SettingsValue &value, bool write=true)=0
Write a setting to <datadir>/settings.json.
virtual void initMessage(const std::string &message)=0
Send init message.
virtual void initError(const bilingual_str &message)=0
Send init error.
virtual std::vector< util::SettingsValue > getSettingsList(const std::string &arg)=0
Get list of settings values.
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.
bool error(const char *fmt, const Args &...args)
static bool exists(const path &p)
static std::string PathToString(const path &path)
Convert path object to byte string.
static path PathFromString(const std::string &string)
Convert byte string to path object.
fs::path AbsPathJoin(const fs::path &base, const fs::path &path)
Helper function for joining two paths.
T GetRand(T nMax=std::numeric_limits< T >::max()) noexcept
Generate a uniform random integer of type T in the range [0..nMax) nMax defaults to std::numeric_limi...
auto Join(const std::vector< T > &list, const BaseType &separator, UnaryOp unary_op) -> decltype(unary_op(list.at(0)))
Join a list of items.
bilingual_str _(const char *psz)
Translation function.
bilingual_str Untranslated(std::string original)
Mark a bilingual_str as untranslated.
bool RemoveWallet(const std::shared_ptr< CWallet > &wallet, std::optional< bool > load_on_start, std::vector< bilingual_str > &warnings)
std::unique_ptr< WalletDatabase > MakeWalletDatabase(const std::string &name, const DatabaseOptions &options, DatabaseStatus &status, bilingual_str &error_string)
void MaybeResendWalletTxs()
Called periodically by the schedule thread.
void UnloadWallet(std::shared_ptr< CWallet > &&wallet)
Explicitly unload and delete the wallet.
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.