diff --git a/src/chainparams.cpp b/src/chainparams.cpp index 58cc734177da09..45b3ca376f7798 100644 --- a/src/chainparams.cpp +++ b/src/chainparams.cpp @@ -43,6 +43,20 @@ void ReadSigNetArgs(const ArgsManager& args, CChainParams::SigNetOptions& option } } +void ReadSigNetChainArgs(const ArgsManager& args, CChainParams::SigNetOptions& options) { + const auto chain = args.GetArg("-chain", ""); + if (chain.starts_with("signet_")){ + auto seed_node = args.GetSectionArg(chain, "signetseednode"); + if (!seed_node.empty()) { + options.seeds.emplace(seed_node); + } + auto signet_challenge = args.GetSectionArg(chain, "signetchallenge"); + if (!signet_challenge.empty()) { + options.challenge.emplace(validateSignetChallenge(signet_challenge)); + } + } +} + void ReadRegTestArgs(const ArgsManager& args, CChainParams::RegTestOptions& options) { if (auto value = args.GetBoolArg("-fastprune")) options.fastprune = *value; @@ -120,6 +134,7 @@ std::unique_ptr CreateChainParams(const ArgsManager& args, c case ChainType::SIGNET: { auto opts = CChainParams::SigNetOptions{}; ReadSigNetArgs(args, opts); + ReadSigNetChainArgs(gArgs, opts); return CChainParams::SigNet(opts); } case ChainType::REGTEST: { diff --git a/src/common/args.cpp b/src/common/args.cpp index 6a879fc070c042..923ed3b9f12d7d 100644 --- a/src/common/args.cpp +++ b/src/common/args.cpp @@ -388,6 +388,21 @@ std::vector ArgsManager::GetArgs(const std::string& strArg) const return result; } +std::vector ArgsManager::GetSectionArg(const std::string& section, const std::string& strArg) const +{ + std::vector result; + LOCK(cs_args); + if (auto* _section = common::FindKey(m_settings.ro_config, section)) { + if (auto* values = common::FindKey(*_section, strArg)) { + for (int i = 0; i < values->size(); i++) { + result.push_back((*values)[i].get_str()); + } + + } + } + return result; +} + bool ArgsManager::IsArgSet(const std::string& strArg) const { return !GetSetting(strArg).isNull(); diff --git a/src/common/args.h b/src/common/args.h index d7099f956e67a4..33dd9631d4a35c 100644 --- a/src/common/args.h +++ b/src/common/args.h @@ -252,6 +252,15 @@ class ArgsManager */ std::vector GetArgs(const std::string& strArg) const; + /** + * Retrieves values associated with a specified argument in a given configuration section. + * + * @param section section in m_settings.ro_config to seach + * @param strArg Argument to get (e.g. "-foo") + * @return Vector of string values for the argument in the configuration file. + */ + std::vector GetSectionArg(const std::string& section, const std::string& strArg) const; + /** * Return true if the given argument has been manually set * diff --git a/src/util/chaintype.cpp b/src/util/chaintype.cpp index 8a199e352a41d6..7eee38703693fe 100644 --- a/src/util/chaintype.cpp +++ b/src/util/chaintype.cpp @@ -29,7 +29,7 @@ std::optional ChainTypeFromString(std::string_view chain) return ChainType::MAIN; } else if (chain == "test") { return ChainType::TESTNET; - } else if (chain == "signet") { + } else if (chain == "signet" || chain.starts_with("signet_") ) { return ChainType::SIGNET; } else if (chain == "regtest") { return ChainType::REGTEST;