5#include <chainparams.h>
69 if (orig_config_path.empty()) {
71 "Data directory %s contains a %s file which is explicitly ignored using -noconf.",
74 }
else if (!fs::equivalent(orig_config_path, base_config_path)) {
75 const std::string cli_config_path =
args.
GetArg(
"-conf",
"");
76 const std::string config_source = cli_config_path.empty()
80 "Data directory %1$s contains a %2$s file which is ignored, because a different configuration file "
81 "%3$s from %4$s is being used instead. Possible ways to address this would be to:\n"
82 "- Delete or rename the %2$s file in data directory %1$s.\n"
83 "- Change datadir= or conf= options to specify one configuration file, not two, and use "
84 "includeconf= to include any other configuration files.",
92 error +=
"\n- Set allowignoredconf=1 option to treat this condition as a warning, not an error.";
100 std::vector<std::string> details;
102 const bilingual_str& message =
_(
"Settings file could not be read");
103 if (!settings_abort_fn) {
105 }
else if (settings_abort_fn(message, details)) {
112 const bilingual_str& message =
_(
"Settings file could not be written");
116 }
catch (
const std::exception& e) {
bool CheckDataDirOption(const ArgsManager &args)
const char *const BITCOIN_CONF_FILENAME
fs::path AbsPathForConfigVal(const ArgsManager &args, const fs::path &path, bool net_specific=true)
Most paths passed as configuration arguments are treated as relative to the datadir if they are not a...
void SelectParams(const ChainType chain)
Sets the params returned by Params() to those for the given chain type.
bool ReadSettingsFile(std::vector< std::string > *errors=nullptr)
Read settings file.
ChainType GetChainType() const
Returns the appropriate chain type from the program arguments.
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.
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.
fs::path GetPathArg(std::string arg, const fs::path &default_value={}) const
Return path argument or default value.
Path class wrapper to block calls to the fs::path(std::string) implicit constructor and the fs::path:...
@ 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...
std::optional< ConfigError > InitConfig(ArgsManager &args, SettingsAbortFn settings_abort_fn)
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 a byte string.
bilingual_str _(ConstevalStringLiteral str)
Translation function.
bilingual_str Untranslated(std::string original)
Mark a bilingual_str as untranslated.