diff --git a/src/bitcoind.cpp b/src/bitcoind.cpp index beb7aef1f..c6c1e9a47 100644 --- a/src/bitcoind.cpp +++ b/src/bitcoind.cpp @@ -1,209 +1,209 @@ // Copyright (c) 2009-2010 Satoshi Nakamoto // Copyright (c) 2009-2019 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. #if defined(HAVE_CONFIG_H) #include #endif #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include const std::function G_TRANSLATION_FUN = nullptr; static void WaitForShutdown(NodeContext &node) { while (!ShutdownRequested()) { UninterruptibleSleep(std::chrono::milliseconds{200}); } Interrupt(node); } ////////////////////////////////////////////////////////////////////////////// // // Start // static bool AppInit(int argc, char *argv[]) { // FIXME: Ideally, we'd like to build the config here, but that's currently // not possible as the whole application has too many global state. However, // this is a first step. auto &config = const_cast(GetConfig()); RPCServer rpcServer; NodeContext node; util::Ref context{node}; HTTPRPCRequestProcessor httpRPCRequestProcessor(config, rpcServer, context); bool fRet = false; util::ThreadSetInternalName("init"); // If Qt is used, parameters/bitcoin.conf are parsed in qt/bitcoin.cpp's // main() SetupServerArgs(node); ArgsManager &args = *Assert(node.args); std::string error; if (!args.ParseParameters(argc, argv, error)) { return InitError(Untranslated( strprintf("Error parsing command line arguments: %s\n", error))); } // Process help and version before taking care about datadir if (HelpRequested(args) || args.IsArgSet("-version")) { - std::string strUsage = PACKAGE_NAME " version " + FormatFullVersion() + - " (" + NETWORK_NAME + " network)\n"; + std::string strUsage = + PACKAGE_NAME " version " + FormatFullVersion() + "\n"; if (args.IsArgSet("-version")) { strUsage += FormatParagraph(LicenseInfo()) + "\n"; } else { strUsage += "\nUsage: bitcoind [options] " "Start " PACKAGE_NAME "\n"; strUsage += "\n" + args.GetHelpMessage(); } tfm::format(std::cout, "%s", strUsage); return true; } try { if (!CheckDataDirOption()) { return InitError(Untranslated( strprintf("Specified data directory \"%s\" does not exist.\n", args.GetArg("-datadir", "")))); } if (!args.ReadConfigFiles(error, true)) { return InitError(Untranslated( strprintf("Error reading configuration file: %s\n", error))); } // Check for -chain, -testnet or -regtest parameter (Params() calls are // only valid after this clause) try { SelectParams(args.GetChainName()); node.chain = interfaces::MakeChain(node, config.GetChainParams()); } catch (const std::exception &e) { return InitError(Untranslated(strprintf("%s\n", e.what()))); } // Make sure we create the net-specific data directory early on: if it // is new, this has a side effect of also creating // //wallets/. // // TODO: this should be removed once GetDataDir() no longer creates the // wallets/ subdirectory. // See more info at: // https://reviews.bitcoinabc.org/D3312 GetDataDir(true); // Error out when loose non-argument tokens are encountered on command // line for (int i = 1; i < argc; i++) { if (!IsSwitchChar(argv[i][0])) { return InitError(Untranslated( strprintf("Command line contains unexpected token '%s', " "see bitcoind -h for a list of options.\n", argv[i]))); } } if (!args.InitSettings(error)) { InitError(Untranslated(error)); return false; } // -server defaults to true for bitcoind but not for the GUI so do this // here args.SoftSetBoolArg("-server", true); // Set this early so that parameter interactions go to console InitLogging(args); InitParameterInteraction(args); if (!AppInitBasicSetup(args)) { // InitError will have been called with detailed error, which ends // up on console return false; } if (!AppInitParameterInteraction(config, args)) { // InitError will have been called with detailed error, which ends // up on console return false; } if (!AppInitSanityChecks()) { // InitError will have been called with detailed error, which ends // up on console return false; } if (args.GetBoolArg("-daemon", false)) { #if HAVE_DECL_DAEMON #if defined(MAC_OSX) #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wdeprecated-declarations" #endif tfm::format(std::cout, PACKAGE_NAME " starting\n"); // Daemonize if (daemon(1, 0)) { // don't chdir (1), do close FDs (0) return InitError(Untranslated( strprintf("daemon() failed: %s\n", strerror(errno)))); } #if defined(MAC_OSX) #pragma GCC diagnostic pop #endif #else return InitError(Untranslated( "-daemon is not supported on this operating system\n")); #endif // HAVE_DECL_DAEMON } // Lock data directory after daemonization if (!AppInitLockDataDirectory()) { // If locking the data directory failed, exit immediately return false; } fRet = AppInitMain(config, rpcServer, httpRPCRequestProcessor, node); } catch (const std::exception &e) { PrintExceptionContinue(&e, "AppInit()"); } catch (...) { PrintExceptionContinue(nullptr, "AppInit()"); } if (!fRet) { Interrupt(node); } else { WaitForShutdown(node); } Shutdown(node); return fRet; } int main(int argc, char *argv[]) { #ifdef WIN32 util::WinCmdLineArgs winArgs; std::tie(argc, argv) = winArgs.get(); #endif SetupEnvironment(); // Connect bitcoind signal handlers noui_connect(); return (AppInit(argc, argv) ? EXIT_SUCCESS : EXIT_FAILURE); } diff --git a/src/network.h b/src/network.h index 8c10273f7..4d5cd1105 100644 --- a/src/network.h +++ b/src/network.h @@ -1,14 +1,13 @@ // Copyright (c) 2020 The Bitcoin developers // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. #ifndef BITCOIN_NETWORK_H #define BITCOIN_NETWORK_H #include -extern const std::string NETWORK_NAME; extern const std::string CURRENCY_UNIT; extern const bool ENABLE_MINER_FUND; #endif // BITCOIN_NETWORK_H diff --git a/src/networks/abc/network.cpp b/src/networks/abc/network.cpp index ac8a72cb4..599bbdd01 100644 --- a/src/networks/abc/network.cpp +++ b/src/networks/abc/network.cpp @@ -1,9 +1,8 @@ // Copyright (c) 2020 The Bitcoin developers // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. #include -const std::string NETWORK_NAME = "ABC"; const std::string CURRENCY_UNIT = "BCHA"; const bool ENABLE_MINER_FUND = true; diff --git a/src/qt/utilitydialog.cpp b/src/qt/utilitydialog.cpp index 823e2266f..8f7ec37e5 100644 --- a/src/qt/utilitydialog.cpp +++ b/src/qt/utilitydialog.cpp @@ -1,167 +1,166 @@ // Copyright (c) 2011-2016 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. #if defined(HAVE_CONFIG_H) #include #endif #include #include #include #include #include #include #ifdef ENABLE_BIP70 #include #endif #include #include #include #include #include #include #include #include #include #include /** "Help message" or "About" dialog box */ HelpMessageDialog::HelpMessageDialog(QWidget *parent, bool about) : QDialog(parent), ui(new Ui::HelpMessageDialog) { ui->setupUi(this); QString version = QString{PACKAGE_NAME} + " " + tr("version") + " " + - QString::fromStdString(FormatFullVersion()) + " (" + - QString::fromStdString(NETWORK_NAME) + " network)"; + QString::fromStdString(FormatFullVersion()); if (about) { setWindowTitle(tr("About %1").arg(PACKAGE_NAME)); std::string licenseInfo = LicenseInfo(); /// HTML-format the license message from the core QString licenseInfoHTML = QString::fromStdString(LicenseInfo()); // Make URLs clickable QRegExp uri("<(.*)>", Qt::CaseSensitive, QRegExp::RegExp2); uri.setMinimal(true); // use non-greedy matching licenseInfoHTML.replace(uri, "\\1"); // Replace newlines with HTML breaks licenseInfoHTML.replace("\n", "
"); ui->aboutMessage->setTextFormat(Qt::RichText); ui->scrollArea->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded); text = version + "\n" + QString::fromStdString(FormatParagraph(licenseInfo)); ui->aboutMessage->setText(version + "

" + licenseInfoHTML); ui->aboutMessage->setWordWrap(true); ui->helpMessage->setVisible(false); } else { setWindowTitle(tr("Command-line options")); QString header = "Usage: bitcoin-qt [command-line options] \n"; QTextCursor cursor(ui->helpMessage->document()); cursor.insertText(version); cursor.insertBlock(); cursor.insertText(header); cursor.insertBlock(); std::string strUsage = gArgs.GetHelpMessage(); QString coreOptions = QString::fromStdString(strUsage); text = version + "\n\n" + header + "\n" + coreOptions; QTextTableFormat tf; tf.setBorderStyle(QTextFrameFormat::BorderStyle_None); tf.setCellPadding(2); QVector widths; widths << QTextLength(QTextLength::PercentageLength, 35); widths << QTextLength(QTextLength::PercentageLength, 65); tf.setColumnWidthConstraints(widths); QTextCharFormat bold; bold.setFontWeight(QFont::Bold); for (const QString &line : coreOptions.split("\n")) { if (line.startsWith(" -")) { cursor.currentTable()->appendRows(1); cursor.movePosition(QTextCursor::PreviousCell); cursor.movePosition(QTextCursor::NextRow); cursor.insertText(line.trimmed()); cursor.movePosition(QTextCursor::NextCell); } else if (line.startsWith(" ")) { cursor.insertText(line.trimmed() + ' '); } else if (line.size() > 0) { // Title of a group if (cursor.currentTable()) { cursor.currentTable()->appendRows(1); } cursor.movePosition(QTextCursor::Down); cursor.insertText(line.trimmed(), bold); cursor.insertTable(1, 2, tf); } } ui->helpMessage->moveCursor(QTextCursor::Start); ui->scrollArea->setVisible(false); ui->aboutLogo->setVisible(false); } GUIUtil::handleCloseWindowShortcut(this); } HelpMessageDialog::~HelpMessageDialog() { delete ui; } void HelpMessageDialog::printToConsole() { // On other operating systems, the expected action is to print the message // to the console. tfm::format(std::cout, "%s\n", qPrintable(text)); } void HelpMessageDialog::showOrPrint() { #if defined(WIN32) // On Windows, show a message box, as there is no stderr/stdout in windowed // applications exec(); #else // On other operating systems, print help text to console printToConsole(); #endif } void HelpMessageDialog::on_okButton_accepted() { close(); } /** "Shutdown" window */ ShutdownWindow::ShutdownWindow(QWidget *parent) : QWidget(parent) { QVBoxLayout *layout = new QVBoxLayout(); layout->addWidget(new QLabel( tr("%1 is shutting down...").arg(PACKAGE_NAME) + "

" + tr("Do not shut down the computer until this window disappears."))); setLayout(layout); GUIUtil::handleCloseWindowShortcut(this); } QWidget *ShutdownWindow::showShutdownWindow(QMainWindow *window) { assert(window != nullptr); // Show a simple window indicating shutdown status QWidget *shutdownWindow = new ShutdownWindow(); shutdownWindow->setWindowTitle(window->windowTitle()); // Center shutdown window at where main window was const QPoint global = window->mapToGlobal(window->rect().center()); shutdownWindow->move(global.x() - shutdownWindow->width() / 2, global.y() - shutdownWindow->height() / 2); shutdownWindow->show(); return shutdownWindow; } void ShutdownWindow::closeEvent(QCloseEvent *event) { event->ignore(); }