Merge #9268: Fix rounding privacy leak introduced in #9260
[bitcoinplatinum.git] / src / chainparams.h
blob633fbd51203f12ff026119ab34878f8117bc0016
1 // Copyright (c) 2009-2010 Satoshi Nakamoto
2 // Copyright (c) 2009-2015 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"
12 #include "protocol.h"
14 #include <vector>
16 struct CDNSSeedData {
17 std::string name, host;
18 bool supportsServiceBitsFiltering;
19 CDNSSeedData(const std::string &strName, const std::string &strHost, bool supportsServiceBitsFilteringIn = false) : name(strName), host(strHost), supportsServiceBitsFiltering(supportsServiceBitsFilteringIn) {}
22 struct SeedSpec6 {
23 uint8_t addr[16];
24 uint16_t port;
27 typedef std::map<int, uint256> MapCheckpoints;
29 struct CCheckpointData {
30 MapCheckpoints mapCheckpoints;
31 int64_t nTimeLastCheckpoint;
32 int64_t nTransactionsLastCheckpoint;
33 double fTransactionsPerDay;
36 /**
37 * CChainParams defines various tweakable parameters of a given instance of the
38 * Bitcoin system. There are three: the main network on which people trade goods
39 * and services, the public test network which gets reset from time to time and
40 * a regression test mode which is intended for private networks only. It has
41 * minimal difficulty to ensure that blocks can be found instantly.
43 class CChainParams
45 public:
46 enum Base58Type {
47 PUBKEY_ADDRESS,
48 SCRIPT_ADDRESS,
49 SECRET_KEY,
50 EXT_PUBLIC_KEY,
51 EXT_SECRET_KEY,
53 MAX_BASE58_TYPES
56 const Consensus::Params& GetConsensus() const { return consensus; }
57 const CMessageHeader::MessageStartChars& MessageStart() const { return pchMessageStart; }
58 int GetDefaultPort() const { return nDefaultPort; }
60 const CBlock& GenesisBlock() const { return genesis; }
61 /** Make miner wait to have peers to avoid wasting work */
62 bool MiningRequiresPeers() const { return fMiningRequiresPeers; }
63 /** Default value for -checkmempool and -checkblockindex argument */
64 bool DefaultConsistencyChecks() const { return fDefaultConsistencyChecks; }
65 /** Policy: Filter transactions that do not match well-defined patterns */
66 bool RequireStandard() const { return fRequireStandard; }
67 uint64_t PruneAfterHeight() const { return nPruneAfterHeight; }
68 /** Make miner stop after a block is found. In RPC, don't return until nGenProcLimit blocks are generated */
69 bool MineBlocksOnDemand() const { return fMineBlocksOnDemand; }
70 /** Return the BIP70 network string (main, test or regtest) */
71 std::string NetworkIDString() const { return strNetworkID; }
72 const std::vector<CDNSSeedData>& DNSSeeds() const { return vSeeds; }
73 const std::vector<unsigned char>& Base58Prefix(Base58Type type) const { return base58Prefixes[type]; }
74 const std::vector<SeedSpec6>& FixedSeeds() const { return vFixedSeeds; }
75 const CCheckpointData& Checkpoints() const { return checkpointData; }
76 protected:
77 CChainParams() {}
79 Consensus::Params consensus;
80 CMessageHeader::MessageStartChars pchMessageStart;
81 int nDefaultPort;
82 uint64_t nPruneAfterHeight;
83 std::vector<CDNSSeedData> vSeeds;
84 std::vector<unsigned char> base58Prefixes[MAX_BASE58_TYPES];
85 std::string strNetworkID;
86 CBlock genesis;
87 std::vector<SeedSpec6> vFixedSeeds;
88 bool fMiningRequiresPeers;
89 bool fDefaultConsistencyChecks;
90 bool fRequireStandard;
91 bool fMineBlocksOnDemand;
92 CCheckpointData checkpointData;
95 /**
96 * Return the currently selected parameters. This won't change after app
97 * startup, except for unit tests.
99 const CChainParams &Params();
102 * @returns CChainParams for the given BIP70 chain name.
104 CChainParams& Params(const std::string& chain);
107 * Sets the params returned by Params() to those for the given BIP70 chain name.
108 * @throws std::runtime_error when the chain is not supported.
110 void SelectParams(const std::string& chain);
113 * Allows modifying the BIP9 regtest parameters.
115 void UpdateRegtestBIP9Parameters(Consensus::DeploymentPos d, int64_t nStartTime, int64_t nTimeout);
117 #endif // BITCOIN_CHAINPARAMS_H