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
This commit is contained in:
Fabian Jahr
2024-04-22 14:52:40 +02:00
parent 4d8e5edbaa
commit 542e13b293
6 changed files with 143 additions and 14 deletions

View File

@@ -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;
}