Inside Bitcoin
Opening the selected file…
Inside Bitcoin
Opening the selected file…
The code behind the network, with room to understand it.
Release published 2026-10-28 · Snapshot fetched 2026-11-01. Latest stable release at fetch time; development branches and Git history are excluded. Only the selected code window and visible folders load here.
1// Copyright (c) 2011-present The Bitcoin Core developers2// Distributed under the MIT software license, see the accompanying3// file COPYING or http://www.opensource.org/licenses/mit-license.php.5#include <bitcoin-build-config.h> // IWYU pragma: keep7#include <qt/utilitydialog.h>9#include <qt/forms/ui_helpmessagedialog.h>11#include <qt/guiutil.h>13#include <clientversion.h>14#include <common/args.h>15#include <common/license_info.h>16#include <init.h>17#include <util/strencodings.h>19#include <cstdio>21#include <QCloseEvent>22#include <QLabel>23#include <QMainWindow>24#include <QRegularExpression>25#include <QString>26#include <QTextCursor>27#include <QTextTable>28#include <QVBoxLayout>30/** "Help message" or "About" dialog box */31HelpMessageDialog::HelpMessageDialog(QWidget *parent, bool about) :32QDialog(parent, GUIUtil::dialog_flags),33ui(new Ui::HelpMessageDialog)34{35ui->setupUi(this);37QString version = QString{CLIENT_NAME} + " " + tr("version") + " " + QString::fromStdString(FormatFullVersion());39if (about)40{41setWindowTitle(tr("About %1").arg(CLIENT_NAME));43std::string licenseInfo = LicenseInfo();44/// HTML-format the license message from the core45QString licenseInfoHTML = QString::fromStdString(LicenseInfo());46// Make URLs clickable47QRegularExpression uri(QStringLiteral("<(.*)>"), QRegularExpression::InvertedGreedinessOption);48licenseInfoHTML.replace(uri, QStringLiteral("<a href=\"\\1\">\\1</a>"));49// Replace newlines with HTML breaks50licenseInfoHTML.replace("\n", "<br>");52ui->aboutMessage->setTextFormat(Qt::RichText);53ui->scrollArea->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded);54text = version + "\n" + QString::fromStdString(FormatParagraph(licenseInfo));55ui->aboutMessage->setText(version + "<br><br>" + licenseInfoHTML);56ui->aboutMessage->setWordWrap(true);57ui->helpMessage->setVisible(false);58} else {59setWindowTitle(tr("Command-line options"));60QString header = "The bitcoin-qt application provides a graphical interface for interacting with " CLIENT_NAME ".\n\n"61"It combines the core functionalities of bitcoind with a user-friendly interface for wallet management, transaction history, and network statistics.\n\n"62"It is suitable for users who prefer a graphical over a command-line interface.\n\n"63"You can optionally specify a payment [URI], in e.g. the BIP21 URI format.\n\n"64"Usage: bitcoin-qt [options] [URI]\n\n";65QTextCursor cursor(ui->helpMessage->document());66cursor.insertText(version);67cursor.insertBlock();68cursor.insertText(header);69cursor.insertBlock();71std::string strUsage = gArgs.GetHelpMessage();72QString coreOptions = QString::fromStdString(strUsage);73text = version + "\n\n" + header + "\n" + coreOptions;75QTextTableFormat tf;76tf.setBorderStyle(QTextFrameFormat::BorderStyle_None);77tf.setCellPadding(2);78QVector<QTextLength> widths;79widths << QTextLength(QTextLength::PercentageLength, 35);80widths << QTextLength(QTextLength::PercentageLength, 65);81tf.setColumnWidthConstraints(widths);83QTextCharFormat bold;84bold.setFontWeight(QFont::Bold);86for (const QString &line : coreOptions.split("\n")) {87if (line.startsWith(" -"))88{89cursor.currentTable()->appendRows(1);90cursor.movePosition(QTextCursor::PreviousCell);91cursor.movePosition(QTextCursor::NextRow);92cursor.insertText(line.trimmed());93cursor.movePosition(QTextCursor::NextCell);94} else if (line.startsWith(" ")) {95cursor.insertText(line.trimmed()+' ');96} else if (line.size() > 0) {97//Title of a group98if (cursor.currentTable())99cursor.currentTable()->appendRows(1);100cursor.movePosition(QTextCursor::Down);101cursor.insertText(line.trimmed(), bold);102cursor.insertTable(1, 2, tf);103}104}106ui->helpMessage->moveCursor(QTextCursor::Start);107ui->scrollArea->setVisible(false);108ui->aboutLogo->setVisible(false);109}111GUIUtil::handleCloseWindowShortcut(this);112}114HelpMessageDialog::~HelpMessageDialog()115{116delete ui;117}119void HelpMessageDialog::printToConsole()120{121// On other operating systems, the expected action is to print the message to the console.122tfm::format(std::cout, "%s", qPrintable(text));123}125void HelpMessageDialog::showOrPrint()126{127#if defined(WIN32)128// On Windows, show a message box, as there is no stderr/stdout in windowed applications129exec();130#else131// On other operating systems, print help text to console132printToConsole();133#endif134}136void HelpMessageDialog::on_okButton_accepted()137{138close();139}142/** "Shutdown" window */143ShutdownWindow::ShutdownWindow(QWidget *parent, Qt::WindowFlags f):144QWidget(parent, f)145{146QVBoxLayout *layout = new QVBoxLayout();147layout->addWidget(new QLabel(148tr("%1 is shutting down…").arg(CLIENT_NAME) + "<br /><br />" +149tr("Do not shut down the computer until this window disappears.")));150setLayout(layout);152GUIUtil::handleCloseWindowShortcut(this);153}155QWidget* ShutdownWindow::showShutdownWindow(QMainWindow* window)156{157assert(window != nullptr);159// Show a simple window indicating shutdown status160QWidget *shutdownWindow = new ShutdownWindow();161shutdownWindow->setWindowTitle(window->windowTitle());163// Center shutdown window at where main window was164const QPoint global = window->mapToGlobal(window->rect().center());165shutdownWindow->move(global.x() - shutdownWindow->width() / 2, global.y() - shutdownWindow->height() / 2);166shutdownWindow->show();167return shutdownWindow;168}170void ShutdownWindow::closeEvent(QCloseEvent *event)171{172event->ignore();173}
Independent explanations by MyBitcoinExplorer. Not affiliated with or endorsed by Bitcoin Core. Guides are educational and do not replace the source or its tests.
Bitcoin Core source © its contributors, distributed under the MIT license. Original notices and bundled third-party licenses are retained in the source tree.