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-11-27 18:09:11 +01:00
|
|
|
// Copyright (c) 2014 vertoe & 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;
|
|
|
|
vAlertPubKey = ParseHex("040184710fa689ad5023690c80f3a49c8f13f8d45b8c857fbcbc8bc4a8e4d3eb4b10f4d4604fa08dce601aaf0f470216fe1b51850b4acf21b179c45070ac7b03a9");
|
2014-11-27 18:09:11 +01:00
|
|
|
nDefaultPort = 9999;
|
|
|
|
nRPCPort = 9998;
|
2013-05-07 15:16:25 +02:00
|
|
|
bnProofOfWorkLimit = CBigNum(~uint256(0) >> 32);
|
|
|
|
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;
|
|
|
|
|
|
|
|
/* exit without failure */
|
|
|
|
printf("So far so good... Next: Update X11! \n");
|
|
|
|
exit(0); /* @TODO Debug remove! */
|
2013-05-07 15:16:25 +02: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);
|
|
|
|
base58Prefixes[SECRET_KEY] = list_of(128);
|
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;
|
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
// Testnet (v3)
|
|
|
|
//
|
|
|
|
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;
|
|
|
|
|
|
|
|
vAlertPubKey = ParseHex("040184710fa689ad5023690c80f3a49c8f13f8d45b8c857fbcbc8bc4a8e4d3eb4b10f4d4604fa08dce601aaf0f470216fe1b51850b4acf21b179c45070ac7b03a9");
|
2014-11-27 18:09:11 +01:00
|
|
|
nDefaultPort = 19999;
|
|
|
|
nRPCPort = 19998;
|
2013-05-07 15:16:25 +02:00
|
|
|
strDataDir = "testnet3";
|
|
|
|
|
|
|
|
// Modify the testnet genesis block so the timestamp is valid for a later start.
|
2014-11-28 10:56:02 +01:00
|
|
|
genesis.nTime = 1390666206;
|
|
|
|
genesis.nNonce = 3861367235;
|
|
|
|
|
|
|
|
/* exit without failure */
|
|
|
|
printf("So far so good... Next: Update X11! \n");
|
|
|
|
exit(0); /* @TODO Debug remove! */
|
|
|
|
|
2013-05-07 15:16:25 +02:00
|
|
|
hashGenesisBlock = genesis.GetHash();
|
2014-11-28 10:56: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-11-28 10:56:02 +01:00
|
|
|
base58Prefixes[PUBKEY_ADDRESS] = list_of(138); // Testnet addresses start with x
|
2013-06-23 02:33:47 +02:00
|
|
|
base58Prefixes[SCRIPT_ADDRESS] = list_of(196);
|
|
|
|
base58Prefixes[SECRET_KEY] = list_of(239);
|
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;
|
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
// Regression test
|
|
|
|
//
|
|
|
|
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);
|
|
|
|
genesis.nTime = 1296688602;
|
|
|
|
genesis.nBits = 0x207fffff;
|
|
|
|
genesis.nNonce = 2;
|
|
|
|
hashGenesisBlock = genesis.GetHash();
|
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
|
|
|
|
|
|
|
/* exit without failure */
|
|
|
|
printf("So far so good... Next: Update X11! \n");
|
|
|
|
exit(0); /* @TODO Debug remove! */
|
|
|
|
|
2013-05-07 15:16:25 +02:00
|
|
|
assert(hashGenesisBlock == uint256("0x0f9188f13cb7b2c71f2a335e3a4fc328bf5beb436012afca590b1a11466e2206"));
|
|
|
|
|
|
|
|
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;
|
|
|
|
}
|