38 std::vector<std::pair<std::string, std::string>> &options,
41 std::string::size_type pos;
43 while (std::getline(stream, str)) {
45 if ((pos = str.find(
'#')) != std::string::npos) {
46 str = str.substr(0, pos);
49 const static std::string
pattern =
" \t\r\n";
52 if (*str.begin() ==
'[' && *str.rbegin() ==
']') {
53 const std::string
section = str.substr(1, str.size() - 2);
56 }
else if (*str.begin() ==
'-') {
58 "parse error on line %i: %s, options in configuration file "
59 "must be specified without leading -",
62 }
else if ((pos = str.find(
'=')) != std::string::npos) {
67 std::string_view{str}.substr(pos + 1),
pattern);
69 name.find(
"rpcpassword") != std::string::npos) {
71 "parse error on line %i, using # in rpcpassword can be "
72 "ambiguous and should be avoided",
76 options.emplace_back(
name, value);
77 if ((pos =
name.rfind(
'.')) != std::string::npos &&
84 if (str.size() >= 2 && str.substr(0, 2) ==
"no") {
86 "option, use %s=1 instead",
102 std::vector<std::pair<std::string, std::string>> options;
107 for (
const std::pair<std::string, std::string> &
option : options) {
109 std::string key =
option.first;
120 LogPrintf(
"Ignoring unknown configuration value %s\n",
174 for (
size_t i = std::max(
176 i < values->size(); ++i) {
198 LogPrintf(
"Included configuration file %s\n",
201 error =
"Failed to include configuration file " +
219 "warning: -includeconf cannot be used from "
220 "included files; ignoring -includeconf=%s\n",
229 error =
strprintf(
"specified data directory \"%s\" does not exist.",
238 if (path.is_absolute()) {
bool CheckValid(const std::string &key, const util::SettingsValue &val, unsigned int flags, std::string &error)
Check settings value validity according to flags.
bool CheckDataDirOption(const ArgsManager &args)
util::SettingsValue InterpretOption(std::string §ion, std::string &key, const std::string &value)
Interpret -nofoo as if the user supplied -foo=0.
fs::path GetConfigFile(const ArgsManager &args, const fs::path &configuration_file_path)
fs::path GetDataDirNet() const
Get data directory path with appended network identifier.
std::optional< unsigned int > GetArgFlags(const std::string &name) const
Return Flags for known arg.
void ClearPathCache()
Clear cached directory paths.
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 ReadConfigStream(std::istream &stream, const std::string &filepath, std::string &error, bool ignore_invalid_keys=false)
bool ReadConfigFiles(std::string &error, bool ignore_invalid_keys=false)
std::string GetChainName() const
Looks for -regtest, -testnet and returns the appropriate BIP70 chain name.
Path class wrapper to block calls to the fs::path(std::string) implicit constructor and the fs::path:...
static bool GetConfigOptions(std::istream &stream, const std::string &filepath, std::string &error, std::vector< std::pair< std::string, std::string > > &options, std::list< SectionInfo > §ions)
fs::path AbsPathForConfigVal(const ArgsManager &args, const fs::path &path, bool net_specific)
Most paths passed as configuration arguments are treated as relative to the datadir if they are not a...
fs::path GetConfigFile(const ArgsManager &args, const fs::path &configuration_file_path)
bool error(const char *fmt, const Args &...args)
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.
auto FindKey(Map &&map, Key &&key) -> decltype(&map.at(key))
Map lookup helper.
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...
std::string TrimString(std::string_view str, std::string_view pattern=" \f\n\r\t\v")
std::string_view TrimStringView(std::string_view str, std::string_view pattern=" \f\n\r\t\v")
Accessor for list of settings that skips negated values when iterated over.
size_t negated() const
Number of negated values.
bool last_negated() const
True if the last value is negated.