2013-05-07 15:16:25 +02:00
|
|
|
// Copyright (c) 2010 Satoshi Nakamoto
|
2014-02-08 22:50:24 +01:00
|
|
|
// Copyright (c) 2009-2014 The Bitcoin developers
|
2014-12-11 16:58:38 +01:00
|
|
|
// Copyright (c) 2014 The Darkcoin developers
|
2013-05-07 15:16:25 +02:00
|
|
|
// Distributed under the MIT/X11 software license, see the accompanying
|
|
|
|
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
|
|
|
|
|
|
|
#include "chainparams.h"
|
2013-04-13 07:13:08 +02:00
|
|
|
|
|
|
|
#include "assert.h"
|
2013-06-24 16:41:16 +02:00
|
|
|
#include "core.h"
|
|
|
|
#include "protocol.h"
|
2013-05-07 15:16:25 +02:00
|
|
|
#include "util.h"
|
|
|
|
|
2013-06-23 02:33:47 +02:00
|
|
|
#include <boost/assign/list_of.hpp>
|
|
|
|
|
|
|
|
using namespace boost::assign;
|
|
|
|
|
2013-05-07 15:16:25 +02:00
|
|
|
//
|
|
|
|
// Main network
|
|
|
|
//
|
|
|
|
|
|
|
|
unsigned int pnSeed[] =
|
|
|
|
{
|
2014-11-28 10:56:02 +01:00
|
|
|
0x3210ce66, 0x3213747b, 0x1717ba83, 0x3210ce66, 0x3213747b,
|
|
|
|
0x1715cc22, 0xbc8e2769, 0x36f8e397, 0x2a793a5b, 0x3251c027,
|
|
|
|
0x05fe6003, 0xaf73c92c, 0xd035bf02, 0xc06f4182, 0xa2f32110,
|
2013-05-07 15:16:25 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
class CMainParams : public CChainParams {
|
|
|
|
public:
|
|
|
|
CMainParams() {
|
|
|
|
// 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 4-byte int at any alignment.
|
2014-11-28 10:56:02 +01:00
|
|
|
pchMessageStart[0] = 0xbf;
|
|
|
|
pchMessageStart[1] = 0x0c;
|
|
|
|
pchMessageStart[2] = 0x6b;
|
|
|
|
pchMessageStart[3] = 0xbd;
|
2014-12-12 23:19:02 +01:00
|
|
|
vAlertPubKey = ParseHex("048240a8748a80a286b270ba126705ced4f2ce5a7847b3610ea3c06513150dade2a8512ed5ea86320824683fc0818f0ac019214973e677acd1244f6d0571fc5103");
|
2014-11-27 18:09:11 +01:00
|
|
|
nDefaultPort = 9999;
|
|
|
|
nRPCPort = 9998;
|
2014-11-29 12:29:14 +01:00
|
|
|
bnProofOfWorkLimit = CBigNum(~uint256(0) >> 20); // Darkcoin starting difficulty is 1 / 2^12
|
2013-05-07 15:16:25 +02:00
|
|
|
nSubsidyHalvingInterval = 210000;
|
|
|
|
|
2014-11-28 10:56:02 +01:00
|
|
|
// Genesis block
|
|
|
|
const char* pszTimestamp = "Wired 09/Jan/2014 The Grand Experiment Goes Live: Overstock.com Is Now Accepting Bitcoins";
|
2013-05-07 15:16:25 +02:00
|
|
|
CTransaction txNew;
|
|
|
|
txNew.vin.resize(1);
|
|
|
|
txNew.vout.resize(1);
|
2014-03-26 20:50:29 +01:00
|
|
|
txNew.vin[0].scriptSig = CScript() << 486604799 << CScriptNum(4) << vector<unsigned char>((const unsigned char*)pszTimestamp, (const unsigned char*)pszTimestamp + strlen(pszTimestamp));
|
2013-05-07 15:16:25 +02:00
|
|
|
txNew.vout[0].nValue = 50 * COIN;
|
2014-11-28 10:56:02 +01:00
|
|
|
txNew.vout[0].scriptPubKey = CScript() << ParseHex("040184710fa689ad5023690c80f3a49c8f13f8d45b8c857fbcbc8bc4a8e4d3eb4b10f4d4604fa08dce601aaf0f470216fe1b51850b4acf21b179c45070ac7b03a9") << OP_CHECKSIG;
|
2013-05-07 15:16:25 +02:00
|
|
|
genesis.vtx.push_back(txNew);
|
|
|
|
genesis.hashPrevBlock = 0;
|
|
|
|
genesis.hashMerkleRoot = genesis.BuildMerkleTree();
|
|
|
|
genesis.nVersion = 1;
|
2014-11-28 10:56:02 +01:00
|
|
|
genesis.nTime = 1390095618;
|
|
|
|
genesis.nBits = 0x1e0ffff0;
|
|
|
|
genesis.nNonce = 28917698;
|
|
|
|
|
2014-11-28 11:53:08 +01:00
|
|
|
hashGenesisBlock = genesis.GetHash();
|
2014-11-28 10:56:02 +01:00
|
|
|
assert(hashGenesisBlock == uint256("0x00000ffd590b1485b3caadc19b22e6379c733355108f107a430458cdf3407ab6"));
|
|
|
|
assert(genesis.hashMerkleRoot == uint256("0xe0028eb9648db56b1ac77cf090b99048a8007e2bb64b68f092c03c7f56a662c7"));
|
2013-05-07 15:16:25 +02:00
|
|
|
|
2014-11-27 18:56:59 +01:00
|
|
|
vSeeds.push_back(CDNSSeedData("darkcoin.io", "dnsseed.darkcoin.io"));
|
|
|
|
vSeeds.push_back(CDNSSeedData("darkcoin.qa", "dnsseed.darkcoin.qa"));
|
2013-05-07 15:16:25 +02:00
|
|
|
|
2014-11-28 10:56:02 +01:00
|
|
|
base58Prefixes[PUBKEY_ADDRESS] = list_of(76); // Darkcoin addresses start with X
|
2013-06-23 02:33:47 +02:00
|
|
|
base58Prefixes[SCRIPT_ADDRESS] = list_of(5);
|
2014-12-06 16:42:40 +01:00
|
|
|
base58Prefixes[SECRET_KEY] = list_of(204);
|
2013-07-15 01:05:25 +02:00
|
|
|
base58Prefixes[EXT_PUBLIC_KEY] = list_of(0x04)(0x88)(0xB2)(0x1E);
|
|
|
|
base58Prefixes[EXT_SECRET_KEY] = list_of(0x04)(0x88)(0xAD)(0xE4);
|
2013-05-07 15:16:25 +02:00
|
|
|
|
|
|
|
// 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' of between one and two
|
|
|
|
// weeks ago.
|
2013-04-13 07:13:08 +02:00
|
|
|
const int64_t nOneWeek = 7*24*60*60;
|
2013-05-07 15:16:25 +02:00
|
|
|
struct in_addr ip;
|
|
|
|
memcpy(&ip, &pnSeed[i], sizeof(ip));
|
|
|
|
CAddress addr(CService(ip, GetDefaultPort()));
|
|
|
|
addr.nTime = GetTime() - GetRand(nOneWeek) - nOneWeek;
|
|
|
|
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;
|
|
|
|
|
|
|
|
|
|
|
|
//
|
2014-12-05 09:25:30 +01:00
|
|
|
// Testnet (v4)
|
2013-05-07 15:16:25 +02:00
|
|
|
//
|
|
|
|
class CTestNetParams : public CMainParams {
|
|
|
|
public:
|
|
|
|
CTestNetParams() {
|
|
|
|
// 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 4-byte int at any alignment.
|
2014-11-28 10:56:02 +01:00
|
|
|
pchMessageStart[0] = 0xce;
|
|
|
|
pchMessageStart[1] = 0xe2;
|
|
|
|
pchMessageStart[2] = 0xca;
|
|
|
|
pchMessageStart[3] = 0xff;
|
|
|
|
|
2014-12-12 23:19:02 +01:00
|
|
|
vAlertPubKey = ParseHex("04517d8a699cb43d3938d7b24faaff7cda448ca4ea267723ba614784de661949bf632d6304316b244646dea079735b9a6fc4af804efb4752075b9fe2245e14e412");
|
2014-11-27 18:09:11 +01:00
|
|
|
nDefaultPort = 19999;
|
|
|
|
nRPCPort = 19998;
|
2014-12-23 16:32:55 +01:00
|
|
|
strDataDir = "testnet3";
|
2013-05-07 15:16:25 +02:00
|
|
|
|
|
|
|
// Modify the testnet genesis block so the timestamp is valid for a later start.
|
2014-12-12 23:19:02 +01:00
|
|
|
genesis.nTime = 1390666206;
|
|
|
|
genesis.nNonce = 3861367235;
|
2014-11-28 10:56:02 +01:00
|
|
|
|
2014-11-28 11:53:08 +01:00
|
|
|
hashGenesisBlock = genesis.GetHash();
|
2014-12-12 23:19:02 +01:00
|
|
|
assert(hashGenesisBlock == uint256("0x00000bafbc94add76cb75e2ec92894837288a481e5c005f6563d91623bf8bc2c"));
|
2013-05-07 15:16:25 +02:00
|
|
|
|
|
|
|
vFixedSeeds.clear();
|
|
|
|
vSeeds.clear();
|
2014-11-27 18:56:59 +01:00
|
|
|
vSeeds.push_back(CDNSSeedData("darkcoin.io", "testnet-seed.darkcoin.io"));
|
|
|
|
vSeeds.push_back(CDNSSeedData("darkcoin.qa", "testnet-seed.darkcoin.qa"));
|
2013-05-07 15:16:25 +02:00
|
|
|
|
2014-12-23 16:32:55 +01:00
|
|
|
base58Prefixes[PUBKEY_ADDRESS] = list_of(111); // Testnet v3 addresses start with x
|
2013-06-23 02:33:47 +02:00
|
|
|
base58Prefixes[SCRIPT_ADDRESS] = list_of(196);
|
2014-12-06 16:42:40 +01:00
|
|
|
base58Prefixes[SECRET_KEY] = list_of(266);
|
2013-07-15 01:05:25 +02:00
|
|
|
base58Prefixes[EXT_PUBLIC_KEY] = list_of(0x04)(0x35)(0x87)(0xCF);
|
|
|
|
base58Prefixes[EXT_SECRET_KEY] = list_of(0x04)(0x35)(0x83)(0x94);
|
2013-05-07 15:16:25 +02:00
|
|
|
}
|
|
|
|
virtual Network NetworkID() const { return CChainParams::TESTNET; }
|
|
|
|
};
|
|
|
|
static CTestNetParams testNetParams;
|
|
|
|
|
|
|
|
|
|
|
|
//
|
2014-12-04 22:24:59 +01:00
|
|
|
// Regression test
|
2013-05-07 15:16:25 +02:00
|
|
|
//
|
|
|
|
class CRegTestParams : public CTestNetParams {
|
|
|
|
public:
|
|
|
|
CRegTestParams() {
|
2014-11-28 10:56:02 +01:00
|
|
|
pchMessageStart[0] = 0xfc;
|
|
|
|
pchMessageStart[1] = 0xc1;
|
|
|
|
pchMessageStart[2] = 0xb7;
|
|
|
|
pchMessageStart[3] = 0xdc;
|
2013-05-07 15:16:25 +02:00
|
|
|
nSubsidyHalvingInterval = 150;
|
|
|
|
bnProofOfWorkLimit = CBigNum(~uint256(0) >> 1);
|
2014-12-04 22:24:59 +01:00
|
|
|
genesis.nTime = 1417713337;
|
2013-05-07 15:16:25 +02:00
|
|
|
genesis.nBits = 0x207fffff;
|
2014-12-04 22:24:59 +01:00
|
|
|
genesis.nNonce = 1096447;
|
2014-11-28 10:56:02 +01:00
|
|
|
nDefaultPort = 19994;
|
2013-05-07 15:16:25 +02:00
|
|
|
strDataDir = "regtest";
|
2014-11-28 10:56:02 +01:00
|
|
|
|
2014-11-29 12:29:14 +01:00
|
|
|
hashGenesisBlock = genesis.GetHash();
|
2014-12-04 22:24:59 +01:00
|
|
|
assert(hashGenesisBlock == uint256("0x000008ca1832a4baf228eb1553c03d3a2c8e02399550dd6ea8d65cec3ef23d2e"));
|
2013-05-07 15:16:25 +02:00
|
|
|
|
|
|
|
vSeeds.clear(); // Regtest mode doesn't have any DNS seeds.
|
|
|
|
}
|
|
|
|
|
|
|
|
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;
|
|
|
|
}
|