2014-06-19 15:10:04 +02:00
// Copyright (c) 2010 Satoshi Nakamoto
2018-07-26 18:36:45 -04:00
// Copyright (c) 2009-2018 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>
# include <util.h>
2018-07-12 00:39:40 -04:00
# include <utilmemory.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 " ;
const std : : string CBaseChainParams : : REGTEST = " regtest " ;
2015-05-25 09:00:17 +02:00
2018-04-28 16:54:58 -04:00
void SetupChainParamsBaseOptions ( )
2015-05-25 09:00:17 +02:00
{
2016-10-21 19:15:26 +02:00
gArgs . AddArg ( " -chain=<chain> " , " Use the chain <chain> (default: main). Reserved values: main, test, regtest " , false , OptionsCategory : : CHAINPARAMS ) ;
2018-04-28 16:54:58 -04: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 18:49:44 +02:00
gArgs . AddArg ( " -testnet " , " Use the test chain " , false , OptionsCategory : : CHAINPARAMS ) ;
2016-10-21 19:15:26 +02:00
gArgs . AddArg ( " -vbparams=deployment:start:end " , " Use given start/end times for specified version bits deployment (regtest or custom only) " , true , OptionsCategory : : CHAINPARAMS ) ;
gArgs . AddArg ( " -seednode=<ip> " , " Use specified node as seed node. This option can be specified multiple times to connect to multiple nodes. (custom only) " , true , OptionsCategory : : CHAINPARAMS ) ;
2018-11-09 12:20:05 +00:00
gArgs . AddArg ( " -con_mandatorycoinbase " , " All non-zero valued coinbase outputs must go to this scriptPubKey, if set. " , false , OptionsCategory : : ELEMENTS ) ;
gArgs . AddArg ( " -con_blocksubsidy " , " Defines the amount of block subsidy to start with, at genesis block. " , false , OptionsCategory : : ELEMENTS ) ;
gArgs . AddArg ( " -con_connect_coinbase " , " Connect outputs in genesis block to utxo database. " , false , OptionsCategory : : ELEMENTS ) ;
2018-10-12 14:47:35 -04:00
gArgs . AddArg ( " -con_blockheightinheader " , " Whether the chain includes the block height directly in the header, for easier validation of block height in low-resource environments. (default: true) " , false , OptionsCategory : : CHAINPARAMS ) ;
2018-12-11 10:44:05 -05:00
gArgs . AddArg ( " -con_genesis_style=<style> " , " Use genesis style <style> (default: elements). Results in genesis block compatibility with various networks. Allowed values: elements, bitcoin " , true , OptionsCategory : : ELEMENTS ) ;
2018-12-05 20:31:36 +01:00
gArgs . AddArg ( " -con_signed_blocks " , " Signed blockchain. Uses input of `-signblockscript` to define what signatures are necessary to solve it. " , false , OptionsCategory : : CHAINPARAMS ) ;
gArgs . AddArg ( " -signblockscript " , " Signed blockchain enumberance. Only active when `-con_signed_blocks` set to true. " , false , OptionsCategory : : CHAINPARAMS ) ;
gArgs . AddArg ( " -con_max_block_sig_size " , " Max allowed witness data for the signed block header. " , false , OptionsCategory : : CHAINPARAMS ) ;
2018-12-11 12:38:46 +01:00
gArgs . AddArg ( " -con_has_parent_chain " , " Whether or not there is a parent chain. " , false , OptionsCategory : : CHAINPARAMS ) ;
gArgs . AddArg ( " -parentgenesisblockhash " , " The genesis blockhash of the parent chain. " , false , OptionsCategory : : CHAINPARAMS ) ;
gArgs . AddArg ( " -con_parentpowlimit " , " The proof-of-work limit value for the parent chain. " , false , OptionsCategory : : CHAINPARAMS ) ;
2018-12-20 12:32:29 +01:00
gArgs . AddArg ( " -con_parent_chain_signblockscript " , " Whether parent chain uses pow or signed blocks. If the parent chain uses signed blocks, the challenge (scriptPubKey) script. If not, an empty string. (default: empty script [ie parent uses pow]) " , false , OptionsCategory : : CHAINPARAMS ) ;
2018-12-11 12:38:46 +01:00
gArgs . AddArg ( " -fedpegscript " , " The script for the federated peg. " , false , 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
}
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
{
2015-06-30 21:39:49 +02:00
if ( chain = = CBaseChainParams : : MAIN )
2018-12-11 13:18:46 +01:00
return MakeUnique < CBaseChainParams > ( " " , 8332 , 18332 ) ;
2015-06-30 21:39:49 +02:00
else if ( chain = = CBaseChainParams : : TESTNET )
2018-12-11 13:18:46 +01:00
return MakeUnique < CBaseChainParams > ( " testnet3 " , 18332 , 8332 ) ;
2015-06-30 21:39:49 +02:00
else if ( chain = = CBaseChainParams : : REGTEST )
2018-12-11 13:18:46 +01:00
return MakeUnique < CBaseChainParams > ( " regtest " , 18443 , 18332 ) ;
2016-10-21 19:15:26 +02:00
2018-12-11 13:18:46 +01:00
// ELEMENTS:
return MakeUnique < CBaseChainParams > ( chain , 7041 , 18332 ) ;
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
}