1 // Copyright (c) 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 #include "chainparamsbase.h"
8 #include "tinyformat.h"
13 const std::string
CBaseChainParams::MAIN
= "main";
14 const std::string
CBaseChainParams::TESTNET
= "test";
15 const std::string
CBaseChainParams::REGTEST
= "regtest";
17 void AppendParamsHelpMessages(std::string
& strUsage
, bool debugHelp
)
19 strUsage
+= HelpMessageGroup(_("Chain selection options:"));
20 strUsage
+= HelpMessageOpt("-testnet", _("Use the test chain"));
22 strUsage
+= HelpMessageOpt("-regtest", "Enter regression test mode, which uses a special chain in which blocks can be solved instantly. "
23 "This is intended for regression testing tools and app development.");
30 class CBaseMainParams
: public CBaseChainParams
38 static CBaseMainParams mainParams
;
43 class CBaseTestNetParams
: public CBaseChainParams
49 strDataDir
= "testnet3";
52 static CBaseTestNetParams testNetParams
;
57 class CBaseRegTestParams
: public CBaseChainParams
63 strDataDir
= "regtest";
66 static CBaseRegTestParams regTestParams
;
68 static CBaseChainParams
* pCurrentBaseParams
= 0;
70 const CBaseChainParams
& BaseParams()
72 assert(pCurrentBaseParams
);
73 return *pCurrentBaseParams
;
76 CBaseChainParams
& BaseParams(const std::string
& chain
)
78 if (chain
== CBaseChainParams::MAIN
)
80 else if (chain
== CBaseChainParams::TESTNET
)
82 else if (chain
== CBaseChainParams::REGTEST
)
85 throw std::runtime_error(strprintf("%s: Unknown chain %s.", __func__
, chain
));
88 void SelectBaseParams(const std::string
& chain
)
90 pCurrentBaseParams
= &BaseParams(chain
);
93 std::string
ChainNameFromCommandLine()
95 bool fRegTest
= GetBoolArg("-regtest", false);
96 bool fTestNet
= GetBoolArg("-testnet", false);
98 if (fTestNet
&& fRegTest
)
99 throw std::runtime_error("Invalid combination of -regtest and -testnet.");
101 return CBaseChainParams::REGTEST
;
103 return CBaseChainParams::TESTNET
;
104 return CBaseChainParams::MAIN
;
107 bool AreBaseParamsConfigured()
109 return pCurrentBaseParams
!= NULL
;