diff options
Diffstat (limited to 'src/kernel/chainparams.cpp')
-rw-r--r-- | src/kernel/chainparams.cpp | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/src/kernel/chainparams.cpp b/src/kernel/chainparams.cpp index 26c261eba2..94b8a44323 100644 --- a/src/kernel/chainparams.cpp +++ b/src/kernel/chainparams.cpp @@ -542,3 +542,33 @@ std::unique_ptr<const CChainParams> CChainParams::TestNet() { return std::make_unique<const CTestNetParams>(); } + +std::vector<int> CChainParams::GetAvailableSnapshotHeights() const +{ + std::vector<int> heights; + heights.reserve(m_assumeutxo_data.size()); + + for (const auto& data : m_assumeutxo_data) { + heights.emplace_back(data.height); + } + return heights; +} + +std::optional<ChainType> GetNetworkForMagic(const MessageStartChars& message) +{ + const auto mainnet_msg = CChainParams::Main()->MessageStart(); + const auto testnet_msg = CChainParams::TestNet()->MessageStart(); + const auto regtest_msg = CChainParams::RegTest({})->MessageStart(); + const auto signet_msg = CChainParams::SigNet({})->MessageStart(); + + if (std::equal(message.begin(), message.end(), mainnet_msg.data())) { + return ChainType::MAIN; + } else if (std::equal(message.begin(), message.end(), testnet_msg.data())) { + return ChainType::TESTNET; + } else if (std::equal(message.begin(), message.end(), regtest_msg.data())) { + return ChainType::REGTEST; + } else if (std::equal(message.begin(), message.end(), signet_msg.data())) { + return ChainType::SIGNET; + } + return std::nullopt; +} |