@@ -537,6 +537,22 @@ class ArgsManagerHelper {
537
537
538
538
return found_result;
539
539
}
540
+
541
+ /* Special test for -testnet and -regtest args, because we
542
+ * don't want to be confused by craziness like "[regtest] testnet=1"
543
+ */
544
+ static inline bool GetNetBoolArg (const ArgsManager &am, const std::string& net_arg)
545
+ {
546
+ std::pair<bool ,std::string> found_result (false ,std::string ());
547
+ found_result = GetArgHelper (am.m_override_args , net_arg, true );
548
+ if (!found_result.first ) {
549
+ found_result = GetArgHelper (am.m_config_args , net_arg, true );
550
+ if (!found_result.first ) {
551
+ return false ; // not set
552
+ }
553
+ }
554
+ return InterpretBool (found_result.second ); // is set, so evaluate
555
+ }
540
556
};
541
557
542
558
/* *
@@ -950,8 +966,8 @@ void ArgsManager::ReadConfigFile(const std::string& confPath)
950
966
951
967
std::string ArgsManager::GetChainName () const
952
968
{
953
- bool fRegTest = GetBoolArg ( " -regtest" , false );
954
- bool fTestNet = GetBoolArg ( " -testnet" , false );
969
+ bool fRegTest = ArgsManagerHelper::GetNetBoolArg (* this , " -regtest" );
970
+ bool fTestNet = ArgsManagerHelper::GetNetBoolArg (* this , " -testnet" );
955
971
956
972
if (fTestNet && fRegTest )
957
973
throw std::runtime_error (" Invalid combination of -regtest and -testnet." );
0 commit comments