mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-06-28 01:41:57 +02:00
util: disallow setting conf in bitcoin.conf
Help from `bitcoind -h` states that conf can only be used from the commandline. However, if conf is set in a bitcoin.conf file, it is ignored but there is no error. Show an error to user if conf is set in a .conf file and prompt them to use `includeconf` if they wish to specify additional config files. Adds `IsConfSupported` function to allow for easily adding conf options to disallow or throw warnings for.
This commit is contained in:
parent
73b61717a9
commit
5e744f4238
@ -935,6 +935,14 @@ static bool GetConfigOptions(std::istream& stream, const std::string& filepath,
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool IsConfSupported(KeyInfo& key, std::string& error) {
|
||||||
|
if (key.name == "conf") {
|
||||||
|
error = "conf cannot be set in the configuration file; use includeconf= if you want to include additional config files";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
bool ArgsManager::ReadConfigStream(std::istream& stream, const std::string& filepath, std::string& error, bool ignore_invalid_keys)
|
bool ArgsManager::ReadConfigStream(std::istream& stream, const std::string& filepath, std::string& error, bool ignore_invalid_keys)
|
||||||
{
|
{
|
||||||
LOCK(cs_args);
|
LOCK(cs_args);
|
||||||
@ -945,6 +953,7 @@ bool ArgsManager::ReadConfigStream(std::istream& stream, const std::string& file
|
|||||||
for (const std::pair<std::string, std::string>& option : options) {
|
for (const std::pair<std::string, std::string>& option : options) {
|
||||||
KeyInfo key = InterpretKey(option.first);
|
KeyInfo key = InterpretKey(option.first);
|
||||||
std::optional<unsigned int> flags = GetArgFlags('-' + key.name);
|
std::optional<unsigned int> flags = GetArgFlags('-' + key.name);
|
||||||
|
if (!IsConfSupported(key, error)) return false;
|
||||||
if (flags) {
|
if (flags) {
|
||||||
std::optional<util::SettingsValue> value = InterpretValue(key, &option.second, *flags, error);
|
std::optional<util::SettingsValue> value = InterpretValue(key, &option.second, *flags, error);
|
||||||
if (!value) {
|
if (!value) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user