2014-06-19 06:10:04 -07:00
// Copyright (c) 2010 Satoshi Nakamoto
2018-07-26 15:36:45 -07:00
// Copyright (c) 2009-2018 The Bitcoin Core developers
2014-10-25 02:24:16 -07:00
// Distributed under the MIT software license, see the accompanying
2014-06-19 06:10:04 -07:00
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
2017-11-09 16:57:53 -08:00
# include <chainparamsbase.h>
2014-06-19 06:10:04 -07:00
2017-11-09 16:57:53 -08:00
# include <tinyformat.h>
# include <util.h>
2018-07-11 21:39:40 -07:00
# include <utilmemory.h>
2014-06-19 06:10:04 -07:00
2014-08-28 13:56:53 -07:00
# include <assert.h>
2015-06-30 12:39:49 -07:00
const std : : string CBaseChainParams : : MAIN = " main " ;
const std : : string CBaseChainParams : : TESTNET = " test " ;
const std : : string CBaseChainParams : : REGTEST = " regtest " ;
2015-05-25 00:00:17 -07:00
2018-04-28 13:54:58 -07:00
void SetupChainParamsBaseOptions ( )
2015-05-25 00:00:17 -07:00
{
2018-04-28 13:54:58 -07:00
gArgs . AddArg ( " -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. " , true , OptionsCategory : : CHAINPARAMS ) ;
2018-05-29 09:49:44 -07:00
gArgs . AddArg ( " -testnet " , " Use the test chain " , false , OptionsCategory : : CHAINPARAMS ) ;
2018-06-16 13:38:13 -07:00
gArgs . AddArg ( " -vbparams=deployment:start:end " , " Use given start/end times for specified version bits deployment (regtest-only) " , true , OptionsCategory : : CHAINPARAMS ) ;
2015-05-25 00:00:17 -07:00
}
2015-06-30 12:39:49 -07:00
2015-05-21 18:50:01 -07:00
static std : : unique_ptr < CBaseChainParams > globalChainBaseParams ;
2014-06-19 06:10:04 -07:00
2014-09-19 10:21:46 -07:00
const CBaseChainParams & BaseParams ( )
{
2015-05-21 18:50:01 -07:00
assert ( globalChainBaseParams ) ;
return * globalChainBaseParams ;
2014-06-19 06:10:04 -07:00
}
2015-05-21 18:50:01 -07:00
std : : unique_ptr < CBaseChainParams > CreateBaseChainParams ( const std : : string & chain )
2014-09-19 10:21:46 -07:00
{
2015-06-30 12:39:49 -07:00
if ( chain = = CBaseChainParams : : MAIN )
2018-07-20 20:54:39 -07:00
return MakeUnique < CBaseChainParams > ( " " , 7932 ) ;
2015-06-30 12:39:49 -07:00
else if ( chain = = CBaseChainParams : : TESTNET )
2018-07-20 20:54:39 -07:00
return MakeUnique < CBaseChainParams > ( " testnet " , 17932 ) ;
2015-06-30 12:39:49 -07:00
else if ( chain = = CBaseChainParams : : REGTEST )
2018-07-20 20:54:39 -07:00
return MakeUnique < CBaseChainParams > ( " regtest " , 17443 ) ;
2015-06-30 12:39:49 -07:00
else
throw std : : runtime_error ( strprintf ( " %s: Unknown chain %s. " , __func__ , chain ) ) ;
2014-06-19 06:10:04 -07:00
}
2015-06-27 12:21:41 -07:00
void SelectBaseParams ( const std : : string & chain )
{
2015-05-21 18:50:01 -07:00
globalChainBaseParams = CreateBaseChainParams ( chain ) ;
2018-04-04 01:03:00 -07:00
gArgs . SelectConfigNetwork ( chain ) ;
2015-06-27 12:21:41 -07:00
}