1 // Copyright (c) 2009-2010 Satoshi Nakamoto
2 // Copyright (c) 2009-2014 The Bitcoin Core developers
3 // Distributed under the MIT software license, see the accompanying
4 // file COPYING or https://www.opensource.org/licenses/mit-license.php .
6 #ifndef BITCOIN_CHAINPARAMS_H
7 #define BITCOIN_CHAINPARAMS_H
9 #include "chainparamsbase.h"
10 #include "consensus/params.h"
11 #include "primitives/block.h"
14 #define KOMODO_MINDIFF_NBITS 0x200f0f0f
19 std::string name, host;
20 CDNSSeedData(const std::string &strName, const std::string &strHost) : name(strName), host(strHost) {}
28 typedef std::map<int, uint256> MapCheckpoints;
32 * CChainParams defines various tweakable parameters of a given instance of the
33 * Bitcoin system. There are three: the main network on which people trade goods
34 * and services, the public test network which gets reset from time to time and
35 * a regression test mode which is intended for private networks only. It has
36 * minimal difficulty to ensure that blocks can be found instantly.
57 struct CCheckpointData {
58 MapCheckpoints mapCheckpoints;
59 int64_t nTimeLastCheckpoint;
60 int64_t nTransactionsLastCheckpoint;
61 double fTransactionsPerDay;
65 SAPLING_PAYMENT_ADDRESS,
66 SAPLING_FULL_VIEWING_KEY,
67 SAPLING_INCOMING_VIEWING_KEY,
68 SAPLING_EXTENDED_SPEND_KEY,
73 const Consensus::Params& GetConsensus() const { return consensus; }
74 const CMessageHeader::MessageStartChars& MessageStart() const { return pchMessageStart; }
75 const std::vector<unsigned char>& AlertKey() const { return vAlertPubKey; }
76 int GetDefaultPort() const { return nDefaultPort; }
78 CAmount SproutValuePoolCheckpointHeight() const { return nSproutValuePoolCheckpointHeight; }
79 CAmount SproutValuePoolCheckpointBalance() const { return nSproutValuePoolCheckpointBalance; }
80 uint256 SproutValuePoolCheckpointBlockHash() const { return hashSproutValuePoolCheckpointBlock; }
81 bool ZIP209Enabled() const { return fZIP209Enabled; }
83 const CBlock& GenesisBlock() const { return genesis; }
84 /** Make miner wait to have peers to avoid wasting work */
85 bool MiningRequiresPeers() const { return fMiningRequiresPeers; }
86 /** Default value for -checkmempool and -checkblockindex argument */
87 bool DefaultConsistencyChecks() const { return fDefaultConsistencyChecks; }
88 /** Policy: Filter transactions that do not match well-defined patterns */
89 bool RequireStandard() const { return fRequireStandard; }
90 int64_t PruneAfterHeight() const { return nPruneAfterHeight; }
91 std::string CurrencyUnits() const { return strCurrencyUnits; }
92 uint32_t BIP44CoinType() const { return bip44CoinType; }
93 /** Make miner stop after a block is found. In RPC, don't return until nGenProcLimit blocks are generated */
94 bool MineBlocksOnDemand() const { return fMineBlocksOnDemand; }
95 /** In the future use NetworkIDString() for RPC fields */
96 bool TestnetToBeDeprecatedFieldRPC() const { return fTestnetToBeDeprecatedFieldRPC; }
97 /** Return the BIP70 network string (main, test or regtest) */
98 std::string NetworkIDString() const { return strNetworkID; }
99 const std::vector<CDNSSeedData>& DNSSeeds() const { return vSeeds; }
100 const std::vector<unsigned char>& Base58Prefix(Base58Type type) const { return base58Prefixes[type]; }
101 const std::string& Bech32HRP(Bech32Type type) const { return bech32HRPs[type]; }
102 const std::vector<SeedSpec6>& FixedSeeds() const { return vFixedSeeds; }
103 const CCheckpointData& Checkpoints() const { return checkpointData; }
104 /** Return the founder's reward address and script for a given block height */
105 std::string GetFoundersRewardAddressAtHeight(int height) const;
106 CScript GetFoundersRewardScriptAtHeight(int height) const;
107 std::string GetFoundersRewardAddressAtIndex(int i) const;
108 /** Enable disable coinbase protection on mainnet */
109 void DisableCoinbaseMustBeProtected() { consensus.fCoinbaseMustBeProtected = false; }
110 void EnableCoinbaseMustBeProtected() { consensus.fCoinbaseMustBeProtected = true; }
112 /** Enforce coinbase consensus rule in regtest mode */
113 void SetRegTestCoinbaseMustBeProtected() { consensus.fCoinbaseMustBeProtected = true; }
115 void SetDefaultPort(uint16_t port) { nDefaultPort = port; }
116 void SetCheckpointData(CCheckpointData checkpointData);
118 //void setnonce(uint32_t nonce) { memcpy(&genesis.nNonce,&nonce,sizeof(nonce)); }
119 //void settimestamp(uint32_t timestamp) { genesis.nTime = timestamp; }
120 //void setgenesis(CBlock &block) { genesis = block; }
121 //void recalc_genesis(uint32_t nonce) { genesis = CreateGenesisBlock(ASSETCHAINS_TIMESTAMP, nonce, GENESIS_NBITS, 1, COIN); };
122 std::vector<CDNSSeedData> vSeeds;
123 std::vector<SeedSpec6> vFixedSeeds;
124 CMessageHeader::MessageStartChars pchMessageStart; // jl777 moved
125 Consensus::Params consensus;
130 //! Raw pub key bytes for the broadcast alert signing key.
131 std::vector<unsigned char> vAlertPubKey;
132 int nMinerThreads = 0;
134 int nDefaultPort = 0;
135 uint64_t nPruneAfterHeight = 0;
136 std::vector<unsigned char> base58Prefixes[MAX_BASE58_TYPES];
137 std::string bech32HRPs[MAX_BECH32_TYPES];
138 std::string strNetworkID;
139 std::string strCurrencyUnits;
140 uint32_t bip44CoinType;
142 bool fMiningRequiresPeers = false;
143 bool fDefaultConsistencyChecks = false;
144 bool fRequireStandard = false;
145 bool fMineBlocksOnDemand = false;
146 bool fTestnetToBeDeprecatedFieldRPC = false;
147 CCheckpointData checkpointData;
148 std::vector<std::string> vFoundersRewardAddress;
150 CAmount nSproutValuePoolCheckpointHeight = 0;
151 CAmount nSproutValuePoolCheckpointBalance = 0;
152 uint256 hashSproutValuePoolCheckpointBlock;
153 bool fZIP209Enabled = false;
157 * Return the currently selected parameters. This won't change after app
158 * startup, except for unit tests.
160 const CChainParams &Params();
161 bool AreParamsInitialized();
162 void DisableCoinbaseMustBeProtected();
163 void EnableCoinbaseMustBeProtected();
165 /** Return parameters for the given network. */
166 CChainParams &Params(CBaseChainParams::Network network);
168 /** Sets the params returned by Params() to those for the given network. */
169 void SelectParams(CBaseChainParams::Network network);
172 * Looks for -regtest or -testnet and then calls SelectParams as appropriate.
173 * Returns false if an invalid combination is given.
175 bool SelectParamsFromCommandLine();
178 * Allows modifying the network upgrade regtest parameters.
180 void UpdateNetworkUpgradeParameters(Consensus::UpgradeIndex idx, int nActivationHeight);
182 void UpdateRegtestPow(int64_t nPowMaxAdjustDown, int64_t nPowMaxAdjustUp, uint256 powLimit);
184 #endif // BITCOIN_CHAINPARAMS_H