2014-06-19 09:10:04 -04:00
|
|
|
// Copyright (c) 2010 Satoshi Nakamoto
|
2015-12-13 13:58:29 -03:00
|
|
|
// Copyright (c) 2009-2015 The Bitcoin Core developers
|
2014-10-25 06:24:16 -03:00
|
|
|
// Distributed under the MIT software license, see the accompanying
|
2014-06-19 09:10:04 -04:00
|
|
|
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
|
|
|
|
2017-11-09 21:57:53 -03:00
|
|
|
#include <chainparamsbase.h>
|
2014-06-19 09:10:04 -04:00
|
|
|
|
2017-11-09 21:57:53 -03:00
|
|
|
#include <tinyformat.h>
|
|
|
|
#include <util.h>
|
2014-06-19 09:10:04 -04:00
|
|
|
|
2014-08-28 16:56:53 -04:00
|
|
|
#include <assert.h>
|
|
|
|
|
2015-06-30 16:39:49 -03:00
|
|
|
const std::string CBaseChainParams::MAIN = "main";
|
|
|
|
const std::string CBaseChainParams::TESTNET = "test";
|
|
|
|
const std::string CBaseChainParams::REGTEST = "regtest";
|
2015-05-25 04:00:17 -03:00
|
|
|
|
|
|
|
void AppendParamsHelpMessages(std::string& strUsage, bool debugHelp)
|
|
|
|
{
|
|
|
|
strUsage += HelpMessageGroup(_("Chain selection options:"));
|
|
|
|
strUsage += HelpMessageOpt("-testnet", _("Use the test chain"));
|
|
|
|
if (debugHelp) {
|
|
|
|
strUsage += HelpMessageOpt("-regtest", "Enter regression test mode, which uses a special chain in which blocks can be solved instantly. "
|
|
|
|
"This is intended for regression testing tools and app development.");
|
|
|
|
}
|
|
|
|
}
|
2015-06-30 16:39:49 -03:00
|
|
|
|
2014-10-25 06:24:16 -03:00
|
|
|
/**
|
|
|
|
* Main network
|
|
|
|
*/
|
2014-09-19 14:21:46 -03:00
|
|
|
class CBaseMainParams : public CBaseChainParams
|
|
|
|
{
|
2014-06-19 09:10:04 -04:00
|
|
|
public:
|
2014-09-19 14:21:46 -03:00
|
|
|
CBaseMainParams()
|
|
|
|
{
|
2014-06-19 09:10:04 -04:00
|
|
|
nRPCPort = 8332;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2014-10-25 06:24:16 -03:00
|
|
|
/**
|
|
|
|
* Testnet (v3)
|
|
|
|
*/
|
2015-07-03 09:30:18 -03:00
|
|
|
class CBaseTestNetParams : public CBaseChainParams
|
2014-09-19 14:21:46 -03:00
|
|
|
{
|
2014-06-19 09:10:04 -04:00
|
|
|
public:
|
2014-09-19 14:21:46 -03:00
|
|
|
CBaseTestNetParams()
|
|
|
|
{
|
2014-06-19 09:10:04 -04:00
|
|
|
nRPCPort = 18332;
|
|
|
|
strDataDir = "testnet3";
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2014-10-25 06:24:16 -03:00
|
|
|
/*
|
|
|
|
* Regression test
|
|
|
|
*/
|
2015-07-03 09:30:18 -03:00
|
|
|
class CBaseRegTestParams : public CBaseChainParams
|
2014-09-19 14:21:46 -03:00
|
|
|
{
|
2014-06-19 09:10:04 -04:00
|
|
|
public:
|
2014-09-19 14:21:46 -03:00
|
|
|
CBaseRegTestParams()
|
|
|
|
{
|
2017-07-14 10:47:10 -04:00
|
|
|
nRPCPort = 18443;
|
2014-06-19 09:10:04 -04:00
|
|
|
strDataDir = "regtest";
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2015-05-21 22:50:01 -03:00
|
|
|
static std::unique_ptr<CBaseChainParams> globalChainBaseParams;
|
2014-06-19 09:10:04 -04:00
|
|
|
|
2014-09-19 14:21:46 -03:00
|
|
|
const CBaseChainParams& BaseParams()
|
|
|
|
{
|
2015-05-21 22:50:01 -03:00
|
|
|
assert(globalChainBaseParams);
|
|
|
|
return *globalChainBaseParams;
|
2014-06-19 09:10:04 -04:00
|
|
|
}
|
|
|
|
|
2015-05-21 22:50:01 -03:00
|
|
|
std::unique_ptr<CBaseChainParams> CreateBaseChainParams(const std::string& chain)
|
2014-09-19 14:21:46 -03:00
|
|
|
{
|
2015-06-30 16:39:49 -03:00
|
|
|
if (chain == CBaseChainParams::MAIN)
|
2015-05-21 22:50:01 -03:00
|
|
|
return std::unique_ptr<CBaseChainParams>(new CBaseMainParams());
|
2015-06-30 16:39:49 -03:00
|
|
|
else if (chain == CBaseChainParams::TESTNET)
|
2015-05-21 22:50:01 -03:00
|
|
|
return std::unique_ptr<CBaseChainParams>(new CBaseTestNetParams());
|
2015-06-30 16:39:49 -03:00
|
|
|
else if (chain == CBaseChainParams::REGTEST)
|
2015-05-21 22:50:01 -03:00
|
|
|
return std::unique_ptr<CBaseChainParams>(new CBaseRegTestParams());
|
2015-06-30 16:39:49 -03:00
|
|
|
else
|
|
|
|
throw std::runtime_error(strprintf("%s: Unknown chain %s.", __func__, chain));
|
2014-06-19 09:10:04 -04:00
|
|
|
}
|
|
|
|
|
2015-06-27 16:21:41 -03:00
|
|
|
void SelectBaseParams(const std::string& chain)
|
|
|
|
{
|
2015-05-21 22:50:01 -03:00
|
|
|
globalChainBaseParams = CreateBaseChainParams(chain);
|
2015-06-27 16:21:41 -03:00
|
|
|
}
|
|
|
|
|
2015-06-30 16:39:49 -03:00
|
|
|
std::string ChainNameFromCommandLine()
|
2014-09-19 14:21:46 -03:00
|
|
|
{
|
2017-08-01 15:17:40 -04:00
|
|
|
bool fRegTest = gArgs.GetBoolArg("-regtest", false);
|
|
|
|
bool fTestNet = gArgs.GetBoolArg("-testnet", false);
|
2014-06-19 09:10:04 -04:00
|
|
|
|
2014-08-31 18:41:28 -04:00
|
|
|
if (fTestNet && fRegTest)
|
2015-05-25 04:00:17 -03:00
|
|
|
throw std::runtime_error("Invalid combination of -regtest and -testnet.");
|
2014-08-31 18:41:28 -04:00
|
|
|
if (fRegTest)
|
2014-10-09 14:15:38 -03:00
|
|
|
return CBaseChainParams::REGTEST;
|
2014-08-31 18:41:28 -04:00
|
|
|
if (fTestNet)
|
2014-10-09 14:15:38 -03:00
|
|
|
return CBaseChainParams::TESTNET;
|
|
|
|
return CBaseChainParams::MAIN;
|
2014-08-31 18:41:28 -04:00
|
|
|
}
|