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 http://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.
54 struct CCheckpointData {
55 MapCheckpoints mapCheckpoints;
56 int64_t nTimeLastCheckpoint;
57 int64_t nTransactionsLastCheckpoint;
58 double fTransactionsPerDay;
61 const Consensus::Params& GetConsensus() const { return consensus; }
62 const CMessageHeader::MessageStartChars& MessageStart() const { return pchMessageStart; }
63 const std::vector<unsigned char>& AlertKey() const { return vAlertPubKey; }
64 int GetDefaultPort() const { return nDefaultPort; }
66 const CBlock& GenesisBlock() const { return genesis; }
67 /** Make miner wait to have peers to avoid wasting work */
68 bool MiningRequiresPeers() const { return fMiningRequiresPeers; }
69 /** Default value for -checkmempool and -checkblockindex argument */
70 bool DefaultConsistencyChecks() const { return fDefaultConsistencyChecks; }
71 /** Policy: Filter transactions that do not match well-defined patterns */
72 bool RequireStandard() const { return fRequireStandard; }
73 int64_t MaxTipAge() const { return nMaxTipAge; }
74 int64_t PruneAfterHeight() const { return nPruneAfterHeight; }
75 unsigned int EquihashN() const { return nEquihashN; }
76 unsigned int EquihashK() const { return nEquihashK; }
77 std::string CurrencyUnits() const { return strCurrencyUnits; }
78 /** Make miner stop after a block is found. In RPC, don't return until nGenProcLimit blocks are generated */
79 bool MineBlocksOnDemand() const { return fMineBlocksOnDemand; }
80 /** In the future use NetworkIDString() for RPC fields */
81 bool TestnetToBeDeprecatedFieldRPC() const { return fTestnetToBeDeprecatedFieldRPC; }
82 /** Return the BIP70 network string (main, test or regtest) */
83 std::string NetworkIDString() const { return strNetworkID; }
84 const std::vector<CDNSSeedData>& DNSSeeds() const { return vSeeds; }
85 const std::vector<unsigned char>& Base58Prefix(Base58Type type) const { return base58Prefixes[type]; }
86 const std::vector<SeedSpec6>& FixedSeeds() const { return vFixedSeeds; }
87 const CCheckpointData& Checkpoints() const { return checkpointData; }
88 /** Return the founder's reward address and script for a given block height */
89 std::string GetFoundersRewardAddressAtHeight(int height) const;
90 CScript GetFoundersRewardScriptAtHeight(int height) const;
91 std::string GetFoundersRewardAddressAtIndex(int i) const;
92 /** Enforce coinbase consensus rule in regtest mode */
93 void SetRegTestCoinbaseMustBeProtected() { consensus.fCoinbaseMustBeProtected = true; }
95 void SetDefaultPort(uint16_t port) { nDefaultPort = port; }
96 void SetCheckpointData(CCheckpointData checkpointData);
98 //void setnonce(uint32_t nonce) { memcpy(&genesis.nNonce,&nonce,sizeof(nonce)); }
99 //void settimestamp(uint32_t timestamp) { genesis.nTime = timestamp; }
100 //void setgenesis(CBlock &block) { genesis = block; }
101 //void recalc_genesis(uint32_t nonce) { genesis = CreateGenesisBlock(ASSETCHAINS_TIMESTAMP, nonce, GENESIS_NBITS, 1, COIN); };
102 int nDefaultPort = 0;
103 CMessageHeader::MessageStartChars pchMessageStart; // jl777 moved
104 Consensus::Params consensus;
109 //! Raw pub key bytes for the broadcast alert signing key.
110 std::vector<unsigned char> vAlertPubKey;
111 int nMinerThreads = 0;
113 uint64_t nPruneAfterHeight = 0;
114 unsigned int nEquihashN = 0;
115 unsigned int nEquihashK = 0;
116 std::vector<CDNSSeedData> vSeeds;
117 std::vector<unsigned char> base58Prefixes[MAX_BASE58_TYPES];
118 std::string strNetworkID;
119 std::string strCurrencyUnits;
121 std::vector<SeedSpec6> vFixedSeeds;
122 bool fMiningRequiresPeers = false;
123 bool fDefaultConsistencyChecks = false;
124 bool fRequireStandard = false;
125 bool fMineBlocksOnDemand = false;
126 bool fTestnetToBeDeprecatedFieldRPC = false;
127 CCheckpointData checkpointData;
128 std::vector<std::string> vFoundersRewardAddress;
132 * Return the currently selected parameters. This won't change after app
133 * startup, except for unit tests.
135 const CChainParams &Params();
137 /** Return parameters for the given network. */
138 CChainParams &Params(CBaseChainParams::Network network);
140 /** Sets the params returned by Params() to those for the given network. */
141 void SelectParams(CBaseChainParams::Network network);
144 * Looks for -regtest or -testnet and then calls SelectParams as appropriate.
145 * Returns false if an invalid combination is given.
147 bool SelectParamsFromCommandLine();
150 * Allows modifying the network upgrade regtest parameters.
152 void UpdateNetworkUpgradeParameters(Consensus::UpgradeIndex idx, int nActivationHeight);
154 #endif // BITCOIN_CHAINPARAMS_H