Anoncoin  0.9.4
P2P Digital Currency
chainparams.cpp
Go to the documentation of this file.
1 // Copyright (c) 2010 Satoshi Nakamoto
2 // Copyright (c) 2009-2014 The Bitcoin developers
3 // Copyright (c) 2013-2015 The Anoncoin Core developers
4 // Distributed under the MIT/X11 software license, see the accompanying
5 // file COPYING or http://www.opensource.org/licenses/mit-license.php.
6 
7 #include "chainparams.h"
8 // Anoncoin-config.h has been loaded...
9 
10 #include "assert.h"
11 #include "core.h"
12 #include "protocol.h"
13 #include "util.h"
14 
15 #include <boost/assign/list_of.hpp>
16 
17 using namespace boost::assign;
18 
19 #ifdef ENABLE_I2PSAM
20 static const string I2pSeedAddresses[] = {
21  "8w-NRnXaxoGZdyupTXX78~CmF8csc~RhJr8XR2vMbNpazKhGjWNfRjhCmwqXkkW9vwkNjovW2AAbof7PfVnMCff0sHSxMTiBNsH8cuHJS2ckBSJI3h4G4ffJLc5gflangrG1raHKrMXCw8Cn56pisx4RKokEKUYdeEPiMdyJUO5yjZW2oyk4NpaUaQCqFmcglIvNOCYzVe~LK124wjJQAJc5iME1Sg9sOHaGMPL5N2qkAm5osOg2S7cZNRdIkoNOq-ztxghrv5bDL0ybeC0sfIQzvxDiKugCrSHEHCvwkA~xOu9nhNlUvoPDyCRRi~ImeomdNoqke28di~h2JF7wBGE~3ACxxOMaa0I~c9LV3O7pRU2Xj9HDn76eMGL7YCcCU4dRByu97oqfB3E~qqmmFp8W1tgvnEAMtXFTFZPYc33ZaCaIJQD7UXcQRSRV7vjw39jhx49XFsmYV3K6~D8bN8U4sRJnKQpzOJGpOSEJWh88bII0XuA55bJsfrR4VEQ5AAAA",
22  "hL51K8bxVvqX2Z4epXReUYlWTNUAK-1XdlbBd7e796s2A3icCQRhJvGlaa6PX~tgPvos-2IJp9hFQrVa0lyKyYmpQN9X7GOErtsL-JbMQpglQsEd94jDRAsiBuvgyPZij~NNdBxKRMDvNm9s7eovzhEFTAimTSB-sgeZ4Afxx2IrNXDFM6KS8AUm8YsaMldzX9zKQDeuV0slp4ZfIAVQhZZy9zTZSmUNPnXQR7XPh5w7FkXzmKMTKSyG~layJ3AorQWqzZXmykzf4z3CE4zkzQcwc0~ZIcAg9tYvM2AdQIdgeN6ISMim6L8q6ku6abuONkyw-NJTi3NopeGHZva21Tc3uHetsKoW434N24HBVUtIjJVjGsbZ7xBfz2xM5kyhPl6SlD-RJarCw47Rovmfc9Piq6q3S~Zw-rvRl-xDMJzwraIYNjAROouDwjI9Bqnguq9DH5uFBxf4uN69X7T~yWTAjdvelZKp6BGe~HGo7bNQjBmymhlH4erCKZEXOaxDAAAA"
23 };
24 #endif // ENABLE_I2PSAM
25 
26 //
27 // Main network
28 //
29 unsigned int pnSeed[] =
30 {
31  0x0
32 };
33 
34 class CMainParams : public CChainParams {
35 public:
37  strNetworkID = "main";
38 
39  // The message start string is designed to be unlikely to occur in normal data.
40  // The characters are rarely used upper ASCII, not valid as UTF-8, and produce
41  // a large 4-byte int at any alignment.
42  pchMessageStart[0] = 0xfa;
43  pchMessageStart[1] = 0xca;
44  pchMessageStart[2] = 0xba;
45  pchMessageStart[3] = 0xda;
46  vAlertPubKey = ParseHex("04b2941a448ab9860beb73fa2f600c09bf9fe4d18d5ff0b3957bf94c6d177d61f88660d7c0dd9adef984080ddea03c898039759f66c2011c111c4394692f814962");
47  nDefaultPort = 9377;
48  nRPCPort = 9376;
49 
50  // ToDo: These proof of work limits need to be checked, PRIME's value hasn't been looked up yet.
51  // GR NOTE to Team: 9.99 coders removed CBigNum, stop using. Port to the new coding convention, with what your working on now....
52  // ...had that figured out once, think our new type is CScriptNum(), need to look it up myself.
53  bnProofOfWorkLimit[SCRYPT_ANC] = CBigNum().SetCompact(0x1e0ffff0); // As defined in Anoncoin 8.6....
54  bnProofOfWorkLimit[SHA256D_BTC] = CBigNum(~uint256(0) >> 32); /* Bitcoin difficulty is very large (taken from 9.99 code 12/2014 */
55  bnProofOfWorkLimit[PRIME_XPM] = CBigNum(~uint256(0) >> 20);
56 
57 // Genesis:
58 //2ca51355580bb293fe369c5f34954069c263e9a9e8d70945ebb4c38f05778558
59 //238467b132120c9660156a6752663593e01b2f3e79b2abbc21b71308daa22ec4
60 //7ce7004d764515f9b43cb9f07547c8e2e00d94c9348b3da33c8681d350f2c736
61 //block.nTime = 1370190760
62 //block.nNonce = 347089008
63 //block.GetHash = 2c85519db50a40c033ccb3d4cb729414016afa537c66537f7d3d52dcd1d484a3
64 //CBlock(hash=2c85519db50a40c033cc, PoW=00000be19c5a519257aa, ver=1, hashPrevBlock=00000000000000000000, hashMerkleRoot=7ce7004d76, nTime=1370190760, nBits=1e0ffff0, nNonce=347089008, vtx=1)
65 // CTransaction(hash=7ce7004d76, ver=1, vin.size=1, vout.size=1, nLockTime=0)
66 // CTxIn(COutPoint(0000000000, -1), coinbase 04ffff001d01044c5e30322f4a756e2f323031333a202054686520556e6976657273652c20776527726520616c6c206f6e652e20427574207265616c6c792c206675636b207468652043656e7472616c2062616e6b732e202d20416e6f6e796d6f757320343230)
67 // CTxOut(error)
68 // vMerkleTree: 7ce7004d76
69  const char* pszTimestamp = "02/Jun/2013: The Universe, we're all one. But really, fuck the Central banks. - Anonymous 420";
70  CTransaction txNew;
71  txNew.vin.resize(1);
72  txNew.vout.resize(1);
73  txNew.vin[0].scriptSig = CScript() << 486604799 << CScriptNum(4) << vector<unsigned char>((const unsigned char*)pszTimestamp, (const unsigned char*)pszTimestamp + strlen(pszTimestamp));
74  txNew.vout[0].nValue = 0 * COIN;
75  txNew.vout[0].scriptPubKey = CScript() << 0x0 << OP_CHECKSIG;
76  genesis.vtx.push_back(txNew);
77  genesis.hashPrevBlock = 0;
78  genesis.hashMerkleRoot = genesis.BuildMerkleTree();
79  genesis.nVersion = 1;
80  genesis.nTime = 1370190760;
81  genesis.nBits = 0x1e0ffff0;
82  genesis.nNonce = 347089008;
83 
84  hashGenesisBlock = genesis.GetHash();
85  assert(hashGenesisBlock == uint256("0x2c85519db50a40c033ccb3d4cb729414016afa537c66537f7d3d52dcd1d484a3"));
86  assert(genesis.hashMerkleRoot == uint256("0x7ce7004d764515f9b43cb9f07547c8e2e00d94c9348b3da33c8681d350f2c736"));
87 
88 // ToDo: Named domains can NOT go into fixed, unless converted to ip addresses. Is that what is wanted here, on these first 2 entries? Or....?
89 // vSeeds.push_back(CDNSSeedData("coinpool.in", "anoncoin.dnsseed.coinpool.in")); // Normal Seednode, NO DNS-SEED!
90 // vSeeds.push_back(CDNSSeedData("anoncoin.net", "dnsseed01.anoncoin.net")); // Normal Seednode, NO DNS-SEED!
91  vSeeds.push_back(CDNSSeedData("anoncoin.darkgamex.ch", "anc.dnsseed01.anoncoin.darkgamex.ch")); // K1773R's DNSSeed
92  vSeeds.push_back(CDNSSeedData("www.virtual-currency.com", "anc.dnsseed01.anoncoin.virtual-currency.com")); // keystroke's DNSSeed
93 
94 #ifdef ENABLE_I2PSAM
95 
99 // As of 12/30/2014, these following entries were not working. Renewing tests for awhile, or removed...
100  i2pvSeeds.push_back(CDNSSeedData("d46o5wddsdrvg2ywnu4o57zeloayt7oyg56adz63xukordgfommq.b32.i2p", "d46o5wddsdrvg2ywnu4o57zeloayt7oyg56adz63xukordgfommq.b32.i2p"));
101  i2pvSeeds.push_back(CDNSSeedData("u2om3hgjpghqfi7yid75xdmvzlgjybstzp6mtmaxse4aztm23rwq.b32.i2p", "u2om3hgjpghqfi7yid75xdmvzlgjybstzp6mtmaxse4aztm23rwq.b32.i2p"));
102  i2pvSeeds.push_back(CDNSSeedData("htigbyeisbqizn63ftqw7ggfwfeolwkb3zfxwmyffygbilwqsswq.b32.i2p", "htigbyeisbqizn63ftqw7ggfwfeolwkb3zfxwmyffygbilwqsswq.b32.i2p"));
103  i2pvSeeds.push_back(CDNSSeedData("st4eyxcp73zzbpatgt26pt3rlfwb7g5ywedol65baalgpnhvzqpa.b32.i2p", "st4eyxcp73zzbpatgt26pt3rlfwb7g5ywedol65baalgpnhvzqpa.b32.i2p"));
104  i2pvSeeds.push_back(CDNSSeedData("qgmxpnpujddsd5ez67p4ognqsvo64tnzdbzesezdbtb3atyoxcpq.b32.i2p", "qgmxpnpujddsd5ez67p4ognqsvo64tnzdbzesezdbtb3atyoxcpq.b32.i2p"));
105  i2pvSeeds.push_back(CDNSSeedData("7zbwzykhyjcmmessswamkxfyya7hioiy2oq7voaw27625qwruqia.b32.i2p", "7zbwzykhyjcmmessswamkxfyya7hioiy2oq7voaw27625qwruqia.b32.i2p")); // lunokhod's seednode
106  i2pvSeeds.push_back(CDNSSeedData("ypwvq7jcu3uwyg4ufjqt4a26ca6pxdcnshv6q2okmmjsof5dxzkq.b32.i2p", "ypwvq7jcu3uwyg4ufjqt4a26ca6pxdcnshv6q2okmmjsof5dxzkq.b32.i2p")); // keystroke's seednode
107 
108 // Have been working well since testing the v0.9.4 clients
109  i2pvSeeds.push_back(CDNSSeedData("a4gii55rnvv22qm2ojre2n67bzms5utr4k3ckafwjdoym2cqmv2q.b32.i2p", "a4gii55rnvv22qm2ojre2n67bzms5utr4k3ckafwjdoym2cqmv2q.b32.i2p")); // K1773R's seednode
110  i2pvSeeds.push_back(CDNSSeedData("b7ziruwpk7g2e44xyomnc2nu5tx7bc2f2ai4dzi66uxm3bc3qttq.b32.i2p", "b7ziruwpk7g2e44xyomnc2nu5tx7bc2f2ai4dzi66uxm3bc3qttq.b32.i2p")); // K1773R's seednode (dnsseed01)
111  i2pvSeeds.push_back(CDNSSeedData("72vaef5cmmlcilgvpeltcp77gutsnyic2l5khsgz7kyivla5lwjq.b32.i2p", "72vaef5cmmlcilgvpeltcp77gutsnyic2l5khsgz7kyivla5lwjq.b32.i2p")); // riddler's seednode
112  i2pvSeeds.push_back(CDNSSeedData("qc37luxnbh3hkihxfl2e7nwosebh5sbfvpvjqwn7c3g5kqftb5qq.b32.i2p", "qc37luxnbh3hkihxfl2e7nwosebh5sbfvpvjqwn7c3g5kqftb5qq.b32.i2p")); // psi's seednode
113  i2pvSeeds.push_back(CDNSSeedData("xynjl64xlviqhkjl2fbvupj7y3wct46jtayoxm2ksba6tqzo6tsa.b32.i2p", "xynjl64xlviqhkjl2fbvupj7y3wct46jtayoxm2ksba6tqzo6tsa.b32.i2p")); // Cryptoslave's seednode
114 #endif // ENABLE_I2PSAM
115 
116  base58Prefixes[PUBKEY_ADDRESS] = list_of(23); // Anoncoin addresses start with A
117  base58Prefixes[SCRIPT_ADDRESS] = list_of(5);
118  base58Prefixes[SECRET_KEY] = list_of(151); // Anoncoin secret keys are the Public Key + 128
119  base58Prefixes[EXT_PUBLIC_KEY] = list_of(0x04)(0x88)(0xB2)(0x1E);
120  base58Prefixes[EXT_SECRET_KEY] = list_of(0x04)(0x88)(0xAD)(0xE4);
121 
122  // Convert the pnSeeds array into usable address objects.
123  // ToDo: Generate some usable ip (IPv4) addresses for the pnSeed array See: contrib/seeds/ for details...
124  // OrNot: ...as we migrate to I2P for everything, this becomes less of feature we even care about.
125  for (unsigned int i = 0; i < ARRAYLEN(pnSeed); i++)
126  {
127  // It'll only connect to one or two seed nodes because once it connects,
128  // it'll get a pile of addresses with newer timestamps.
129  // Seed nodes are given a random 'last seen time' of between one and two
130  // weeks ago.
131  const int64_t nOneWeek = 7*24*60*60;
132  struct in_addr ip;
133  memcpy(&ip, &pnSeed[i], sizeof(ip));
134  CAddress addr(CService(ip, GetDefaultPort()));
135  addr.nTime = GetTime() - GetRand(nOneWeek) - nOneWeek;
136  vFixedSeeds.push_back(addr);
137  }
138 #ifdef ENABLE_I2PSAM
139  // As of 12/26/2014, there are NO entries from above clearnet pnSeed array, only using I2P for fixed seeding...
140  for (unsigned int i = 0; i < ARRAYLEN( I2pSeedAddresses ); i++ ) {
141  const int64_t nOneWeek = 7*24*60*60;
142  CService aServiceSeed( I2pSeedAddresses[i] );
143  CAddress addr( aServiceSeed );
144  addr.nTime = GetTime() - GetRand(nOneWeek) - nOneWeek;
145  vFixedSeeds.push_back(addr);
146  }
147 #endif
148  }
149 
150  virtual const CBlock& GenesisBlock() const { return genesis; }
151  virtual Network NetworkID() const { return CChainParams::MAIN; }
152 
153  virtual const vector<CAddress>& FixedSeeds() const { return vFixedSeeds; }
154 protected:
156  vector<CAddress> vFixedSeeds;
157 };
158 static CMainParams mainParams;
159 
160 
161 //
162 // Testnet (v4)
163 //
164 class CTestNetParams : public CMainParams {
165 public:
167  strNetworkID = "testnet4";
168 
169  // The message start string is designed to be unlikely to occur in normal data.
170  // The characters are rarely used upper ASCII, not valid as UTF-8, and produce
171  // a large 4-byte int at any alignment.
172  pchMessageStart[0] = 0xfa;
173  pchMessageStart[1] = 0xc4;
174  pchMessageStart[2] = 0xb7;
175  pchMessageStart[3] = 0xd4;
176  // GR Note: 1/26/2015 - New secp256k1 key values generated for testnet....
177  vAlertPubKey = ParseHex("0442ccd085e52f7b74ee594826e36e417706af91ff7e7236a430b2dd16fe9f1a8132d0718e0bf5a3b7105354bf5bf954330097b21824c26c466836df9538f3d33e");
178  // Private key for alert generation, anyone on the development and test team can use it:
179  // "3082011302010104204b164c9765248427d1b13b9dc4f11107629485f0c61de070d89ebae308822e25a081a53081a2020101302c06072a8648ce3d0101022100fffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f300604010004010704410479be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8022100fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141020101a1440342000442ccd085e52f7b74ee594826e36e417706af91ff7e7236a430b2dd16fe9f1a8132d0718e0bf5a3b7105354bf5bf954330097b21824c26c466836df9538f3d33e"
180  nDefaultPort = 19377;
181  nRPCPort = 19376;
182  strDataDir = "testnet4";
183 
184  // Modify the testnet genesis block so the timestamp is valid for a later start.
185  genesis.nTime = 1317798646;
186  genesis.nNonce = 385270584;
187  hashGenesisBlock = genesis.GetHash();
188  // ToDo: This assertion fails @ runtime, need to do the math:
189  // assert(hashGenesisBlock == uint256("0xf5ae71e26c74beacc88382716aced69cddf3dffff24f384e1808905e0188f68f"));
190 
191  vFixedSeeds.clear();
192  vSeeds.clear();
193  vSeeds.push_back(CDNSSeedData("anoncoin.net", "dnsseed01.anoncoin.net"));
194 
195  base58Prefixes[PUBKEY_ADDRESS] = list_of(111); // Anoncoin v8 compatible testnet Public keys use this value
196  base58Prefixes[SCRIPT_ADDRESS] = list_of(196);
197  base58Prefixes[SECRET_KEY] = list_of(239); // Anoncoin testnet secret keys are the Public Key + 128
198  base58Prefixes[EXT_PUBLIC_KEY] = list_of(0x04)(0x35)(0x87)(0xCF);
199  base58Prefixes[EXT_SECRET_KEY] = list_of(0x04)(0x35)(0x83)(0x94);
200  }
201  virtual Network NetworkID() const { return CChainParams::TESTNET; }
202 };
203 static CTestNetParams testNetParams;
204 
205 
206 //
207 // Regression test
208 //
210 public:
212  strNetworkID = "regtest";
213 
214  pchMessageStart[0] = 0xfa;
215  pchMessageStart[1] = 0xbf;
216  pchMessageStart[2] = 0xb5;
217  pchMessageStart[3] = 0xda;
218 
219  // ToDo: Proof of work limits, for regression testing are very small, more than likely these should work
220  bnProofOfWorkLimit[SCRYPT_ANC] = CBigNum(~uint256(0) >> 1);
221  bnProofOfWorkLimit[SHA256D_BTC] = CBigNum(~uint256(0) >> 1);
222  bnProofOfWorkLimit[PRIME_XPM] = CBigNum(~uint256(0) >> 1);
223 
224  genesis.nTime = 1296688602;
225  genesis.nBits = 0x207fffff;
226  genesis.nNonce = 2;
227  hashGenesisBlock = genesis.GetHash();
228  nDefaultPort = 19444;
229  nRPCPort = 19443;
230  strDataDir = "regtest";
231  // ToDo: This assertion fails @ runtime, need to do the math:
232  // assert(hashGenesisBlock == uint256("0x9372df8b4c0144d2238b73d65ce81b5eb37ec416c23fc29307b89de4b0493cf8"));
233 
234  vSeeds.clear(); // Regtest mode doesn't have any DNS seeds.
235  }
236 
237  virtual bool RequireRPCPassword() const { return false; }
238  virtual Network NetworkID() const { return CChainParams::REGTEST; }
239 };
240 static CRegTestParams regTestParams;
241 
242 static CChainParams *pCurrentParams = &mainParams;
243 
245  return *pCurrentParams;
246 }
247 
249  switch (network) {
250  case CChainParams::MAIN:
251  pCurrentParams = &mainParams;
252  break;
254  pCurrentParams = &testNetParams;
255  break;
257  pCurrentParams = &regTestParams;
258  break;
259  default:
260  assert(false && "Unimplemented network");
261  return;
262  }
263 }
264 
266  bool fRegTest = GetBoolArg("-regtest", false);
267  bool fTestNet = GetBoolArg("-testnet", false);
268 
269  if (fTestNet && fRegTest) {
270  return false;
271  }
272 
273  if (fRegTest) {
275  } else if (fTestNet) {
277  } else {
279  }
280  return true;
281 }
uint64_t GetRand(uint64_t nMax)
Definition: util.cpp:186
vector< CAddress > vFixedSeeds
unsigned int pnSeed[]
Definition: chainparams.cpp:29
Definition: core.h:394
virtual const vector< CAddress > & FixedSeeds() const
bool SelectParamsFromCommandLine()
Looks for -regtest or -testnet and then calls SelectParams as appropriate.
CChainParams defines various tweakable parameters of a given instance of the Anoncoin system...
Definition: chainparams.h:47
CBigNum & SetCompact(unsigned int nCompact)
Definition: bignum.h:295
bool GetBoolArg(const std::string &strArg, bool fDefault)
Return boolean argument or default value.
Definition: util.cpp:520
virtual bool RequireRPCPassword() const
void SelectParams(CChainParams::Network network)
Sets the params returned by Params() to those for the given network.
std::vector< CTxOut > vout
Definition: core.h:187
A combination of a network address (CNetAddr) and a (TCP) port.
Definition: netbase.h:109
std::vector< CTxIn > vin
Definition: core.h:186
C++ wrapper for BIGNUM (OpenSSL bignum)
Definition: bignum.h:57
A CService with information about it as peer.
Definition: protocol.h:91
int64_t GetTime()
Definition: util.cpp:1220
CBlock genesis
256-bit unsigned integer
Definition: uint256.h:532
unsigned int nTime
Definition: protocol.h:121
const CChainParams & Params()
Return the currently selected parameters.
Serialized script, used inside transaction inputs and outputs.
Definition: script.h:413
void * memcpy(void *a, const void *b, size_t c)
virtual const CBlock & GenesisBlock() const
#define ARRAYLEN(array)
Definition: util.h:46
virtual Network NetworkID() const
virtual Network NetworkID() const
The basic transaction that is broadcasted on the network and contained in blocks. ...
Definition: core.h:179
vector< unsigned char > ParseHex(const char *psz)
Definition: util.cpp:419
virtual Network NetworkID() const