2014-06-19 09:10:04 -04:00
// Copyright (c) 2010 Satoshi Nakamoto
2020-12-31 05:48:25 -03:00
// Copyright (c) 2009-2020 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>
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 " ;
2020-03-05 03:58:30 -03:00
const std : : string CBaseChainParams : : SIGNET = " signet " ;
2015-06-30 16:39:49 -03:00
const std : : string CBaseChainParams : : REGTEST = " regtest " ;
2015-05-25 04:00:17 -03:00
2020-07-19 03:31:51 -04:00
void SetupChainParamsBaseOptions ( ArgsManager & argsman )
2015-05-25 04:00:17 -03:00
{
2020-09-25 08:55:40 -03:00
argsman . AddArg ( " -chain=<chain> " , " Use the chain <chain> (default: main). Allowed values: main, test, signet, regtest " , ArgsManager : : ALLOW_ANY , OptionsCategory : : CHAINPARAMS ) ;
2020-07-19 03:47:05 -04:00
argsman . 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 ) ;
2021-08-27 10:53:11 -04:00
argsman . AddArg ( " -testactivationheight=name@height. " , " Set the activation height of 'name' (segwit, bip34, dersig, cltv, csv). (regtest-only) " , ArgsManager : : ALLOW_ANY | ArgsManager : : DEBUG_ONLY , OptionsCategory : : DEBUG_TEST ) ;
2020-07-19 03:47:05 -04:00
argsman . AddArg ( " -testnet " , " Use the test chain. Equivalent to -chain=test. " , ArgsManager : : ALLOW_ANY , OptionsCategory : : CHAINPARAMS ) ;
2021-03-06 05:18:49 -03:00
argsman . AddArg ( " -vbparams=deployment:start:end[:min_activation_height] " , " Use given start/end times and min_activation_height for specified version bits deployment (regtest-only) " , ArgsManager : : ALLOW_ANY | ArgsManager : : DEBUG_ONLY , OptionsCategory : : CHAINPARAMS ) ;
2020-09-25 08:55:40 -03:00
argsman . AddArg ( " -signet " , " Use the signet chain. Equivalent to -chain=signet. Note that the network is defined by the -signetchallenge parameter " , ArgsManager : : ALLOW_ANY , OptionsCategory : : CHAINPARAMS ) ;
2020-03-05 04:51:00 -03:00
argsman . AddArg ( " -signetchallenge " , " Blocks must satisfy the given script to be considered valid (only for signet networks; defaults to the global default signet test network challenge) " , ArgsManager : : ALLOW_STRING , OptionsCategory : : CHAINPARAMS ) ;
argsman . AddArg ( " -signetseednode " , " Specify a seed node for the signet network, in the hostname[:port] format, e.g. sig.net:1234 (may be used multiple times to specify multiple seed nodes; defaults to the global default signet test network seed node(s)) " , ArgsManager : : ALLOW_STRING , 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
}
2020-09-24 15:11:48 -03:00
/**
* Port numbers for incoming Tor connections ( 8334 , 18334 , 38334 , 18445 ) have
* been chosen arbitrarily to keep ranges of used ports tight .
*/
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
{
2020-03-05 03:58:30 -03:00
if ( chain = = CBaseChainParams : : MAIN ) {
2021-03-10 06:28:08 -03:00
return std : : make_unique < CBaseChainParams > ( " " , 8332 , 8334 ) ;
2020-03-05 03:58:30 -03:00
} else if ( chain = = CBaseChainParams : : TESTNET ) {
2021-03-10 06:28:08 -03:00
return std : : make_unique < CBaseChainParams > ( " testnet3 " , 18332 , 18334 ) ;
2020-03-05 03:58:30 -03:00
} else if ( chain = = CBaseChainParams : : SIGNET ) {
2021-03-10 06:28:08 -03:00
return std : : make_unique < CBaseChainParams > ( " signet " , 38332 , 38334 ) ;
2020-03-05 03:58:30 -03:00
} else if ( chain = = CBaseChainParams : : REGTEST ) {
2021-03-10 06:28:08 -03:00
return std : : make_unique < CBaseChainParams > ( " regtest " , 18443 , 18445 ) ;
2020-03-05 03:58:30 -03:00
}
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
}