| 924 | } |
| 925 | |
| 926 | std::variant<ChainType, std::string> ArgsManager::GetChainArg() const |
| 927 | { |
| 928 | auto get_net = [&](const std::string& arg) { |
| 929 | LOCK(cs_args); |
| 930 | common::SettingsValue value = common::GetSetting(m_settings, /* section= */ "", SettingName(arg), |
| 931 | /* ignore_default_section_config= */ false, |
| 932 | /*ignore_nonpersistent=*/false, |
| 933 | /* get_chain_type= */ true); |
| 934 | return value.isNull() ? false : value.isBool() ? value.get_bool() : InterpretBool(value.get_str()); |
| 935 | }; |
| 936 | |
| 937 | const bool fRegTest = get_net("-regtest"); |
| 938 | const bool fSigNet = get_net("-signet"); |
| 939 | const bool fTestNet = get_net("-testnet"); |
| 940 | const bool fTestNet4 = get_net("-testnet4"); |
| 941 | const auto chain_arg = GetArg("-chain"); |
| 942 | |
| 943 | if ((int)chain_arg.has_value() + (int)fRegTest + (int)fSigNet + (int)fTestNet + (int)fTestNet4 > 1) { |
| 944 | throw std::runtime_error("Invalid combination of -regtest, -signet, -testnet, -testnet4 and -chain. Can use at most one."); |
| 945 | } |
| 946 | if (chain_arg) { |
| 947 | if (auto parsed = ChainTypeFromString(*chain_arg)) return *parsed; |
| 948 | // Not a known string, so return original string |
| 949 | return *chain_arg; |
| 950 | } |
| 951 | if (fRegTest) return ChainType::REGTEST; |
| 952 | if (fSigNet) return ChainType::SIGNET; |
| 953 | if (fTestNet) return ChainType::TESTNET; |
| 954 | if (fTestNet4) return ChainType::TESTNET4; |
| 955 | return ChainType::MAIN; |
| 956 | } |
| 957 | |
| 958 | bool ArgsManager::UseDefaultSection(const std::string& arg) const |
| 959 | { |
nothing calls this directly
no test coverage detected