|
|
|
@ -373,6 +373,7 @@ bool ArgsManager::ParseParameters(int argc, const char* const argv[], std::strin
|
|
|
|
|
|
|
|
|
|
for (int i = 1; i < argc; i++) {
|
|
|
|
|
std::string key(argv[i]);
|
|
|
|
|
if (key == "-") break; //bitcoin-tx using stdin
|
|
|
|
|
std::string val;
|
|
|
|
|
size_t is_index = key.find('=');
|
|
|
|
|
if (is_index != std::string::npos) {
|
|
|
|
@ -392,15 +393,13 @@ bool ArgsManager::ParseParameters(int argc, const char* const argv[], std::strin
|
|
|
|
|
if (key.length() > 1 && key[1] == '-')
|
|
|
|
|
key.erase(0, 1);
|
|
|
|
|
|
|
|
|
|
// Check that the arg is known
|
|
|
|
|
if (!(IsSwitchChar(key[0]) && key.size() == 1)) {
|
|
|
|
|
if (!IsArgKnown(key)) {
|
|
|
|
|
error = strprintf("Invalid parameter %s", key.c_str());
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
const unsigned int flags = FlagsOfKnownArg(key);
|
|
|
|
|
if (flags) {
|
|
|
|
|
InterpretOption(key, val, m_override_args);
|
|
|
|
|
} else {
|
|
|
|
|
error = strprintf("Invalid parameter %s", key.c_str());
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
InterpretOption(key, val, m_override_args);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// we do not allow -includeconf from command line, so we clear it here
|
|
|
|
@ -416,7 +415,7 @@ bool ArgsManager::ParseParameters(int argc, const char* const argv[], std::strin
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool ArgsManager::IsArgKnown(const std::string& key) const
|
|
|
|
|
unsigned int ArgsManager::FlagsOfKnownArg(const std::string& key) const
|
|
|
|
|
{
|
|
|
|
|
assert(key[0] == '-');
|
|
|
|
|
|
|
|
|
@ -434,9 +433,12 @@ bool ArgsManager::IsArgKnown(const std::string& key) const
|
|
|
|
|
|
|
|
|
|
LOCK(cs_args);
|
|
|
|
|
for (const auto& arg_map : m_available_args) {
|
|
|
|
|
if (arg_map.second.count(base_arg_name)) return true;
|
|
|
|
|
const auto search = arg_map.second.find(base_arg_name);
|
|
|
|
|
if (search != arg_map.second.end()) {
|
|
|
|
|
return search->second.m_flags;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
return ArgsManager::NONE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
std::vector<std::string> ArgsManager::GetArgs(const std::string& strArg) const
|
|
|
|
@ -835,18 +837,17 @@ bool ArgsManager::ReadConfigStream(std::istream& stream, const std::string& file
|
|
|
|
|
}
|
|
|
|
|
for (const std::pair<std::string, std::string>& option : options) {
|
|
|
|
|
const std::string strKey = std::string("-") + option.first;
|
|
|
|
|
// Check that the arg is known
|
|
|
|
|
if (!IsArgKnown(strKey)) {
|
|
|
|
|
if (!ignore_invalid_keys) {
|
|
|
|
|
const unsigned int flags = FlagsOfKnownArg(strKey);
|
|
|
|
|
if (flags) {
|
|
|
|
|
InterpretOption(strKey, option.second, m_config_args);
|
|
|
|
|
} else {
|
|
|
|
|
if (ignore_invalid_keys) {
|
|
|
|
|
LogPrintf("Ignoring unknown configuration value %s\n", option.first);
|
|
|
|
|
} else {
|
|
|
|
|
error = strprintf("Invalid configuration value %s", option.first.c_str());
|
|
|
|
|
return false;
|
|
|
|
|
} else {
|
|
|
|
|
LogPrintf("Ignoring unknown configuration value %s\n", option.first);
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
InterpretOption(strKey, option.second, m_config_args);
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|