7#include <chainparams.h>
25 strprintf(
_(
"Specified data directory \"%s\" does not exist."),
26 args.
GetArg(
"-datadir",
""))};
45 strprintf(
_(
"Error reading configuration file: %s"), error)};
77 !fs::equivalent(orig_config_path, base_config_path)) {
78 const std::string cli_config_path = args.
GetArg(
"-conf",
"");
79 const std::string config_source =
80 cli_config_path.empty()
86 "Data directory %1$s contains a %2$s file which is ignored, "
87 "because a different configuration file "
88 "%3$s from %4$s is being used instead. Possible ways to "
89 "address this would be to:\n"
90 "- Delete or rename the %2$s file in data directory %1$s.\n"
91 "- Change datadir= or conf= options to specify one "
92 "configuration file, not two, and use "
93 "includeconf= to include any other configuration files.\n"
94 "- Set allowignoredconf=1 option to treat this condition as a "
95 "warning, not an error.",
99 if (args.
GetBoolArg(
"-allowignoredconf",
false)) {
108 std::vector<std::string> details;
111 _(
"Settings file could not be read");
112 if (!settings_abort_fn) {
114 }
else if (settings_abort_fn(message, details)) {
123 _(
"Settings file could not be written");
128 }
catch (
const std::exception &e) {
bool CheckDataDirOption(const ArgsManager &args)
const char *const BITCOIN_CONF_FILENAME
void SelectParams(const ChainType chain)
Sets the params returned by Params() to those for the given BIP70 chain name.
bool ReadSettingsFile(std::vector< std::string > *errors=nullptr)
Read settings file.
ChainType GetChainType() const
Looks for -regtest, -testnet and returns the appropriate BIP70 chain name.
fs::path GetDataDirNet() const
Get data directory path with appended network identifier.
bool GetSettingsPath(fs::path *filepath=nullptr, bool temp=false, bool backup=false) const
Get settings file path, or return false if read-write settings were disabled with -nosettings.
bool WriteSettingsFile(std::vector< std::string > *errors=nullptr, bool backup=false) const
Write settings file or backup settings file.
fs::path GetDataDirBase() const
Get data directory path.
fs::path GetConfigFilePath() const
Return config file path (read-only)
std::string GetArg(const std::string &strArg, const std::string &strDefault) const
Return string argument or default value.
bool ReadConfigFiles(std::string &error, bool ignore_invalid_keys=false)
bool GetBoolArg(const std::string &strArg, bool fDefault) const
Return boolean argument or default value.
Path class wrapper to block calls to the fs::path(std::string) implicit constructor and the fs::path:...
std::optional< ConfigError > InitConfig(ArgsManager &args, SettingsAbortFn settings_abort_fn)
Read config files, and create datadir and settings.json if they don't exist.
@ ABORTED
Aborted by user.
@ FAILED_WRITE
Failed to write settings.json.
@ FAILED
Failed generically.
std::function< bool(const bilingual_str &message, const std::vector< std::string > &details)> SettingsAbortFn
Callback function to let the user decide whether to abort loading if settings.json file exists and ca...
static bool create_directories(const std::filesystem::path &p)
Create directory (and if necessary its parents), unless the leaf directory already exists or is a sym...
static auto quoted(const std::string &s)
static bool exists(const path &p)
static std::string PathToString(const path &path)
Convert path object to byte string.
bilingual_str _(const char *psz)
Translation function.
bilingual_str Untranslated(std::string original)
Mark a bilingual_str as untranslated.