2019-12-30 06:39:22 -03:00
|
|
|
// Copyright (c) 2014-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.
|
|
|
|
|
2014-11-03 12:16:40 -03:00
|
|
|
#ifndef BITCOIN_CHAINPARAMSBASE_H
|
|
|
|
#define BITCOIN_CHAINPARAMSBASE_H
|
2014-06-19 09:10:04 -04:00
|
|
|
|
2015-05-21 22:50:01 -03:00
|
|
|
#include <memory>
|
2014-06-19 09:10:04 -04:00
|
|
|
#include <string>
|
|
|
|
|
2020-07-19 03:31:51 -04:00
|
|
|
class ArgsManager;
|
|
|
|
|
2014-06-19 09:10:04 -04:00
|
|
|
/**
|
|
|
|
* CBaseChainParams defines the base parameters (shared between bitcoin-cli and bitcoind)
|
|
|
|
* of a given instance of the Bitcoin system.
|
|
|
|
*/
|
|
|
|
class CBaseChainParams
|
|
|
|
{
|
|
|
|
public:
|
2019-10-28 14:33:40 -03:00
|
|
|
///@{
|
|
|
|
/** Chain name strings */
|
2015-06-30 16:39:49 -03:00
|
|
|
static const std::string MAIN;
|
|
|
|
static const std::string TESTNET;
|
2020-03-05 03:58:30 -03:00
|
|
|
static const std::string SIGNET;
|
2015-06-30 16:39:49 -03:00
|
|
|
static const std::string REGTEST;
|
2019-10-28 14:33:40 -03:00
|
|
|
///@}
|
2014-06-19 09:10:04 -04:00
|
|
|
|
|
|
|
const std::string& DataDir() const { return strDataDir; }
|
|
|
|
int RPCPort() const { return nRPCPort; }
|
2020-09-24 15:11:48 -03:00
|
|
|
uint16_t OnionServiceTargetPort() const { return m_onion_service_target_port; }
|
2014-09-19 14:21:46 -03:00
|
|
|
|
2017-12-11 22:32:44 -03:00
|
|
|
CBaseChainParams() = delete;
|
2020-09-24 15:11:48 -03:00
|
|
|
CBaseChainParams(const std::string& data_dir, int rpc_port, uint16_t onion_service_target_port)
|
|
|
|
: nRPCPort(rpc_port), m_onion_service_target_port(onion_service_target_port), strDataDir(data_dir) {}
|
2014-06-19 09:10:04 -04:00
|
|
|
|
2017-12-11 22:32:44 -03:00
|
|
|
private:
|
2014-06-19 09:10:04 -04:00
|
|
|
int nRPCPort;
|
2020-09-24 15:11:48 -03:00
|
|
|
const uint16_t m_onion_service_target_port;
|
2014-06-19 09:10:04 -04:00
|
|
|
std::string strDataDir;
|
|
|
|
};
|
|
|
|
|
2015-05-21 22:50:01 -03:00
|
|
|
/**
|
|
|
|
* Creates and returns a std::unique_ptr<CBaseChainParams> of the chosen chain.
|
|
|
|
* @returns a CBaseChainParams* of the chosen chain.
|
|
|
|
* @throws a std::runtime_error if the chain is not supported.
|
|
|
|
*/
|
|
|
|
std::unique_ptr<CBaseChainParams> CreateBaseChainParams(const std::string& chain);
|
|
|
|
|
2015-05-25 04:00:17 -03:00
|
|
|
/**
|
2018-04-28 17:54:58 -03:00
|
|
|
*Set the arguments for chainparams
|
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
|
|
|
|
2014-06-19 09:10:04 -04:00
|
|
|
/**
|
2015-04-28 11:48:28 -03:00
|
|
|
* Return the currently selected parameters. This won't change after app
|
|
|
|
* startup, except for unit tests.
|
2014-06-19 09:10:04 -04:00
|
|
|
*/
|
2014-09-19 14:21:46 -03:00
|
|
|
const CBaseChainParams& BaseParams();
|
2014-06-19 09:10:04 -04:00
|
|
|
|
|
|
|
/** Sets the params returned by Params() to those for the given network. */
|
2015-06-30 16:39:49 -03:00
|
|
|
void SelectBaseParams(const std::string& chain);
|
2014-06-19 09:10:04 -04:00
|
|
|
|
2014-11-03 12:16:40 -03:00
|
|
|
#endif // BITCOIN_CHAINPARAMSBASE_H
|