|
7 | 7 |
|
8 | 8 | #include <chainparamsseeds.h>
|
9 | 9 | #include <consensus/merkle.h>
|
| 10 | +#include <hash.h> // for signet block challenge hash |
10 | 11 | #include <tinyformat.h>
|
11 | 12 | #include <util/system.h>
|
12 | 13 | #include <util/strencodings.h>
|
@@ -63,6 +64,8 @@ class CMainParams : public CChainParams {
|
63 | 64 | public:
|
64 | 65 | CMainParams() {
|
65 | 66 | strNetworkID = CBaseChainParams::MAIN;
|
| 67 | + consensus.signet_blocks = false; |
| 68 | + consensus.signet_challenge.clear(); |
66 | 69 | consensus.nSubsidyHalvingInterval = 210000;
|
67 | 70 | consensus.BIP16Exception = uint256S("0x00000000000002dc756eebf4f49723ed8d30cc28a5f108eb94b1ba88ac4f9c22");
|
68 | 71 | consensus.BIP34Height = 227931;
|
@@ -172,6 +175,8 @@ class CTestNetParams : public CChainParams {
|
172 | 175 | public:
|
173 | 176 | CTestNetParams() {
|
174 | 177 | strNetworkID = CBaseChainParams::TESTNET;
|
| 178 | + consensus.signet_blocks = false; |
| 179 | + consensus.signet_challenge.clear(); |
175 | 180 | consensus.nSubsidyHalvingInterval = 210000;
|
176 | 181 | consensus.BIP16Exception = uint256S("0x00000000dd30457c001f4095d208cc1296b0eed002427aa599874af7a432b105");
|
177 | 182 | consensus.BIP34Height = 21111;
|
@@ -250,13 +255,104 @@ class CTestNetParams : public CChainParams {
|
250 | 255 | }
|
251 | 256 | };
|
252 | 257 |
|
| 258 | +/** |
| 259 | + * Signet |
| 260 | + */ |
| 261 | +class SigNetParams : public CChainParams { |
| 262 | +public: |
| 263 | + explicit SigNetParams(const ArgsManager& args) { |
| 264 | + std::vector<uint8_t> bin; |
| 265 | + vSeeds.clear(); |
| 266 | + |
| 267 | + if (!args.IsArgSet("-signetchallenge")) { |
| 268 | + LogPrintf("Using default signet network\n"); |
| 269 | + bin = ParseHex("512103ad5e0edad18cb1f0fc0d28a3d4f1f3e445640337489abb10404f2d1e086be430210359ef5021964fe22d6f8e05b2463c9540ce96883fe3b278760f048f5189f2e6c452ae"); |
| 270 | + vSeeds.emplace_back("178.128.221.177"); |
| 271 | + vSeeds.emplace_back("2a01:7c8:d005:390::5"); |
| 272 | + vSeeds.emplace_back("ntv3mtqw5wt63red.onion:38333"); |
| 273 | + } else { |
| 274 | + const auto signet_challenge = args.GetArgs("-signetchallenge"); |
| 275 | + if (signet_challenge.size() != 1) { |
| 276 | + throw std::runtime_error(strprintf("%s: -signetchallenge cannot be multiple values.", __func__)); |
| 277 | + } |
| 278 | + bin = ParseHex(signet_challenge[0]); |
| 279 | + |
| 280 | + LogPrintf("Signet with challenge %s\n", signet_challenge[0]); |
| 281 | + } |
| 282 | + |
| 283 | + if (args.IsArgSet("-signetseednode")) { |
| 284 | + vSeeds = args.GetArgs("-signetseednode"); |
| 285 | + } |
| 286 | + |
| 287 | + strNetworkID = CBaseChainParams::SIGNET; |
| 288 | + consensus.signet_blocks = true; |
| 289 | + consensus.signet_challenge.assign(bin.begin(), bin.end()); |
| 290 | + consensus.nSubsidyHalvingInterval = 210000; |
| 291 | + consensus.BIP34Height = 1; |
| 292 | + consensus.BIP65Height = 1; |
| 293 | + consensus.BIP66Height = 1; |
| 294 | + consensus.CSVHeight = 1; |
| 295 | + consensus.SegwitHeight = 1; |
| 296 | + consensus.nPowTargetTimespan = 14 * 24 * 60 * 60; // two weeks |
| 297 | + consensus.nPowTargetSpacing = 10 * 60; |
| 298 | + consensus.fPowAllowMinDifficultyBlocks = false; |
| 299 | + consensus.fPowNoRetargeting = false; |
| 300 | + consensus.nRuleChangeActivationThreshold = 1916; |
| 301 | + consensus.nMinerConfirmationWindow = 2016; |
| 302 | + consensus.powLimit = uint256S("00000377ae000000000000000000000000000000000000000000000000000000"); |
| 303 | + consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].bit = 28; |
| 304 | + consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].nStartTime = 1199145601; // January 1, 2008 |
| 305 | + consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].nTimeout = 1230767999; // December 31, 2008 |
| 306 | + |
| 307 | + // message start is defined as the first 4 bytes of the sha256d of the block script |
| 308 | + CHashWriter h(SER_DISK, 0); |
| 309 | + h << consensus.signet_challenge; |
| 310 | + uint256 hash = h.GetHash(); |
| 311 | + memcpy(pchMessageStart, hash.begin(), 4); |
| 312 | + LogPrintf("Signet derived magic (message start): %s\n", HexStr({pchMessageStart, pchMessageStart + 4})); |
| 313 | + |
| 314 | + nDefaultPort = 38333; |
| 315 | + nPruneAfterHeight = 1000; |
| 316 | + m_assumed_blockchain_size = 0; |
| 317 | + m_assumed_chain_state_size = 0; |
| 318 | + |
| 319 | + genesis = CreateGenesisBlock(1598918400, 52613770, 0x1e0377ae, 1, 50 * COIN); |
| 320 | + consensus.hashGenesisBlock = genesis.GetHash(); |
| 321 | + assert(consensus.hashGenesisBlock == uint256S("0x00000008819873e925422c1ff0f99f7cc9bbb232af63a077a480a3633bee1ef6")); |
| 322 | + assert(genesis.hashMerkleRoot == uint256S("0x4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b")); |
| 323 | + |
| 324 | + vFixedSeeds.clear(); |
| 325 | + |
| 326 | + base58Prefixes[PUBKEY_ADDRESS] = std::vector<unsigned char>(1,111); |
| 327 | + base58Prefixes[SCRIPT_ADDRESS] = std::vector<unsigned char>(1,196); |
| 328 | + base58Prefixes[SECRET_KEY] = std::vector<unsigned char>(1,239); |
| 329 | + base58Prefixes[EXT_PUBLIC_KEY] = {0x04, 0x35, 0x87, 0xCF}; |
| 330 | + base58Prefixes[EXT_SECRET_KEY] = {0x04, 0x35, 0x83, 0x94}; |
| 331 | + |
| 332 | + bech32_hrp = "tb"; |
| 333 | + |
| 334 | + fDefaultConsistencyChecks = false; |
| 335 | + fRequireStandard = true; |
| 336 | + m_is_test_chain = true; |
| 337 | + m_is_mockable_chain = false; |
| 338 | + |
| 339 | + chainTxData = ChainTxData{ |
| 340 | + 0, |
| 341 | + 0, |
| 342 | + 0 |
| 343 | + }; |
| 344 | + } |
| 345 | +}; |
| 346 | + |
253 | 347 | /**
|
254 | 348 | * Regression test
|
255 | 349 | */
|
256 | 350 | class CRegTestParams : public CChainParams {
|
257 | 351 | public:
|
258 | 352 | explicit CRegTestParams(const ArgsManager& args) {
|
259 | 353 | strNetworkID = CBaseChainParams::REGTEST;
|
| 354 | + consensus.signet_blocks = false; |
| 355 | + consensus.signet_challenge.clear(); |
260 | 356 | consensus.nSubsidyHalvingInterval = 150;
|
261 | 357 | consensus.BIP16Exception = uint256();
|
262 | 358 | consensus.BIP34Height = 500; // BIP34 activated on regtest (Used in functional tests)
|
@@ -391,12 +487,15 @@ const CChainParams &Params() {
|
391 | 487 |
|
392 | 488 | std::unique_ptr<const CChainParams> CreateChainParams(const std::string& chain)
|
393 | 489 | {
|
394 |
| - if (chain == CBaseChainParams::MAIN) |
| 490 | + if (chain == CBaseChainParams::MAIN) { |
395 | 491 | return std::unique_ptr<CChainParams>(new CMainParams());
|
396 |
| - else if (chain == CBaseChainParams::TESTNET) |
| 492 | + } else if (chain == CBaseChainParams::TESTNET) { |
397 | 493 | return std::unique_ptr<CChainParams>(new CTestNetParams());
|
398 |
| - else if (chain == CBaseChainParams::REGTEST) |
| 494 | + } else if (chain == CBaseChainParams::SIGNET) { |
| 495 | + return std::unique_ptr<CChainParams>(new SigNetParams(gArgs)); |
| 496 | + } else if (chain == CBaseChainParams::REGTEST) { |
399 | 497 | return std::unique_ptr<CChainParams>(new CRegTestParams(gArgs));
|
| 498 | + } |
400 | 499 | throw std::runtime_error(strprintf("%s: Unknown chain %s.", __func__, chain));
|
401 | 500 | }
|
402 | 501 |
|
|
0 commit comments