update SelectParamsFromCommandLine() handling/order
- move SelectParamsFromCommandLine() from init.cpp to bitcoin.cpp to allow to use TestNet() for Bitcoin-Qt instead of GetBoolArg("-testnet", false) - change order in bitcoind.cpp to match bitcoin.cpp functionality - hamonize error message strings for missing datadir and failing SelectParamsFromCommandLine() in bitcoin.cpp and bitcoind.cpp - use TestNet() call in splashscreen.cpp
This commit is contained in:
parent
3624356e82
commit
a2189fbaf6
4 changed files with 36 additions and 22 deletions
|
@ -39,10 +39,15 @@ bool AppInit(int argc, char* argv[])
|
||||||
ParseParameters(argc, argv);
|
ParseParameters(argc, argv);
|
||||||
if (!boost::filesystem::is_directory(GetDataDir(false)))
|
if (!boost::filesystem::is_directory(GetDataDir(false)))
|
||||||
{
|
{
|
||||||
fprintf(stderr, "Error: Specified directory does not exist\n");
|
fprintf(stderr, "Error: Specified data directory \"%s\" does not exist.\n", mapArgs["-datadir"].c_str());
|
||||||
Shutdown();
|
return false;
|
||||||
}
|
}
|
||||||
ReadConfigFile(mapArgs, mapMultiArgs);
|
ReadConfigFile(mapArgs, mapMultiArgs);
|
||||||
|
// Check for -testnet or -regtest parameter (TestNet() calls are only valid after this clause)
|
||||||
|
if (!SelectParamsFromCommandLine()) {
|
||||||
|
fprintf(stderr, "Error: Invalid combination of -regtest and -testnet.\n");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if (mapArgs.count("-?") || mapArgs.count("--help"))
|
if (mapArgs.count("-?") || mapArgs.count("--help"))
|
||||||
{
|
{
|
||||||
|
@ -67,10 +72,6 @@ bool AppInit(int argc, char* argv[])
|
||||||
|
|
||||||
if (fCommandLine)
|
if (fCommandLine)
|
||||||
{
|
{
|
||||||
if (!SelectParamsFromCommandLine()) {
|
|
||||||
fprintf(stderr, "Error: invalid combination of -regtest and -testnet.\n");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
int ret = CommandLineRPC(argc, argv);
|
int ret = CommandLineRPC(argc, argv);
|
||||||
exit(ret);
|
exit(ret);
|
||||||
}
|
}
|
||||||
|
|
|
@ -373,9 +373,6 @@ bool AppInit2(boost::thread_group& threadGroup)
|
||||||
// ********************************************************* Step 2: parameter interactions
|
// ********************************************************* Step 2: parameter interactions
|
||||||
|
|
||||||
Checkpoints::fEnabled = GetBoolArg("-checkpoints", true);
|
Checkpoints::fEnabled = GetBoolArg("-checkpoints", true);
|
||||||
if (!SelectParamsFromCommandLine()) {
|
|
||||||
return InitError("Invalid combination of -testnet and -regtest.");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mapArgs.count("-bind")) {
|
if (mapArgs.count("-bind")) {
|
||||||
// when specifying an explicit binding address, you want to listen on it
|
// when specifying an explicit binding address, you want to listen on it
|
||||||
|
|
|
@ -154,10 +154,23 @@ static void initTranslations(QTranslator &qtTranslatorBase, QTranslator &qtTrans
|
||||||
#ifndef BITCOIN_QT_TEST
|
#ifndef BITCOIN_QT_TEST
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
|
bool fMissingDatadir = false;
|
||||||
|
bool fSelParFromCLFailed = false;
|
||||||
|
|
||||||
fHaveGUI = true;
|
fHaveGUI = true;
|
||||||
|
|
||||||
// Command-line options take precedence:
|
// Command-line options take precedence:
|
||||||
ParseParameters(argc, argv);
|
ParseParameters(argc, argv);
|
||||||
|
// ... then bitcoin.conf:
|
||||||
|
if (!boost::filesystem::is_directory(GetDataDir(false))) {
|
||||||
|
fMissingDatadir = true;
|
||||||
|
} else {
|
||||||
|
ReadConfigFile(mapArgs, mapMultiArgs);
|
||||||
|
}
|
||||||
|
// Check for -testnet or -regtest parameter (TestNet() calls are only valid after this clause)
|
||||||
|
if (!SelectParamsFromCommandLine()) {
|
||||||
|
fSelParFromCLFailed = true;
|
||||||
|
}
|
||||||
|
|
||||||
#if QT_VERSION < 0x050000
|
#if QT_VERSION < 0x050000
|
||||||
// Internal string conversion is all UTF-8
|
// Internal string conversion is all UTF-8
|
||||||
|
@ -175,7 +188,7 @@ int main(int argc, char *argv[])
|
||||||
// as it is used to locate QSettings)
|
// as it is used to locate QSettings)
|
||||||
QApplication::setOrganizationName("Bitcoin");
|
QApplication::setOrganizationName("Bitcoin");
|
||||||
QApplication::setOrganizationDomain("bitcoin.org");
|
QApplication::setOrganizationDomain("bitcoin.org");
|
||||||
if (GetBoolArg("-testnet", false)) // Separate UI settings for testnet
|
if (TestNet()) // Separate UI settings for testnet
|
||||||
QApplication::setApplicationName("Bitcoin-Qt-testnet");
|
QApplication::setApplicationName("Bitcoin-Qt-testnet");
|
||||||
else
|
else
|
||||||
QApplication::setApplicationName("Bitcoin-Qt");
|
QApplication::setApplicationName("Bitcoin-Qt");
|
||||||
|
@ -184,6 +197,17 @@ int main(int argc, char *argv[])
|
||||||
QTranslator qtTranslatorBase, qtTranslator, translatorBase, translator;
|
QTranslator qtTranslatorBase, qtTranslator, translatorBase, translator;
|
||||||
initTranslations(qtTranslatorBase, qtTranslator, translatorBase, translator);
|
initTranslations(qtTranslatorBase, qtTranslator, translatorBase, translator);
|
||||||
|
|
||||||
|
// Now that translations are initialized check for errors and allow a translatable error message
|
||||||
|
if (fMissingDatadir) {
|
||||||
|
QMessageBox::critical(0, QObject::tr("Bitcoin"),
|
||||||
|
QObject::tr("Error: Specified data directory \"%1\" does not exist.").arg(QString::fromStdString(mapArgs["-datadir"])));
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
else if (fSelParFromCLFailed) {
|
||||||
|
QMessageBox::critical(0, QObject::tr("Bitcoin"), QObject::tr("Error: Invalid combination of -regtest and -testnet."));
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
// User language is set up: pick a data directory
|
// User language is set up: pick a data directory
|
||||||
Intro::pickDataDirectory();
|
Intro::pickDataDirectory();
|
||||||
|
|
||||||
|
@ -196,16 +220,7 @@ int main(int argc, char *argv[])
|
||||||
// Install global event filter that makes sure that long tooltips can be word-wrapped
|
// Install global event filter that makes sure that long tooltips can be word-wrapped
|
||||||
app.installEventFilter(new GUIUtil::ToolTipToRichTextFilter(TOOLTIP_WRAP_THRESHOLD, &app));
|
app.installEventFilter(new GUIUtil::ToolTipToRichTextFilter(TOOLTIP_WRAP_THRESHOLD, &app));
|
||||||
|
|
||||||
// ... then bitcoin.conf:
|
// ... now GUI settings:
|
||||||
if (!boost::filesystem::is_directory(GetDataDir(false)))
|
|
||||||
{
|
|
||||||
QMessageBox::critical(0, QObject::tr("Bitcoin"),
|
|
||||||
QObject::tr("Error: Specified data directory \"%1\" does not exist.").arg(QString::fromStdString(mapArgs["-datadir"])));
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
ReadConfigFile(mapArgs, mapMultiArgs);
|
|
||||||
|
|
||||||
// ... then GUI settings:
|
|
||||||
OptionsModel optionsModel;
|
OptionsModel optionsModel;
|
||||||
|
|
||||||
// Subscribe to global signals from core
|
// Subscribe to global signals from core
|
||||||
|
@ -245,7 +260,7 @@ int main(int argc, char *argv[])
|
||||||
|
|
||||||
boost::thread_group threadGroup;
|
boost::thread_group threadGroup;
|
||||||
|
|
||||||
BitcoinGUI window(GetBoolArg("-testnet", false), 0);
|
BitcoinGUI window(TestNet(), 0);
|
||||||
guiref = &window;
|
guiref = &window;
|
||||||
|
|
||||||
QTimer* pollShutdownTimer = new QTimer(guiref);
|
QTimer* pollShutdownTimer = new QTimer(guiref);
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
#include "splashscreen.h"
|
#include "splashscreen.h"
|
||||||
#include "clientversion.h"
|
#include "clientversion.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
#include "chainparams.h"
|
||||||
|
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
|
@ -26,7 +27,7 @@ SplashScreen::SplashScreen(const QPixmap &pixmap, Qt::WindowFlags f) :
|
||||||
|
|
||||||
// load the bitmap for writing some text over it
|
// load the bitmap for writing some text over it
|
||||||
QPixmap newPixmap;
|
QPixmap newPixmap;
|
||||||
if(GetBoolArg("-testnet", false)) {
|
if(TestNet()) {
|
||||||
newPixmap = QPixmap(":/images/splash_testnet");
|
newPixmap = QPixmap(":/images/splash_testnet");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
Loading…
Reference in a new issue