Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

chainparams.h 4.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  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. #ifndef BITCOIN_CHAINPARAMS_H
  6. #define BITCOIN_CHAINPARAMS_H
  7. #include "chainparamsbase.h"
  8. #include "checkpoints.h"
  9. #include "consensus/params.h"
  10. #include "primitives/block.h"
  11. #include "protocol.h"
  12. #include <vector>
  13. struct CDNSSeedData {
  14. std::string name, host;
  15. CDNSSeedData(const std::string &strName, const std::string &strHost) : name(strName), host(strHost) {}
  16. };
  17. struct SeedSpec6 {
  18. uint8_t addr[16];
  19. uint16_t port;
  20. };
  21. /**
  22. * CChainParams defines various tweakable parameters of a given instance of the
  23. * Bitcoin system. There are three: the main network on which people trade goods
  24. * and services, the public test network which gets reset from time to time and
  25. * a regression test mode which is intended for private networks only. It has
  26. * minimal difficulty to ensure that blocks can be found instantly.
  27. */
  28. class CChainParams
  29. {
  30. public:
  31. enum Base58Type {
  32. PUBKEY_ADDRESS,
  33. SCRIPT_ADDRESS,
  34. SECRET_KEY,
  35. EXT_PUBLIC_KEY,
  36. EXT_SECRET_KEY,
  37. MAX_BASE58_TYPES
  38. };
  39. const Consensus::Params& GetConsensus() const { return consensus; }
  40. const CMessageHeader::MessageStartChars& MessageStart() const { return pchMessageStart; }
  41. const std::vector<unsigned char>& AlertKey() const { return vAlertPubKey; }
  42. int GetDefaultPort() const { return nDefaultPort; }
  43. /** Used if GenerateBitcoins is called with a negative number of threads */
  44. int DefaultMinerThreads() const { return nMinerThreads; }
  45. const CBlock& GenesisBlock() const { return genesis; }
  46. bool RequireRPCPassword() const { return fRequireRPCPassword; }
  47. /** Make miner wait to have peers to avoid wasting work */
  48. bool MiningRequiresPeers() const { return fMiningRequiresPeers; }
  49. /** Default value for -checkmempool and -checkblockindex argument */
  50. bool DefaultConsistencyChecks() const { return fDefaultConsistencyChecks; }
  51. /** Policy: Filter transactions that do not match well-defined patterns */
  52. bool RequireStandard() const { return fRequireStandard; }
  53. int64_t PruneAfterHeight() const { return nPruneAfterHeight; }
  54. /** Make miner stop after a block is found. In RPC, don't return until nGenProcLimit blocks are generated */
  55. bool MineBlocksOnDemand() const { return fMineBlocksOnDemand; }
  56. /** In the future use NetworkIDString() for RPC fields */
  57. bool TestnetToBeDeprecatedFieldRPC() const { return fTestnetToBeDeprecatedFieldRPC; }
  58. /** Return the BIP70 network string (main, test or regtest) */
  59. std::string NetworkIDString() const { return strNetworkID; }
  60. const std::vector<CDNSSeedData>& DNSSeeds() const { return vSeeds; }
  61. const std::vector<unsigned char>& Base58Prefix(Base58Type type) const { return base58Prefixes[type]; }
  62. const std::vector<SeedSpec6>& FixedSeeds() const { return vFixedSeeds; }
  63. const Checkpoints::CCheckpointData& Checkpoints() const { return checkpointData; }
  64. protected:
  65. CChainParams() {}
  66. Consensus::Params consensus;
  67. CMessageHeader::MessageStartChars pchMessageStart;
  68. //! Raw pub key bytes for the broadcast alert signing key.
  69. std::vector<unsigned char> vAlertPubKey;
  70. int nDefaultPort;
  71. int nMinerThreads;
  72. uint64_t nPruneAfterHeight;
  73. std::vector<CDNSSeedData> vSeeds;
  74. std::vector<unsigned char> base58Prefixes[MAX_BASE58_TYPES];
  75. std::string strNetworkID;
  76. CBlock genesis;
  77. std::vector<SeedSpec6> vFixedSeeds;
  78. bool fRequireRPCPassword;
  79. bool fMiningRequiresPeers;
  80. bool fDefaultConsistencyChecks;
  81. bool fRequireStandard;
  82. bool fMineBlocksOnDemand;
  83. bool fTestnetToBeDeprecatedFieldRPC;
  84. Checkpoints::CCheckpointData checkpointData;
  85. };
  86. /**
  87. * Return the currently selected parameters. This won't change after app
  88. * startup, except for unit tests.
  89. */
  90. const CChainParams &Params();
  91. /** Return parameters for the given network. */
  92. CChainParams &Params(CBaseChainParams::Network network);
  93. /** Sets the params returned by Params() to those for the given network. */
  94. void SelectParams(CBaseChainParams::Network network);
  95. /**
  96. * Looks for -regtest or -testnet and then calls SelectParams as appropriate.
  97. * Returns false if an invalid combination is given.
  98. */
  99. bool SelectParamsFromCommandLine();
  100. #endif // BITCOIN_CHAINPARAMS_H