deploymentinfo.cpp raw
1 // Copyright (c) 2016-2021 The Limenka developers
2 // Distributed under the MIT software license, see the accompanying
3 // file COPYING or http://www.opensource.org/licenses/mit-license.php.
4
5 #include <deploymentinfo.h>
6
7 #include <consensus/params.h>
8
9 #include <string_view>
10
11 const struct VBDeploymentInfo VersionBitsDeploymentInfo[Consensus::MAX_VERSION_BITS_DEPLOYMENTS] = {
12 {
13 /*.name =*/ "testdummy",
14 /*.gbt_force =*/ true,
15 },
16 {
17 /*.name =*/ "taproot",
18 /*.gbt_force =*/ true,
19 },
20 {
21 /*.name =*/ "reduced_data",
22 /*.gbt_force =*/ true,
23 },
24 VBDeploymentInfo{
25 .name = "p2spkh",
26 .gbt_force = true,
27 },
28 };
29
30 std::string DeploymentName(Consensus::BuriedDeployment dep)
31 {
32 assert(ValidDeployment(dep));
33 switch (dep) {
34 case Consensus::DEPLOYMENT_HEIGHTINCB:
35 return "bip34";
36 case Consensus::DEPLOYMENT_CLTV:
37 return "bip65";
38 case Consensus::DEPLOYMENT_DERSIG:
39 return "bip66";
40 case Consensus::DEPLOYMENT_CSV:
41 return "csv";
42 case Consensus::DEPLOYMENT_SEGWIT:
43 return "segwit";
44 } // no default case, so the compiler can warn about missing cases
45 return "";
46 }
47
48 std::optional<Consensus::BuriedDeployment> GetBuriedDeployment(const std::string_view name)
49 {
50 if (name == "segwit") {
51 return Consensus::BuriedDeployment::DEPLOYMENT_SEGWIT;
52 } else if (name == "bip34") {
53 return Consensus::BuriedDeployment::DEPLOYMENT_HEIGHTINCB;
54 } else if (name == "dersig") {
55 return Consensus::BuriedDeployment::DEPLOYMENT_DERSIG;
56 } else if (name == "cltv") {
57 return Consensus::BuriedDeployment::DEPLOYMENT_CLTV;
58 } else if (name == "csv") {
59 return Consensus::BuriedDeployment::DEPLOYMENT_CSV;
60 }
61 return std::nullopt;
62 }
63