2014-06-19 15:10:04 +02:00
|
|
|
// Copyright (c) 2010 Satoshi Nakamoto
|
2014-12-17 02:47:57 +01:00
|
|
|
// Copyright (c) 2009-2014 The Bitcoin Core developers
|
2014-10-25 11:24:16 +02:00
|
|
|
// Distributed under the MIT software license, see the accompanying
|
2014-06-19 15:10:04 +02:00
|
|
|
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
|
|
|
|
|
|
|
#include "chainparamsbase.h"
|
|
|
|
|
|
|
|
#include "util.h"
|
|
|
|
|
2014-08-28 22:56:53 +02:00
|
|
|
#include <assert.h>
|
|
|
|
|
2014-10-25 11:24:16 +02:00
|
|
|
/**
|
|
|
|
* Main network
|
|
|
|
*/
|
2014-09-19 19:21:46 +02:00
|
|
|
class CBaseMainParams : public CBaseChainParams
|
|
|
|
{
|
2014-06-19 15:10:04 +02:00
|
|
|
public:
|
2014-09-19 19:21:46 +02:00
|
|
|
CBaseMainParams()
|
|
|
|
{
|
2014-06-19 15:10:04 +02:00
|
|
|
nRPCPort = 8332;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
static CBaseMainParams mainParams;
|
|
|
|
|
2014-10-25 11:24:16 +02:00
|
|
|
/**
|
|
|
|
* Testnet (v3)
|
|
|
|
*/
|
2015-07-03 14:30:18 +02:00
|
|
|
class CBaseTestNetParams : public CBaseChainParams
|
2014-09-19 19:21:46 +02:00
|
|
|
{
|
2014-06-19 15:10:04 +02:00
|
|
|
public:
|
2014-09-19 19:21:46 +02:00
|
|
|
CBaseTestNetParams()
|
|
|
|
{
|
2014-06-19 15:10:04 +02:00
|
|
|
nRPCPort = 18332;
|
|
|
|
strDataDir = "testnet3";
|
|
|
|
}
|
|
|
|
};
|
|
|
|
static CBaseTestNetParams testNetParams;
|
|
|
|
|
2014-10-25 11:24:16 +02:00
|
|
|
/*
|
|
|
|
* Regression test
|
|
|
|
*/
|
2015-07-03 14:30:18 +02:00
|
|
|
class CBaseRegTestParams : public CBaseChainParams
|
2014-09-19 19:21:46 +02:00
|
|
|
{
|
2014-06-19 15:10:04 +02:00
|
|
|
public:
|
2014-09-19 19:21:46 +02:00
|
|
|
CBaseRegTestParams()
|
|
|
|
{
|
2015-07-03 14:30:18 +02:00
|
|
|
nRPCPort = 18332;
|
2014-06-19 15:10:04 +02:00
|
|
|
strDataDir = "regtest";
|
|
|
|
}
|
|
|
|
};
|
|
|
|
static CBaseRegTestParams regTestParams;
|
|
|
|
|
2014-10-25 11:24:16 +02:00
|
|
|
/*
|
|
|
|
* Unit test
|
|
|
|
*/
|
2014-09-04 21:23:42 +02:00
|
|
|
class CBaseUnitTestParams : public CBaseMainParams
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
CBaseUnitTestParams()
|
|
|
|
{
|
|
|
|
strDataDir = "unittest";
|
|
|
|
}
|
|
|
|
};
|
|
|
|
static CBaseUnitTestParams unitTestParams;
|
|
|
|
|
2014-09-19 19:21:46 +02:00
|
|
|
static CBaseChainParams* pCurrentBaseParams = 0;
|
2014-06-19 15:10:04 +02:00
|
|
|
|
2014-09-19 19:21:46 +02:00
|
|
|
const CBaseChainParams& BaseParams()
|
|
|
|
{
|
2014-06-19 15:10:04 +02:00
|
|
|
assert(pCurrentBaseParams);
|
|
|
|
return *pCurrentBaseParams;
|
|
|
|
}
|
|
|
|
|
2014-09-19 19:21:46 +02:00
|
|
|
void SelectBaseParams(CBaseChainParams::Network network)
|
|
|
|
{
|
2014-06-19 15:10:04 +02:00
|
|
|
switch (network) {
|
2014-09-19 19:21:46 +02:00
|
|
|
case CBaseChainParams::MAIN:
|
|
|
|
pCurrentBaseParams = &mainParams;
|
|
|
|
break;
|
|
|
|
case CBaseChainParams::TESTNET:
|
|
|
|
pCurrentBaseParams = &testNetParams;
|
|
|
|
break;
|
|
|
|
case CBaseChainParams::REGTEST:
|
|
|
|
pCurrentBaseParams = ®TestParams;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
assert(false && "Unimplemented network");
|
|
|
|
return;
|
2014-06-19 15:10:04 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-10-09 19:15:38 +02:00
|
|
|
CBaseChainParams::Network NetworkIdFromCommandLine()
|
2014-09-19 19:21:46 +02:00
|
|
|
{
|
2014-06-19 15:10:04 +02:00
|
|
|
bool fRegTest = GetBoolArg("-regtest", false);
|
|
|
|
bool fTestNet = GetBoolArg("-testnet", false);
|
|
|
|
|
2014-09-01 00:41:28 +02:00
|
|
|
if (fTestNet && fRegTest)
|
2014-10-09 19:15:38 +02:00
|
|
|
return CBaseChainParams::MAX_NETWORK_TYPES;
|
2014-09-01 00:41:28 +02:00
|
|
|
if (fRegTest)
|
2014-10-09 19:15:38 +02:00
|
|
|
return CBaseChainParams::REGTEST;
|
2014-09-01 00:41:28 +02:00
|
|
|
if (fTestNet)
|
2014-10-09 19:15:38 +02:00
|
|
|
return CBaseChainParams::TESTNET;
|
|
|
|
return CBaseChainParams::MAIN;
|
2014-09-01 00:41:28 +02:00
|
|
|
}
|
|
|
|
|
2014-10-16 22:49:33 +02:00
|
|
|
bool SelectBaseParamsFromCommandLine()
|
2014-09-01 00:41:28 +02:00
|
|
|
{
|
2014-10-09 19:15:38 +02:00
|
|
|
CBaseChainParams::Network network = NetworkIdFromCommandLine();
|
2014-09-01 00:41:28 +02:00
|
|
|
if (network == CBaseChainParams::MAX_NETWORK_TYPES)
|
2014-06-19 15:10:04 +02:00
|
|
|
return false;
|
|
|
|
|
2014-09-01 00:41:28 +02:00
|
|
|
SelectBaseParams(network);
|
2014-06-19 15:10:04 +02:00
|
|
|
return true;
|
|
|
|
}
|
2014-07-15 10:22:27 +02:00
|
|
|
|
2014-09-19 19:21:46 +02:00
|
|
|
bool AreBaseParamsConfigured()
|
|
|
|
{
|
2014-07-15 10:22:27 +02:00
|
|
|
return pCurrentBaseParams != NULL;
|
|
|
|
}
|