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.
1001GUIUtil::ShowModalDialogAsynchronously(dlg);1002}1004void BitcoinGUI::showDebugWindow()1005{1006GUIUtil::bringToFront(rpcConsole);1007Q_EMIT consoleShown(rpcConsole);1008}1010void BitcoinGUI::showDebugWindowActivateConsole()1011{1012rpcConsole->setTabFocus(RPCConsole::TabTypes::CONSOLE);1013showDebugWindow();1014}1016void BitcoinGUI::showHelpMessageClicked()1017{1018GUIUtil::bringToFront(helpMessageDialog);1019}1021#ifdef ENABLE_WALLET1022void BitcoinGUI::openClicked()1023{1024OpenURIDialog dlg(platformStyle, this);1025if(dlg.exec())1026{1027Q_EMIT receivedURI(dlg.getURI());1028}1029}1031void BitcoinGUI::gotoOverviewPage()1032{1033overviewAction->setChecked(true);1034if (walletFrame) walletFrame->gotoOverviewPage();1035}1037void BitcoinGUI::gotoHistoryPage()1038{1039historyAction->setChecked(true);1040if (walletFrame) walletFrame->gotoHistoryPage();1041}1043void BitcoinGUI::gotoReceiveCoinsPage()1044{1045receiveCoinsAction->setChecked(true);1046if (walletFrame) walletFrame->gotoReceiveCoinsPage();1047}1049void BitcoinGUI::gotoSendCoinsPage(QString addr)1050{1051sendCoinsAction->setChecked(true);1052if (walletFrame) walletFrame->gotoSendCoinsPage(addr);1053}1055void BitcoinGUI::gotoSignMessageTab(QString addr)1056{1057if (walletFrame) walletFrame->gotoSignMessageTab(addr);1058}1060void BitcoinGUI::gotoVerifyMessageTab(QString addr)1061{1062if (walletFrame) walletFrame->gotoVerifyMessageTab(addr);1063}1064void BitcoinGUI::gotoLoadPSBT(bool from_clipboard)1065{1066if (walletFrame) walletFrame->gotoLoadPSBT(from_clipboard);1067}1068#endif // ENABLE_WALLET1070void BitcoinGUI::updateNetworkState()1071{1072if (!clientModel) return;1073int count = clientModel->getNumConnections();1074QString icon;1075switch(count)1076{1077case 0: icon = ":/icons/connect_0"; break;1078case 1: case 2: case 3: icon = ":/icons/connect_1"; break;1079case 4: case 5: case 6: icon = ":/icons/connect_2"; break;1080case 7: case 8: case 9: icon = ":/icons/connect_3"; break;1081default: icon = ":/icons/connect_4"; break;1082}1084QString tooltip;1086if (m_node.getNetworkActive()) {1087//: A substring of the tooltip.1088tooltip = tr("%n active connection(s) to Bitcoin network.", "", count);1089} else {1090//: A substring of the tooltip.1091tooltip = tr("Network activity disabled.");1092icon = ":/icons/network_disabled";1093}1095// Don't word-wrap this (fixed-width) tooltip1096tooltip = QLatin1String("<nobr>") + tooltip + QLatin1String("<br>") +1097//: A substring of the tooltip. "More actions" are available via the context menu.1098tr("Click for more actions.") + QLatin1String("</nobr>");1099connectionsControl->setToolTip(tooltip);1101connectionsControl->setThemedPixmap(icon, STATUSBAR_ICONSIZE, STATUSBAR_ICONSIZE);1102}1104void BitcoinGUI::setNumConnections(int count)1105{1106updateNetworkState();1107}1109void BitcoinGUI::setNetworkActive(bool network_active)1110{1111updateNetworkState();1112m_network_context_menu->clear();1113m_network_context_menu->addAction(1114//: A context menu item. The "Peers tab" is an element of the "Node window".1115tr("Show Peers tab"),1116[this] {1117rpcConsole->setTabFocus(RPCConsole::TabTypes::PEERS);1118showDebugWindow();1119});1120m_network_context_menu->addAction(1121network_active ?1122//: A context menu item.1123tr("Disable network activity") :1124//: A context menu item. The network activity was disabled previously.1125tr("Enable network activity"),1126[this, new_state = !network_active] { m_node.setNetworkActive(new_state); });1127}1129void BitcoinGUI::updateHeadersSyncProgressLabel()1130{1131int64_t headersTipTime = clientModel->getHeaderTipTime();1132int headersTipHeight = clientModel->getHeaderTipHeight();1133int estHeadersLeft = (GetTime() - headersTipTime) / Params().GetConsensus().nPowTargetSpacing;1134if (estHeadersLeft > HEADER_HEIGHT_DELTA_SYNC)1135progressBarLabel->setText(tr("Syncing Headers (%1%)…").arg(QString::number(100.0 / (headersTipHeight+estHeadersLeft)*headersTipHeight, 'f', 1)));1136}1138void BitcoinGUI::updateHeadersPresyncProgressLabel(int64_t height, const QDateTime& blockDate)1139{1140int estHeadersLeft = blockDate.secsTo(QDateTime::currentDateTime()) / Params().GetConsensus().nPowTargetSpacing;1141if (estHeadersLeft > HEADER_HEIGHT_DELTA_SYNC)1142progressBarLabel->setText(tr("Pre-syncing Headers (%1%)…").arg(QString::number(100.0 / (height+estHeadersLeft)*height, 'f', 1)));1143}1145void BitcoinGUI::openOptionsDialogWithTab(OptionsDialog::Tab tab)1146{1147if (!clientModel || !clientModel->getOptionsModel())1148return;1150auto dlg = new OptionsDialog(this, enableWallet);1151connect(dlg, &OptionsDialog::quitOnReset, this, &BitcoinGUI::quitRequested);1152dlg->setCurrentTab(tab);1153dlg->setClientModel(clientModel);1154dlg->setModel(clientModel->getOptionsModel());1155GUIUtil::ShowModalDialogAsynchronously(dlg);1156}1158void BitcoinGUI::setNumBlocks(int count, const QDateTime& blockDate, double nVerificationProgress, SyncType synctype, SynchronizationState sync_state)1159{1160// Disabling macOS App Nap on initial sync, disk and reindex operations.1161#ifdef Q_OS_MACOS1162if (sync_state == SynchronizationState::POST_INIT) {1163m_app_nap_inhibitor->enableAppNap();1164} else {1165m_app_nap_inhibitor->disableAppNap();1166}1167#endif1169if (modalOverlay)1170{1171if (synctype != SyncType::BLOCK_SYNC)1172modalOverlay->setKnownBestHeight(count, blockDate, synctype == SyncType::HEADER_PRESYNC);1173else1174modalOverlay->tipUpdate(count, blockDate, nVerificationProgress);1175}1176if (!clientModel)1177return;1179// Prevent orphan statusbar messages (e.g. hover Quit in main menu, wait until chain-sync starts -> garbled text)1180statusBar()->clearMessage();1182// Acquire current block source1183BlockSource blockSource{clientModel->getBlockSource()};1184switch (blockSource) {1185case BlockSource::NETWORK:1186if (synctype == SyncType::HEADER_PRESYNC) {1187updateHeadersPresyncProgressLabel(count, blockDate);1188return;1189} else if (synctype == SyncType::HEADER_SYNC) {1190updateHeadersSyncProgressLabel();1191return;1192}1193progressBarLabel->setText(tr("Synchronizing with network…"));1194updateHeadersSyncProgressLabel();1195break;1196case BlockSource::DISK:1197if (synctype != SyncType::BLOCK_SYNC) {1198progressBarLabel->setText(tr("Indexing blocks on disk…"));1199} else {1200progressBarLabel->setText(tr("Processing blocks on disk…"));1201}1202break;1203case BlockSource::NONE:1204if (synctype != SyncType::BLOCK_SYNC) {1205return;1206}1207progressBarLabel->setText(tr("Connecting to peers…"));1208break;1209}1211QString tooltip;1213QDateTime currentDate = QDateTime::currentDateTime();1214qint64 secs = blockDate.secsTo(currentDate);1216tooltip = tr("Processed %n block(s) of transaction history.", "", count);1218// Set icon state: spinning if catching up, tick otherwise1219if (secs < MAX_BLOCK_TIME_GAP) {1220tooltip = tr("Up to date") + QString(".<br>") + tooltip;1221labelBlocksIcon->setThemedPixmap(QStringLiteral(":/icons/synced"), STATUSBAR_ICONSIZE, STATUSBAR_ICONSIZE);1223#ifdef ENABLE_WALLET1224if(walletFrame)1225{1226walletFrame->showOutOfSyncWarning(false);1227modalOverlay->showHide(true, true);1228}1229#endif // ENABLE_WALLET1231progressBarLabel->setVisible(false);1232progressBar->setVisible(false);1233}1234else1235{1236QString timeBehindText = GUIUtil::formatNiceTimeOffset(secs);1238progressBarLabel->setVisible(true);1239progressBar->setFormat(tr("%1 behind").arg(timeBehindText));1240progressBar->setMaximum(1000000000);1241progressBar->setValue(nVerificationProgress * 1000000000.0 + 0.5);1242progressBar->setVisible(true);1244tooltip = tr("Catching up…") + QString("<br>") + tooltip;1245if(count != prevBlocks)1246{1247labelBlocksIcon->setThemedPixmap(1248QString(":/animation/spinner-%1").arg(spinnerFrame, 3, 10, QChar('0')),1249STATUSBAR_ICONSIZE, STATUSBAR_ICONSIZE);1250spinnerFrame = (spinnerFrame + 1) % SPINNER_FRAMES;
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.