-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathchainparams.cpp
More file actions
225 lines (187 loc) · 7.26 KB
/
Copy pathchainparams.cpp
File metadata and controls
225 lines (187 loc) · 7.26 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
// Copyright (c) 2010 Satoshi Nakamoto
// Copyright (c) 2009-2012 The Bitraam developers
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include "assert.h"
#include "chainparams.h"
#include "core.h"
#include "protocol.h"
#include "util.h"
//
// Main network
//
unsigned int pnSeed[] =
{
0x6baaaa0b
};
class CMainParams : public CChainParams {
public:
CMainParams() {
// The message start string is designed to be unlikely to occur in normal data.
pchMessageStart[0] = 0xb0;
pchMessageStart[1] = 0xfc;
pchMessageStart[2] = 0xaf;
pchMessageStart[3] = 0xef;
nDefaultPort = 31415;
nRPCPort = 31416;
bnProofOfWorkLimit = CBigNum(~uint256(0) >> 20);
nSubsidyHalvingInterval = 9467280;
// Build the genesis block. Note that the output of the genesis coinbase cannot
// be spent as it did not originally exist in the database.
const char* pszTimestamp = "MAHARISHI MAHESH YOGI";
CTransaction txNew;
txNew.vin.resize(1);
txNew.vout.resize(1);
txNew.vin[0].scriptSig = CScript() << 486604799 << CBigNum(4) << vector<unsigned char>((const unsigned char*)pszTimestamp, (const unsigned char*)pszTimestamp + strlen(pszTimestamp));
txNew.vout[0].nValue = 50 * COIN;
txNew.vout[0].scriptPubKey = CScript() << ParseHex("04678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc3f4cef38c4f35504e51ec112de5c384df7ba0b8d578a4c702b6bf11d5f") << OP_CHECKSIG;
genesis.vtx.push_back(txNew);
genesis.hashPrevBlock = 0;
genesis.hashMerkleRoot = genesis.BuildMerkleTree();
genesis.nVersion = 1;
genesis.nTime = 1735689600;
genesis.nBits = 0x1e0fffff;
genesis.nNonce = 1015127;
hashGenesisBlock = genesis.GetHash();
printf("%s\n", hashGenesisBlock.ToString().c_str());
printf("%s\n", genesis.hashMerkleRoot.ToString().c_str());
printf("%x\n", bnProofOfWorkLimit.GetCompact());
genesis.print();
assert(hashGenesisBlock == uint256("0x0000055d0a3daa9c4b0d3629d3e9ba64f3cfa29643da9939b889d9d69a736b4e"));
assert(genesis.hashMerkleRoot == uint256("0x2cec01a5fba766ee1d863fcdecec3695219008469eb0dbc1a8fa512bb5fe5127"));
vSeeds.push_back(CDNSSeedData("bitraam.org", "seednode.bitraam.org"));
base58Prefixes[PUBKEY_ADDRESS] = 40;
base58Prefixes[SCRIPT_ADDRESS] = 30;
base58Prefixes[SECRET_KEY] = 224;
// Convert the pnSeeds array into usable address objects.
for (unsigned int i = 0; i < ARRAYLEN(pnSeed); i++)
{
// It'll only connect to one or two seed nodes because once it connects,
// it'll get a pile of addresses with newer timestamps.
// Seed nodes are given a random 'last seen time'
const int64 nTwoDays = 2 * 24 * 60 * 60;
struct in_addr ip;
memcpy(&ip, &pnSeed[i], sizeof(ip));
CAddress addr(CService(ip, GetDefaultPort()));
addr.nTime = GetTime() - GetRand(nTwoDays) - nTwoDays;
vFixedSeeds.push_back(addr);
}
}
virtual const CBlock& GenesisBlock() const { return genesis; }
virtual Network NetworkID() const { return CChainParams::MAIN; }
virtual const vector<CAddress>& FixedSeeds() const {
return vFixedSeeds;
}
protected:
CBlock genesis;
vector<CAddress> vFixedSeeds;
};
static CMainParams mainParams;
//
// Testnet (v3)
//
class CTestNetParams : public CMainParams {
public:
CTestNetParams() {
// The message start string is designed to be unlikely to occur in normal data.
pchMessageStart[0] = 0x1c;
pchMessageStart[1] = 0x90;
pchMessageStart[2] = 0x6f;
pchMessageStart[3] = 0x88;
nDefaultPort = 51255;
nRPCPort = 51254;
strDataDir = "testnet";
// Modify the testnet genesis block so the timestamp is valid for a later start.
genesis.nTime = 1394251332;
genesis.nNonce = 0;
//// debug print
hashGenesisBlock = genesis.GetHash();
//while (hashGenesisBlock > bnProofOfWorkLimit.getuint256()){
// if (++genesis.nNonce==0) break;
// hashGenesisBlock = genesis.GetHash();
//}
printf("%s\n", hashGenesisBlock.ToString().c_str());
printf("%s\n", genesis.hashMerkleRoot.ToString().c_str());
genesis.print();
vFixedSeeds.clear();
vSeeds.clear();
// vSeeds.push_back(CDNSSeedData("BitRaam.test", "test.BitRaam.org"));
base58Prefixes[PUBKEY_ADDRESS] = 130;
base58Prefixes[SCRIPT_ADDRESS] = 30;
base58Prefixes[SECRET_KEY] = 239;
}
virtual Network NetworkID() const { return CChainParams::TESTNET; }
};
static CTestNetParams testNetParams;
//
// Regression test
//
class CRegTestParams : public CTestNetParams {
public:
CRegTestParams() {
pchMessageStart[0] = 0xfa;
pchMessageStart[1] = 0x0f;
pchMessageStart[2] = 0xa5;
pchMessageStart[3] = 0x5a;
nSubsidyHalvingInterval = 9467280;
bnProofOfWorkLimit = CBigNum(~uint256(0) >> 1);
genesis.nTime = 1296688602;
genesis.nBits = 0x207fffff;
genesis.nNonce = 3;
hashGenesisBlock = genesis.GetHash();
nDefaultPort = 18444;
strDataDir = "regtest";
//// debug print
hashGenesisBlock = genesis.GetHash();
//while (hashGenesisBlock > bnProofOfWorkLimit.getuint256()){
// if (++genesis.nNonce==0) break;
// hashGenesisBlock = genesis.GetHash();
//}
printf("%s\n", hashGenesisBlock.ToString().c_str());
printf("%s\n", genesis.hashMerkleRoot.ToString().c_str());
genesis.print();
// assert(hashGenesisBlock == uint256("0x13d8d31dde96874006da503dd2b63fa68c698dc823334359e417aa3a92f80433"));
vSeeds.clear(); // Regtest mode doesn't have any DNS seeds.
base58Prefixes[PUBKEY_ADDRESS] = 0;
base58Prefixes[SCRIPT_ADDRESS] = 5;
base58Prefixes[SECRET_KEY] = 128;
}
virtual bool RequireRPCPassword() const { return false; }
virtual Network NetworkID() const { return CChainParams::REGTEST; }
};
static CRegTestParams regTestParams;
static CChainParams *pCurrentParams = &mainParams;
const CChainParams &Params() {
return *pCurrentParams;
}
void SelectParams(CChainParams::Network network) {
switch (network) {
case CChainParams::MAIN:
pCurrentParams = &mainParams;
break;
case CChainParams::TESTNET:
pCurrentParams = &testNetParams;
break;
case CChainParams::REGTEST:
pCurrentParams = ®TestParams;
break;
default:
assert(false && "Unimplemented network");
return;
}
}
bool SelectParamsFromCommandLine() {
bool fRegTest = GetBoolArg("-regtest", false);
bool fTestNet = GetBoolArg("-testnet", false);
if (fTestNet && fRegTest) {
return false;
}
if (fRegTest) {
SelectParams(CChainParams::REGTEST);
} else if (fTestNet) {
SelectParams(CChainParams::TESTNET);
} else {
SelectParams(CChainParams::MAIN);
}
return true;
}