diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -426,6 +426,7 @@ endfunction() add_network_sources(NETWORK_SOURCES + checkpoints.cpp network.cpp ) diff --git a/src/chainparams.h b/src/chainparams.h --- a/src/chainparams.h +++ b/src/chainparams.h @@ -140,4 +140,6 @@ */ void SelectParams(const std::string &chain); +const CCheckpointData &CheckpointData(const std::string &chain); + #endif // BITCOIN_CHAINPARAMS_H diff --git a/src/chainparams.cpp b/src/chainparams.cpp --- a/src/chainparams.cpp +++ b/src/chainparams.cpp @@ -209,56 +209,7 @@ m_is_test_chain = false; m_is_mockable_chain = false; - checkpointData = { - .mapCheckpoints = { - {11111, BlockHash::fromHex("0000000069e244f73d78e8fd29ba2fd2ed6" - "18bd6fa2ee92559f542fdb26e7c1d")}, - {33333, BlockHash::fromHex("000000002dd5588a74784eaa7ab0507a18a" - "d16a236e7b1ce69f00d7ddfb5d0a6")}, - {74000, BlockHash::fromHex("0000000000573993a3c9e41ce34471c079d" - "cf5f52a0e824a81e7f953b8661a20")}, - {105000, BlockHash::fromHex("00000000000291ce28027faea320c8d2b0" - "54b2e0fe44a773f3eefb151d6bdc97")}, - {134444, BlockHash::fromHex("00000000000005b12ffd4cd315cd34ffd4" - "a594f430ac814c91184a0d42d2b0fe")}, - {168000, BlockHash::fromHex("000000000000099e61ea72015e79632f21" - "6fe6cb33d7899acb35b75c8303b763")}, - {193000, BlockHash::fromHex("000000000000059f452a5f7340de6682a9" - "77387c17010ff6e6c3bd83ca8b1317")}, - {210000, BlockHash::fromHex("000000000000048b95347e83192f69cf03" - "66076336c639f9b7228e9ba171342e")}, - {216116, BlockHash::fromHex("00000000000001b4f4b433e81ee46494af" - "945cf96014816a4e2370f11b23df4e")}, - {225430, BlockHash::fromHex("00000000000001c108384350f74090433e" - "7fcf79a606b8e797f065b130575932")}, - {250000, BlockHash::fromHex("000000000000003887df1f29024b06fc22" - "00b55f8af8f35453d7be294df2d214")}, - {279000, BlockHash::fromHex("0000000000000001ae8c72a0b0c301f67e" - "3afca10e819efa9041e458e9bd7e40")}, - {295000, BlockHash::fromHex("00000000000000004d9b4ef50f0f9d686f" - "d69db2e03af35a100370c64632a983")}, - // UAHF fork block. - {478558, BlockHash::fromHex("0000000000000000011865af4122fe3b14" - "4e2cbeea86142e8ff2fb4107352d43")}, - // Nov, 13 DAA activation block. - {504031, BlockHash::fromHex("0000000000000000011ebf65b60d0a3de8" - "0b8175be709d653b4c1a1beeb6ab9c")}, - // Monolith activation. - {530359, BlockHash::fromHex("0000000000000000011ada8bd08f46074f" - "44a8f155396f43e38acf9501c49103")}, - // Magnetic anomaly activation. - {556767, BlockHash::fromHex("0000000000000000004626ff6e3b936941" - "d341c5932ece4357eeccac44e6d56c")}, - // Great wall activation. - {582680, BlockHash::fromHex("000000000000000001b4b8e36aec7d4f96" - "71a47872cb9a74dc16ca398c7dcc18")}, - // Graviton activation. - {609136, BlockHash::fromHex("000000000000000000b48bb207faac5ac6" - "55c313e41ac909322eaa694f5bc5b1")}, - // Phonon activation. - {635259, BlockHash::fromHex("00000000000000000033dfef1fc2d6a5d5" - "520b078c55193a9bf498c5b27530f7")}, - }}; + checkpointData = CheckpointData(CBaseChainParams::MAIN); // Data as of block // 000000000000000001d2ce557406b017a928be25ee98906397d339c3f68eec5d @@ -401,31 +352,7 @@ m_is_test_chain = true; m_is_mockable_chain = false; - checkpointData = { - .mapCheckpoints = { - {546, BlockHash::fromHex("000000002a936ca763904c3c35fce2f3556c5" - "59c0214345d31b1bcebf76acb70")}, - // UAHF fork block. - {1155875, - BlockHash::fromHex("00000000f17c850672894b9a75b63a1e72830bbd5f" - "4c8889b5c1a80e7faef138")}, - // Nov, 13. DAA activation block. - {1188697, - BlockHash::fromHex("0000000000170ed0918077bde7b4d36cc4c91be69f" - "a09211f748240dabe047fb")}, - // Great wall activation. - {1303885, - BlockHash::fromHex("00000000000000479138892ef0e4fa478ccc938fb9" - "4df862ef5bde7e8dee23d3")}, - // Graviton activation. - {1341712, - BlockHash::fromHex("00000000fffc44ea2e202bd905a9fbbb9491ef9e9d" - "5a9eed4039079229afa35b")}, - // Phonon activation. - {1378461, BlockHash::fromHex( - "0000000099f5509b5f36b1926bcf82b21d936ebeade" - "e811030dfbbb7fae915d7")}, - }}; + checkpointData = CheckpointData(CBaseChainParams::TESTNET); // Data as of block // 000000000005b07ecf85563034d13efd81c1a29e47e22b20f4fc6919d5b09cd6 @@ -535,11 +462,7 @@ m_is_test_chain = true; m_is_mockable_chain = true; - checkpointData = { - .mapCheckpoints = { - {0, BlockHash::fromHex("0f9188f13cb7b2c71f2a335e3a4fc328bf5beb4" - "36012afca590b1a11466e2206")}, - }}; + checkpointData = CheckpointData(CBaseChainParams::REGTEST); chainTxData = ChainTxData{0, 0, 0}; diff --git a/src/networks/abc/checkpoints.cpp b/src/networks/abc/checkpoints.cpp new file mode 100644 --- /dev/null +++ b/src/networks/abc/checkpoints.cpp @@ -0,0 +1,104 @@ +// Copyright (c) 2020 The Bitcoin developers +// Distributed under the MIT software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. + +#include +#include + +static CCheckpointData mainNetCheckpointData = { + .mapCheckpoints = { + {11111, BlockHash::fromHex("0000000069e244f73d78e8fd29ba2fd2ed6" + "18bd6fa2ee92559f542fdb26e7c1d")}, + {33333, BlockHash::fromHex("000000002dd5588a74784eaa7ab0507a18a" + "d16a236e7b1ce69f00d7ddfb5d0a6")}, + {74000, BlockHash::fromHex("0000000000573993a3c9e41ce34471c079d" + "cf5f52a0e824a81e7f953b8661a20")}, + {105000, BlockHash::fromHex("00000000000291ce28027faea320c8d2b0" + "54b2e0fe44a773f3eefb151d6bdc97")}, + {134444, BlockHash::fromHex("00000000000005b12ffd4cd315cd34ffd4" + "a594f430ac814c91184a0d42d2b0fe")}, + {168000, BlockHash::fromHex("000000000000099e61ea72015e79632f21" + "6fe6cb33d7899acb35b75c8303b763")}, + {193000, BlockHash::fromHex("000000000000059f452a5f7340de6682a9" + "77387c17010ff6e6c3bd83ca8b1317")}, + {210000, BlockHash::fromHex("000000000000048b95347e83192f69cf03" + "66076336c639f9b7228e9ba171342e")}, + {216116, BlockHash::fromHex("00000000000001b4f4b433e81ee46494af" + "945cf96014816a4e2370f11b23df4e")}, + {225430, BlockHash::fromHex("00000000000001c108384350f74090433e" + "7fcf79a606b8e797f065b130575932")}, + {250000, BlockHash::fromHex("000000000000003887df1f29024b06fc22" + "00b55f8af8f35453d7be294df2d214")}, + {279000, BlockHash::fromHex("0000000000000001ae8c72a0b0c301f67e" + "3afca10e819efa9041e458e9bd7e40")}, + {295000, BlockHash::fromHex("00000000000000004d9b4ef50f0f9d686f" + "d69db2e03af35a100370c64632a983")}, + // UAHF fork block. + {478558, BlockHash::fromHex("0000000000000000011865af4122fe3b14" + "4e2cbeea86142e8ff2fb4107352d43")}, + // Nov, 13 DAA activation block. + {504031, BlockHash::fromHex("0000000000000000011ebf65b60d0a3de8" + "0b8175be709d653b4c1a1beeb6ab9c")}, + // Monolith activation. + {530359, BlockHash::fromHex("0000000000000000011ada8bd08f46074f" + "44a8f155396f43e38acf9501c49103")}, + // Magnetic anomaly activation. + {556767, BlockHash::fromHex("0000000000000000004626ff6e3b936941" + "d341c5932ece4357eeccac44e6d56c")}, + // Great wall activation. + {582680, BlockHash::fromHex("000000000000000001b4b8e36aec7d4f96" + "71a47872cb9a74dc16ca398c7dcc18")}, + // Graviton activation. + {609136, BlockHash::fromHex("000000000000000000b48bb207faac5ac6" + "55c313e41ac909322eaa694f5bc5b1")}, + // Phonon activation. + {635259, BlockHash::fromHex("00000000000000000033dfef1fc2d6a5d5" + "520b078c55193a9bf498c5b27530f7")}, + }}; + +static CCheckpointData testNetCheckpointData = { + .mapCheckpoints = { + {546, BlockHash::fromHex("000000002a936ca763904c3c35fce2f3556c5" + "59c0214345d31b1bcebf76acb70")}, + // UAHF fork block. + {1155875, + BlockHash::fromHex("00000000f17c850672894b9a75b63a1e72830bbd5f" + "4c8889b5c1a80e7faef138")}, + // Nov, 13. DAA activation block. + {1188697, + BlockHash::fromHex("0000000000170ed0918077bde7b4d36cc4c91be69f" + "a09211f748240dabe047fb")}, + // Great wall activation. + {1303885, + BlockHash::fromHex("00000000000000479138892ef0e4fa478ccc938fb9" + "4df862ef5bde7e8dee23d3")}, + // Graviton activation. + {1341712, + BlockHash::fromHex("00000000fffc44ea2e202bd905a9fbbb9491ef9e9d" + "5a9eed4039079229afa35b")}, + // Phonon activation. + {1378461, + BlockHash::fromHex("0000000099f5509b5f36b1926bcf82b21d936ebeade" + "e811030dfbbb7fae915d7")}, + }}; + +static CCheckpointData regTestCheckpointData = { + .mapCheckpoints = { + {0, BlockHash::fromHex("0f9188f13cb7b2c71f2a335e3a4fc328bf5beb4" + "36012afca590b1a11466e2206")}, + }}; + +const CCheckpointData &CheckpointData(const std::string &chain) { + if (chain == CBaseChainParams::MAIN) { + return mainNetCheckpointData; + } + if (chain == CBaseChainParams::TESTNET) { + return testNetCheckpointData; + } + if (chain == CBaseChainParams::REGTEST) { + return regTestCheckpointData; + } + + throw std::runtime_error( + strprintf("%s: Unknown chain %s.", __func__, chain)); +} diff --git a/src/networks/bchn/checkpoints.cpp b/src/networks/bchn/checkpoints.cpp new file mode 100644 --- /dev/null +++ b/src/networks/bchn/checkpoints.cpp @@ -0,0 +1,104 @@ +// Copyright (c) 2020 The Bitcoin developers +// Distributed under the MIT software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. + +#include +#include + +static CCheckpointData mainNetCheckpointData = { + .mapCheckpoints = { + {11111, BlockHash::fromHex("0000000069e244f73d78e8fd29ba2fd2ed6" + "18bd6fa2ee92559f542fdb26e7c1d")}, + {33333, BlockHash::fromHex("000000002dd5588a74784eaa7ab0507a18a" + "d16a236e7b1ce69f00d7ddfb5d0a6")}, + {74000, BlockHash::fromHex("0000000000573993a3c9e41ce34471c079d" + "cf5f52a0e824a81e7f953b8661a20")}, + {105000, BlockHash::fromHex("00000000000291ce28027faea320c8d2b0" + "54b2e0fe44a773f3eefb151d6bdc97")}, + {134444, BlockHash::fromHex("00000000000005b12ffd4cd315cd34ffd4" + "a594f430ac814c91184a0d42d2b0fe")}, + {168000, BlockHash::fromHex("000000000000099e61ea72015e79632f21" + "6fe6cb33d7899acb35b75c8303b763")}, + {193000, BlockHash::fromHex("000000000000059f452a5f7340de6682a9" + "77387c17010ff6e6c3bd83ca8b1317")}, + {210000, BlockHash::fromHex("000000000000048b95347e83192f69cf03" + "66076336c639f9b7228e9ba171342e")}, + {216116, BlockHash::fromHex("00000000000001b4f4b433e81ee46494af" + "945cf96014816a4e2370f11b23df4e")}, + {225430, BlockHash::fromHex("00000000000001c108384350f74090433e" + "7fcf79a606b8e797f065b130575932")}, + {250000, BlockHash::fromHex("000000000000003887df1f29024b06fc22" + "00b55f8af8f35453d7be294df2d214")}, + {279000, BlockHash::fromHex("0000000000000001ae8c72a0b0c301f67e" + "3afca10e819efa9041e458e9bd7e40")}, + {295000, BlockHash::fromHex("00000000000000004d9b4ef50f0f9d686f" + "d69db2e03af35a100370c64632a983")}, + // UAHF fork block. + {478558, BlockHash::fromHex("0000000000000000011865af4122fe3b14" + "4e2cbeea86142e8ff2fb4107352d43")}, + // Nov, 13 DAA activation block. + {504031, BlockHash::fromHex("0000000000000000011ebf65b60d0a3de8" + "0b8175be709d653b4c1a1beeb6ab9c")}, + // Monolith activation. + {530359, BlockHash::fromHex("0000000000000000011ada8bd08f46074f" + "44a8f155396f43e38acf9501c49103")}, + // Magnetic anomaly activation. + {556767, BlockHash::fromHex("0000000000000000004626ff6e3b936941" + "d341c5932ece4357eeccac44e6d56c")}, + // Great wall activation. + {582680, BlockHash::fromHex("000000000000000001b4b8e36aec7d4f96" + "71a47872cb9a74dc16ca398c7dcc18")}, + // Graviton activation. + {609136, BlockHash::fromHex("000000000000000000b48bb207faac5ac6" + "55c313e41ac909322eaa694f5bc5b1")}, + // Phonon activation. + {635259, BlockHash::fromHex("00000000000000000033dfef1fc2d6a5d5" + "520b078c55193a9bf498c5b27530f7")}, + }}; + +static CCheckpointData testNetCheckpointData = { + .mapCheckpoints = { + {546, BlockHash::fromHex("000000002a936ca763904c3c35fce2f3556c5" + "59c0214345d31b1bcebf76acb70")}, + // UAHF fork block. + {1155875, + BlockHash::fromHex("00000000f17c850672894b9a75b63a1e72830bbd5f" + "4c8889b5c1a80e7faef138")}, + // Nov, 13. DAA activation block. + {1188697, + BlockHash::fromHex("0000000000170ed0918077bde7b4d36cc4c91be69f" + "a09211f748240dabe047fb")}, + // Great wall activation. + {1303885, + BlockHash::fromHex("00000000000000479138892ef0e4fa478ccc938fb9" + "4df862ef5bde7e8dee23d3")}, + // Graviton activation. + {1341712, + BlockHash::fromHex("00000000fffc44ea2e202bd905a9fbbb9491ef9e9d" + "5a9eed4039079229afa35b")}, + // Phonon activation. + {1378461, + BlockHash::fromHex("0000000099f5509b5f36b1926bcf82b21d936ebeade" + "e811030dfbbb7fae915d7")}, + }}; + +static CCheckpointData regTestCheckpointData = { + .mapCheckpoints = { + {0, BlockHash::fromHex("0f9188f13cb7b2c71f2a335e3a4fc328bf5beb4" + "36012afca590b1a11466e2206")}, + }}; + +const CCheckpointData &CheckpointData(const std::string &chain) { + if (chain == CBaseChainParams::MAIN) { + return mainNetCheckpointData; + } + if (chain == CBaseChainParams::TESTNET) { + return testNetCheckpointData; + } + if (chain == CBaseChainParams::REGTEST) { + return regTestCheckpointData; + } + + throw std::runtime_error( + strprintf("%s: Unknown chain %s.", __func__, chain)); +}