]> Git Repo - VerusCoin.git/blob - src/chainparams.h
Auto merge of #1765 - ITH4Coinomia:patch-2, r=ebfull
[VerusCoin.git] / src / chainparams.h
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.
5
6 #ifndef BITCOIN_CHAINPARAMS_H
7 #define BITCOIN_CHAINPARAMS_H
8
9 #include "chainparamsbase.h"
10 #include "checkpoints.h"
11 #include "consensus/params.h"
12 #include "primitives/block.h"
13 #include "protocol.h"
14
15 #include <vector>
16
17 struct CDNSSeedData {
18     std::string name, host;
19     CDNSSeedData(const std::string &strName, const std::string &strHost) : name(strName), host(strHost) {}
20 };
21
22 struct SeedSpec6 {
23     uint8_t addr[16];
24     uint16_t port;
25 };
26
27
28 /**
29  * CChainParams defines various tweakable parameters of a given instance of the
30  * Bitcoin system. There are three: the main network on which people trade goods
31  * and services, the public test network which gets reset from time to time and
32  * a regression test mode which is intended for private networks only. It has
33  * minimal difficulty to ensure that blocks can be found instantly.
34  */
35 class CChainParams
36 {
37 public:
38     enum Base58Type {
39         PUBKEY_ADDRESS,
40         SCRIPT_ADDRESS,
41         SECRET_KEY,
42         EXT_PUBLIC_KEY,
43         EXT_SECRET_KEY,
44
45         ZCPAYMENT_ADDRRESS,
46         ZCSPENDING_KEY,
47
48         MAX_BASE58_TYPES
49     };
50
51     const Consensus::Params& GetConsensus() const { return consensus; }
52     const CMessageHeader::MessageStartChars& MessageStart() const { return pchMessageStart; }
53     const std::vector<unsigned char>& AlertKey() const { return vAlertPubKey; }
54     int GetDefaultPort() const { return nDefaultPort; }
55
56     /** Used if GenerateBitcoins is called with a negative number of threads */
57     int DefaultMinerThreads() const { return nMinerThreads; }
58     const CBlock& GenesisBlock() const { return genesis; }
59     bool RequireRPCPassword() const { return fRequireRPCPassword; }
60     /** Make miner wait to have peers to avoid wasting work */
61     bool MiningRequiresPeers() const { return fMiningRequiresPeers; }
62     /** Default value for -checkmempool and -checkblockindex argument */
63     bool DefaultConsistencyChecks() const { return fDefaultConsistencyChecks; }
64     /** Policy: Filter transactions that do not match well-defined patterns */
65     bool RequireStandard() const { return fRequireStandard; }
66     int64_t MaxTipAge() const { return nMaxTipAge; }
67     int64_t PruneAfterHeight() const { return nPruneAfterHeight; }
68     unsigned int EquihashN() const { return nEquihashN; }
69     unsigned int EquihashK() const { return nEquihashK; }
70     std::string CurrencyUnits() const { return strCurrencyUnits; }
71     /** Make miner stop after a block is found. In RPC, don't return until nGenProcLimit blocks are generated */
72     bool MineBlocksOnDemand() const { return fMineBlocksOnDemand; }
73     /** In the future use NetworkIDString() for RPC fields */
74     bool TestnetToBeDeprecatedFieldRPC() const { return fTestnetToBeDeprecatedFieldRPC; }
75     /** Return the BIP70 network string (main, test or regtest) */
76     std::string NetworkIDString() const { return strNetworkID; }
77     const std::vector<CDNSSeedData>& DNSSeeds() const { return vSeeds; }
78     const std::vector<unsigned char>& Base58Prefix(Base58Type type) const { return base58Prefixes[type]; }
79     const std::vector<SeedSpec6>& FixedSeeds() const { return vFixedSeeds; }
80     const Checkpoints::CCheckpointData& Checkpoints() const { return checkpointData; }
81     /** Return the founder's reward address and script for a given block height */
82     std::string GetFoundersRewardAddressAtHeight(int height) const;
83     CScript GetFoundersRewardScriptAtHeight(int height) const;
84     std::string GetFoundersRewardAddressAtIndex(int i) const;
85     /** Enforce coinbase consensus rule in regtest mode */
86     void SetRegTestCoinbaseMustBeProtected() { consensus.fCoinbaseMustBeProtected = true; }
87 protected:
88     CChainParams() {}
89
90     Consensus::Params consensus;
91     CMessageHeader::MessageStartChars pchMessageStart;
92     //! Raw pub key bytes for the broadcast alert signing key.
93     std::vector<unsigned char> vAlertPubKey;
94     int nDefaultPort = 0;
95     int nMinerThreads = 0;
96     long nMaxTipAge = 0;
97     uint64_t nPruneAfterHeight = 0;
98     unsigned int nEquihashN = 0;
99     unsigned int nEquihashK = 0;
100     std::vector<CDNSSeedData> vSeeds;
101     std::vector<unsigned char> base58Prefixes[MAX_BASE58_TYPES];
102     std::string strNetworkID;
103     std::string strCurrencyUnits;
104     CBlock genesis;
105     std::vector<SeedSpec6> vFixedSeeds;
106     bool fRequireRPCPassword = false;
107     bool fMiningRequiresPeers = false;
108     bool fDefaultConsistencyChecks = false;
109     bool fRequireStandard = false;
110     bool fMineBlocksOnDemand = false;
111     bool fTestnetToBeDeprecatedFieldRPC = false;
112     Checkpoints::CCheckpointData checkpointData;
113     std::vector<std::string> vFoundersRewardAddress;
114 };
115
116 /**
117  * Return the currently selected parameters. This won't change after app
118  * startup, except for unit tests.
119  */
120 const CChainParams &Params();
121
122 /** Return parameters for the given network. */
123 CChainParams &Params(CBaseChainParams::Network network);
124
125 /** Sets the params returned by Params() to those for the given network. */
126 void SelectParams(CBaseChainParams::Network network);
127
128 /**
129  * Looks for -regtest or -testnet and then calls SelectParams as appropriate.
130  * Returns false if an invalid combination is given.
131  */
132 bool SelectParamsFromCommandLine();
133
134 #endif // BITCOIN_CHAINPARAMS_H
This page took 0.031381 seconds and 4 git commands to generate.