Fabcoin Core  0.16.2
P2P Digital Currency
chainparams.cpp
Go to the documentation of this file.
1 // Copyright (c) 2010 Satoshi Nakamoto
2 // Copyright (c) 2009-2017 The Bitcoin Core developers
3 // Distributed under the MIT software license, see the accompanying
4 // file COPYING or http://www.opensource.org/licenses/mit-license.php.
5 
6 #include <chainparams.h>
7 #include <consensus/merkle.h>
8 
9 #include <tinyformat.h>
10 #include <util.h>
11 #include <utilstrencodings.h>
12 
13 // For equihash_parameters_acceptable.
14 #include <crypto/equihash.h>
15 #include <net.h>
16 #include <validation.h>
17 
18 #define equihash_parameters_acceptable(N, K) \
19  ((CBlockHeader::HEADER_SIZE + equihash_solution_size(N, K))*MAX_HEADERS_RESULTS < \
20  MAX_PROTOCOL_MESSAGE_LENGTH-1000)
21 
22 #include <assert.h>
23 #include <chainparamsseeds.h>
24 
25 static CBlock CreateGenesisBlock(const char* pszTimestamp, const CScript& genesisOutputScript, uint32_t nTime, const uint256& nNonce, const std::vector<unsigned char>& nSolution, uint32_t nBits, int32_t nVersion, const CAmount& genesisReward)
26 {
27  CMutableTransaction txNew;
28  txNew.nVersion = 1;
29  txNew.vin.resize(1);
30  txNew.vout.resize(1);
31  txNew.vin[0].scriptSig = CScript() << 00 << 520617983 << CScriptNum(4) << std::vector<unsigned char>((const unsigned char*)pszTimestamp, (const unsigned char*)pszTimestamp + strlen(pszTimestamp));
32  txNew.vout[0].nValue = genesisReward;
33  txNew.vout[0].scriptPubKey = genesisOutputScript;
34 
35  CBlock genesis;
36  genesis.nTime = nTime;
37  genesis.nBits = nBits;
38  genesis.nNonce = nNonce;
39  genesis.nSolution = nSolution;
40  genesis.nVersion = nVersion;
41  genesis.vtx.push_back(MakeTransactionRef(std::move(txNew)));
42 
43  genesis.hashPrevBlock.SetNull();
44  genesis.nHeight = 0;
45  genesis.hashMerkleRoot = BlockMerkleRoot(genesis);
46  genesis.hashStateRoot = uint256(h256Touint(dev::h256("e965ffd002cd6ad0e2dc402b8044de833e06b23127ea8c3d80aec91410771495"))); // fasc
47  genesis.hashUTXORoot = uint256(h256Touint(dev::sha3(dev::rlp("")))); // fasc
48 
49 
50  return genesis;
51 }
52 
65 static CBlock CreateGenesisBlock(uint32_t nTime, const uint256& nNonce, const std::vector<unsigned char>& nSolution, uint32_t nBits, int32_t nVersion, const CAmount& genesisReward)
66 {
67  const char* pszTimestamp = "Facebook data scandal opens new era in global privacy enforcement";
68  const CScript genesisOutputScript = CScript() << ParseHex("0322fdc78866c654c11da2fac29f47b2936f2c75a569155017893607b9386a4861") << OP_CHECKSIG;
69  return CreateGenesisBlock(pszTimestamp, genesisOutputScript, nTime, nNonce, nSolution, nBits, nVersion, genesisReward);
70 }
71 
72 
73 static CBlock CreateGenesisBlockTestnet(uint32_t nTime, const uint256& nNonce, const std::vector<unsigned char>& nSolution, uint32_t nBits, int32_t nVersion, const CAmount& genesisReward)
74 {
75  const char* pszTimestamp = "Trump fires Rex Tillerson, selects Mike Pompeo as new Secretary of State";
76  const CScript genesisOutputScript = CScript() << ParseHex("04678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc3f4cef38c4f35504e51ec112de5c384df7ba0b8d578a4c702b6bf11d5f") << OP_CHECKSIG;
77  return CreateGenesisBlock(pszTimestamp, genesisOutputScript, nTime, nNonce, nSolution, nBits, nVersion, genesisReward);
78 }
79 
80 static CBlock CreateGenesisBlock_legacy(const char* pszTimestamp, const CScript& genesisOutputScript, uint32_t nTime, uint32_t nNonce, uint32_t nBits, int32_t nVersion, const CAmount& genesisReward)
81 
82 {
83  CMutableTransaction txNew;
84  txNew.nVersion = 1;
85  txNew.vin.resize(1);
86  txNew.vout.resize(1);
87  //txNew.vin[0].scriptSig = CScript() << 486604799 << CScriptNum(4) << std::vector<unsigned char>((const unsigned char*)pszTimestamp, (const unsigned char*)pszTimestamp + strlen(pszTimestamp));
88 
89  txNew.vin[0].scriptSig = CScript() << 00 << 488804799 << CScriptNum(4) << std::vector<unsigned char>((const unsigned char*)pszTimestamp, (const unsigned char*)pszTimestamp + strlen(pszTimestamp));
90 
91  txNew.vout[0].nValue = genesisReward;
92  txNew.vout[0].scriptPubKey = genesisOutputScript;
93 
94  CBlock genesis;
95  genesis.nTime = nTime;
96  genesis.nBits = nBits;
97  genesis.nNonce = ArithToUint256(arith_uint256(nNonce));
98  genesis.nVersion = nVersion;
99  genesis.vtx.push_back(MakeTransactionRef(std::move(txNew)));
100  genesis.hashPrevBlock.SetNull();
101  genesis.nHeight = 0;
102  genesis.hashMerkleRoot = BlockMerkleRoot(genesis);
103  genesis.hashStateRoot = uint256(h256Touint(dev::h256("e965ffd002cd6ad0e2dc402b8044de833e06b23127ea8c3d80aec91410771495"))); // fasc
104  genesis.hashUTXORoot = uint256(h256Touint(dev::sha3(dev::rlp("")))); // fasc
105 
106  return genesis;
107 }
108 
109 static CBlock CreateGenesisBlock_legacy(uint32_t nTime, uint32_t nNonce, uint32_t nBits, int32_t nVersion, const CAmount& genesisReward)
110 {
111  const char* pszTimestamp = "The Times 03/Jan/2009 Chancellor on brink of second bailout for banks";
112  const CScript genesisOutputScript = CScript() << ParseHex("04678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc3f4cef38c4f35504e51ec112de5c384df7ba0b8d578a4c702b6bf11d5f") << OP_CHECKSIG;
113  return CreateGenesisBlock_legacy(pszTimestamp, genesisOutputScript, nTime, nNonce, nBits, nVersion, genesisReward);
114 }
115 
116 
117 
118 void CChainParams::UpdateVersionBitsParameters(Consensus::DeploymentPos d, int64_t nStartTime, int64_t nTimeout)
119 {
120  consensus.vDeployments[d].nStartTime = nStartTime;
121  consensus.vDeployments[d].nTimeout = nTimeout;
122 }
123 
128 const arith_uint256 maxUint = UintToArith256(uint256S("ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"));
129 
130 class CMainParams : public CChainParams {
131 public:
133  strNetworkID = "main";
134  consensus.strNetworkID = "main";
135 
137  consensus.FABHeight = 0;
138  consensus.ContractHeight = 235000;
139  consensus.EquihashFABHeight = 235000;
140  consensus.LWMAHeight = 235000;
142  consensus.BIP34Hash = uint256S("0x0001cfb309df094182806bf71c66fd4d2d986ff2a309d211db602fc9a7db1835");
143  consensus.BIP65Height = 0;
144  consensus.BIP66Height = 0;
145  consensus.CoinbaseLock = 80000;
146  consensus.ForceSegwit = true;
147 
148  consensus.powLimit = uint256S("07ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");
149  consensus.powLimitLegacy = uint256S("0003ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");
150 
151  //Digishield parameters
156 
157  //LWMA parameters
160  consensus.MaxFutureBlockTime = 20 * 60; // 20 mins
161  consensus.MaxBlockInterval = 10; // 10 T
162 
163  consensus.nPowTargetTimespan = 1.75 * 24 * 60 * 60; // 1.75 days
164  consensus.nPowTargetSpacing = 1.25 * 60; // 75 seconds
165 
168 
171 
173  consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].nStartTime = 1199145601; // January 1, 2008
174  consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].nTimeout = 1230767999; // December 31, 2008
175 
176  // Deployment of BIP68, BIP112, and BIP113.
180 
181  // Deployment of SegWit (BIP141, BIP143, and BIP147)
185  // The best chain should have at least this much work.
186  consensus.nMinimumChainWork = uint256S("0x0000000000000000000000000000000000000000000000000000000000000000"); // need change to the value of the longest chain
187 
188  // By default assume that the signatures in ancestors of this block are valid.
189  consensus.defaultAssumeValid = uint256S("0x03292eeaf1835cffc791e15b05f558adc080f85b3c54e351c1010a2699d2fc48");
190 
196  pchMessageStart[0] = 0xfa;
197  pchMessageStart[1] = 0xbe;
198  pchMessageStart[2] = 0xbf;
199  pchMessageStart[3] = 0xab;
200  nDefaultPort = 8665;
201  nPruneAfterHeight = 100000;
202 
203  const size_t N = 200, K = 9;
204  BOOST_STATIC_ASSERT(equihash_parameters_acceptable(N, K));
205  nEquihashN = N;
206  nEquihashK = K;
207 
208  // 1517433514 2018.1.31
209  genesis = CreateGenesisBlock(
210  1522249768,
211  uint256S("0x000000000000000000000000000000000000000000000000000000000000007f"),
212  ParseHex("001895e4c29529f904cf86613cdbddc709a5deb8122360c532ab93dd776a4ad816af47c4cb62ab3ba8840dc4a99373a991f1a56bb25983cab978f4bd3518671872b44ed606b884e8fa94c439f7a9a9be273c929d0116f7dd750b18474139c1d3eb2bb0d1ea467c95120d5ecf91b223f9c9d02f7306076851be1ab0bb4dd40d7a44aa45180cc2caba1302a725fc8e332df520d35f61e429bba2373398448695d43c40dad5459bbae8016aaa0a7259a4f7cd5d938a6bf3d52166c8945a3620775e1ca7cbceab00265791e6eb55db14cadb28f104113f346b8f8a53897d15a73678d8fa94421da59831a0ea3c331ed1150d3c891ed67b0a2287e0fde72d09a1dc008989428f954918932162245ad49d17a52b4c02db629d582b3ef66f77963de0780a57af3b661a0a158b1790e25395bb7a2116405564c1216eac80e7296f364edd574551ddff52e8bb198b4f3fe61c144b034a8ecd959856f3e9ad223c371655e95a08bc56be121eb9e4ab88c8598c71b2214394d02a127f14806119129eff36d2d206b199744d90ad7b966a6a7c0fdc319ca381f5964061c5b6a64ba5d6d3af09fc1871ea0fbe753e34147f32f0a0e1f9acbb5d4e8713f82c8a15432b76039a7d2fb3b511df46bfb65aa1acb63b911b5da25878e8e20d5b2ad23fcc7f04b349175ad1ff1cd46725116d2f2ded4f23dd02ba5e31258ba9868104c657133058db5ccf53f1dfdfd40d48cc6847891c070d8beb06a0835fdf161962837263eaf83e79a2c405cd4233cc964d159e0fc2aad4ed62111dfc2bd5252763d3a719b4237fcb865a56ecd2cc836cb45deb76072dafa5bfc2f6c32837251e90d34e35624258705d2fc1eede3017b3bf7f34c3597021cf69ee3ddfe70509df35aff0207bf7a9aff44d6ea3574e61ce37c3c02ff992db7f904ffb2424f43d18528f1e169875baf001e78645d1e93549fca822cce874b9bd72de14bcc908b83be8436307b56bcc37766051672f0a465fb6fd0b01cab3a3149ad19b7ab11d1968111db04c78124e57e33c73305796ccce1376b697cb9b55cd455a07cd01f5da47bf41a8e23ef8c026da68b308f5054df66a2efce3f12f4ed1354c72e6954ef09addb7b953eec90e91ce6ee4ced42339741357e859ed667bb01de632229ef738bed0434d946ba2745551cc6ca824fbd4b906843ff45be9c2a9ee8e1127405d0665c6090ee5092a46d42429e7b6696dd6937d65697edea8c9b82a9617edc717abcf5bdfb047f45a7b4ab509b06155215926855fcf825b14b51a63a322aa7556691799b672ff150f1fda6d280f35d657b257a6c04eb674779937606e24c64294a2c35d8b9738bc2d753b0b3f595f1455196c2c8ca11bd7bd86d523d5f4441656acc79a31b02db3e3936e58aa84cfe3463baf32cf09dc8839fee402f11c46091accc1786340f67d4e49c480eb99c5f218a5d31cf395f4312aaef38a26ed219df655d088200c5a51be2e55603dc04d54b68de3d2f26ac0742f6553578db6e3e4982d37297564e97af665fdd638bf0d05f4c17a4fc8d3abcf7ab329a7a553a92daf38a522383c77a2b2cfd56d6d06a89a6a575fc73ba67d342e1149dcea061564b92295c4080fe525b60a1b19ba8d442815321817a7c57cdb47767ebe3a425054d492a005d7ac6922cd615678c9c4a05b2698a61dd0fb17c1775a4e2675ac5011b762b8c3175cab6a8e8679cffb0a5a466e679126c3ce54d259d94a9cf6d2b73b99031aef95081ed2a602c008f499c3d95a1de1dd3f4aba0b5dbb6dac950f75a455b1e68d237569965a8cdd380ceaa32e8b9792f3c0df736c25382be58360f511f517ca90fbbce898a198c964b4cace26ead3d6bce7f427ddd73f6fa84c05674426404ce13daa228a563d50"),
213  0x2007ffff, 1, 25 * COIN );
215  assert(consensus.hashGenesisBlock == uint256S("0x03292eeaf1835cffc791e15b05f558adc080f85b3c54e351c1010a2699d2fc48"));
216  assert(genesis.hashMerkleRoot == uint256S("0xe89cf9aeaa7b90a0c6695946bf23a41447c4ade44a63e6fa40481e35957e69aa"));
217 
218  // Note that of those with the service bits flag, most only support a subset of possible options
219  vSeeds.emplace_back("dnsseed.fabnetwork.info", true); // only supports x1, x5, x9, and xd
220  vSeeds.emplace_back("dnsseed.fabcoin.club", true); // only supports x1, x5, x9, and xd
221  vSeeds.emplace_back("dnsseed1.fabcoin.club", true); // only supports x1, x5, x9, and xd
222  vSeeds.emplace_back("dnsseed.fabcoin.biz", true); // only supports x1, x5, x9, and xd
223 
224  vFixedSeeds = std::vector<SeedSpec6>(pnSeed6_main, pnSeed6_main + ARRAYLEN(pnSeed6_main));
225 
226  base58Prefixes[PUBKEY_ADDRESS] = std::vector<unsigned char>(1,0);
227  base58Prefixes[SCRIPT_ADDRESS] = std::vector<unsigned char>(1,5);
228  base58Prefixes[SECRET_KEY] = std::vector<unsigned char>(1,128);
229  base58Prefixes[EXT_PUBLIC_KEY] = {0x04, 0x88, 0xB2, 0x1E};
230  base58Prefixes[EXT_SECRET_KEY] = {0x04, 0x88, 0xAD, 0xE4};
231 
232  fMiningRequiresPeers = true;
234  fRequireStandard = true;
235  fMineBlocksOnDemand = false;
236 
238  {
239  { 0, uint256S("0x03292eeaf1835cffc791e15b05f558adc080f85b3c54e351c1010a2699d2fc48")},
240  { 1388, uint256S("0x000048a31f2269d3dbc2a9c70d39eeeb155f435f00f65a0681cedc558f05ecd2")},
241  { 1398, uint256S("0x00017f30bd3c67005fb37d7c9c3d31df571699710126ae23137bddaee9d4ae70")},
242  }
243  };
244 
246  0,
247  0,
248  0
249  };
250  }
251 };
252 
256 class CTestNetParams : public CChainParams {
257 public:
259 
260  strNetworkID = "test";
261  consensus.strNetworkID = "test";
262 
264  consensus.FABHeight = 0;
265  consensus.ContractHeight = 192430 ;
266  consensus.EquihashFABHeight = 221370;
267  consensus.LWMAHeight = 221370;
269  consensus.BIP34Hash = uint256S("0x0001cfb309df094182806bf71c66fd4d2d986ff2a309d211db602fc9a7db1835");
270  consensus.BIP65Height = 0;
271  consensus.BIP66Height = 0;
273  consensus.ForceSegwit = false;
274 
275  consensus.powLimit = uint256S("07ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");
276  consensus.powLimitLegacy = uint256S("0003ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");
277 
278  //Digishield parameters
283 
284  //LWMA parameters
287  consensus.MaxFutureBlockTime = 20 * 60; // 20 mins
288  consensus.MaxBlockInterval = 10; // 10 T
289 
290  consensus.nPowTargetTimespan = 1.75 * 24 * 60 * 60; // 1.75 days, for SHA256 mining only
291  consensus.nPowTargetSpacing = 1.25 * 60; // 75 seconds
292 
295  consensus.nRuleChangeActivationThreshold = 1512; // 75% for testchains
296  consensus.nMinerConfirmationWindow = 2016; // nPowTargetTimespan / nPowTargetSpacing
298  consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].nStartTime = 1199145601; // January 1, 2008
299  consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].nTimeout = 1230767999; // December 31, 2008
300 
301 
302  // Deployment of BIP68, BIP112, and BIP113.
306 
307  // Deployment of SegWit (BIP141, BIP143, and BIP147)
311 
312  // The best chain should have at least this much work.
314 
315  // By default assume that the signatures in ancestors of this block are valid.
316  consensus.defaultAssumeValid = uint256S("0x0500238931fa06c38381611e9244d9523926d6dc501664de27d1bff4e22b9afa");
317 
318  //pchMessageStart[0] = 0x0b;
319  //pchMessageStart[1] = 0x11;
320  //pchMessageStart[2] = 0x09;
321  //pchMessageStart[3] = 0x07;
322  pchMessageStart[0] = 0x0f;
323  pchMessageStart[1] = 0x11;
324  pchMessageStart[2] = 0x0a;
325  pchMessageStart[3] = 0x0b;
326  nDefaultPort = 18665;
327  nPruneAfterHeight = 1000;
328 
329  const size_t N = 200, K = 9;
330  BOOST_STATIC_ASSERT(equihash_parameters_acceptable(N, K));
331  nEquihashN = N;
332  nEquihashK = K;
333 
334  // 1517433514 2018.1.31
335  genesis = CreateGenesisBlockTestnet(
336  1521040319,
337  uint256S("0x0000000000000000000000000000000000000000000000000000000000000060"),
338  ParseHex("009251b3fd34dca9ffe4c81443cd04fe0f0ad2560e258fd3c26174f5afd75c5320d5a47789cbdc141c820aabed9e8ba58a0d61935596edf756b6e15bb98f40269811c6859070075c08f3e15fcbb732ef27fe1c08060a0e584aaa94b35fc3c06e732ebe88e37e913a171278bd615f1ad084dc9e37ed825dd8d7c2539e4dbc06fb37d58686855edd1a71adbcf2c1e1b64015fd02313d46a18df05b7dcface3218c1fd70cf06f73dbf104f1c3da795fc099ab50822d5f680a03cf3a1f41ac09f8cb21de2230256abcf498394ccf3e37b516ccdc0dbbaeb383a6334f417e91a426e818d8c4063ac67b1c972c65bbd6f067e11e01ceff65e2d9c4359de5480f1ac0ce5ccc8acbb6ad93b140443ffd95b7960aca2e12b60d998f53bd405484c815b5beb946704dad001de4436136142b4bd2c5223be9c46741a6b41178301e93239a8b206d37a569c3970f3bf83e38103822f500fbacceda20b3a7920860c6fba7cf4de457f77bc320837eef38257b938d52c71af0639ef65ac77b614c198b3c2886ebc13d7b45f26064fd6738ceb5fd66173a423c5c118f7b3d5fe635f5e2fcc1727a1cdda4e2052af2cf82c8979b40e0c330f26939cde6fd7ce30a1a6ceaa47d1fb86fef604827c74e2542db203eee842d832a68afe7fd93e02223a2dbcc39aa1cfb1ad14e6476f65c0ff6947fe48e873bbce66a7e996a5d96d001311995b151895d269027026cec61dbe3527fcfaa47d2f50924531ca975e59a0e0b66bbef43039fe8c30897fa11d68f0103ab7af49f287b38e2c487fa65580d0875e82ee10489a52e79eb4a60033e8c6c58c1b003570da4a2ccdca4f95a53f9cf5051b59963134bc12220e1804251eff3fcdf83a058fab0d9df72d1d80307d59940b804f7afbde2a0e657a9b886e79b7e45da157085f5335684a70a6265dcd1d55bafa2361e430a03168b8ddf91714341c3023ebd4c241d75af6ef9be0544a3d2879e2ced8ddfc25c94ca8734f6d914f18e1bbc145494913e5105efc2f908df66fd404f3dda0c1cc7ee21fa1088437ba201e32934b296236cb9d476094540d0ba6bb493693d10a110cc04a79c42dfb5e9177307f9061b0fc3e6fcc8c8b0c82e0a7e12f5683d215ed70c7b5c0755baf5658615c64615bde033f8343173af54ee2255a39f2be85716e086bf64ce9f25d403b729336450b7553b3076fbdd434cfded797d429e042c3d913ec5e95582de70c5eb5483850e594ba4462c8de198ef551a6753c503f67d21dc391032118547307b4ee6b158e244ef84b39e2ddd2fbd2d0f0d7ee51536cff189d817ab07d7b34396e5dbe4f4cd0eca6c24bf1f16aacd9338bf6b42ac0d7f7969d97f9184382daab32450b3dda9c2a8653114e2423687753ea7702e866775f2a00db9422bf7552f4c515f3456ff8de30451110943c74f9f482c66278ed9c019a7d7cfa66c2b2eb5cd1f78664bdc8433b1dc378dfd51762dbc76144fcc92e096f26abefa01f267fc9f46c0691af32e18ba10cc49ad6ec39e1f6451a5b47755a226ee05450fe3b898728c2282ee6581c0f0f041da976097e0df1511ac376fdebdefa75c5271216d80317c8431738114ad59324b5e6101e77a1203ea2b5364eebcecd998213dbb6baa1b6dc9bd8f035717e54a91c9e9f512f2079834f471adfca5c8e903a296b4968e7523dbcafa671fe42e7eaab9477f43f8d0b67ef93abd461966061cc2b32c0e0a352f030d15004c31ce6dd2ebb0e0f6273d093d39a6d199fbcdb41647a536662b1376bedc1018bad9be86f72ed461c1b952765055378b69d22132c36ab3e6a75e5f697483faa47a10357f5a4dee561033b740b0c5d0a26653b596c7d094c6db5ed742861458c4ce6acb32ec8167b58460dd52e6abfbdcbcd2"),
339  0x2007ffff, 1, 25 * COIN );
340 
342  assert(consensus.hashGenesisBlock == uint256S("0x0500238931fa06c38381611e9244d9523926d6dc501664de27d1bff4e22b9afa"));
343  assert(genesis.hashMerkleRoot == uint256S("0x3725088af50d5bfa636f5c051887e35b4a117a7c2a46944897e6e91efbe24eb5"));
344 
345  // nodes with support for servicebits filtering should be at the top
346  vSeeds.emplace_back("testnet-seed.fabnetwork.info", true);
347 
348  vFixedSeeds = std::vector<SeedSpec6>(pnSeed6_test, pnSeed6_test + ARRAYLEN(pnSeed6_test));
349 
350  base58Prefixes[PUBKEY_ADDRESS] = std::vector<unsigned char>(1,111);
351  base58Prefixes[SCRIPT_ADDRESS] = std::vector<unsigned char>(1,196);
352  base58Prefixes[SECRET_KEY] = std::vector<unsigned char>(1,239);
353  base58Prefixes[EXT_PUBLIC_KEY] = {0x04, 0x35, 0x87, 0xCF};
354  base58Prefixes[EXT_SECRET_KEY] = {0x04, 0x35, 0x83, 0x94};
355 
356 
357  fMiningRequiresPeers = true;
359  fRequireStandard = false;
360  fMineBlocksOnDemand = false;
361 
363  {
364  {0, uint256S("0x0500238931fa06c38381611e9244d9523926d6dc501664de27d1bff4e22b9afa")},
365  }
366  };
367 
369  0,
370  0,
371  0
372  };
373 
374  }
375 };
376 
380 class CRegTestParams : public CChainParams {
381 public:
383  strNetworkID = "regtest";
384  consensus.strNetworkID = "regtest";
386  consensus.nRuleChangeActivationThreshold = 108; // 75% for testchains
387  consensus.nMinerConfirmationWindow = 144; // Faster than normal for regtest (144 instead of 2016)
388 
389  consensus.BIP34Height = 0; // BIP34 has not activated on regtest (far in the future so block v1 are not rejected in tests) // activate for fabcoin
390  consensus.BIP34Hash = uint256S("0x0e28ba5df35c1ac0893b7d37db241a6f4afac5498da89369067427dc369f9df3");
391  consensus.BIP65Height = 0; // BIP65 activated on regtest (Used in rpc activation tests)
392  consensus.BIP66Height = 0; // BIP66 activated on regtest (Used in rpc activation tests)
393  consensus.powLimit = uint256S("7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");
394 
395  consensus.FABHeight = 1000000;
398  consensus.LWMAHeight = 100;
400  consensus.ForceSegwit = false;
401 
402  //Digishield parameters
406 
407  //LWMA parameters
410  consensus.MaxFutureBlockTime = 20 * 60; // 20 mins
411  consensus.MaxBlockInterval = 10; // 10 T
412 
413  consensus.nPowTargetTimespan = 1.75 * 24 * 60 * 60; // 1.75 days
414  consensus.nPowTargetSpacing = 1.25 * 60; // 75 seconds
415  consensus.powLimit = uint256S("7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");
416  consensus.powLimitLegacy = uint256S("7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");
419 
429 
430  // The best chain should have at least this much work.
432 
433  // By default assume that the signatures in ancestors of this block are valid.
434  consensus.defaultAssumeValid = uint256S("0x0e28ba5df35c1ac0893b7d37db241a6f4afac5498da89369067427dc369f9df3");
435 
436  pchMessageStart[0] = 0xfa;
437  pchMessageStart[1] = 0xbf;
438  pchMessageStart[2] = 0xb5;
439  pchMessageStart[3] = 0xda;
440  nDefaultPort = 38665;
441  nPruneAfterHeight = 1000;
442 
443  const size_t N = 48, K = 5;
444  BOOST_STATIC_ASSERT(equihash_parameters_acceptable(N, K));
445  nEquihashN = N;
446  nEquihashK = K;
447 
448 /*
449 for (int i=0;i<20;i++) {
450  genesis = CreateGenesisBlock_legacy(1296688602, i, 0x207fffff, 5, 50 * COIN);
451  consensus.hashGenesisBlock = genesis.GetHash(consensus);
452  std::cout << consensus.hashGenesisBlock.GetHex() << std::endl;
453 }
454 */
455 
456  genesis = CreateGenesisBlock_legacy(1296688602, 12, 0x207fffff, 5, 50 * COIN);
458  assert(consensus.hashGenesisBlock == uint256S("0x0e28ba5df35c1ac0893b7d37db241a6f4afac5498da89369067427dc369f9df3"));
459  assert(genesis.hashMerkleRoot == uint256S("0x487e51f691fd29b1ee5c7fc3341eb4f91b86f4a8eace12d259f89f70af558ee1"));
460 
461  vFixedSeeds.clear();
462  vSeeds.clear();
463 
464  base58Prefixes[PUBKEY_ADDRESS] = std::vector<unsigned char>(1,111);
465  base58Prefixes[SCRIPT_ADDRESS] = std::vector<unsigned char>(1,196);
466  base58Prefixes[SECRET_KEY] = std::vector<unsigned char>(1,239);
467  base58Prefixes[EXT_PUBLIC_KEY] = {0x04, 0x35, 0x87, 0xCF};
468  base58Prefixes[EXT_SECRET_KEY] = {0x04, 0x35, 0x83, 0x94};
469 
470  fMiningRequiresPeers = false;
472  fRequireStandard = false;
473  fMineBlocksOnDemand = true;
474 
476  {
477  {0, uint256S("0e28ba5df35c1ac0893b7d37db241a6f4afac5498da89369067427dc369f9df3")},
478 
479  }
480  };
481 
483  0,
484  0,
485  0
486  };
487 
488  }
489 };
490 
495 {
496 public:
498  {
499  strNetworkID = "unittest";
500  consensus.strNetworkID = "unittest";
501 
502  // Activate the the BIPs for regtest as in Fabcoin
504  consensus.nRuleChangeActivationThreshold = 633; // 258 75% for testchains
505  consensus.nMinerConfirmationWindow = 844; // Faster than normal for regtest (144 instead of 2016)
506 
507  consensus.BIP34Height = 100000000; // BIP34 has not activated on regtest (far in the future so block v1 are not rejected in tests)
509  consensus.BIP65Height = 1351; // BIP65 activated on regtest (Used in rpc activation tests)
510  consensus.BIP66Height = 1251; // BIP66 activated on regtest (Used in rpc activation tests)
511  consensus.FABHeight = 24000;
513  consensus.ForceSegwit = false;
514  }
515 };
516 
517 
518 static std::unique_ptr<CChainParams> globalChainParams;
519 
521  assert(globalChainParams);
522  return *globalChainParams;
523 }
524 
526  assert(globalChainParams);
527  return *globalChainParams;
528 }
529 
530 std::unique_ptr<CChainParams> CreateChainParams(const std::string& chain)
531 {
532  if (chain == CBaseChainParams::MAIN)
533  return std::unique_ptr<CChainParams>(new CMainParams());
534  else if (chain == CBaseChainParams::TESTNET)
535  return std::unique_ptr<CChainParams>(new CTestNetParams());
536  else if (chain == CBaseChainParams::REGTEST)
537  return std::unique_ptr<CChainParams>(new CRegTestParams());
538  else if (chain == CBaseChainParams::UNITTEST)
539  return std::unique_ptr<CChainParams>(new CUnitTestParams());
540 
541  throw std::runtime_error(strprintf("%s: Unknown chain %s.", __func__, chain));
542 }
543 
544 void SelectParams(const std::string& network)
545 {
546  SelectBaseParams(network);
547  globalChainParams = CreateChainParams(network);
548 }
549 
550 void UpdateVersionBitsParameters(Consensus::DeploymentPos d, int64_t nStartTime, int64_t nTimeout)
551 {
552  globalChainParams->UpdateVersionBitsParameters(d, nStartTime, nTimeout);
553 }
bool fMineBlocksOnDemand
Definition: chainparams.h:102
uint256 BIP34Hash
Definition: params.h:46
int nDefaultPort
Definition: chainparams.h:90
void SetNull()
Definition: uint256.h:46
void UpdateVersionBitsParameters(Consensus::DeploymentPos d, int64_t nStartTime, int64_t nTimeout)
uint256 nNonce
Definition: block.h:53
int64_t nPowTargetTimespan
Definition: params.h:81
bool fPowNoRetargeting
Definition: params.h:80
static const std::string REGTEST
bytes rlp(_T _t)
Export a single item in RLP format, returning a byte array.
Definition: RLP.h:467
Definition: block.h:155
bool ForceSegwit
whether segwit is active
Definition: params.h:64
#define strprintf
Definition: tinyformat.h:1054
std::vector< CTxIn > vin
Definition: transaction.h:392
std::vector< unsigned char > base58Prefixes[MAX_BASE58_TYPES]
Definition: chainparams.h:95
static const std::string UNITTEST
uint32_t nHeight
Definition: block.h:46
bool bZawyLwmaSolvetimeLimitation
Definition: params.h:92
bool fPowAllowMinDifficultyBlocks
Definition: params.h:79
int BIP66Height
Block height at which BIP66 becomes active.
Definition: params.h:50
assert(len-trim+(2 *lenIndices)<=WIDTH)
CChainParams defines various tweakable parameters of a given instance of the Fabcoin system...
Definition: chainparams.h:47
int64_t nDigishieldPowMaxAdjustDown
Definition: params.h:97
CBlock genesis
Definition: chainparams.h:97
uint32_t nTime
Definition: block.h:48
uint32_t FABHeight
Block height at which Fabcoin Equihash hard fork becomes active.
Definition: params.h:52
CMessageHeader::MessageStartChars pchMessageStart
Definition: chainparams.h:89
arith_uint256 UintToArith256(const uint256 &a)
ChainTxData chainTxData
Definition: chainparams.h:104
static const std::string MAIN
BIP70 chain name strings (main, test or regtest)
int nSubsidyHalvingInterval
Definition: params.h:43
int64_t CAmount
Amount in lius (Can be negative)
Definition: amount.h:15
const CChainParams & GetParams()
uint256 powLimit
Proof of work parameters.
Definition: params.h:75
uint256 hashMerkleRoot
Definition: block.h:45
std::unique_ptr< CChainParams > CreateChainParams(const std::string &chain)
Creates and returns a std::unique_ptr<CChainParams> of the chosen chain.
DeploymentPos
Definition: params.h:15
bool fRequireStandard
Definition: chainparams.h:101
void SelectParams(const std::string &network)
Sets the params returned by Params() to those for the given BIP70 chain name.
int BIP34Height
Block height and hash at which BIP34 becomes active.
Definition: params.h:45
int CoinbaseLock
Block height before which the coinbase subsidy will be locked for the same period.
Definition: params.h:62
uint256 uint256S(const char *str)
Definition: uint256.h:153
int64_t nStartTime
Start MedianTime for version bits miner confirmation.
Definition: params.h:31
Regression test.
int64_t nPowTargetSpacing
Definition: params.h:82
uint32_t ContractHeight
Block height at which Fabcoin Smart Contract hard fork becomes active.
Definition: params.h:56
uint256 hashPrevBlock
Definition: block.h:44
int64_t nDigishieldPowAveragingWindow
Definition: params.h:96
unsigned int nEquihashK
Definition: chainparams.h:93
uint256 BlockMerkleRoot(const CBlock &block, bool *mutated)
Definition: merkle.cpp:158
uint32_t nMinerConfirmationWindow
Definition: params.h:71
std::vector< unsigned char > nSolution
Definition: block.h:54
std::vector< CTxOut > vout
Definition: transaction.h:393
256-bit unsigned big integer.
std::vector< CDNSSeedData > vSeeds
Definition: chainparams.h:94
const arith_uint256 maxUint
Main network.
uint8_t MaxBlockInterval
Definition: params.h:93
int BIP65Height
Block height at which BIP65 becomes active.
Definition: params.h:48
std::string strNetworkID
Definition: params.h:40
Testnet (v3)
int64_t nTimeout
Timeout/expiry MedianTime for the deployment attempt.
Definition: params.h:33
256-bit opaque blob.
Definition: uint256.h:132
uint256 nMinimumChainWork
Definition: params.h:85
uint256 ArithToUint256(const arith_uint256 &a)
std::vector< CTransactionRef > vtx
Definition: block.h:159
uint256 GetHash() const
Definition: block.cpp:38
std::vector< SeedSpec6 > vFixedSeeds
Definition: chainparams.h:98
Regression network parameters overwrites for unit testing.
#define ARRAYLEN(array)
uint256 defaultAssumeValid
Definition: params.h:86
const CChainParams & Params()
Return the currently selected parameters.
Serialized script, used inside transaction inputs and outputs.
Definition: script.h:417
int64_t MaxFutureBlockTime
Limit BITCOIN_MAX_FUTURE_BLOCK_TIME.
Definition: params.h:60
#define equihash_parameters_acceptable(N, K)
Definition: chainparams.cpp:18
Consensus::Params consensus
Definition: chainparams.h:88
bool sha3(bytesConstRef _input, bytesRef o_output)
Calculate SHA3-256 hash of the given input and load it into the given output.
Definition: SHA3.cpp:214
std::string strNetworkID
Definition: chainparams.h:96
bool fMiningRequiresPeers
Definition: chainparams.h:99
uint32_t EquihashFABHeight
Block height at which EquihashFAB (184,7) becomes active.
Definition: params.h:58
uint256 powLimitLegacy
Definition: params.h:76
static const std::string TESTNET
A mutable version of CTransaction.
Definition: transaction.h:390
uint256 hashStateRoot
Definition: block.h:50
uint32_t nRuleChangeActivationThreshold
Minimum blocks including miner confirmation of the total of 2016 blocks in a retargeting period...
Definition: params.h:70
uint64_t nPruneAfterHeight
Definition: chainparams.h:91
#define d(i)
Definition: sha.cpp:732
int64_t nDigishieldPowMaxAdjustUp
Definition: params.h:98
int bit
Bit position to select the particular bit in nVersion.
Definition: params.h:29
CCheckpointData checkpointData
Definition: chainparams.h:103
void SelectBaseParams(const std::string &chain)
Sets the params returned by Params() to those for the given network.
uint256 hashUTXORoot
Definition: block.h:51
int32_t nVersion
Definition: block.h:43
uint256 hashGenesisBlock
Definition: params.h:42
bool fDefaultConsistencyChecks
Definition: chainparams.h:100
uint256 h256Touint(const dev::h256 &in)
Definition: uint256.h:178
BIP9Deployment vDeployments[MAX_VERSION_BITS_DEPLOYMENTS]
Definition: params.h:72
uint32_t LWMAHeight
Block height at which LWMA becomes active.
Definition: params.h:54
unsigned int nEquihashN
Definition: chainparams.h:92
uint32_t nBits
Definition: block.h:49
std::vector< unsigned char > ParseHex(const char *psz)
int64_t nZawyLwmaAveragingWindow
Definition: params.h:91