@@ -459,9 +459,9 @@ bool ArgsManager::ParseParameters(int argc, const char* const argv[], std::strin
459459 if (it != m_override_args.end ()) {
460460 if (it->second .size () > 0 ) {
461461 for (const auto & ic : it->second ) {
462- fprintf (stderr, " warning: -includeconf cannot be used from commandline; ignoring -includeconf=%s \n " , ic. c_str ()) ;
462+ error += " -includeconf cannot be used from commandline; -includeconf=" + ic + " \n " ;
463463 }
464- m_override_args. erase (it) ;
464+ return false ;
465465 }
466466 }
467467 return true ;
@@ -849,11 +849,12 @@ bool ArgsManager::ReadConfigFiles(std::string& error, bool ignore_invalid_keys)
849849 // if there is an -includeconf in the override args, but it is empty, that means the user
850850 // passed '-noincludeconf' on the command line, in which case we should not include anything
851851 if (m_override_args.count (" -includeconf" ) == 0 ) {
852+ std::string chain_id = GetChainName ();
852853 std::vector<std::string> includeconf (GetArgs (" -includeconf" ));
853854 {
854855 // We haven't set m_network yet (that happens in SelectParams()), so manually check
855856 // for network.includeconf args.
856- std::vector<std::string> includeconf_net (GetArgs (std::string (" -" ) + GetChainName () + " .includeconf" ));
857+ std::vector<std::string> includeconf_net (GetArgs (std::string (" -" ) + chain_id + " .includeconf" ));
857858 includeconf.insert (includeconf.end (), includeconf_net.begin (), includeconf_net.end ());
858859 }
859860
@@ -862,7 +863,7 @@ bool ArgsManager::ReadConfigFiles(std::string& error, bool ignore_invalid_keys)
862863 {
863864 LOCK (cs_args);
864865 m_config_args.erase (" -includeconf" );
865- m_config_args.erase (std::string (" -" ) + GetChainName () + " .includeconf" );
866+ m_config_args.erase (std::string (" -" ) + chain_id + " .includeconf" );
866867 }
867868
868869 for (const std::string& to_include : includeconf) {
@@ -873,15 +874,22 @@ bool ArgsManager::ReadConfigFiles(std::string& error, bool ignore_invalid_keys)
873874 }
874875 LogPrintf (" Included configuration file %s\n " , to_include.c_str ());
875876 } else {
876- fprintf (stderr, " Failed to include configuration file %s\n " , to_include.c_str ());
877+ error = " Failed to include configuration file " + to_include;
878+ return false ;
877879 }
878880 }
879881
880882 // Warn about recursive -includeconf
881883 includeconf = GetArgs (" -includeconf" );
882884 {
883- std::vector<std::string> includeconf_net (GetArgs (std::string (" -" ) + GetChainName () + " .includeconf" ));
885+ std::vector<std::string> includeconf_net (GetArgs (std::string (" -" ) + chain_id + " .includeconf" ));
884886 includeconf.insert (includeconf.end (), includeconf_net.begin (), includeconf_net.end ());
887+ std::string chain_id_final = GetChainName ();
888+ if (chain_id_final != chain_id) {
889+ // Also warn about recursive includeconf for the chain that was specified in one of the includeconfs
890+ includeconf_net = GetArgs (std::string (" -" ) + chain_id_final + " .includeconf" );
891+ includeconf.insert (includeconf.end (), includeconf_net.begin (), includeconf_net.end ());
892+ }
885893 }
886894 for (const std::string& to_include : includeconf) {
887895 fprintf (stderr, " warning: -includeconf cannot be used from included files; ignoring -includeconf=%s\n " , to_include.c_str ());
0 commit comments