2014-06-19 09:10:04 -04:00
// Copyright (c) 2010 Satoshi Nakamoto
2019-12-30 06:39:22 -03:00
// Copyright (c) 2009-2019 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>
2018-10-22 19:51:11 -03:00
# include <util/system.h>
# include <util/memory.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
2018-04-28 17:54:58 -03:00
void SetupChainParamsBaseOptions ( )
2015-05-25 04:00:17 -03:00
{
2016-10-13 17:38:10 -03:00
gArgs . AddArg ( " -chain=<chain> " , " Use the chain <chain> (default: main). Allowed values: main, test, regtest " , ArgsManager : : ALLOW_ANY , OptionsCategory : : CHAINPARAMS ) ;
2018-04-28 17:54:58 -03:00
gArgs . AddArg ( " -regtest " , " Enter regression test mode, which uses a special chain in which blocks can be solved instantly. "
2016-10-13 17:38:10 -03:00
" This is intended for regression testing tools and app development. Equivalent to -chain=regtest. " , ArgsManager : : ALLOW_ANY | ArgsManager : : DEBUG_ONLY , OptionsCategory : : CHAINPARAMS ) ;
2019-05-20 14:59:07 -04:00
gArgs . AddArg ( " -segwitheight=<n> " , " Set the activation height of segwit. -1 to disable. (regtest-only) " , ArgsManager : : ALLOW_ANY | ArgsManager : : DEBUG_ONLY , OptionsCategory : : DEBUG_TEST ) ;
2016-10-13 17:38:10 -03:00
gArgs . AddArg ( " -testnet " , " Use the test chain. Equivalent to -chain=test. " , ArgsManager : : ALLOW_ANY , OptionsCategory : : CHAINPARAMS ) ;
scripted-diff: Use ArgsManager::DEBUG_ONLY flag
-BEGIN VERIFY SCRIPT-
sed -i 's/unsigned int flags, const bool debug_only,/unsigned int flags,/' src/util/system.h src/util/system.cpp
sed -i 's/ArgsManager::NONE, debug_only/flags, false/' src/util/system.cpp
sed -i 's/arg.second.m_debug_only/(arg.second.m_flags \& ArgsManager::DEBUG_ONLY)/' src/util/system.cpp
sed -i 's/ArgsManager::ALLOW_ANY, true, OptionsCategory::/ArgsManager::ALLOW_ANY | ArgsManager::DEBUG_ONLY, OptionsCategory::/' $(git grep --files-with-matches 'AddArg(' src)
sed -i 's/ArgsManager::ALLOW_ANY, false, OptionsCategory::/ArgsManager::ALLOW_ANY, OptionsCategory::/' $(git grep --files-with-matches 'AddArg(' src)
-END VERIFY SCRIPT-
2019-07-27 05:06:32 -04:00
gArgs . AddArg ( " -vbparams=deployment:start:end " , " Use given start/end times for specified version bits deployment (regtest-only) " , ArgsManager : : ALLOW_ANY | ArgsManager : : DEBUG_ONLY , OptionsCategory : : CHAINPARAMS ) ;
2015-05-25 04:00:17 -03:00
}
2015-06-30 16:39:49 -03:00
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 )
2017-12-11 22:32:44 -03:00
return MakeUnique < CBaseChainParams > ( " " , 8332 ) ;
2015-06-30 16:39:49 -03:00
else if ( chain = = CBaseChainParams : : TESTNET )
2017-12-11 22:32:44 -03:00
return MakeUnique < CBaseChainParams > ( " testnet3 " , 18332 ) ;
2015-06-30 16:39:49 -03:00
else if ( chain = = CBaseChainParams : : REGTEST )
2017-12-11 22:32:44 -03:00
return MakeUnique < CBaseChainParams > ( " regtest " , 18443 ) ;
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 ) ;
2018-04-04 05:03:00 -03:00
gArgs . SelectConfigNetwork ( chain ) ;
2015-06-27 16:21:41 -03:00
}