 |
Bitcoin Core
22.99.0
P2P Digital Currency
|
Go to the documentation of this file.
22 #include <system_error>
32 std::error_code
error;
36 fs::path canonical_wallet_dir = fs::canonical(wallet_dir,
error);
40 }
else if (!fs::is_directory(canonical_wallet_dir)) {
44 }
else if (!wallet_dir.is_absolute()) {
53 chain.
initMessage(
_(
"Verifying wallet(s)…").translated);
74 std::set<fs::path> wallet_paths;
77 const auto& wallet_file =
wallet.get_str();
80 if (!wallet_paths.insert(path).second) {
107 std::set<fs::path> wallet_paths;
118 std::vector<bilingual_str> warnings;
133 }
catch (
const std::runtime_error& e) {
142 pwallet->postInitProcess();
169 while (!wallets.empty()) {
170 auto wallet = wallets.back();
172 std::vector<bilingual_str> warnings;
void StartWallets(WalletContext &context, CScheduler &scheduler)
Complete startup of wallets.
Simple class for background tasks that should be run periodically or once "after a while".
bool GetBoolArg(const std::string &strArg, bool fDefault) const
Return boolean argument or default value.
static bool exists(const path &p)
bilingual_str _(const char *psz)
Translation function.
bool AddWallet(WalletContext &context, const std::shared_ptr< CWallet > &wallet)
void UnloadWallets(WalletContext &context)
Close all wallets.
fs::path GetPathArg(std::string pathlike_arg) const
Get a normalized path from a specified pathlike argument.
bool IsArgSet(const std::string &strArg) const
Return true if the given argument has been manually set.
void MaybeResendWalletTxs(WalletContext &context)
Called periodically by the schedule thread.
virtual std::vector< util::SettingsValue > getSettingsList(const std::string &arg)=0
Get list of settings values.
fs::path AbsPathJoin(const fs::path &base, const fs::path &path)
Helper function for joining two paths.
static std::string PathToString(const path &path)
Convert path object to a byte string.
#define Assert(val)
Identity function.
void FlushWallets(WalletContext &context)
Flush all wallets in preparation for shutdown.
std::vector< std::shared_ptr< CWallet > > GetWallets(WalletContext &context)
Interface giving clients (wallet processes, maybe other analysis tools in the future) ability to acce...
bilingual_str Untranslated(std::string original)
Mark a bilingual_str as untranslated.
std::unique_ptr< WalletDatabase > MakeWalletDatabase(const std::string &name, const DatabaseOptions &options, DatabaseStatus &status, bilingual_str &error_string)
Path class wrapper to block calls to the fs::path(std::string) implicit constructor and the fs::path:...
bool LoadWallets(WalletContext &context)
Load wallet databases.
void ForceSetArg(const std::string &strArg, const std::string &strValue)
void scheduleEvery(Function f, std::chrono::milliseconds delta)
Repeat f until the scheduler is stopped.
static path PathFromString(const std::string &string)
Convert byte string to path object.
virtual bool updateRwSetting(const std::string &name, const util::SettingsValue &value, bool write=true)=0
Write a setting to <datadir>/settings.json.
virtual void initWarning(const bilingual_str &message)=0
Send init warning.
bool VerifyWallets(WalletContext &context)
Responsible for reading and validating the -wallet arguments and verifying the wallet database.
auto Join(const std::vector< T > &list, const BaseType &separator, UnaryOp unary_op) -> decltype(unary_op(list.at(0)))
Join a list of items.
static const bool DEFAULT_FLUSHWALLET
Overview of wallet database classes:
fs::path GetWalletDir()
Get the path of the wallet directory.
virtual void initMessage(const std::string &message)=0
Send init message.
static std::shared_ptr< CWallet > Create(WalletContext &context, 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)
virtual void initError(const bilingual_str &message)=0
Send init error.
WalletContext struct containing references to state shared between CWallet instances,...
void UnloadWallet(std::shared_ptr< CWallet > &&wallet)
Explicitly unload and delete the wallet.
bool error(const char *fmt, const Args &... args)
void MaybeCompactWalletDB(WalletContext &context)
Compacts BDB state so that wallet.dat is self-contained (if there are changes)
interfaces::Chain * chain
bool RemoveWallet(WalletContext &context, const std::shared_ptr< CWallet > &wallet, std::optional< bool > load_on_start, std::vector< bilingual_str > &warnings)
void StopWallets(WalletContext &context)
Stop all wallets. Wallets will be flushed first.