1 // Copyright (c) 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.
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
;
71 class CBaseUnitTestParams
: public CBaseMainParams
76 strDataDir
= "unittest";
79 static CBaseUnitTestParams unitTestParams
;
81 static CBaseChainParams
* pCurrentBaseParams
= 0;
83 const CBaseChainParams
& BaseParams()
85 assert(pCurrentBaseParams
);
86 return *pCurrentBaseParams
;
89 void SelectBaseParams(const std::string
& chain
)
91 if (chain
== CBaseChainParams::MAIN
)
92 pCurrentBaseParams
= &mainParams
;
93 else if (chain
== CBaseChainParams::TESTNET
)
94 pCurrentBaseParams
= &testNetParams
;
95 else if (chain
== CBaseChainParams::REGTEST
)
96 pCurrentBaseParams
= ®TestParams
;
98 throw std::runtime_error(strprintf("%s: Unknown chain %s.", __func__
, chain
));
101 std::string
ChainNameFromCommandLine()
103 bool fRegTest
= GetBoolArg("-regtest", false);
104 bool fTestNet
= GetBoolArg("-testnet", false);
106 if (fTestNet
&& fRegTest
)
107 throw std::runtime_error("Invalid combination of -regtest and -testnet.");
109 return CBaseChainParams::REGTEST
;
111 return CBaseChainParams::TESTNET
;
112 return CBaseChainParams::MAIN
;
115 bool AreBaseParamsConfigured()
117 return pCurrentBaseParams
!= NULL
;