From 6275ff8ed6e518770f794011a9abfa91e2d2f029 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jorge=20Tim=C3=B3n?= Date: Sun, 24 May 2015 23:35:55 +0200 Subject: [PATCH] Chainparams: Generic selection with -chain= in addition of -testnet and -regtest --- src/bitcoin-cli.cpp | 2 +- src/bitcoin-tx.cpp | 2 +- src/bitcoind.cpp | 2 +- src/chainparamsbase.cpp | 3 ++- src/qt/bitcoin.cpp | 2 +- src/qt/guiutil.cpp | 4 ++-- 6 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/bitcoin-cli.cpp b/src/bitcoin-cli.cpp index 7039f80198..7784405951 100644 --- a/src/bitcoin-cli.cpp +++ b/src/bitcoin-cli.cpp @@ -99,7 +99,7 @@ static bool AppInitRPC(int argc, char* argv[]) fprintf(stderr,"Error reading configuration file: %s\n", e.what()); return false; } - // Check for -testnet or -regtest parameter (BaseParams() calls are only valid after this clause) + // Check for -chain, -testnet or -regtest parameter (BaseParams() calls are only valid after this clause) try { SelectBaseParams(ChainNameFromCommandLine()); } catch (const std::exception& e) { diff --git a/src/bitcoin-tx.cpp b/src/bitcoin-tx.cpp index 8e8ac47455..1b41a00981 100644 --- a/src/bitcoin-tx.cpp +++ b/src/bitcoin-tx.cpp @@ -38,7 +38,7 @@ static bool AppInitRawTx(int argc, char* argv[]) // ParseParameters(argc, argv); - // Check for -testnet or -regtest parameter (Params() calls are only valid after this clause) + // Check for -chain, -testnet or -regtest parameter (Params() calls are only valid after this clause) try { SelectParams(ChainNameFromCommandLine()); } catch (const std::exception& e) { diff --git a/src/bitcoind.cpp b/src/bitcoind.cpp index 28bc374acc..0240472cac 100644 --- a/src/bitcoind.cpp +++ b/src/bitcoind.cpp @@ -110,7 +110,7 @@ bool AppInit(int argc, char* argv[]) fprintf(stderr,"Error reading configuration file: %s\n", e.what()); return false; } - // Check for -testnet or -regtest parameter (Params() calls are only valid after this clause) + // Check for -chain, -testnet or -regtest parameter (Params() calls are only valid after this clause) try { SelectParams(ChainNameFromCommandLine()); } catch (const std::exception& e) { diff --git a/src/chainparamsbase.cpp b/src/chainparamsbase.cpp index 66bf058619..c8c98432f7 100644 --- a/src/chainparamsbase.cpp +++ b/src/chainparamsbase.cpp @@ -17,6 +17,7 @@ const std::string CBaseChainParams::REGTEST = "regtest"; void AppendParamsHelpMessages(std::string& strUsage, bool debugHelp) { strUsage += HelpMessageGroup(_("Chain selection options:")); + strUsage += HelpMessageOpt("-chain=", _("Use the chain (default: main). Allowed values: main, testnet, regtest")); strUsage += HelpMessageOpt("-testnet", _("Use the test chain")); if (debugHelp) { strUsage += HelpMessageOpt("-regtest", "Enter regression test mode, which uses a special chain in which blocks can be solved instantly. " @@ -99,7 +100,7 @@ std::string ChainNameFromCommandLine() return CBaseChainParams::REGTEST; if (fTestNet) return CBaseChainParams::TESTNET; - return CBaseChainParams::MAIN; + return GetArg("-chain", CBaseChainParams::MAIN); } bool AreBaseParamsConfigured() diff --git a/src/qt/bitcoin.cpp b/src/qt/bitcoin.cpp index 430e6dd0e8..aa4c405e1a 100644 --- a/src/qt/bitcoin.cpp +++ b/src/qt/bitcoin.cpp @@ -603,7 +603,7 @@ int main(int argc, char *argv[]) // - QSettings() will use the new application name after this, resulting in network-specific settings // - Needs to be done before createOptionsModel - // Check for -testnet or -regtest parameter (Params() calls are only valid after this clause) + // Check for -chain, -testnet or -regtest parameter (Params() calls are only valid after this clause) try { SelectParams(ChainNameFromCommandLine()); } catch(std::exception &e) { diff --git a/src/qt/guiutil.cpp b/src/qt/guiutil.cpp index 947a4c6821..c28aa12e21 100644 --- a/src/qt/guiutil.cpp +++ b/src/qt/guiutil.cpp @@ -645,7 +645,7 @@ bool SetStartOnSystemStartup(bool fAutoStart) // Start client minimized QString strArgs = "-min"; // Set -testnet /-regtest options - strArgs += QString::fromStdString(strprintf(" -testnet=%d -regtest=%d", GetBoolArg("-testnet", false), GetBoolArg("-regtest", false))); + strArgs += QString::fromStdString(strprintf(" -chain=%s", ChainNameFromCommandLine())); #ifdef UNICODE boost::scoped_array args(new TCHAR[strArgs.length() + 1]); @@ -756,7 +756,7 @@ bool SetStartOnSystemStartup(bool fAutoStart) optionFile << "Name=Bitcoin\n"; else optionFile << strprintf("Name=Bitcoin (%s)\n", chain); - optionFile << "Exec=" << pszExePath << strprintf(" -min -testnet=%d -regtest=%d\n", GetBoolArg("-testnet", false), GetBoolArg("-regtest", false)); + optionFile << "Exec=" << pszExePath << strprintf(" -min -chain=%s\n", chain); optionFile << "Terminal=false\n"; optionFile << "Hidden=false\n"; optionFile.close();