forked from digibyte/digibyte
-
Notifications
You must be signed in to change notification settings - Fork 64
/
Copy pathchainparams.cpp
887 lines (748 loc) · 46.4 KB
/
chainparams.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
// Copyright (c) 2010 Satoshi Nakamoto
// Copyright (c) 2009-2020 The Bitcoin Core developers
// Copyright (c) 2014-2020 The DigiByte Core developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include "arith_uint256.h"
#include <chainparams.h>
#include <chainparamsseeds.h>
#include <consensus/merkle.h>
#include <deploymentinfo.h>
#include <hash.h> // for signet block challenge hash
#include <util/system.h>
#include <assert.h>
#include <boost/algorithm/string/classification.hpp>
#include <boost/algorithm/string/split.hpp>
static CBlock CreateGenesisBlock(const char* pszTimestamp, const CScript& genesisOutputScript, uint32_t nTime, uint32_t nNonce, uint32_t nBits, int32_t nVersion, const CAmount& genesisReward)
{
CMutableTransaction txNew;
txNew.nVersion = 1;
txNew.vin.resize(1);
txNew.vout.resize(1);
txNew.vin[0].scriptSig = CScript() << 486604799 << CScriptNum(4) << std::vector<unsigned char>((const unsigned char*)pszTimestamp, (const unsigned char*)pszTimestamp + strlen(pszTimestamp));
txNew.vout[0].nValue = 8000;
txNew.vout[0].scriptPubKey = CScript() << 0x0 << OP_CHECKSIG;
CBlock genesis;
genesis.nTime = nTime;
genesis.nBits = nBits;
genesis.nNonce = nNonce;
genesis.nVersion = nVersion;
genesis.vtx.push_back(MakeTransactionRef(std::move(txNew)));
genesis.hashPrevBlock.SetNull();
genesis.hashMerkleRoot = BlockMerkleRoot(genesis);
return genesis;
}
/**
* Build the genesis block. Note that the output of its generation
* transaction cannot be spent since it did not originally exist in the
* database.
*
* CBlock(hash=000000000019d6, ver=1, hashPrevBlock=00000000000000, hashMerkleRoot=4a5e1e, nTime=1231006505, nBits=1d00ffff, nNonce=2083236893, vtx=1)
* CTransaction(hash=4a5e1e, ver=1, vin.size=1, vout.size=1, nLockTime=0)
* CTxIn(COutPoint(000000, -1), coinbase 04ffff001d0104455468652054696d65732030332f4a616e2f32303039204368616e63656c6c6f72206f6e206272696e6b206f66207365636f6e64206261696c6f757420666f722062616e6b73)
* CTxOut(nValue=50.00000000, scriptPubKey=0x5F1DF16B2B704C8A578D0B)
* vMerkleTree: 4a5e1e
*/
static CBlock CreateGenesisBlock(uint32_t nTime, uint32_t nNonce, uint32_t nBits, int32_t nVersion, const CAmount& genesisReward)
{
const char* pszTimestamp = "USA Today: 10/Jan/2014, Target: Data stolen from up to 110M customers";
const CScript genesisOutputScript = CScript() << 0x0 << OP_CHECKSIG;
return CreateGenesisBlock(pszTimestamp, genesisOutputScript, nTime, nNonce, nBits, nVersion, genesisReward);
}
/**
* Main network on which people trade goods and services.
*/
class CMainParams : public CChainParams {
public:
CMainParams() {
strNetworkID = CBaseChainParams::MAIN;
consensus.signet_blocks = false;
consensus.signet_challenge.clear();
consensus.BIP16Exception = uint256S("0x0");
// BIP34, BIP65 and BIP66, CSV and Segwit were activated simultaneously
// DEPLOYMENT_NVERSIONBIPS, DEPLOYMENT_CSV, DEPLOYMENT_SEGWIT
consensus.BIP34Hash = uint256S("0xadd8ca420f557f62377ec2be6e6f47b96cf2e68160d58aeb7b73433de834cca0");
consensus.BIP34Height = consensus.BIP65Height = consensus.BIP66Height = 4394880; // add8ca420f557f62377ec2be6e6f47b96cf2e68160d58aeb7b73433de834cca0
consensus.CSVHeight = consensus.SegwitHeight = 4394880;
consensus.ReserveAlgoBitsHeight = 8547840; // d2c03966aeef35f739b222c8332b68df2676204d49c390b3a2544b967c46163f
consensus.powLimit = ArithToUint256(~arith_uint256(0) >> 20);
consensus.initialTarget[ALGO_ODO] = ArithToUint256(~arith_uint256(0) >> 40); // 256 difficulty
consensus.nPowTargetTimespan = 14 * 24 * 60 * 60; // two weeks
consensus.nPowTargetSpacing = 60 / 4;
consensus.fPowAllowMinDifficultyBlocks = false;
consensus.fEasyPow = false;
consensus.fPowNoRetargeting = false;
consensus.fRbfEnabled = false;
// DigiByte Specific Consensus Code
consensus.nOdoShapechangeInterval = 10*24*60*60; // 10 days
consensus.nRuleChangeActivationThreshold = 28224; // 28224 - 70% of 40320 blocks
consensus.nMinerConfirmationWindow = 40320; // nPowTargetTimespan / nPowTargetSpacing 40320 blocks main net - 1 week
// Need to make sure we ignore activation warnings below Odo activation height, also ignores Segwit activation
consensus.MinBIP9WarningHeight = 9152640; // Odo height + miner confirmation window, nMinerConfirmationWindow was un initialized before, so hard coded now
// DigiByte Hard Fork Block Heights
consensus.multiAlgoDiffChangeTarget = 145000; // Block 145,000 MultiAlgo Hard Fork
consensus.alwaysUpdateDiffChangeTarget = 400000; // Block 400,000 MultiShield Hard Fork
consensus.workComputationChangeTarget = 1430000; // Block 1,430,000 DigiSpeed Hard Fork
consensus.algoSwapChangeTarget = 9100000; // Block 9,100,000 Odo PoW Hard Fork
consensus.OdoHeight = 9112320; // 906b712a7b1f54f10b0faf86111e832ddb7b8ce86ac71a4edd2c61e5ccfe9428
consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].bit = 27;
consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].nStartTime = 1199145601; // January 1, 2008
consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].nTimeout = 1230767999; // December 31, 2008
consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].min_activation_height = 0; // No activation delay
// Deployment of Taproot (BIPs 340-342)
consensus.vDeployments[Consensus::DEPLOYMENT_TAPROOT].bit = 2;
consensus.vDeployments[Consensus::DEPLOYMENT_TAPROOT].nStartTime = 1736510438; // 10th January 2025
consensus.vDeployments[Consensus::DEPLOYMENT_TAPROOT].nTimeout = 1799582438; // 10th January 2027
consensus.vDeployments[Consensus::DEPLOYMENT_TAPROOT].min_activation_height = 0; // No activation delay
// The best chain should have at least this much work.
consensus.nMinimumChainWork = uint256S("0x00");
// By default assume that the signatures in ancestors of this block are valid.
consensus.defaultAssumeValid = uint256S("0xf530a66ba6fe93e647f7d88a9b3f22bfe8c2c2ab1ec1b0286286f86b82d6a10f"); // Block 20,000,000
/**
* The message start string is designed to be unlikely to occur in normal data.
* The characters are rarely used upper ASCII, not valid as UTF-8, and produce
* a large 32-bit integer with any alignment.
*/
pchMessageStart[0] = 0xfa;
pchMessageStart[1] = 0xc3;
pchMessageStart[2] = 0xb6;
pchMessageStart[3] = 0xda;
nDefaultPort = 12024;
nPruneAfterHeight = 100000;
m_assumed_blockchain_size = 32;
m_assumed_chain_state_size = 1;
genesis = CreateGenesisBlock(1389388394, 2447652, 0x1e0ffff0, 1, 8000);
consensus.hashGenesisBlock = genesis.GetHash();
assert(consensus.hashGenesisBlock == uint256S("0x7497ea1b465eb39f1c8f507bc877078fe016d6fcb6dfad3a64c98dcc6e1e8496"));
assert(genesis.hashMerkleRoot == uint256S("0x72ddd9496b004221ed0557358846d9248ecd4c440ebd28ed901efc18757d0fad"));
// Note that of those which support the service bits prefix, most only support a subset of
// possible options.
// This is fine at runtime as we'll fall back to using them as an addrfetch if they don't support the
// service bits we want, but we should get them updated to support all service bits wanted by any
// release ASAP to avoid it where possible.
// The current status of the DigiByte DNS Seed Servers can be checked here: http://digibyteseed.com/
// If you notice a problem with an exiting Seed Server, please contact the DigiByte Critical Infrastructure team (DGBCIT)
// via the #DGBCIT channel on the DigiByte Discord server: https://discord.com/channels/878200503815782400/1133815334013509764
// Alternatively, create an issue ticket here: https://github.com/DigiByte-Core/digibyte/issues
// When adding a new MAINNET Seed Server URL below, please include the name of the person in charge of it
// and their Github handle so they can be contacted in an emergency.
// DigiByte MAINNET DNS Seed Server:
vSeeds.emplace_back("seed.digibyte.io"); // Jared Tate @JaredTate
vSeeds.emplace_back("seed.diginode.tools"); // Olly Stedall @saltedlolly
vSeeds.emplace_back("seed.digibyteblockchain.org"); // John Song @j50ng
vSeeds.emplace_back("eu.digibyteseed.com"); // Jan De Jong @jongjan88
vSeeds.emplace_back("seed.digibyte.link"); // Bastian Driessen @bastiandriessen
vSeeds.emplace_back("seed.quakeguy.com"); // Paul Morgan Quakeitup @SnKQuaKe
vSeeds.emplace_back("seed.aroundtheblock.app"); // Mark McNiel @JohnnyLawDGB
vSeeds.emplace_back("seed.digibyte.services"); // Craig Donnachie @cdonnachie
base58Prefixes[PUBKEY_ADDRESS] = std::vector<unsigned char>(1,30);
base58Prefixes[SCRIPT_ADDRESS_OLD] = std::vector<unsigned char>(1,5);
base58Prefixes[SCRIPT_ADDRESS] = std::vector<unsigned char>(1,63);
base58Prefixes[SECRET_KEY] = std::vector<unsigned char>(1,128);
base58Prefixes[SECRET_KEY_OLD] = std::vector<unsigned char>(1,158);
base58Prefixes[EXT_PUBLIC_KEY] = {0x04, 0x88, 0xB2, 0x1E};
base58Prefixes[EXT_SECRET_KEY] = {0x04, 0x88, 0xAD, 0xE4};
bech32_hrp = "dgb";
vFixedSeeds = std::vector<uint8_t>(std::begin(chainparams_seed_main), std::end(chainparams_seed_main));
fDefaultConsistencyChecks = false;
fRequireStandard = true;
m_is_test_chain = false;
m_is_mockable_chain = false;
checkpointData = (CCheckpointData) {
{
{ 0, uint256S("0x7497ea1b465eb39f1c8f507bc877078fe016d6fcb6dfad3a64c98dcc6e1e8496")},
{ 5000, uint256S("0x95753d284404118788a799ac754a3fdb5d817f5bd73a78697dfe40985c085596")},
{ 10000, uint256S("0x12f90b8744f3b965e107ad9fd8b33ba6d95a91882fbc4b5f8588d70d494bed88")},
{ 12000, uint256S("0xa1266acba91dc3d5737d9e8c6e21b7a91901f7f4c48082ce3d84dd394a13e415")},
{ 14300, uint256S("0x24f665d71b0c6c88f6f72a863e9f1ba8e835cc52d13ad895dc5426021c7d2c48")},
{ 30000, uint256S("0x17c69ef6b403571b1bd333c91fbe116e451ba8281be12aa6bafb0486764bb315")},
{ 60000, uint256S("0x57b2c612b60462a3d6c388c8b30a68cb6f7e2034eea962b12b7ef506454fa2c1")},
{ 110000, uint256S("0xab2da24656493015f2fd288994661e1cc657d90aa34c755514af044aaaf1569d")},
{ 141100, uint256S("0x145c2cb5239a4e019c730ce8468d927a3955529c2bae077850783da97ddbca05")},
{ 141656, uint256S("0x683d27720429f28bcfa22d8385b7a06f307c8fd918d49215148fbd41a0dda595")},
{ 245000, uint256S("0x852c475c605e1f20bbe60219c811abaeef08bf0d4ff87eef59200fd7a7567fa7")},
{ 302000, uint256S("0xfb6d14ac5e0208f00d941db1fcbfe050f093cfd0c05ed151c809e4428bc14286")},
{ 331000, uint256S("0xbd1a1d002750e1648746eb29c78d30fa1043c8b6f89d82924c4488be06fa3d19")},
{ 360000, uint256S("0x8fee7e3f6c38dccd3047a3e4667c63406f835c2890024030a2ab2dc6dba7c912")},
{ 400100, uint256S("0x82325a97cd97ac14b0a57408f881b1a9fc40174f8430a4580429499ac5d153c8")},
{ 521000, uint256S("0xd23fd1e1f994c0586d761b71bb3530e9ab45bd0fabda3a5a2e394f3dc4d9bb04")},
{ 1380000, uint256S("0x00000000000001969b1e5836dd8bf6a001d96f4a16d336e09405b62b29feead6")},
{ 1435000, uint256S("0xf78cc9c2791c8a23720e2efcdaf46584046ee5db8f050e21a3a15a13f5c68da0")},
{ 4255555, uint256S("0x23f72e760542bf021ec76d04231ad7cf80142069a79ba702028e074b726f86ef")},
{ 6000000, uint256S("0x6495a84f8f83981a435a6cbf9e6dd4bf0f38618c8325213ca6ef6add40c0ddd8")},
{ 20000000, uint256S("0xf530a66ba6fe93e647f7d88a9b3f22bfe8c2c2ab1ec1b0286286f86b82d6a10f")},
}
};
chainTxData = ChainTxData{
// Data from RPC: getchaintxstats 172800 0000000000000004d65cca5df8c44830e0a20ff58881e3dfd317528f6635a77c
/* nTime */ 1692147015,
/* nTxCount */ 44039736,
/* dTxRate */ 0.1244932494502668,
};
// BEGIN OLD DGB Consensus Diff Timing Code
/**
Current DigiByte 2017 Difficulty Adjustment Code & Block Target. See explanation here:
https://github.com/digibyte/digibyte-old/pull/36
https://github.com/digibyte/digibyte-old/pull/15
Difficulty is updated for every algorithm on every block, not just the algorithm that was solved.
In particular, the difficulty of one algorithm may decrease when a different algorithm is solved.
An attacker with 90% of the SHA256D hashrate and 33% of each of the other 4 algorithms would
have insufficient hashpower to mount a 51% attack.
- MultiAlgo POW (Scrypt, SHA256D, Qubit, Skein and Groestl) algorithms
- 15 Second Block Target (1.5 min per Algo)
- ~21 billion total coins in 21 years
- 8000 coins per block, reduces by 0.5% every 10,080 blocks starting 2/28/14 1% monthly reduction
- Difficulty retarget every 1 block per algo (1.5 Min)
**/
consensus.nTargetTimespan = 0.10 * 24 * 60 * 60; // 2.4 hours
consensus.nTargetSpacing = 60; // 60 seconds
consensus.nInterval = consensus.nTargetTimespan / consensus.nTargetSpacing;
consensus.nDiffChangeTarget = 67200; // DigiShield Hard Fork Block BIP34Height 67,200
// Old 1% monthly DGB Reward before 15 secon block change
consensus.patchBlockRewardDuration = 10080; //10080; - No longer used
//4 blocks per min, x60 minutes x 24hours x 14 days = 80,160 blocks for 0.5% reduction in DGB reward supply - No longer used
consensus.patchBlockRewardDuration2 = 80160; //80160;
consensus.nTargetTimespanRe = 1*60; // 60 Seconds
consensus.nTargetSpacingRe = 1*60; // 60 seconds
consensus.nIntervalRe = consensus.nTargetTimespanRe / consensus.nTargetSpacingRe; // 1 block
consensus.nAveragingInterval = 10; // 10 blocks
consensus.multiAlgoTargetSpacing = 30*5; // NUM_ALGOS * 30 seconds
consensus.multiAlgoTargetSpacingV4 = 15*5; // NUM_ALGOS * 15 seconds
consensus.nAveragingTargetTimespan = consensus.nAveragingInterval * consensus.multiAlgoTargetSpacing; // 10* NUM_ALGOS * 30
consensus.nAveragingTargetTimespanV4 = consensus.nAveragingInterval * consensus.multiAlgoTargetSpacingV4; // 10 * NUM_ALGOS * 15
consensus.nMaxAdjustDown = 40; // 40% adjustment down
consensus.nMaxAdjustUp = 20; // 20% adjustment up
consensus.nMaxAdjustDownV3 = 16; // 16% adjustment down
consensus.nMaxAdjustUpV3 = 8; // 8% adjustment up
consensus.nMaxAdjustDownV4 = 16;
consensus.nMaxAdjustUpV4 = 8;
consensus.nMinActualTimespan = consensus.nAveragingTargetTimespan * (100 - consensus.nMaxAdjustUp) / 100;
consensus.nMaxActualTimespan = consensus.nAveragingTargetTimespan * (100 + consensus.nMaxAdjustDown) / 100;
consensus.nMinActualTimespanV3 = consensus.nAveragingTargetTimespan * (100 - consensus.nMaxAdjustUpV3) / 100;
consensus.nMaxActualTimespanV3 = consensus.nAveragingTargetTimespan * (100 + consensus.nMaxAdjustDownV3) / 100;
consensus.nMinActualTimespanV4 = consensus.nAveragingTargetTimespanV4 * (100 - consensus.nMaxAdjustUpV4) / 100;
consensus.nMaxActualTimespanV4 = consensus.nAveragingTargetTimespanV4 * (100 + consensus.nMaxAdjustDownV4) / 100;
consensus.nLocalTargetAdjustment = 4; //target adjustment per algo
consensus.nLocalDifficultyAdjustment = 4; //difficulty adjustment per algo
// END Old DGB Diff Timing Code
}
};
/**
* Testnet (v3): public test network which is reset from time to time.
*/
class CTestNetParams : public CChainParams {
public:
CTestNetParams() {
strNetworkID = "test";
consensus.powLimit = ArithToUint256(~arith_uint256(0) >> 20);
consensus.initialTarget[ALGO_ODO] = ArithToUint256(~arith_uint256(0) >> 36); // 16 difficulty
consensus.nSubsidyHalvingInterval = 300;
consensus.nPowTargetTimespan = 14 * 24 * 60 * 60; // two weeks
consensus.nPowTargetSpacing = 60 / 4;
consensus.BIP16Exception = uint256();
consensus.BIP34Height = 500; // BIP34 activated on regtest (Used in functional tests)
consensus.BIP34Hash = uint256();
consensus.BIP65Height = 1351; // BIP65 activated on regtest (Used in functional tests)
consensus.BIP66Height = 1251; // BIP66 activated on regtest (Used in functional tests)
consensus.CSVHeight = 1; // CSV activated on regtest (Used in rpc activation tests)
consensus.SegwitHeight = 0; // SEGWIT is always activated on regtest unless overridden
consensus.ReserveAlgoBitsHeight = 0;
consensus.OdoHeight = 600;
consensus.MinBIP9WarningHeight = 0;
/** Current DigiByte 2017 Difficulty Adjustment Code & Block Target. See explanation here:
https://github.com/digibyte/digibyte-old/pull/36
https://github.com/digibyte/digibyte-old/pull/15
Difficulty is updated for every algorithm on every block, not just the algorithm that was solved.
In particular, the difficulty of one algorithm may decrease when a different algorithm is solved.
An attacker with 90% of the SHA256D hashrate and 33% of each of the other 4 algorithms would
have insufficient hashpower to mount a 51% attack.
- MultiAlgo POW (Scrypt, SHA256D, Qubit, Skein and Groestl) algorithms
- 15 Second Block Target (1.5 min per Algo)
- ~21 billion total coins in 21 years
- 8000 coins per block, reduces by 0.5% every 10,080 blocks starting 2/28/14 1% monthly reduction
- Difficulty retarget every 1 block per algo (1.5 Min)
**/
consensus.nTargetTimespan = 0.10 * 24 * 60 * 60; // 2.4 hours
consensus.nTargetSpacing = 60; // 60 seconds
consensus.nInterval = consensus.nTargetTimespan / consensus.nTargetSpacing;
consensus.nDiffChangeTarget = 67; // DigiShield Hard Fork Block BIP34Height 67,200
// Old 1% monthly DGB Reward before 15 secon block change
consensus.patchBlockRewardDuration = 10; //10080; - No longer used
//4 blocks per min, x60 minutes x 24hours x 14 days = 80,160 blocks for 0.5% reduction in DGB reward supply - No longer used
consensus.patchBlockRewardDuration2 = 80; //80160;
consensus.nTargetTimespanRe = 1*60; // 60 Seconds
consensus.nTargetSpacingRe = 1*60; // 60 seconds
consensus.nIntervalRe = consensus.nTargetTimespanRe / consensus.nTargetSpacingRe; // 1 block
consensus.nAveragingInterval = 10; // 10 blocks
consensus.multiAlgoTargetSpacing = 30*5; // NUM_ALGOS * 30 seconds
consensus.multiAlgoTargetSpacingV4 = 15*5; // NUM_ALGOS * 15 seconds
consensus.nAveragingTargetTimespan = consensus.nAveragingInterval * consensus.multiAlgoTargetSpacing; // 10* NUM_ALGOS * 30
consensus.nAveragingTargetTimespanV4 = consensus.nAveragingInterval * consensus.multiAlgoTargetSpacingV4; // 10 * NUM_ALGOS * 15
consensus.nMaxAdjustDown = 40; // 40% adjustment down
consensus.nMaxAdjustUp = 20; // 20% adjustment up
consensus.nMaxAdjustDownV3 = 16; // 16% adjustment down
consensus.nMaxAdjustUpV3 = 8; // 8% adjustment up
consensus.nMaxAdjustDownV4 = 16;
consensus.nMaxAdjustUpV4 = 8;
consensus.nMinActualTimespan = consensus.nAveragingTargetTimespan * (100 - consensus.nMaxAdjustUp) / 100;
consensus.nMaxActualTimespan = consensus.nAveragingTargetTimespan * (100 + consensus.nMaxAdjustDown) / 100;
consensus.nMinActualTimespanV3 = consensus.nAveragingTargetTimespan * (100 - consensus.nMaxAdjustUpV3) / 100;
consensus.nMaxActualTimespanV3 = consensus.nAveragingTargetTimespan * (100 + consensus.nMaxAdjustDownV3) / 100;
consensus.nMinActualTimespanV4 = consensus.nAveragingTargetTimespanV4 * (100 - consensus.nMaxAdjustUpV4) / 100;
consensus.nMaxActualTimespanV4 = consensus.nAveragingTargetTimespanV4 * (100 + consensus.nMaxAdjustDownV4) / 100;
consensus.nLocalTargetAdjustment = 4; //target adjustment per algo
consensus.nLocalDifficultyAdjustment = 4; //difficulty adjustment per algo
// DigiByte Hard Fork Block Heights
consensus.multiAlgoDiffChangeTarget = 100; // Block 145,000 MultiAlgo Hard Fork
consensus.alwaysUpdateDiffChangeTarget = 400; // Block 400,000 MultiShield Hard Fork
consensus.workComputationChangeTarget = 1430; // Block 1,430,000 DigiSpeed Hard Fork
consensus.algoSwapChangeTarget = 20000; // Block 9,000,000 Odo PoW Hard Fork
consensus.fPowAllowMinDifficultyBlocks = true;
consensus.fEasyPow = false;
consensus.fPowNoRetargeting = true;
consensus.nRuleChangeActivationThreshold = 4032; // 4032 - 70% of 5760
consensus.nMinerConfirmationWindow = 5760; // 1 day of blocks on testnet
consensus.fRbfEnabled = false;
consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].bit = 27;
consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].nStartTime = 1619222400; // April 24th, 2021
consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].nTimeout = 1628640000; // August 11th, 2021
consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].min_activation_height = 0; // No activation delay
// Deployment of Taproot (BIPs 340-342)
consensus.vDeployments[Consensus::DEPLOYMENT_TAPROOT].bit = 2;
consensus.vDeployments[Consensus::DEPLOYMENT_TAPROOT].nStartTime = 1718921304; // 20th June 2024 Testnet
consensus.vDeployments[Consensus::DEPLOYMENT_TAPROOT].nTimeout = 1750457304; // 20th June 2025 Testnet
consensus.vDeployments[Consensus::DEPLOYMENT_TAPROOT].min_activation_height = 0; // No activation delay
consensus.nOdoShapechangeInterval = 1*24*60*60; // 1 day
// The best chain should have at least this much work.
consensus.nMinimumChainWork = uint256S("0x00");
// By default assume that the signatures in ancestors of this block are valid.
consensus.defaultAssumeValid = uint256S("0x00"); //1079274
pchMessageStart[0] = 0xfd;
pchMessageStart[1] = 0xc8;
pchMessageStart[2] = 0xbd;
pchMessageStart[3] = 0xdd;
nDefaultPort = 12026;
nPruneAfterHeight = 1000;
m_assumed_blockchain_size = 40;
m_assumed_chain_state_size = 2;
genesis = CreateGenesisBlock(1516939474, 2411473, 0x1e0ffff0, 1, 8000 * COIN);
consensus.hashGenesisBlock = genesis.GetHash();
assert(consensus.hashGenesisBlock == uint256S("0x308ea0711d5763be2995670dd9ca9872753561285a84da1d58be58acaa822252"));
assert(genesis.hashMerkleRoot == uint256S("0x72ddd9496b004221ed0557358846d9248ecd4c440ebd28ed901efc18757d0fad"));
vFixedSeeds.clear();
vSeeds.clear();
// The current status of the DigiByte DNS Seed Servers can be checked here: http://digibyteseed.com/
// If you notice a problem with an exiting Seed Server, please contact the DigiByte Critical Infrastructure team (DGBCIT)
// via the #DGBCIT channel on the DigiByte Discord server: https://discord.com/channels/878200503815782400/1133815334013509764
// Alternatively, create an issue ticket here: https://github.com/DigiByte-Core/digibyte/issues
// When adding a new TESTNET Seed Server URL below, please include the name of the person in charge of it
// and their Github handle so they can be contacted in an emergency.
// nodes with support for servicebits filtering should be at the top
// DigiByte TESTNET DNS Seed Servers:
vSeeds.emplace_back("testnetseed.diginode.tools"); // Olly Stedall @saltedlolly
vSeeds.emplace_back("testseed.digibyteblockchain.org"); // John Song @j50ng
vSeeds.emplace_back("testnet.digibyteseed.com"); // Jan De Jong @jongjan88
vSeeds.emplace_back("testnetseed.digibyte.link"); // Bastian Driessen @bastiandriessen
vSeeds.emplace_back("testnetseed.digibyte.services"); // Craig Donnachie @cdonnachie
base58Prefixes[PUBKEY_ADDRESS] = std::vector<unsigned char>(1,126);
base58Prefixes[SCRIPT_ADDRESS] = std::vector<unsigned char>(1,140);
base58Prefixes[SECRET_KEY] = std::vector<unsigned char>(1,254);
base58Prefixes[EXT_PUBLIC_KEY] = {0x04, 0x35, 0x87, 0xCF};
base58Prefixes[EXT_SECRET_KEY] = {0x04, 0x35, 0x83, 0x94};
bech32_hrp = "dgbt";
vFixedSeeds = std::vector<uint8_t>(std::begin(chainparams_seed_test), std::end(chainparams_seed_test));
fDefaultConsistencyChecks = false;
fRequireStandard = false;
m_is_test_chain = true;
m_is_mockable_chain = false;
checkpointData = {
{
{ 546, uint256S("0x08fa50178f4b4f9fe1bbaed3b0a2ee58d1c51cc8185f70c8089e4b95763d9cdb")},
}
};
m_assumeutxo_data = MapAssumeutxo{
// TODO to be specified in a future patch.
};
chainTxData = ChainTxData{
// Data from RPC: getchaintxstats 172800 048c8a5a82d702e029633a8a2cec681f614f7beebb1e62a6c2f9d980d1215993
/* nTime */ 1691854789,
/* nTxCount */ 2676308,
/* dTxRate */ 0.02783886417253829,
};
}
};
/**
* Signet: test network with an additional consensus parameter (see BIP325).
*/
class SigNetParams : public CChainParams {
public:
explicit SigNetParams(const ArgsManager& args) {
std::vector<uint8_t> bin;
vSeeds.clear();
if (!args.IsArgSet("-signetchallenge")) {
bin = ParseHex("512103ad5e0edad18cb1f0fc0d28a3d4f1f3e445640337489abb10404f2d1e086be430210359ef5021964fe22d6f8e05b2463c9540ce96883fe3b278760f048f5189f2e6c452ae");
vSeeds.emplace_back("178.128.221.177");
vSeeds.emplace_back("2a01:7c8:d005:390::5");
vSeeds.emplace_back("v7ajjeirttkbnt32wpy3c6w3emwnfr3fkla7hpxcfokr3ysd3kqtzmqd.onion:38333");
consensus.nMinimumChainWork = uint256S("0x0000000000000000000000000000000000000000000000000000008546553c03");
consensus.defaultAssumeValid = uint256S("0x000000187d4440e5bff91488b700a140441e089a8aaea707414982460edbfe54"); // 47200
m_assumed_blockchain_size = 1;
m_assumed_chain_state_size = 0;
chainTxData = ChainTxData{
// Data from RPC: getchaintxstats 4096 000000187d4440e5bff91488b700a140441e089a8aaea707414982460edbfe54
/* nTime */ 1626696658,
/* nTxCount */ 387761,
/* dTxRate */ 0.04035946932424404,
};
} else {
const auto signet_challenge = args.GetArgs("-signetchallenge");
if (signet_challenge.size() != 1) {
throw std::runtime_error(strprintf("%s: -signetchallenge cannot be multiple values.", __func__));
}
bin = ParseHex(signet_challenge[0]);
consensus.nMinimumChainWork = uint256{};
consensus.defaultAssumeValid = uint256{};
m_assumed_blockchain_size = 0;
m_assumed_chain_state_size = 0;
chainTxData = ChainTxData{
0,
0,
0,
};
LogPrintf("Signet with challenge %s\n", signet_challenge[0]);
}
if (args.IsArgSet("-signetseednode")) {
vSeeds = args.GetArgs("-signetseednode");
}
strNetworkID = CBaseChainParams::SIGNET;
consensus.signet_blocks = true;
consensus.signet_challenge.assign(bin.begin(), bin.end());
consensus.nSubsidyHalvingInterval = 210000;
consensus.BIP16Exception = uint256{};
consensus.BIP34Height = 1;
consensus.BIP34Hash = uint256{};
consensus.BIP65Height = 1;
consensus.BIP66Height = 1;
consensus.CSVHeight = 1;
consensus.SegwitHeight = 1;
consensus.ReserveAlgoBitsHeight = 1;
consensus.OdoHeight = 1;
consensus.nPowTargetTimespan = 14 * 24 * 60 * 60; // two weeks
consensus.nPowTargetSpacing = 10 * 60;
consensus.fPowAllowMinDifficultyBlocks = false;
consensus.fEasyPow = false;
consensus.fPowNoRetargeting = false;
consensus.nRuleChangeActivationThreshold = 1815; // 90% of 2016
consensus.nMinerConfirmationWindow = 2016; // nPowTargetTimespan / nPowTargetSpacing
consensus.fRbfEnabled = false;
consensus.MinBIP9WarningHeight = 0;
consensus.initialTarget[ALGO_ODO] = ArithToUint256(~arith_uint256(0) >> 38); // 4 difficulty
consensus.powLimit = uint256S("00000377ae000000000000000000000000000000000000000000000000000000");
consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].bit = 27;
consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].nStartTime = Consensus::BIP9Deployment::NEVER_ACTIVE;
consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].nTimeout = Consensus::BIP9Deployment::NO_TIMEOUT;
consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].min_activation_height = 0; // No activation delay
// Activation of Taproot (BIPs 340-342)
consensus.vDeployments[Consensus::DEPLOYMENT_TAPROOT].bit = 2;
consensus.vDeployments[Consensus::DEPLOYMENT_TAPROOT].nStartTime = Consensus::BIP9Deployment::ALWAYS_ACTIVE;
consensus.vDeployments[Consensus::DEPLOYMENT_TAPROOT].nTimeout = Consensus::BIP9Deployment::NO_TIMEOUT;
consensus.vDeployments[Consensus::DEPLOYMENT_TAPROOT].min_activation_height = 0; // No activation delay
// message start is defined as the first 4 bytes of the sha256d of the block script
CHashWriter h(SER_DISK, 0);
h << consensus.signet_challenge;
uint256 hash = h.GetHash();
memcpy(pchMessageStart, hash.begin(), 4);
nDefaultPort = 38443;
nPruneAfterHeight = 1000;
genesis = CreateGenesisBlock(1598918400, 52613770, 0x1e0377ae, 1, 8000 * COIN);
consensus.hashGenesisBlock = genesis.GetHash();
assert(consensus.hashGenesisBlock == uint256S("9cf8c097b1afc5a37d2d050d2b423b052c2da2856acf0e41c40af1da334fcbf7"));
assert(genesis.hashMerkleRoot == uint256S("72ddd9496b004221ed0557358846d9248ecd4c440ebd28ed901efc18757d0fad"));
vFixedSeeds.clear();
base58Prefixes[PUBKEY_ADDRESS] = std::vector<unsigned char>(1,126);
base58Prefixes[SCRIPT_ADDRESS] = std::vector<unsigned char>(1,140);
base58Prefixes[SECRET_KEY] = std::vector<unsigned char>(1,254);
base58Prefixes[EXT_PUBLIC_KEY] = {0x04, 0x35, 0x87, 0xCF};
base58Prefixes[EXT_SECRET_KEY] = {0x04, 0x35, 0x83, 0x94};
bech32_hrp = "dgbt";
fDefaultConsistencyChecks = false;
fRequireStandard = true;
m_is_test_chain = true;
m_is_mockable_chain = false;
}
};
/**
* Regression test: intended for private networks only. Has minimal difficulty to ensure that
* blocks can be found instantly.
*/
class CRegTestParams : public CChainParams {
public:
explicit CRegTestParams(const ArgsManager& args) {
strNetworkID = CBaseChainParams::REGTEST;
consensus.signet_blocks = false;
consensus.signet_challenge.clear();
consensus.nSubsidyHalvingInterval = 300;
consensus.BIP16Exception = uint256();
consensus.BIP34Height = 500; // BIP34 activated on regtest (Used in functional tests)
consensus.BIP34Hash = uint256();
consensus.BIP65Height = 1351; // BIP65 activated on regtest (Used in functional tests)
consensus.BIP66Height = 1251; // BIP66 activated on regtest (Used in functional tests)
consensus.CSVHeight = 432; // CSV activated on regtest (Used in rpc activation tests)
consensus.SegwitHeight = 0; // SEGWIT is always activated on regtest unless overridden
consensus.ReserveAlgoBitsHeight = 0;
consensus.OdoHeight = 600;
consensus.MinBIP9WarningHeight = 0;
consensus.powLimit = uint256S("7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");
consensus.fPowAllowMinDifficultyBlocks = true;
consensus.fEasyPow = false; // allow easy blocks on regtest (can be set with -easypow)
consensus.nPowTargetTimespan = 14 * 24 * 60 * 60; // two weeks
consensus.nPowTargetSpacing = 60 / 4;
consensus.nTargetTimespan = 0.10 * 48 * 60 * 60; // 4.8 hours
consensus.nTargetSpacing = 60; // 60 seconds
consensus.nInterval = consensus.nTargetTimespan / consensus.nTargetSpacing;
consensus.nDiffChangeTarget = 334; // DigiShield Hard Fork Block BIP34Height 67,200
// Old 1% monthly DGB Reward before 15 secon block change
consensus.patchBlockRewardDuration = 10; //10080; - No longer used
//4 blocks per min, x60 minutes x 24hours x 14 days = 80,160 blocks for 0.5% reduction in DGB reward supply - No longer used
consensus.patchBlockRewardDuration2 = 80; //80;
consensus.nTargetTimespanRe = 1*60; // 60 Seconds
consensus.nTargetSpacingRe = 1*60; // 60 seconds
consensus.nIntervalRe = consensus.nTargetTimespanRe / consensus.nTargetSpacingRe; // 1 block
consensus.nAveragingInterval = 10; // 10 blocks
consensus.multiAlgoTargetSpacing = 30*5; // NUM_ALGOS * 30 seconds
consensus.multiAlgoTargetSpacingV4 = 15*5; // NUM_ALGOS * 15 seconds
consensus.nAveragingTargetTimespan = consensus.nAveragingInterval * consensus.multiAlgoTargetSpacing; // 10* NUM_ALGOS * 30
consensus.nAveragingTargetTimespanV4 = consensus.nAveragingInterval * consensus.multiAlgoTargetSpacingV4; // 10 * NUM_ALGOS * 15
consensus.nMaxAdjustDown = 40; // 40% adjustment down
consensus.nMaxAdjustUp = 20; // 20% adjustment up
consensus.nMaxAdjustDownV3 = 16; // 16% adjustment down
consensus.nMaxAdjustUpV3 = 8; // 8% adjustment up
consensus.nMaxAdjustDownV4 = 16;
consensus.nMaxAdjustUpV4 = 8;
consensus.nMinActualTimespan = consensus.nAveragingTargetTimespan * (100 - consensus.nMaxAdjustUp) / 100;
consensus.nMaxActualTimespan = consensus.nAveragingTargetTimespan * (100 + consensus.nMaxAdjustDown) / 100;
consensus.nMinActualTimespanV3 = consensus.nAveragingTargetTimespan * (100 - consensus.nMaxAdjustUpV3) / 100;
consensus.nMaxActualTimespanV3 = consensus.nAveragingTargetTimespan * (100 + consensus.nMaxAdjustDownV3) / 100;
consensus.nMinActualTimespanV4 = consensus.nAveragingTargetTimespanV4 * (100 - consensus.nMaxAdjustUpV4) / 100;
consensus.nMaxActualTimespanV4 = consensus.nAveragingTargetTimespanV4 * (100 + consensus.nMaxAdjustDownV4) / 100;
consensus.nLocalTargetAdjustment = 4; //target adjustment per algo
consensus.nLocalDifficultyAdjustment = 4; //difficulty adjustment per algo
consensus.BIP65Height = 1351;
consensus.BIP66Height = 1251;
// DigiByte Hard Fork Block Heights
consensus.multiAlgoDiffChangeTarget = 290; // Block 145,000 MultiAlgo Hard Fork
consensus.alwaysUpdateDiffChangeTarget = 400; // Block 400,000 MultiShield Hard Fork
consensus.workComputationChangeTarget = 1430; // Block 1,430,000 DigiSpeed Hard Fork
consensus.algoSwapChangeTarget = 2000; // Block 9,000,000 Odo PoW Hard Fork
consensus.nRuleChangeActivationThreshold = 168; // 70% of 240
consensus.nMinerConfirmationWindow = 240; // 1 hour in RegTest
consensus.fRbfEnabled = false;
consensus.nOdoShapechangeInterval = 4; // 1 minute
consensus.fPowNoRetargeting = true;
consensus.initialTarget[ALGO_ODO] = ArithToUint256(~arith_uint256(0) >> 38); // 4 difficulty
// Old 1% monthly DGB Reward before 15 secon block change
consensus.patchBlockRewardDuration = 10; //10080; - No longer used
//4 blocks per min, x60 minutes x 24hours x 14 days = 80,160 blocks for 0.5% reduction in DGB reward supply - No longer used
consensus.patchBlockRewardDuration2 = 80; //80;
consensus.nTargetTimespanRe = 1*60; // 60 Seconds
consensus.nTargetSpacingRe = 1*60; // 60 seconds
consensus.nIntervalRe = consensus.nTargetTimespanRe / consensus.nTargetSpacingRe; // 1 block
consensus.nAveragingInterval = 10; // 10 blocks
consensus.multiAlgoTargetSpacing = 30*5; // NUM_ALGOS * 30 seconds
consensus.multiAlgoTargetSpacingV4 = 15*5; // NUM_ALGOS * 15 seconds
consensus.nAveragingTargetTimespan = consensus.nAveragingInterval * consensus.multiAlgoTargetSpacing; // 10* NUM_ALGOS * 30
consensus.nAveragingTargetTimespanV4 = consensus.nAveragingInterval * consensus.multiAlgoTargetSpacingV4; // 10 * NUM_ALGOS * 15
consensus.nMaxAdjustDown = 40; // 40% adjustment down
consensus.nMaxAdjustUp = 20; // 20% adjustment up
consensus.nMaxAdjustDownV3 = 16; // 16% adjustment down
consensus.nMaxAdjustUpV3 = 8; // 8% adjustment up
consensus.nMaxAdjustDownV4 = 16;
consensus.nMaxAdjustUpV4 = 8;
consensus.nMinActualTimespan = consensus.nAveragingTargetTimespan * (100 - consensus.nMaxAdjustUp) / 100;
consensus.nMaxActualTimespan = consensus.nAveragingTargetTimespan * (100 + consensus.nMaxAdjustDown) / 100;
consensus.nMinActualTimespanV3 = consensus.nAveragingTargetTimespan * (100 - consensus.nMaxAdjustUpV3) / 100;
consensus.nMaxActualTimespanV3 = consensus.nAveragingTargetTimespan * (100 + consensus.nMaxAdjustDownV3) / 100;
consensus.nMinActualTimespanV4 = consensus.nAveragingTargetTimespanV4 * (100 - consensus.nMaxAdjustUpV4) / 100;
consensus.nMaxActualTimespanV4 = consensus.nAveragingTargetTimespanV4 * (100 + consensus.nMaxAdjustDownV4) / 100;
consensus.nLocalTargetAdjustment = 4; //target adjustment per algo
consensus.nLocalDifficultyAdjustment = 4; //difficulty adjustment per algo
consensus.BIP65Height = 1351;
consensus.BIP66Height = 1251;
consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].bit = 27;
consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].nStartTime = 0;
consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].nTimeout = Consensus::BIP9Deployment::NO_TIMEOUT;
consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].min_activation_height = 0; // No activation delay
// Activation of Taproot (BIPs 340-342)
consensus.vDeployments[Consensus::DEPLOYMENT_TAPROOT].bit = 2;
consensus.vDeployments[Consensus::DEPLOYMENT_TAPROOT].nStartTime = Consensus::BIP9Deployment::ALWAYS_ACTIVE;
consensus.vDeployments[Consensus::DEPLOYMENT_TAPROOT].nTimeout = Consensus::BIP9Deployment::NO_TIMEOUT;
consensus.vDeployments[Consensus::DEPLOYMENT_TAPROOT].min_activation_height = 0; // No activation delay
consensus.nMinimumChainWork = uint256{};
consensus.defaultAssumeValid = uint256{};
pchMessageStart[0] = 0xfa;
pchMessageStart[1] = 0xbf;
pchMessageStart[2] = 0xb5;
pchMessageStart[3] = 0xda;
nDefaultPort = 18444;
nPruneAfterHeight = args.GetBoolArg("-fastprune", false) ? 100 : 1000;
m_assumed_blockchain_size = 0;
m_assumed_chain_state_size = 0;
bech32_hrp = "dgbrt";
UpdateActivationParametersFromArgs(args);
genesis = CreateGenesisBlock(1519460922, 4, 0x207fffff, 1, 8000 * COIN);
consensus.hashGenesisBlock = genesis.GetHash();
assert(consensus.hashGenesisBlock == uint256S("0x4598a0f2b823aaf9e77ee6d5e46f1edb824191dcd48b08437b7cec17e6ae6e26"));
assert(genesis.hashMerkleRoot == uint256S("0x72ddd9496b004221ed0557358846d9248ecd4c440ebd28ed901efc18757d0fad"));
vFixedSeeds.clear(); //!< Regtest mode doesn't have any fixed seeds.
vSeeds.clear(); //!< Regtest mode doesn't have any DNS seeds.
fDefaultConsistencyChecks = true;
fRequireStandard = true;
m_is_test_chain = true;
m_is_mockable_chain = true;
checkpointData = {
{
{0, uint256S("4598a0f2b823aaf9e77ee6d5e46f1edb824191dcd48b08437b7cec17e6ae6e26")},
}
};
m_assumeutxo_data = MapAssumeutxo{
{
110,
{AssumeutxoHash{uint256S("0x58c8c65a67deee7f6cca0d5a08254b73198f13201485cb6a39dba03e5f41ee65")}, 110},
},
{
200,
{AssumeutxoHash{uint256S("0x51c8d11d8b5c1de51543c579736e786aa2736206d1e11e627568029ce092cf62")}, 200},
},
};
chainTxData = ChainTxData{
0,
0,
0
};
base58Prefixes[PUBKEY_ADDRESS] = std::vector<unsigned char>(1,126);
base58Prefixes[SCRIPT_ADDRESS] = std::vector<unsigned char>(1,140);
base58Prefixes[SECRET_KEY] = std::vector<unsigned char>(1,254);
base58Prefixes[EXT_PUBLIC_KEY] = {0x04, 0x35, 0x87, 0xCF};
base58Prefixes[EXT_SECRET_KEY] = {0x04, 0x35, 0x83, 0x94};
}
/**
* Allows modifying the Version Bits regtest parameters.
*/
void UpdateVersionBitsParameters(Consensus::DeploymentPos d, int64_t nStartTime, int64_t nTimeout, int min_activation_height)
{
consensus.vDeployments[d].nStartTime = nStartTime;
consensus.vDeployments[d].nTimeout = nTimeout;
consensus.vDeployments[d].min_activation_height = min_activation_height;
}
void UpdateActivationParametersFromArgs(const ArgsManager& args);
};
static void MaybeUpdateHeights(const ArgsManager& args, Consensus::Params& consensus)
{
for (const std::string& arg : args.GetArgs("-testactivationheight")) {
const auto found{arg.find('@')};
if (found == std::string::npos) {
throw std::runtime_error(strprintf("Invalid format (%s) for -testactivationheight=name@height.", arg));
}
const auto name{arg.substr(0, found)};
const auto value{arg.substr(found + 1)};
int32_t height;
if (!ParseInt32(value, &height) || height < 0 || height >= std::numeric_limits<int>::max()) {
throw std::runtime_error(strprintf("Invalid height value (%s) for -testactivationheight=name@height.", arg));
}
if (name == "segwit") {
consensus.SegwitHeight = int{height};
} else if (name == "bip34") {
consensus.BIP34Height = int{height};
} else if (name == "dersig") {
consensus.BIP66Height = int{height};
} else if (name == "cltv") {
consensus.BIP65Height = int{height};
} else if (name == "csv") {
consensus.CSVHeight = int{height};
} else {
throw std::runtime_error(strprintf("Invalid name (%s) for -testactivationheight=name@height.", arg));
}
}
}
// This method was added to enable easy mining on regtest networks only.
// It will postpone the activation of MultiAlgo by 999999 blocks to make sure
// it will be easy to mine blocks in regtest network.
// This method can only be applied to RegTest networks by design and is called from
// `CRegTestParams::UpdateActivationParametersFromArgs`
static void MaybeEnableEasyMining(const ArgsManager& args, Consensus::Params& consensus)
{
if (!args.IsArgSet("-easypow")) return;
consensus.fEasyPow = true;
consensus.fPowAllowMinDifficultyBlocks = true;
// // Postpone MultiAlgo Activation to the 1-millionth block
consensus.multiAlgoDiffChangeTarget = 1000000;
// Delay new difficulty retargeting algorithm.
// This will also delay have fixed subsidy as follows:
// if (nHeight < 1440) 72000 * COIN;
// if (nHeight < 5760) 16000 * COIN;
// else nSubsidy = 8000 * COIN;
consensus.nDiffChangeTarget = 1000000;
// Delay softforks
consensus.BIP34Height = 1000000;
consensus.OdoHeight = 1000000;
consensus.CSVHeight = 1000000;
}
void CRegTestParams::UpdateActivationParametersFromArgs(const ArgsManager& args)
{
MaybeEnableEasyMining(args, consensus);
MaybeUpdateHeights(args, consensus);
if (!args.IsArgSet("-vbparams")) return;
for (const std::string& strDeployment : args.GetArgs("-vbparams")) {
std::vector<std::string> vDeploymentParams;
boost::split(vDeploymentParams, strDeployment, boost::is_any_of(":"));
if (vDeploymentParams.size() < 3 || 4 < vDeploymentParams.size()) {
throw std::runtime_error("Version bits parameters malformed, expecting deployment:start:end[:min_activation_height]");
}
int64_t nStartTime, nTimeout;
int min_activation_height = 0;
if (!ParseInt64(vDeploymentParams[1], &nStartTime)) {
throw std::runtime_error(strprintf("Invalid nStartTime (%s)", vDeploymentParams[1]));
}
if (!ParseInt64(vDeploymentParams[2], &nTimeout)) {
throw std::runtime_error(strprintf("Invalid nTimeout (%s)", vDeploymentParams[2]));
}
if (vDeploymentParams.size() >= 4 && !ParseInt32(vDeploymentParams[3], &min_activation_height)) {
throw std::runtime_error(strprintf("Invalid min_activation_height (%s)", vDeploymentParams[3]));
}
bool found = false;
for (int j=0; j < (int)Consensus::MAX_VERSION_BITS_DEPLOYMENTS; ++j) {
if (vDeploymentParams[0] == VersionBitsDeploymentInfo[j].name) {
UpdateVersionBitsParameters(Consensus::DeploymentPos(j), nStartTime, nTimeout, min_activation_height);
found = true;
LogPrintf("Setting version bits activation parameters for %s to start=%ld, timeout=%ld, min_activation_height=%d\n", vDeploymentParams[0], nStartTime, nTimeout, min_activation_height);
break;
}
}
if (!found) {
throw std::runtime_error(strprintf("Invalid deployment (%s)", vDeploymentParams[0]));
}
}
}
static std::unique_ptr<const CChainParams> globalChainParams;
const CChainParams &Params() {
assert(globalChainParams);
return *globalChainParams;
}
std::unique_ptr<const CChainParams> CreateChainParams(const ArgsManager& args, const std::string& chain)
{
if (chain == CBaseChainParams::MAIN) {
return std::unique_ptr<CChainParams>(new CMainParams());
} else if (chain == CBaseChainParams::TESTNET) {
return std::unique_ptr<CChainParams>(new CTestNetParams());
} else if (chain == CBaseChainParams::SIGNET) {
return std::unique_ptr<CChainParams>(new SigNetParams(args));
} else if (chain == CBaseChainParams::REGTEST) {
return std::unique_ptr<CChainParams>(new CRegTestParams(args));
}
throw std::runtime_error(strprintf("%s: Unknown chain %s.", __func__, chain));
}
void SelectParams(const std::string& network)
{
SelectBaseParams(network);
globalChainParams = CreateChainParams(gArgs, network);
}