|
| 1 | +// Copyright (c) 2010 Satoshi Nakamoto |
| 2 | +// Copyright (c) 2009-2012 The Bitcoin developers |
| 3 | +// Distributed under the MIT/X11 software license, see the accompanying |
| 4 | +// file COPYING or http://www.opensource.org/licenses/mit-license.php. |
| 5 | + |
| 6 | +#include "compat.h" |
| 7 | + |
| 8 | +#include "util.h" |
| 9 | +#include "cdnsseeddata.h" |
| 10 | +#include "chainparamsseeds.h" |
| 11 | +#include "cmainparams.h" |
| 12 | +#include "ctestnetparams.h" |
| 13 | +#include "cregtestparams.h" |
| 14 | +#include "ctxin.h" |
| 15 | +#include "ctxout.h" |
| 16 | +#include "caddress.h" |
| 17 | +#include "ctransaction.h" |
| 18 | + |
| 19 | +#include "chainparams.h" |
| 20 | + |
| 21 | +static CMainParams mainParams; |
| 22 | +static CTestNetParams testNetParams; |
| 23 | +static CRegTestParams regTestParams; |
| 24 | +static CChainParams *pCurrentParams = &mainParams; |
| 25 | + |
| 26 | +const CChainParams &Params() |
| 27 | +{ |
| 28 | + return *pCurrentParams; |
| 29 | +} |
| 30 | + |
| 31 | +void SelectParams(CChainParams_Network network) |
| 32 | +{ |
| 33 | + switch (network) |
| 34 | + { |
| 35 | + case CChainParams_Network::MAIN: |
| 36 | + pCurrentParams = &mainParams; |
| 37 | + break; |
| 38 | + |
| 39 | + case CChainParams_Network::TESTNET: |
| 40 | + pCurrentParams = &testNetParams; |
| 41 | + break; |
| 42 | + |
| 43 | + case CChainParams_Network::REGTEST: |
| 44 | + pCurrentParams = ®TestParams; |
| 45 | + break; |
| 46 | + |
| 47 | + default: |
| 48 | + assert(false && "Unimplemented network"); |
| 49 | + return; |
| 50 | + } |
| 51 | +} |
| 52 | + |
| 53 | +bool SelectParamsFromCommandLine() |
| 54 | +{ |
| 55 | + bool fRegTest = GetBoolArg("-regtest", false); |
| 56 | + bool fTestNet = GetBoolArg("-testnet", false); |
| 57 | + |
| 58 | + if (fTestNet && fRegTest) |
| 59 | + { |
| 60 | + return false; |
| 61 | + } |
| 62 | + |
| 63 | + if (fRegTest) |
| 64 | + { |
| 65 | + SelectParams(CChainParams_Network::REGTEST); |
| 66 | + } |
| 67 | + else if (fTestNet) |
| 68 | + { |
| 69 | + SelectParams(CChainParams_Network::TESTNET); |
| 70 | + } |
| 71 | + else |
| 72 | + { |
| 73 | + SelectParams(CChainParams_Network::MAIN); |
| 74 | + } |
| 75 | + |
| 76 | + return true; |
| 77 | +} |
| 78 | + |
| 79 | +bool TestNet() |
| 80 | +{ |
| 81 | + // Note: it's deliberate that this returns "false" for regression test mode. |
| 82 | + return Params().NetworkID() == CChainParams_Network::TESTNET; |
| 83 | +} |
| 84 | + |
0 commit comments