22#include <system_error>
32 if (
args.IsArgSet(
"-walletdir")) {
33 const fs::path wallet_dir{
args.GetPathArg(
"-walletdir")};
34 std::error_code error;
38 fs::path canonical_wallet_dir = fs::canonical(wallet_dir, error);
39 if (error || !fs::exists(canonical_wallet_dir)) {
40 chain.
initError(
strprintf(
_(
"Specified -walletdir \"%s\" does not exist"), fs::PathToString(wallet_dir)));
42 }
else if (!fs::is_directory(canonical_wallet_dir)) {
43 chain.
initError(
strprintf(
_(
"Specified -walletdir \"%s\" is not a directory"), fs::PathToString(wallet_dir)));
46 }
else if (!wallet_dir.is_absolute()) {
47 chain.
initError(
strprintf(
_(
"Specified -walletdir \"%s\" is a relative path"), fs::PathToString(wallet_dir)));
50 args.ForceSetArg(
"-walletdir", fs::PathToString(canonical_wallet_dir));
61 if (!
args.IsArgSet(
"wallet")) {
79 std::set<fs::path> wallet_paths;
83 chain.
initError(
_(
"Invalid value detected for '-wallet' or '-nowallet'. "
84 "'-wallet' requires a string value, while '-nowallet' accepts only '1' to disable all wallets"));
87 const auto& wallet_file =
wallet.get_str();
90 if (!wallet_paths.insert(path).second) {
122 std::set<fs::path> wallet_paths;
125 chain.
initError(
_(
"Invalid value detected for '-wallet' or '-nowallet'. "
126 "'-wallet' requires a string value, while '-nowallet' accepts only '1' to disable all wallets"));
130 if (!wallet_paths.insert(fs::PathFromString(
name)).second) {
139 std::vector<bilingual_str> warnings;
150 std::shared_ptr<CWallet> pwallet = database ?
CWallet::LoadExisting(context,
name, std::move(database), error, warnings) :
nullptr;
161 }
catch (
const std::runtime_error& e) {
169 for (
const std::shared_ptr<CWallet>& pwallet :
GetWallets(context)) {
170 pwallet->postInitProcess();
179 while (!wallets.empty()) {
180 auto wallet = wallets.back();
182 std::vector<bilingual_str> warnings;
auto Join(const C &container, const S &separator, UnaryOp unary_op)
Join all container items.
#define Assert(val)
Identity function.
void scheduleEvery(Function f, std::chrono::milliseconds delta) EXCLUSIVE_LOCKS_REQUIRED(!newTaskMutex)
Repeat f until the scheduler is stopped.
void push_back(UniValue val)
virtual bool overwriteRwSetting(const std::string &name, common::SettingsValue value, SettingsAction action=SettingsAction::WRITE)=0
virtual void initMessage(const std::string &message)=0
Send init message.
virtual std::vector< common::SettingsValue > getSettingsList(const std::string &arg)=0
Get list of settings values.
virtual void initError(const bilingual_str &message)=0
Send init error.
virtual void initWarning(const bilingual_str &message)=0
Send init warning.
static std::shared_ptr< CWallet > LoadExisting(WalletContext &context, const std::string &name, std::unique_ptr< WalletDatabase > database, bilingual_str &error, std::vector< bilingual_str > &warnings)
fs::path AbsPathJoin(const fs::path &base, const fs::path &path)
Helper function for joining two paths.
auto Join(const C &container, const S &separator, UnaryOp unary_op)
Join all container items.
void StartWallets(WalletContext &context)
Complete startup of wallets.
void ReadDatabaseArgs(const ArgsManager &args, DatabaseOptions &options)
void MaybeResendWalletTxs(WalletContext &context)
Called periodically by the schedule thread.
std::vector< std::shared_ptr< CWallet > > GetWallets(WalletContext &context)
bool VerifyWallets(WalletContext &context)
Responsible for reading and validating the -wallet arguments and verifying the wallet database.
fs::path GetWalletDir()
Get the path of the wallet directory.
std::unique_ptr< WalletDatabase > MakeWalletDatabase(const std::string &name, const DatabaseOptions &options, DatabaseStatus &status, bilingual_str &error_string)
void NotifyWalletLoaded(WalletContext &context, const std::shared_ptr< CWallet > &wallet)
bool AddWallet(WalletContext &context, const std::shared_ptr< CWallet > &wallet)
void UnloadWallets(WalletContext &context)
bool LoadWallets(WalletContext &context)
Load wallet databases.
void WaitForDeleteWallet(std::shared_ptr< CWallet > &&wallet)
bool RemoveWallet(WalletContext &context, const std::shared_ptr< CWallet > &wallet, std::optional< bool > load_on_start, std::vector< bilingual_str > &warnings)
bool verify
Check data integrity on load.
interfaces::Chain * chain
consteval auto _(util::TranslatedLiteral str)
bilingual_str Untranslated(std::string original)
Mark a bilingual_str as untranslated.