2014-06-19 09:10:04 -04:00
|
|
|
// Copyright (c) 2010 Satoshi Nakamoto
|
2018-01-02 12:12:05 -05:00
|
|
|
// Copyright (c) 2009-2017 The Bitcoin Core developers
|
2014-10-25 05:24:16 -04: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 19:57:53 -05:00
|
|
|
#include <chainparamsbase.h>
|
2014-06-19 09:10:04 -04:00
|
|
|
|
2017-11-09 19:57:53 -05: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 15:39:49 -04:00
|
|
|
const std::string CBaseChainParams::MAIN = "main";
|
|
|
|
|
const std::string CBaseChainParams::TESTNET = "test";
|
|
|
|
|
const std::string CBaseChainParams::REGTEST = "regtest";
|
2015-05-25 03:00:17 -04:00
|
|
|
|
|
|
|
|
void AppendParamsHelpMessages(std::string& strUsage, bool debugHelp)
|
|
|
|
|
{
|
|
|
|
|
strUsage += HelpMessageGroup(_("Chain selection options:"));
|
|
|
|
|
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.");
|
|
|
|
|
}
|
2018-02-02 02:19:41 -05:00
|
|
|
strUsage += HelpMessageOpt("-testnet", _("Use the test chain"));
|
2015-05-25 03:00:17 -04:00
|
|
|
}
|
2015-06-30 15:39:49 -04:00
|
|
|
|
2015-05-21 21:50:01 -04:00
|
|
|
static std::unique_ptr<CBaseChainParams> globalChainBaseParams;
|
2014-06-19 09:10:04 -04:00
|
|
|
|
2014-09-19 13:21:46 -04:00
|
|
|
const CBaseChainParams& BaseParams()
|
|
|
|
|
{
|
2015-05-21 21:50:01 -04:00
|
|
|
assert(globalChainBaseParams);
|
|
|
|
|
return *globalChainBaseParams;
|
2014-06-19 09:10:04 -04:00
|
|
|
}
|
|
|
|
|
|
2015-05-21 21:50:01 -04:00
|
|
|
std::unique_ptr<CBaseChainParams> CreateBaseChainParams(const std::string& chain)
|
2014-09-19 13:21:46 -04:00
|
|
|
{
|
2015-06-30 15:39:49 -04:00
|
|
|
if (chain == CBaseChainParams::MAIN)
|
2017-12-11 20:32:44 -05:00
|
|
|
return MakeUnique<CBaseChainParams>("", 8332);
|
2015-06-30 15:39:49 -04:00
|
|
|
else if (chain == CBaseChainParams::TESTNET)
|
2017-12-11 20:32:44 -05:00
|
|
|
return MakeUnique<CBaseChainParams>("testnet3", 18332);
|
2015-06-30 15:39:49 -04:00
|
|
|
else if (chain == CBaseChainParams::REGTEST)
|
2017-12-11 20:32:44 -05:00
|
|
|
return MakeUnique<CBaseChainParams>("regtest", 18443);
|
2015-06-30 15:39:49 -04:00
|
|
|
else
|
|
|
|
|
throw std::runtime_error(strprintf("%s: Unknown chain %s.", __func__, chain));
|
2014-06-19 09:10:04 -04:00
|
|
|
}
|
|
|
|
|
|
2015-06-27 15:21:41 -04:00
|
|
|
void SelectBaseParams(const std::string& chain)
|
|
|
|
|
{
|
2015-05-21 21:50:01 -04:00
|
|
|
globalChainBaseParams = CreateBaseChainParams(chain);
|
2015-06-27 15:21:41 -04:00
|
|
|
}
|