-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathchainparams.cpp
More file actions
357 lines (308 loc) · 16.7 KB
/
Copy pathchainparams.cpp
File metadata and controls
357 lines (308 loc) · 16.7 KB
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
// Copyright (c) 2010 Satoshi Nakamoto
// Copyright (c) 2009-2015 The Bitcoin Core developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include "chainparams.h"
#include "consensus/merkle.h"
#include "tinyformat.h"
#include "util.h"
#include "utilstrencodings.h"
#include <assert.h>
#include <boost/assign/list_of.hpp>
#include "chainparamsseeds.h"
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 = genesisReward;
txNew.vout[0].scriptPubKey = genesisOutputScript;
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
*/
extern CBlock CreateGenesisBlock(uint32_t nTime, uint32_t nNonce, uint32_t nBits, int32_t nVersion, const CAmount& genesisReward, const char* pszTimestamp="NY Times 05/Oct/2011 Steve Jobs, Apple’s Visionary, Dies at 56")
{
const CScript genesisOutputScript = CScript() << 0x0 << OP_CHECKSIG;
return CreateGenesisBlock(pszTimestamp, genesisOutputScript, nTime, nNonce, nBits, nVersion, genesisReward);
}
/**
* Main network
*/
/**
* What makes a good checkpoint block?
* + Is surrounded by blocks with reasonable timestamps
* (no blocks before with a timestamp after, none after with
* timestamp before)
* + Contains no strange transactions
*/
class CMainParams : public CChainParams {
public:
CMainParams() {
strNetworkID = "main";
consensus.BIP34Height = 0;
consensus.BIP34Hash = uint256S("");
consensus.BIP65Height = 0;
consensus.BIP66Height = 0;
consensus.powLimit = uint256S("00000fffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");
consensus.nPowTargetTimespan = 3 * 60 * 60;
consensus.nPowTargetSpacing = 3 * 60;
consensus.fPowAllowMinDifficultyBlocks = false;
consensus.fPowNoRetargeting = false;
consensus.nRuleChangeActivationThreshold = 3;
consensus.nMinerConfirmationWindow = 144;
consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].bit = 28;
consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].nStartTime = 1199145601; // January 1, 2008
consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].nTimeout = 1230767999; // December 31, 2008
// Deployment of BIP68, BIP112, and BIP113.
consensus.vDeployments[Consensus::DEPLOYMENT_CSV].bit = 0;
consensus.vDeployments[Consensus::DEPLOYMENT_CSV].nStartTime = 1485561600; // January 28, 2017
consensus.vDeployments[Consensus::DEPLOYMENT_CSV].nTimeout = 1517356801; // January 31st, 2018
// Deployment of SegWit (BIP141, BIP143, and BIP147)
consensus.vDeployments[Consensus::DEPLOYMENT_SEGWIT].bit = 1;
consensus.vDeployments[Consensus::DEPLOYMENT_SEGWIT].nStartTime = 1485561600; // January 28, 2017
consensus.vDeployments[Consensus::DEPLOYMENT_SEGWIT].nTimeout = 1517356801; // January 31st, 2018
// The best chain should have at least this much work.
consensus.nMinimumChainWork = uint256S("0x000000000000000000000000000000000000000000000006805c7318ce2736c0");
/**
* 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] = 0xfc;
pchMessageStart[1] = 0xd9;
pchMessageStart[2] = 0xb7;
pchMessageStart[3] = 0xdd;
nDefaultPort = 5884;
nPruneAfterHeight = 0;
consensus.coinFixOneBlock = 15000;
consensus.coinFixTwoBlock = 62000;
consensus.nReTargetHistoryFact = 4;
genesis = CreateGenesisBlock(1467694536, 1707074, 0x1e0ffff0, 1, 0, "Worlds Tastiest Pizza Still Undiscovered");
consensus.hashGenesisBlock = genesis.GetHash();
assert(genesis.hashMerkleRoot == uint256S("0xdabfed775df0856139f27b377eabf61b8bc5f72abc3c95540e5564ab3dbe6c60"));
assert(consensus.hashGenesisBlock == uint256S("0x21938e71a19f0053f1ea9d2c616feba7c767ade95a20946f26747ae96aaa572b"));
base58Prefixes[PUBKEY_ADDRESS] = std::vector<unsigned char>(1, 92);
base58Prefixes[SCRIPT_ADDRESS] = std::vector<unsigned char>(1, 5);
base58Prefixes[SCRIPT_ADDRESS2] = std::vector<unsigned char>(1, 5 + 5);
base58Prefixes[SECRET_KEY] = std::vector<unsigned char>(1, 220);
base58Prefixes[EXT_PUBLIC_KEY] = boost::assign::list_of(0x04)(0x88)(0xB2)(0x1E).convert_to_container<std::vector<unsigned char> >();
base58Prefixes[EXT_SECRET_KEY] = boost::assign::list_of(0x04)(0x88)(0xAD)(0xE4).convert_to_container<std::vector<unsigned char> >();
vSeeds.push_back(CDNSSeedData("142.93.40.3", "142.93.40.3"));
vSeeds.push_back(CDNSSeedData("node1.minercity.org", "node1.minercity.org"));
vSeeds.push_back(CDNSSeedData("node2.minercity.org", "node2.minercity.org"));
vFixedSeeds = std::vector<SeedSpec6>(pnSeed6_main, pnSeed6_main + ARRAYLEN(pnSeed6_main));
fMiningRequiresPeers = true;
fDefaultConsistencyChecks = false;
fRequireStandard = true;
fMineBlocksOnDemand = false;
checkpointData = (CCheckpointData) {
boost::assign::map_list_of
( 0, uint256S("0x21938e71a19f0053f1ea9d2c616feba7c767ade95a20946f26747ae96aaa572b"))
( 950521, uint256S("0x3fd8beaae900cdc6d4fe7252ed0572516f2f8e079cedb0ffe3ef577e656d6ee6"))
( 950526, uint256S("0x5c8b911f8bbbea5972d2aeaf55594b1397652475d55cd09ec3d0dba482f3000b"))
( 950534, uint256S("0xf403303c0ff512ca5693b1f4eee363443bc8ba6be25c0fb54e5a137350ad57a4"))
( 950552, uint256S("0x8986e7893a4a572324bd5f1d836be037bf65ce962570fb9bd0d42f08740ca673"))
( 950712, uint256S("0x7c5d436197fe453989f3d797bc7e247c905e9fa032aee8188daf617774024b0d"))
( 950739, uint256S("0x21f8a430dc8fc537f6a586f669e059ef164cedb46fb06209b26f750bc026d0c8"))
( 950849, uint256S("0xe4eb68d4627bf7cb4f242618133377fdc8f5cef0ce1692c3c0b51f3b0db10ceb"))
( 959135, uint256S("0xf9767b30c72249a20b7abcda654f6d435ca5f94955a240d1e3e566cedeaa39fa"))
( 959136, uint256S("0x207e225d9825e8abd76e3a494c7cfaf532cd2b138ae11a5d32c3c3162a3f8996"))
( 959137, uint256S("0x1bd73d05be14274de41b0e9a690b36394192a2b56a0f6b0a05ba4f99079ea040"))
};
chainTxData = ChainTxData{
// Data as of block b44bc5ae41d1be67227ba9ad875d7268aa86c965b1d64b47c35be6e8d5c352f4 (height 1155626).
1442662822, // * UNIX timestamp of last known number of transactions
0, // * total number of transactions between genesis and that timestamp
// (the tx=... number in the SetBestChain debug.log lines)
0.06 // * estimated number of transactions per second after that timestamp
};
}
};
static CMainParams mainParams;
/**
* Testnet (v3)
*/
class CTestNetParams : public CChainParams {
public:
CTestNetParams() {
strNetworkID = "test";
consensus.BIP34Height = 0;
consensus.BIP34Hash = uint256S("");
consensus.BIP65Height = 0;
consensus.BIP66Height = 0;
consensus.powLimit = uint256S("00000fffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");
consensus.nPowTargetTimespan = 60;
consensus.nPowTargetSpacing = 180;
consensus.fPowAllowMinDifficultyBlocks = true;
consensus.fPowNoRetargeting = false;
consensus.nRuleChangeActivationThreshold = 3;
consensus.nMinerConfirmationWindow = 4;
consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].bit = 28;
consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].nStartTime = 1;
consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].nTimeout = 2;
// Deployment of BIP68, BIP112, and BIP113.
consensus.vDeployments[Consensus::DEPLOYMENT_CSV].bit = 0;
consensus.vDeployments[Consensus::DEPLOYMENT_CSV].nStartTime = 1;
consensus.vDeployments[Consensus::DEPLOYMENT_CSV].nTimeout = 2;
// Deployment of SegWit (BIP141, BIP143, and BIP147)
consensus.vDeployments[Consensus::DEPLOYMENT_SEGWIT].bit = 1;
consensus.vDeployments[Consensus::DEPLOYMENT_SEGWIT].nStartTime = 1;
consensus.vDeployments[Consensus::DEPLOYMENT_SEGWIT].nTimeout = 2;
// The best chain should have at least this much work.
consensus.nMinimumChainWork = uint256S("0x000000000000000000000000000000000000000000000000000000054cb9e7a0");
consensus.coinFixOneBlock = 15000;
consensus.coinFixTwoBlock = 62000;
consensus.nReTargetHistoryFact = 4;
pchMessageStart[0] = 0xfc;
pchMessageStart[1] = 0xd9;
pchMessageStart[2] = 0xb7;
pchMessageStart[3] = 0xdd;
nDefaultPort = 15884;
nPruneAfterHeight = 1;
genesis = CreateGenesisBlock(1442662822, 62851, 0x1e0ffff0, 1, 0, "Worlds Tastiest Pizza Still Undiscovered");
consensus.hashGenesisBlock = genesis.GetHash();
assert(genesis.hashMerkleRoot == uint256S("0xdabfed775df0856139f27b377eabf61b8bc5f72abc3c95540e5564ab3dbe6c60"));
//assert(consensus.hashGenesisBlock == uint256S("0xfc8c2d66674b632c8a6e3b630a056094297ba92d4e4d05481df8297f0165b77c"));
vFixedSeeds.clear();
vSeeds.clear();
base58Prefixes[PUBKEY_ADDRESS] = std::vector<unsigned char>(1, 28 + 37);
base58Prefixes[SCRIPT_ADDRESS] = std::vector<unsigned char>(1, 28 + 38);
base58Prefixes[SCRIPT_ADDRESS2] = std::vector<unsigned char>(1, 38 + 32);
base58Prefixes[SECRET_KEY] = std::vector<unsigned char>(1, 28 + 165);
base58Prefixes[EXT_PUBLIC_KEY] = boost::assign::list_of(0x04)(0x35)(0x87)(0xCF).convert_to_container<std::vector<unsigned char> >();
base58Prefixes[EXT_SECRET_KEY] = boost::assign::list_of(0x04)(0x35)(0x83)(0x94).convert_to_container<std::vector<unsigned char> >();
vFixedSeeds = std::vector<SeedSpec6>(pnSeed6_test, pnSeed6_test + ARRAYLEN(pnSeed6_test));
fMiningRequiresPeers = true;
fDefaultConsistencyChecks = false;
fRequireStandard = false;
fMineBlocksOnDemand = false;
checkpointData = (CCheckpointData) {
boost::assign::map_list_of
( 0, uint256S("0xfc8c2d66674b632c8a6e3b630a056094297ba92d4e4d05481df8297f0165b77c")),
};
chainTxData = ChainTxData{
// Data as of block b44bc5ae41d1be67227ba9ad875d7268aa86c965b1d64b47c35be6e8d5c352f4 (height 1155626).
1442662822, // * UNIX timestamp of last known number of transactions
0, // * total number of transactions between genesis and that timestamp
// (the tx=... number in the SetBestChain debug.log lines)
0.06 // * estimated number of transactions per second after that timestamp
};
}
};
static CTestNetParams testNetParams;
/**
* Regression test
*/
class CRegTestParams : public CChainParams {
public:
CRegTestParams() {
strNetworkID = "regtest";
consensus.BIP34Height = 100000000; // BIP34 has not activated on regtest (far in the future so block v1 are not rejected in tests)
consensus.BIP34Hash = uint256();
consensus.BIP65Height = 1351; // BIP65 activated on regtest (Used in rpc activation tests)
consensus.BIP66Height = 1251; // BIP66 activated on regtest (Used in rpc activation tests)
consensus.powLimit = uint256S("7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");
consensus.nPowTargetTimespan = 60;
consensus.nPowTargetSpacing = 180;
consensus.fPowAllowMinDifficultyBlocks = true;
consensus.fPowNoRetargeting = true;
consensus.nRuleChangeActivationThreshold = 108; // 75% for testchains
consensus.nMinerConfirmationWindow = 144;
consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].bit = 28;
consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].nStartTime = 0;
consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].nTimeout = 999999999999ULL;
consensus.vDeployments[Consensus::DEPLOYMENT_CSV].bit = 0;
consensus.vDeployments[Consensus::DEPLOYMENT_CSV].nStartTime = 0;
consensus.vDeployments[Consensus::DEPLOYMENT_CSV].nTimeout = 999999999999ULL;
consensus.vDeployments[Consensus::DEPLOYMENT_SEGWIT].bit = 1;
consensus.vDeployments[Consensus::DEPLOYMENT_SEGWIT].nStartTime = 0;
consensus.vDeployments[Consensus::DEPLOYMENT_SEGWIT].nTimeout = 999999999999ULL;
// The best chain should have at least this much work.
consensus.nMinimumChainWork = uint256S("0x00");
consensus.coinFixOneBlock = 15000;
consensus.coinFixTwoBlock = 62000;
consensus.nReTargetHistoryFact = 4;
pchMessageStart[0] = 0xfc;
pchMessageStart[1] = 0xd9;
pchMessageStart[2] = 0xb7;
pchMessageStart[3] = 0xdd;
nDefaultPort = 25884;
nPruneAfterHeight = 1000;
genesis = CreateGenesisBlock(1442662822, 62851, 0x207fffff, 1, 0, "Worlds Tastiest Pizza Still Undiscovered");
consensus.hashGenesisBlock = genesis.GetHash();
//assert(consensus.hashGenesisBlock == uint256S("0xfc8c2d66674b632c8a6e3b630a056094297ba92d4e4d05481df8297f0165b77c"));
assert(genesis.hashMerkleRoot == uint256S("0xdabfed775df0856139f27b377eabf61b8bc5f72abc3c95540e5564ab3dbe6c60"));
vFixedSeeds.clear(); //!< Regtest mode doesn't have any fixed seeds.
vSeeds.clear(); //!< Regtest mode doesn't have any DNS seeds.
fMiningRequiresPeers = false;
fDefaultConsistencyChecks = true;
fRequireStandard = false;
fMineBlocksOnDemand = true;
checkpointData = (CCheckpointData){
boost::assign::map_list_of
( 0, uint256S("0xfc8c2d66674b632c8a6e3b630a056094297ba92d4e4d05481df8297f0165b77c"))
};
chainTxData = ChainTxData{
0,
0,
0
};
base58Prefixes[PUBKEY_ADDRESS] = std::vector<unsigned char>(1, 29 + 37);
base58Prefixes[SCRIPT_ADDRESS] = std::vector<unsigned char>(1, 29 + 38);
base58Prefixes[SCRIPT_ADDRESS2] = std::vector<unsigned char>(1, 38 + 33);
base58Prefixes[SECRET_KEY] = std::vector<unsigned char>(1, 29 + 165);
base58Prefixes[EXT_PUBLIC_KEY] = boost::assign::list_of(0x04)(0x35)(0x87)(0xCF).convert_to_container<std::vector<unsigned char> >();
base58Prefixes[EXT_SECRET_KEY] = boost::assign::list_of(0x04)(0x35)(0x83)(0x94).convert_to_container<std::vector<unsigned char> >();
}
void UpdateBIP9Parameters(Consensus::DeploymentPos d, int64_t nStartTime, int64_t nTimeout)
{
consensus.vDeployments[d].nStartTime = nStartTime;
consensus.vDeployments[d].nTimeout = nTimeout;
}
};
static CRegTestParams regTestParams;
static CChainParams *pCurrentParams = 0;
const CChainParams &Params() {
assert(pCurrentParams);
return *pCurrentParams;
}
CChainParams& Params(const std::string& chain)
{
if (chain == CBaseChainParams::MAIN)
return mainParams;
else if (chain == CBaseChainParams::TESTNET)
return testNetParams;
else if (chain == CBaseChainParams::REGTEST)
return regTestParams;
else
throw std::runtime_error(strprintf("%s: Unknown chain %s.", __func__, chain));
}
void SelectParams(const std::string& network)
{
SelectBaseParams(network);
pCurrentParams = &Params(network);
}
void UpdateRegtestBIP9Parameters(Consensus::DeploymentPos d, int64_t nStartTime, int64_t nTimeout)
{
regTestParams.UpdateBIP9Parameters(d, nStartTime, nTimeout);
}