From 166d96ea1cb86541db6e204a1ad345fe7b36dc12 Mon Sep 17 00:00:00 2001 From: Jianping Wu Date: Mon, 21 Jan 2019 19:34:15 -0800 Subject: [PATCH] Properly fixed testnet checking. --- src/bitcoin-cli.cpp | 8 ++++++++ src/bitcoind.cpp | 8 ++++++++ src/chainparams.cpp | 4 ---- src/init.cpp | 6 ++++++ 4 files changed, 22 insertions(+), 4 deletions(-) diff --git a/src/bitcoin-cli.cpp b/src/bitcoin-cli.cpp index 786ec0cab..250f0a888 100644 --- a/src/bitcoin-cli.cpp +++ b/src/bitcoin-cli.cpp @@ -112,6 +112,14 @@ static int AppInitRPC(int argc, char* argv[]) fprintf(stderr,"Error reading configuration file: %s\n", e.what()); return EXIT_FAILURE; } + +#if 1 + if (ChainNameFromCommandLine() == CBaseChainParams::MAIN) { + printf("\nMainnet is not live yet, use \"-testnet\" option to connect to the testnet.\n\n"); + exit(1); + } +#endif + // Check for -testnet or -regtest parameter (BaseParams() calls are only valid after this clause) try { SelectBaseParams(ChainNameFromCommandLine()); diff --git a/src/bitcoind.cpp b/src/bitcoind.cpp index 7cb75b0b1..cc408b6c3 100644 --- a/src/bitcoind.cpp +++ b/src/bitcoind.cpp @@ -100,6 +100,14 @@ bool AppInit(int argc, char* argv[]) fprintf(stderr,"Error reading configuration file: %s\n", e.what()); return false; } + +#if 1 + if (ChainNameFromCommandLine() == CBaseChainParams::MAIN) { + printf("\nMainnet is not live yet, use \"-testnet\" option to connect to the testnet.\n\n"); + exit(1); + } +#endif + // Check for -testnet or -regtest parameter (Params() calls are only valid after this clause) try { SelectParams(ChainNameFromCommandLine()); diff --git a/src/chainparams.cpp b/src/chainparams.cpp index 7286619c4..fc24d9fbe 100644 --- a/src/chainparams.cpp +++ b/src/chainparams.cpp @@ -116,10 +116,6 @@ public: //TODO: target: 0x1e0fffff, update timestampe and nonce. genesis = CreateGenesisBlock(1543789622, 3302, 0x1f0ffff0, 1, genesisBlockReward); -#if 1 - printf("\nMainnet is not live yet, use -testnet to connect to the testnet.\n\n"); - exit(1); -#endif consensus.hashGenesisBlock = genesis.GetHash(); assert(consensus.hashGenesisBlock == uint256S("0x77c037d74bc51b535629537c8e9530340ea12272f43d261a0ee59e8f2ad0e6f6")); assert(genesis.hashMerkleRoot == uint256S("0xb21d4680875c0e472b7dbf3dbab2aaeb2dbbb5fa8b154f978b5ea0706d1fd5b9")); diff --git a/src/init.cpp b/src/init.cpp index a9eea5b6f..a9414467a 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -1461,6 +1461,12 @@ bool AppInitMain() break; } +#if 1 + if (ChainNameFromCommandLine() == CBaseChainParams::MAIN) { + return InitError(_("Mainnet is not live yet, use \"-testnet\" option to connect to the testnet.")); + } +#endif + // If the loaded chain has a wrong genesis, bail out immediately // (we're likely using a testnet datadir, or the other way around). if (!mapBlockIndex.empty() && mapBlockIndex.count(chainparams.GetConsensus().hashGenesisBlock) == 0)