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 "checkpoints.h"
11 #include "consensus/params.h"
12 #include "primitives/block.h"
15 #define KOMODO_MINDIFF_NBITS 0x200f0f0f
20 std::string name, host;
21 CDNSSeedData(const std::string &strName, const std::string &strHost) : name(strName), host(strHost) {}
31 * CChainParams defines various tweakable parameters of a given instance of the
32 * Bitcoin system. There are three: the main network on which people trade goods
33 * and services, the public test network which gets reset from time to time and
34 * a regression test mode which is intended for private networks only. It has
35 * minimal difficulty to ensure that blocks can be found instantly.
53 const Consensus::Params& GetConsensus() const { return consensus; }
54 const CMessageHeader::MessageStartChars& MessageStart() const { return pchMessageStart; }
55 const std::vector<unsigned char>& AlertKey() const { return vAlertPubKey; }
56 int GetDefaultPort() const { return nDefaultPort; }
58 /** Used if GenerateBitcoins is called with a negative number of threads */
59 int DefaultMinerThreads() const { return nMinerThreads; }
60 const CBlock& GenesisBlock() const { return genesis; }
61 bool RequireRPCPassword() const { return fRequireRPCPassword; }
62 /** Make miner wait to have peers to avoid wasting work */
63 bool MiningRequiresPeers() const { return fMiningRequiresPeers; }
64 /** Default value for -checkmempool and -checkblockindex argument */
65 bool DefaultConsistencyChecks() const { return fDefaultConsistencyChecks; }
66 /** Policy: Filter transactions that do not match well-defined patterns */
67 bool RequireStandard() const { return fRequireStandard; }
68 int64_t MaxTipAge() const { return nMaxTipAge; }
69 int64_t PruneAfterHeight() const { return nPruneAfterHeight; }
70 unsigned int EquihashN() const { return nEquihashN; }
71 unsigned int EquihashK() const { return nEquihashK; }
72 std::string CurrencyUnits() const { return strCurrencyUnits; }
73 /** Make miner stop after a block is found. In RPC, don't return until nGenProcLimit blocks are generated */
74 bool MineBlocksOnDemand() const { return fMineBlocksOnDemand; }
75 /** In the future use NetworkIDString() for RPC fields */
76 bool TestnetToBeDeprecatedFieldRPC() const { return fTestnetToBeDeprecatedFieldRPC; }
77 /** Return the BIP70 network string (main, test or regtest) */
78 std::string NetworkIDString() const { return strNetworkID; }
79 const std::vector<CDNSSeedData>& DNSSeeds() const { return vSeeds; }
80 const std::vector<unsigned char>& Base58Prefix(Base58Type type) const { return base58Prefixes[type]; }
81 const std::vector<SeedSpec6>& FixedSeeds() const { return vFixedSeeds; }
82 const Checkpoints::CCheckpointData& Checkpoints() const { return checkpointData; }
83 /** Return the founder's reward address and script for a given block height */
84 std::string GetFoundersRewardAddressAtHeight(int height) const;
85 CScript GetFoundersRewardScriptAtHeight(int height) const;
86 std::string GetFoundersRewardAddressAtIndex(int i) const;
87 /** Enforce coinbase consensus rule in regtest mode */
88 void SetRegTestCoinbaseMustBeProtected() { consensus.fCoinbaseMustBeProtected = true; }
90 void SetDefaultPort(uint16_t port) { nDefaultPort = port; }
91 //void setnonce(uint32_t nonce) { memcpy(&genesis.nNonce,&nonce,sizeof(nonce)); }
92 //void settimestamp(uint32_t timestamp) { genesis.nTime = timestamp; }
93 //void setgenesis(CBlock &block) { genesis = block; }
94 //void recalc_genesis(uint32_t nonce) { genesis = CreateGenesisBlock(ASSETCHAINS_TIMESTAMP, nonce, GENESIS_NBITS, 1, COIN); };
96 CMessageHeader::MessageStartChars pchMessageStart; // jl777 moved
99 Consensus::Params consensus;
101 //! Raw pub key bytes for the broadcast alert signing key.
102 std::vector<unsigned char> vAlertPubKey;
103 int nMinerThreads = 0;
105 uint64_t nPruneAfterHeight = 0;
106 unsigned int nEquihashN = 0;
107 unsigned int nEquihashK = 0;
108 std::vector<CDNSSeedData> vSeeds;
109 std::vector<unsigned char> base58Prefixes[MAX_BASE58_TYPES];
110 std::string strNetworkID;
111 std::string strCurrencyUnits;
113 std::vector<SeedSpec6> vFixedSeeds;
114 bool fRequireRPCPassword = false;
115 bool fMiningRequiresPeers = false;
116 bool fDefaultConsistencyChecks = false;
117 bool fRequireStandard = false;
118 bool fMineBlocksOnDemand = false;
119 bool fTestnetToBeDeprecatedFieldRPC = false;
120 Checkpoints::CCheckpointData checkpointData;
121 std::vector<std::string> vFoundersRewardAddress;
125 * Return the currently selected parameters. This won't change after app
126 * startup, except for unit tests.
128 const CChainParams &Params();
130 /** Return parameters for the given network. */
131 CChainParams &Params(CBaseChainParams::Network network);
133 /** Sets the params returned by Params() to those for the given network. */
134 void SelectParams(CBaseChainParams::Network network);
137 * Looks for -regtest or -testnet and then calls SelectParams as appropriate.
138 * Returns false if an invalid combination is given.
140 bool SelectParamsFromCommandLine();
142 #endif // BITCOIN_CHAINPARAMS_H