You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

chainparamsbase.h 1.7KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. // Copyright (c) 2014 The Bitcoin Core developers
  2. // Distributed under the MIT software license, see the accompanying
  3. // file COPYING or http://www.opensource.org/licenses/mit-license.php.
  4. #ifndef BITCOIN_CHAINPARAMSBASE_H
  5. #define BITCOIN_CHAINPARAMSBASE_H
  6. #include <string>
  7. #include <vector>
  8. /**
  9. * CBaseChainParams defines the base parameters (shared between bitcoin-cli and bitcoind)
  10. * of a given instance of the Bitcoin system.
  11. */
  12. class CBaseChainParams
  13. {
  14. public:
  15. /** BIP70 chain name strings (main, test or regtest) */
  16. static const std::string MAIN;
  17. static const std::string TESTNET;
  18. static const std::string REGTEST;
  19. static const std::string MAX_NETWORK_TYPES;
  20. const std::string& DataDir() const { return strDataDir; }
  21. int RPCPort() const { return nRPCPort; }
  22. protected:
  23. CBaseChainParams() {}
  24. int nRPCPort;
  25. std::string strDataDir;
  26. };
  27. /**
  28. * Return the currently selected parameters. This won't change after app
  29. * startup, except for unit tests.
  30. */
  31. const CBaseChainParams& BaseParams();
  32. /** Sets the params returned by Params() to those for the given network. */
  33. void SelectBaseParams(const std::string& chain);
  34. /**
  35. * Looks for -regtest, -testnet and returns the appropriate BIP70 chain name.
  36. * @return CBaseChainParams::MAX_NETWORK_TYPES if an invalid combination is given. CBaseChainParams::MAIN by default.
  37. */
  38. std::string ChainNameFromCommandLine();
  39. /**
  40. * Calls NetworkIdFromCommandLine() and then calls SelectParams as appropriate.
  41. * Returns false if an invalid combination is given.
  42. */
  43. bool SelectBaseParamsFromCommandLine();
  44. /**
  45. * Return true if SelectBaseParamsFromCommandLine() has been called to select
  46. * a network.
  47. */
  48. bool AreBaseParamsConfigured();
  49. #endif // BITCOIN_CHAINPARAMSBASE_H