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.
251connect(ui->prune, &QCheckBox::clicked, this, &OptionsDialog::togglePruneWarning);252connect(ui->pruneSize, qOverload<int>(&QSpinBox::valueChanged), this, &OptionsDialog::showRestartWarning);253connect(ui->databaseCache, qOverload<int>(&QSpinBox::valueChanged), this, &OptionsDialog::showRestartWarning);254connect(ui->externalSignerPath, &QLineEdit::textChanged, [this]{ showRestartWarning(); });255connect(ui->threadsScriptVerif, qOverload<int>(&QSpinBox::valueChanged), this, &OptionsDialog::showRestartWarning);256/* Wallet */257connect(ui->spendZeroConfChange, &QCheckBox::clicked, this, &OptionsDialog::showRestartWarning);258/* Network */259connect(ui->allowIncoming, &QCheckBox::clicked, this, &OptionsDialog::showRestartWarning);260connect(ui->enableServer, &QCheckBox::clicked, this, &OptionsDialog::showRestartWarning);261connect(ui->connectSocks, &QCheckBox::clicked, this, &OptionsDialog::showRestartWarning);262connect(ui->connectSocksTor, &QCheckBox::clicked, this, &OptionsDialog::showRestartWarning);263/* Display */264connect(ui->lang, qOverload<>(&QValueComboBox::valueChanged), [this]{ showRestartWarning(); });265connect(ui->thirdPartyTxUrls, &QLineEdit::textChanged, [this]{ showRestartWarning(); });266}268void OptionsDialog::setCurrentTab(OptionsDialog::Tab tab)269{270QWidget *tab_widget = nullptr;271if (tab == OptionsDialog::Tab::TAB_NETWORK) tab_widget = ui->tabNetwork;272if (tab == OptionsDialog::Tab::TAB_MAIN) tab_widget = ui->tabMain;273if (tab_widget && ui->tabWidget->currentWidget() != tab_widget) {274ui->tabWidget->setCurrentWidget(tab_widget);275}276}278void OptionsDialog::setMapper()279{280/* Main */281mapper->addMapping(ui->bitcoinAtStartup, OptionsModel::StartAtStartup);282mapper->addMapping(ui->threadsScriptVerif, OptionsModel::ThreadsScriptVerif);283mapper->addMapping(ui->databaseCache, OptionsModel::DatabaseCache);284mapper->addMapping(ui->prune, OptionsModel::Prune);285mapper->addMapping(ui->pruneSize, OptionsModel::PruneSize);287/* Wallet */288mapper->addMapping(ui->spendZeroConfChange, OptionsModel::SpendZeroConfChange);289mapper->addMapping(ui->coinControlFeatures, OptionsModel::CoinControlFeatures);290mapper->addMapping(ui->subFeeFromAmount, OptionsModel::SubFeeFromAmount);291mapper->addMapping(ui->externalSignerPath, OptionsModel::ExternalSignerPath);292mapper->addMapping(ui->m_enable_psbt_controls, OptionsModel::EnablePSBTControls);294/* Network */295mapper->addMapping(ui->mapPortNatpmp, OptionsModel::MapPortNatpmp);296mapper->addMapping(ui->allowIncoming, OptionsModel::Listen);297mapper->addMapping(ui->enableServer, OptionsModel::Server);299mapper->addMapping(ui->connectSocks, OptionsModel::ProxyUse);300mapper->addMapping(ui->proxyIp, OptionsModel::ProxyIP);301mapper->addMapping(ui->proxyPort, OptionsModel::ProxyPort);303mapper->addMapping(ui->connectSocksTor, OptionsModel::ProxyUseTor);304mapper->addMapping(ui->proxyIpTor, OptionsModel::ProxyIPTor);305mapper->addMapping(ui->proxyPortTor, OptionsModel::ProxyPortTor);307/* Window */308#ifndef Q_OS_MACOS309if (QSystemTrayIcon::isSystemTrayAvailable()) {310mapper->addMapping(ui->showTrayIcon, OptionsModel::ShowTrayIcon);311mapper->addMapping(ui->minimizeToTray, OptionsModel::MinimizeToTray);312}313mapper->addMapping(ui->minimizeOnClose, OptionsModel::MinimizeOnClose);314#endif316/* Display */317mapper->addMapping(ui->lang, OptionsModel::Language);318mapper->addMapping(ui->unit, OptionsModel::DisplayUnit);319mapper->addMapping(ui->thirdPartyTxUrls, OptionsModel::ThirdPartyTxUrls);320}322void OptionsDialog::setOkButtonState(bool fState)323{324ui->okButton->setEnabled(fState);325}327void OptionsDialog::on_resetButton_clicked()328{329if (model) {330// confirmation dialog331/*: Text explaining that the settings changed will not come into effect332until the client is restarted. */333QString reset_dialog_text = tr("Client restart required to activate changes.") + "<br><br>";334/*: Text explaining to the user that the client's current settings335will be backed up at a specific location. %1 is a stand-in336argument for the backup location's path. */337reset_dialog_text.append(tr("Current settings will be backed up at \"%1\".").arg(m_client_model->dataDir()) + "<br><br>");338/*: Text asking the user to confirm if they would like to proceed339with a client shutdown. */340reset_dialog_text.append(tr("Client will be shut down. Do you want to proceed?"));341//: Window title text of pop-up window shown when the user has chosen to reset options.342QMessageBox::StandardButton btnRetVal = QMessageBox::question(this, tr("Confirm options reset"),343reset_dialog_text, QMessageBox::Yes | QMessageBox::Cancel, QMessageBox::Cancel);345if (btnRetVal == QMessageBox::Cancel)346return;348/* reset all options and close GUI */349model->Reset();350close();351Q_EMIT quitOnReset();352}353}355void OptionsDialog::on_openBitcoinConfButton_clicked()356{357QMessageBox config_msgbox(this);358config_msgbox.setIcon(QMessageBox::Information);359//: Window title text of pop-up box that allows opening up of configuration file.360config_msgbox.setWindowTitle(tr("Configuration options"));361/*: Explanatory text about the priority order of instructions considered by client.362The order from high to low being: command-line, configuration file, GUI settings. */363config_msgbox.setText(tr("The configuration file is used to specify advanced user options which override GUI settings. "364"Additionally, any command-line options will override this configuration file."));366QPushButton* open_button = config_msgbox.addButton(tr("Continue"), QMessageBox::ActionRole);367config_msgbox.addButton(tr("Cancel"), QMessageBox::RejectRole);368open_button->setDefault(true);370config_msgbox.exec();372if (config_msgbox.clickedButton() != open_button) return;374/* show an error if there was some problem opening the file */375if (!GUIUtil::openBitcoinConf())376QMessageBox::critical(this, tr("Error"), tr("The configuration file could not be opened."));377}379void OptionsDialog::on_okButton_clicked()380{381model->setData(model->index(OptionsModel::FontForMoney, 0), ui->moneyFont->itemData(ui->moneyFont->currentIndex()));383mapper->submit();384accept();385updateDefaultProxyNets();386}388void OptionsDialog::on_cancelButton_clicked()389{390reject();391}393void OptionsDialog::on_showTrayIcon_stateChanged(int state)394{395if (state == Qt::Checked) {396ui->minimizeToTray->setEnabled(true);397} else {398ui->minimizeToTray->setChecked(false);399ui->minimizeToTray->setEnabled(false);400}401}403void OptionsDialog::togglePruneWarning(bool enabled)404{405ui->pruneWarning->setVisible(!ui->pruneWarning->isVisible());406}408void OptionsDialog::showRestartWarning(bool fPersistent)409{410ui->statusLabel->setStyleSheet("QLabel { color: red; }");412if(fPersistent)413{414ui->statusLabel->setText(tr("Client restart required to activate changes."));415}416else417{418ui->statusLabel->setText(tr("This change would require a client restart."));419// clear non-persistent status label after 10 seconds420// Todo: should perhaps be a class attribute, if we extend the use of statusLabel421QTimer::singleShot(10s, this, &OptionsDialog::clearStatusLabel);422}423}425void OptionsDialog::clearStatusLabel()426{427ui->statusLabel->clear();428if (model && model->isRestartRequired()) {429showRestartWarning(true);430}431}433void OptionsDialog::updateProxyValidationState()434{435QValidatedLineEdit *pUiProxyIp = ui->proxyIp;436QValidatedLineEdit *otherProxyWidget = (pUiProxyIp == ui->proxyIpTor) ? ui->proxyIp : ui->proxyIpTor;437if (pUiProxyIp->isValid() && (!ui->proxyPort->isEnabled() || ui->proxyPort->text().toInt() > 0) && (!ui->proxyPortTor->isEnabled() || ui->proxyPortTor->text().toInt() > 0))438{439setOkButtonState(otherProxyWidget->isValid()); //only enable ok button if both proxies are valid440clearStatusLabel();441}442else443{444setOkButtonState(false);445ui->statusLabel->setStyleSheet("QLabel { color: red; }");446ui->statusLabel->setText(tr("The supplied proxy address is invalid."));447}448}450void OptionsDialog::updateDefaultProxyNets()451{452std::string proxyIpText{ui->proxyIp->text().toStdString()};453if (!IsUnixSocketPath(proxyIpText)) {454const std::optional<CNetAddr> ui_proxy_netaddr{LookupHost(proxyIpText, /*fAllowLookup=*/false)};455const CService ui_proxy{ui_proxy_netaddr.value_or(CNetAddr{}), ui->proxyPort->text().toUShort()};456proxyIpText = ui_proxy.ToStringAddrPort();457}459const auto proxy_ipv4 = model->node().getProxy(NET_IPV4);460ui->proxyReachIPv4->setChecked(proxy_ipv4 && proxy_ipv4->ToString() == proxyIpText);462const auto proxy_ipv6 = model->node().getProxy(NET_IPV6);463ui->proxyReachIPv6->setChecked(proxy_ipv6 && proxy_ipv6->ToString() == proxyIpText);465const auto proxy_onion = model->node().getProxy(NET_ONION);466ui->proxyReachTor->setChecked(proxy_onion && proxy_onion->ToString() == proxyIpText);467}469ProxyAddressValidator::ProxyAddressValidator(QObject *parent) :470QValidator(parent)471{472}474QValidator::State ProxyAddressValidator::validate(QString &input, int &pos) const475{476Q_UNUSED(pos);477uint16_t port{0};478std::string hostname;479if (!SplitHostPort(input.toStdString(), port, hostname) || port != 0) return QValidator::Invalid;481CService serv(LookupNumeric(input.toStdString(), DEFAULT_GUI_PROXY_PORT));482Proxy addrProxy = Proxy(serv, /*tor_stream_isolation=*/true);483if (addrProxy.IsValid())484return QValidator::Acceptable;486return QValidator::Invalid;487}
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.