]>
Commit | Line | Data |
---|---|---|
0e4b3175 | 1 | // Copyright (c) 2010 Satoshi Nakamoto |
57702541 | 2 | // Copyright (c) 2009-2014 The Bitcoin developers |
0e4b3175 MH |
3 | // Distributed under the MIT/X11 software license, see the accompanying |
4 | // file COPYING or http://www.opensource.org/licenses/mit-license.php. | |
5 | ||
0e4b3175 | 6 | #include "chainparams.h" |
51ed9ec9 | 7 | |
6354935c | 8 | #include "random.h" |
0e4b3175 MH |
9 | #include "util.h" |
10 | ||
187115c0 PK |
11 | #include <assert.h> |
12 | ||
8388289e PW |
13 | #include <boost/assign/list_of.hpp> |
14 | ||
09eb201b | 15 | using namespace std; |
8388289e PW |
16 | using namespace boost::assign; |
17 | ||
a60120e9 WL |
18 | struct SeedSpec6 { |
19 | uint8_t addr[16]; | |
20 | uint16_t port; | |
21 | }; | |
22 | ||
23 | #include "chainparamsseeds.h" | |
24 | ||
0e4b3175 MH |
25 | // |
26 | // Main network | |
27 | // | |
28 | ||
a60120e9 WL |
29 | // Convert the pnSeeds6 array into usable address objects. |
30 | static void convertSeed6(std::vector<CAddress> &vSeedsOut, const SeedSpec6 *data, unsigned int count) | |
0e4b3175 | 31 | { |
a60120e9 WL |
32 | // It'll only connect to one or two seed nodes because once it connects, |
33 | // it'll get a pile of addresses with newer timestamps. | |
34 | // Seed nodes are given a random 'last seen time' of between one and two | |
35 | // weeks ago. | |
36 | const int64_t nOneWeek = 7*24*60*60; | |
37 | for (unsigned int i = 0; i < count; i++) | |
38 | { | |
39 | struct in6_addr ip; | |
40 | memcpy(&ip, data[i].addr, sizeof(ip)); | |
41 | CAddress addr(CService(ip, data[i].port)); | |
42 | addr.nTime = GetTime() - GetRand(nOneWeek) - nOneWeek; | |
43 | vSeedsOut.push_back(addr); | |
44 | } | |
45 | } | |
0e4b3175 MH |
46 | |
47 | class CMainParams : public CChainParams { | |
48 | public: | |
49 | CMainParams() { | |
84ce18ca | 50 | networkID = CBaseChainParams::MAIN; |
f5ae6c98 | 51 | strNetworkID = "main"; |
0e4b3175 MH |
52 | // The message start string is designed to be unlikely to occur in normal data. |
53 | // The characters are rarely used upper ASCII, not valid as UTF-8, and produce | |
54 | // a large 4-byte int at any alignment. | |
55 | pchMessageStart[0] = 0xf9; | |
56 | pchMessageStart[1] = 0xbe; | |
57 | pchMessageStart[2] = 0xb4; | |
58 | pchMessageStart[3] = 0xd9; | |
59 | vAlertPubKey = ParseHex("04fc9702847840aaf195de8442ebecedf5b095cdbb9bc716bda9110971b28a49e0ead8564ff0db22209e0374782c093bb899692d524e9d6a6956e7c5ecbcd68284"); | |
60 | nDefaultPort = 8333; | |
df9eb5e1 | 61 | bnProofOfWorkLimit = ~uint256(0) >> 32; |
0e4b3175 | 62 | nSubsidyHalvingInterval = 210000; |
d754f34e | 63 | nEnforceBlockUpgradeMajority = 750; |
64 | nRejectBlockOutdatedMajority = 950; | |
65 | nToCheckBlockUpgradeMajority = 1000; | |
2595b9ac | 66 | nMinerThreads = 0; |
fd704c7b | 67 | nTargetTimespan = 14 * 24 * 60 * 60; // two weeks |
68 | nTargetSpacing = 10 * 60; | |
0e4b3175 MH |
69 | |
70 | // Build the genesis block. Note that the output of the genesis coinbase cannot | |
71 | // be spent as it did not originally exist in the database. | |
72 | // | |
73 | // CBlock(hash=000000000019d6, ver=1, hashPrevBlock=00000000000000, hashMerkleRoot=4a5e1e, nTime=1231006505, nBits=1d00ffff, nNonce=2083236893, vtx=1) | |
74 | // CTransaction(hash=4a5e1e, ver=1, vin.size=1, vout.size=1, nLockTime=0) | |
75 | // CTxIn(COutPoint(000000, -1), coinbase 04ffff001d0104455468652054696d65732030332f4a616e2f32303039204368616e63656c6c6f72206f6e206272696e6b206f66207365636f6e64206261696c6f757420666f722062616e6b73) | |
76 | // CTxOut(nValue=50.00000000, scriptPubKey=0x5F1DF16B2B704C8A578D0B) | |
77 | // vMerkleTree: 4a5e1e | |
78 | const char* pszTimestamp = "The Times 03/Jan/2009 Chancellor on brink of second bailout for banks"; | |
4949004d | 79 | CMutableTransaction txNew; |
0e4b3175 MH |
80 | txNew.vin.resize(1); |
81 | txNew.vout.resize(1); | |
4f497cd9 | 82 | txNew.vin[0].scriptSig = CScript() << 486604799 << CScriptNum(4) << vector<unsigned char>((const unsigned char*)pszTimestamp, (const unsigned char*)pszTimestamp + strlen(pszTimestamp)); |
0e4b3175 MH |
83 | txNew.vout[0].nValue = 50 * COIN; |
84 | txNew.vout[0].scriptPubKey = CScript() << ParseHex("04678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc3f4cef38c4f35504e51ec112de5c384df7ba0b8d578a4c702b6bf11d5f") << OP_CHECKSIG; | |
85 | genesis.vtx.push_back(txNew); | |
86 | genesis.hashPrevBlock = 0; | |
87 | genesis.hashMerkleRoot = genesis.BuildMerkleTree(); | |
88 | genesis.nVersion = 1; | |
89 | genesis.nTime = 1231006505; | |
90 | genesis.nBits = 0x1d00ffff; | |
91 | genesis.nNonce = 2083236893; | |
92 | ||
93 | hashGenesisBlock = genesis.GetHash(); | |
94 | assert(hashGenesisBlock == uint256("0x000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f")); | |
95 | assert(genesis.hashMerkleRoot == uint256("0x4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b")); | |
96 | ||
97 | vSeeds.push_back(CDNSSeedData("bitcoin.sipa.be", "seed.bitcoin.sipa.be")); | |
98 | vSeeds.push_back(CDNSSeedData("bluematt.me", "dnsseed.bluematt.me")); | |
99 | vSeeds.push_back(CDNSSeedData("dashjr.org", "dnsseed.bitcoin.dashjr.org")); | |
cdc11b32 | 100 | vSeeds.push_back(CDNSSeedData("bitcoinstats.com", "seed.bitcoinstats.com")); |
89d72f3d | 101 | vSeeds.push_back(CDNSSeedData("bitnodes.io", "seed.bitnodes.io")); |
0e4b3175 MH |
102 | vSeeds.push_back(CDNSSeedData("xf2.org", "bitseed.xf2.org")); |
103 | ||
8388289e PW |
104 | base58Prefixes[PUBKEY_ADDRESS] = list_of(0); |
105 | base58Prefixes[SCRIPT_ADDRESS] = list_of(5); | |
106 | base58Prefixes[SECRET_KEY] = list_of(128); | |
eb2c9990 PW |
107 | base58Prefixes[EXT_PUBLIC_KEY] = list_of(0x04)(0x88)(0xB2)(0x1E); |
108 | base58Prefixes[EXT_SECRET_KEY] = list_of(0x04)(0x88)(0xAD)(0xE4); | |
0e4b3175 | 109 | |
a60120e9 | 110 | convertSeed6(vFixedSeeds, pnSeed6_main, ARRAYLEN(pnSeed6_main)); |
0e4b3175 | 111 | |
c8c52de3 | 112 | fRequireRPCPassword = true; |
113 | fMiningRequiresPeers = true; | |
114 | fDefaultCheckMemPool = false; | |
115 | fAllowMinDifficultyBlocks = false; | |
116 | fRequireStandard = true; | |
c8c52de3 | 117 | fMineBlocksOnDemand = false; |
0e4b3175 | 118 | } |
0e4b3175 MH |
119 | }; |
120 | static CMainParams mainParams; | |
121 | ||
0e4b3175 MH |
122 | // |
123 | // Testnet (v3) | |
124 | // | |
a60120e9 | 125 | |
0e4b3175 MH |
126 | class CTestNetParams : public CMainParams { |
127 | public: | |
128 | CTestNetParams() { | |
84ce18ca | 129 | networkID = CBaseChainParams::TESTNET; |
f5ae6c98 | 130 | strNetworkID = "test"; |
0e4b3175 MH |
131 | // The message start string is designed to be unlikely to occur in normal data. |
132 | // The characters are rarely used upper ASCII, not valid as UTF-8, and produce | |
133 | // a large 4-byte int at any alignment. | |
134 | pchMessageStart[0] = 0x0b; | |
135 | pchMessageStart[1] = 0x11; | |
136 | pchMessageStart[2] = 0x09; | |
137 | pchMessageStart[3] = 0x07; | |
138 | vAlertPubKey = ParseHex("04302390343f91cc401d56d68b123028bf52e5fca1939df127f63c6467cdf9c8e2c14b61104cf817d0b780da337893ecc4aaff1309e536162dabbdb45200ca2b0a"); | |
139 | nDefaultPort = 18333; | |
d754f34e | 140 | nEnforceBlockUpgradeMajority = 51; |
141 | nRejectBlockOutdatedMajority = 75; | |
142 | nToCheckBlockUpgradeMajority = 100; | |
fd704c7b | 143 | nMinerThreads = 0; |
144 | nTargetTimespan = 14 * 24 * 60 * 60; // two weeks | |
145 | nTargetSpacing = 10 * 60; | |
0e4b3175 MH |
146 | |
147 | // Modify the testnet genesis block so the timestamp is valid for a later start. | |
148 | genesis.nTime = 1296688602; | |
149 | genesis.nNonce = 414098458; | |
150 | hashGenesisBlock = genesis.GetHash(); | |
2b6a8993 | 151 | assert(hashGenesisBlock == uint256("0x000000000933ea01ad0ee984209779baaec3ced90fa3f408719526f8d77f4943")); |
0e4b3175 MH |
152 | |
153 | vFixedSeeds.clear(); | |
154 | vSeeds.clear(); | |
c30329ad | 155 | vSeeds.push_back(CDNSSeedData("alexykot.me", "testnet-seed.alexykot.me")); |
0e4b3175 MH |
156 | vSeeds.push_back(CDNSSeedData("bitcoin.petertodd.org", "testnet-seed.bitcoin.petertodd.org")); |
157 | vSeeds.push_back(CDNSSeedData("bluematt.me", "testnet-seed.bluematt.me")); | |
158 | ||
8388289e PW |
159 | base58Prefixes[PUBKEY_ADDRESS] = list_of(111); |
160 | base58Prefixes[SCRIPT_ADDRESS] = list_of(196); | |
161 | base58Prefixes[SECRET_KEY] = list_of(239); | |
eb2c9990 PW |
162 | base58Prefixes[EXT_PUBLIC_KEY] = list_of(0x04)(0x35)(0x87)(0xCF); |
163 | base58Prefixes[EXT_SECRET_KEY] = list_of(0x04)(0x35)(0x83)(0x94); | |
21913a9a | 164 | |
a60120e9 WL |
165 | convertSeed6(vFixedSeeds, pnSeed6_test, ARRAYLEN(pnSeed6_test)); |
166 | ||
c8c52de3 | 167 | fRequireRPCPassword = true; |
168 | fMiningRequiresPeers = true; | |
169 | fDefaultCheckMemPool = false; | |
170 | fAllowMinDifficultyBlocks = true; | |
171 | fRequireStandard = false; | |
c8c52de3 | 172 | fMineBlocksOnDemand = false; |
173 | } | |
0e4b3175 MH |
174 | }; |
175 | static CTestNetParams testNetParams; | |
176 | ||
0e4b3175 MH |
177 | // |
178 | // Regression test | |
179 | // | |
180 | class CRegTestParams : public CTestNetParams { | |
181 | public: | |
182 | CRegTestParams() { | |
84ce18ca | 183 | networkID = CBaseChainParams::REGTEST; |
f5ae6c98 | 184 | strNetworkID = "regtest"; |
0e4b3175 MH |
185 | pchMessageStart[0] = 0xfa; |
186 | pchMessageStart[1] = 0xbf; | |
187 | pchMessageStart[2] = 0xb5; | |
188 | pchMessageStart[3] = 0xda; | |
189 | nSubsidyHalvingInterval = 150; | |
d754f34e | 190 | nEnforceBlockUpgradeMajority = 750; |
191 | nRejectBlockOutdatedMajority = 950; | |
192 | nToCheckBlockUpgradeMajority = 1000; | |
2595b9ac | 193 | nMinerThreads = 1; |
fd704c7b | 194 | nTargetTimespan = 14 * 24 * 60 * 60; // two weeks |
195 | nTargetSpacing = 10 * 60; | |
df9eb5e1 | 196 | bnProofOfWorkLimit = ~uint256(0) >> 1; |
0e4b3175 MH |
197 | genesis.nTime = 1296688602; |
198 | genesis.nBits = 0x207fffff; | |
199 | genesis.nNonce = 2; | |
200 | hashGenesisBlock = genesis.GetHash(); | |
201 | nDefaultPort = 18444; | |
0e4b3175 MH |
202 | assert(hashGenesisBlock == uint256("0x0f9188f13cb7b2c71f2a335e3a4fc328bf5beb436012afca590b1a11466e2206")); |
203 | ||
204 | vSeeds.clear(); // Regtest mode doesn't have any DNS seeds. | |
0e4b3175 | 205 | |
c8c52de3 | 206 | fRequireRPCPassword = false; |
207 | fMiningRequiresPeers = false; | |
208 | fDefaultCheckMemPool = true; | |
209 | fAllowMinDifficultyBlocks = true; | |
210 | fRequireStandard = false; | |
c8c52de3 | 211 | fMineBlocksOnDemand = true; |
212 | } | |
0e4b3175 MH |
213 | }; |
214 | static CRegTestParams regTestParams; | |
215 | ||
84ce18ca | 216 | static CChainParams *pCurrentParams = 0; |
0e4b3175 MH |
217 | |
218 | const CChainParams &Params() { | |
84ce18ca | 219 | assert(pCurrentParams); |
0e4b3175 MH |
220 | return *pCurrentParams; |
221 | } | |
222 | ||
84ce18ca WL |
223 | void SelectParams(CBaseChainParams::Network network) { |
224 | SelectBaseParams(network); | |
0e4b3175 | 225 | switch (network) { |
84ce18ca | 226 | case CBaseChainParams::MAIN: |
0e4b3175 MH |
227 | pCurrentParams = &mainParams; |
228 | break; | |
84ce18ca | 229 | case CBaseChainParams::TESTNET: |
0e4b3175 MH |
230 | pCurrentParams = &testNetParams; |
231 | break; | |
84ce18ca | 232 | case CBaseChainParams::REGTEST: |
0e4b3175 MH |
233 | pCurrentParams = ®TestParams; |
234 | break; | |
235 | default: | |
236 | assert(false && "Unimplemented network"); | |
237 | return; | |
238 | } | |
239 | } | |
240 | ||
241 | bool SelectParamsFromCommandLine() { | |
84ce18ca | 242 | if (!SelectBaseParamsFromCommandLine()) |
0e4b3175 | 243 | return false; |
0e4b3175 | 244 | |
84ce18ca | 245 | SelectParams(BaseParams().NetworkID()); |
0e4b3175 MH |
246 | return true; |
247 | } |