@@ -373,6 +373,7 @@ bool ArgsManager::ParseParameters(int argc, const char* const argv[], std::strin
373
373
374
374
for (int i = 1 ; i < argc; i++) {
375
375
std::string key (argv[i]);
376
+ if (key == " -" ) break ; // bitcoin-tx using stdin
376
377
std::string val;
377
378
size_t is_index = key.find (' =' );
378
379
if (is_index != std::string::npos) {
@@ -392,15 +393,13 @@ bool ArgsManager::ParseParameters(int argc, const char* const argv[], std::strin
392
393
if (key.length () > 1 && key[1 ] == ' -' )
393
394
key.erase (0 , 1 );
394
395
395
- // Check that the arg is known
396
- if (!( IsSwitchChar (key[ 0 ]) && key. size () == 1 ) ) {
397
- if (! IsArgKnown ( key)) {
398
- error = strprintf ( " Invalid parameter %s " , key. c_str ());
399
- return false ;
400
- }
396
+ const unsigned int flags = FlagsOfKnownArg (key);
397
+ if (flags ) {
398
+ InterpretOption ( key, val, m_override_args);
399
+ } else {
400
+ error = strprintf ( " Invalid parameter %s " , key. c_str ()) ;
401
+ return false ;
401
402
}
402
-
403
- InterpretOption (key, val, m_override_args);
404
403
}
405
404
406
405
// 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
416
415
return true ;
417
416
}
418
417
419
- bool ArgsManager::IsArgKnown (const std::string& key) const
418
+ unsigned int ArgsManager::FlagsOfKnownArg (const std::string& key) const
420
419
{
421
420
assert (key[0 ] == ' -' );
422
421
@@ -434,9 +433,12 @@ bool ArgsManager::IsArgKnown(const std::string& key) const
434
433
435
434
LOCK (cs_args);
436
435
for (const auto & arg_map : m_available_args) {
437
- if (arg_map.second .count (base_arg_name)) return true ;
436
+ const auto search = arg_map.second .find (base_arg_name);
437
+ if (search != arg_map.second .end ()) {
438
+ return search->second .m_flags ;
439
+ }
438
440
}
439
- return false ;
441
+ return ArgsManager::NONE ;
440
442
}
441
443
442
444
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
835
837
}
836
838
for (const std::pair<std::string, std::string>& option : options) {
837
839
const std::string strKey = std::string (" -" ) + option.first ;
838
- // Check that the arg is known
839
- if (!IsArgKnown (strKey)) {
840
- if (!ignore_invalid_keys) {
840
+ const unsigned int flags = FlagsOfKnownArg (strKey);
841
+ if (flags) {
842
+ InterpretOption (strKey, option.second , m_config_args);
843
+ } else {
844
+ if (ignore_invalid_keys) {
845
+ LogPrintf (" Ignoring unknown configuration value %s\n " , option.first );
846
+ } else {
841
847
error = strprintf (" Invalid configuration value %s" , option.first .c_str ());
842
848
return false ;
843
- } else {
844
- LogPrintf (" Ignoring unknown configuration value %s\n " , option.first );
845
- continue ;
846
849
}
847
850
}
848
-
849
- InterpretOption (strKey, option.second , m_config_args);
850
851
}
851
852
return true ;
852
853
}
0 commit comments