2014-06-19 15:10:04 +02:00
// Copyright (c) 2010 Satoshi Nakamoto
2020-12-31 09:48:25 +01:00
// Copyright (c) 2009-2020 The Bitcoin Core developers
2014-10-25 17:24:16 +08:00
// Distributed under the MIT software license, see the accompanying
2014-06-19 15:10:04 +02:00
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
2017-11-10 13:57:53 +13:00
# include <chainparamsbase.h>
2014-06-19 15:10:04 +02:00
2017-11-10 13:57:53 +13:00
# include <tinyformat.h>
2018-10-22 15:51:11 -07:00
# include <util/system.h>
2014-06-19 15:10:04 +02:00
2014-08-28 22:56:53 +02:00
# include <assert.h>
2015-06-30 21:39:49 +02:00
const std : : string CBaseChainParams : : MAIN = " main " ;
const std : : string CBaseChainParams : : TESTNET = " test " ;
2020-03-05 15:58:30 +09:00
const std : : string CBaseChainParams : : SIGNET = " signet " ;
2015-06-30 21:39:49 +02:00
const std : : string CBaseChainParams : : REGTEST = " regtest " ;
2015-05-25 09:00:17 +02:00
2020-07-19 14:31:51 +07:00
void SetupChainParamsBaseOptions ( ArgsManager & argsman )
2015-05-25 09:00:17 +02:00
{
2020-09-25 14: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 14:47:05 +07:00
argsman . AddArg ( " -regtest " , " Enter regression test mode, which uses a special chain in which blocks can be solved instantly. "
2016-10-13 22:38:10 +02: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 16:53:11 +02: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 14:47:05 +07:00
argsman . AddArg ( " -testnet " , " Use the test chain. Equivalent to -chain=test. " , ArgsManager : : ALLOW_ANY , OptionsCategory : : CHAINPARAMS ) ;
2021-03-06 18:18:49 +10: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 14: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 16:51:00 +09: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 09:00:17 +02:00
}
2015-06-30 21:39:49 +02:00
2015-05-22 03:50:01 +02:00
static std : : unique_ptr < CBaseChainParams > globalChainBaseParams ;
2014-06-19 15:10:04 +02:00
2014-09-19 19:21:46 +02:00
const CBaseChainParams & BaseParams ( )
{
2015-05-22 03:50:01 +02:00
assert ( globalChainBaseParams ) ;
return * globalChainBaseParams ;
2014-06-19 15:10:04 +02:00
}
2020-09-24 21: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-22 03:50:01 +02:00
std : : unique_ptr < CBaseChainParams > CreateBaseChainParams ( const std : : string & chain )
2014-09-19 19:21:46 +02:00
{
2020-03-05 15:58:30 +09:00
if ( chain = = CBaseChainParams : : MAIN ) {
2021-03-10 17:28:08 +08:00
return std : : make_unique < CBaseChainParams > ( " " , 8332 , 8334 ) ;
2020-03-05 15:58:30 +09:00
} else if ( chain = = CBaseChainParams : : TESTNET ) {
2021-03-10 17:28:08 +08:00
return std : : make_unique < CBaseChainParams > ( " testnet3 " , 18332 , 18334 ) ;
2020-03-05 15:58:30 +09:00
} else if ( chain = = CBaseChainParams : : SIGNET ) {
2021-03-10 17:28:08 +08:00
return std : : make_unique < CBaseChainParams > ( " signet " , 38332 , 38334 ) ;
2020-03-05 15:58:30 +09:00
} else if ( chain = = CBaseChainParams : : REGTEST ) {
2021-03-10 17:28:08 +08:00
return std : : make_unique < CBaseChainParams > ( " regtest " , 18443 , 18445 ) ;
2020-03-05 15:58:30 +09:00
}
throw std : : runtime_error ( strprintf ( " %s: Unknown chain %s. " , __func__ , chain ) ) ;
2014-06-19 15:10:04 +02:00
}
2015-06-27 19:21:41 +00:00
void SelectBaseParams ( const std : : string & chain )
{
2015-05-22 03:50:01 +02:00
globalChainBaseParams = CreateBaseChainParams ( chain ) ;
2018-04-04 18:03:00 +10:00
gArgs . SelectConfigNetwork ( chain ) ;
2015-06-27 19:21:41 +00:00
}