diff options
author | Fabian Jahr <fjahr@protonmail.com> | 2024-04-22 14:52:40 +0200 |
---|---|---|
committer | Fabian Jahr <fjahr@protonmail.com> | 2024-05-21 13:57:09 +0200 |
commit | 542e13b2937356810bda2c41be83c3b1675e2f2f (patch) | |
tree | 8dc54747b0b42c96b172429e1bbe5424aca047c5 /src/kernel/chainparams.cpp | |
parent | 4d8e5edbaa94805be41ae4c8aa2f4bf7aaa276fe (diff) | |
download | bitcoin-542e13b2937356810bda2c41be83c3b1675e2f2f.tar.xz |
rpc: Enhance metadata of the dumptxoutset output
The following data is added:
- A newly introduced utxo set magic
- A version number
- The network magic
- The block height
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..de142cd2c9 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(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; +} |