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