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.
501}502m_migrate_wallet_menu->addSeparator();503QAction* restore_migrate_file_action = m_migrate_wallet_menu->addAction(tr("Restore and Migrate Wallet File…"));504restore_migrate_file_action->setEnabled(true);506connect(restore_migrate_file_action, &QAction::triggered, [this] {507QString name_data_file = tr("Wallet Data");508QString title_windows = tr("Restore and Migrate Wallet Backup");510QString backup_file = GUIUtil::getOpenFileName(this, title_windows, QString(), name_data_file + QLatin1String(" (*.dat)"), nullptr);511if (backup_file.isEmpty()) return;513bool wallet_name_ok;514/*: Title of pop-up window shown when the user is attempting to515restore a wallet. */516QString title = tr("Restore and Migrate Wallet");517//: Label of the input field where the name of the wallet is entered.518QString label = tr("Wallet Name");519QString wallet_name = QInputDialog::getText(this, title, label, QLineEdit::Normal, "", &wallet_name_ok);520if (!wallet_name_ok || wallet_name.isEmpty()) return;522auto activity = new MigrateWalletActivity(m_wallet_controller, this);523connect(activity, &MigrateWalletActivity::migrated, this, &BitcoinGUI::setCurrentWallet);524connect(activity, &MigrateWalletActivity::migrated, rpcConsole, &RPCConsole::setCurrentWallet);525auto backup_file_path = fs::PathFromString(backup_file.toStdString());526activity->restore_and_migrate(backup_file_path, wallet_name.toStdString());527});528});529connect(m_mask_values_action, &QAction::toggled, this, &BitcoinGUI::setPrivacy);530connect(m_mask_values_action, &QAction::toggled, this, &BitcoinGUI::enableHistoryAction);531GUIUtil::ExceptionSafeConnect(m_export_watchonly_action, &QAction::triggered, [this](bool) {532QString destination = GUIUtil::getSaveFileName(this,533tr("Save Watch-only Wallet Export"), QString(),534//: Name of the wallet data file format.535tr("Wallet Data") + QLatin1String(" (*.dat)"), nullptr);537if (destination.isEmpty()) return;538WalletModel* model = walletFrame->currentWalletModel();539if (!Assume(model)) return;540util::Result<std::string> export_res = model->wallet().exportWatchOnlyWallet(GUIUtil::QStringToPath(destination));541if (export_res) {542QMessageBox::information(nullptr, tr("Export Successful"), tr("The wallet has been exported to ") + QString::fromStdString(*export_res));543} else {544QMessageBox::critical(nullptr, tr("Export Error"), QString::fromStdString(util::ErrorString(export_res).translated));545}546});547}548#endif // ENABLE_WALLET550connect(new QShortcut(QKeySequence(Qt::CTRL | Qt::SHIFT | Qt::Key_C), this), &QShortcut::activated, this, &BitcoinGUI::showDebugWindowActivateConsole);551connect(new QShortcut(QKeySequence(Qt::CTRL | Qt::SHIFT | Qt::Key_D), this), &QShortcut::activated, this, &BitcoinGUI::showDebugWindow);552}554void BitcoinGUI::createMenuBar()555{556appMenuBar = menuBar();558// Configure the menus559QMenu *file = appMenuBar->addMenu(tr("&File"));560if(walletFrame)561{562file->addAction(m_create_wallet_action);563file->addAction(m_open_wallet_action);564file->addAction(m_close_wallet_action);565file->addAction(m_close_all_wallets_action);566file->addAction(m_migrate_wallet_action);567file->addSeparator();568file->addAction(backupWalletAction);569file->addAction(m_restore_wallet_action);570file->addAction(m_export_watchonly_action);571file->addSeparator();572file->addAction(openAction);573file->addAction(signMessageAction);574file->addAction(verifyMessageAction);575file->addAction(m_load_psbt_action);576file->addAction(m_load_psbt_clipboard_action);577file->addSeparator();578}579file->addAction(quitAction);581QMenu *settings = appMenuBar->addMenu(tr("&Settings"));582if(walletFrame)583{584settings->addAction(encryptWalletAction);585settings->addAction(changePassphraseAction);586settings->addSeparator();587settings->addAction(m_mask_values_action);588settings->addSeparator();589}590settings->addAction(optionsAction);592QMenu* window_menu = appMenuBar->addMenu(tr("&Window"));594QAction* minimize_action = window_menu->addAction(tr("&Minimize"));595minimize_action->setShortcut(QKeySequence(tr("Ctrl+M")));596connect(minimize_action, &QAction::triggered, [] {597QApplication::activeWindow()->showMinimized();598});599connect(qApp, &QApplication::focusWindowChanged, this, [minimize_action] (QWindow* window) {600minimize_action->setEnabled(window != nullptr && (window->flags() & Qt::Dialog) != Qt::Dialog && window->windowState() != Qt::WindowMinimized);601});603#ifdef Q_OS_MACOS604QAction* zoom_action = window_menu->addAction(tr("Zoom"));605connect(zoom_action, &QAction::triggered, [] {606QWindow* window = qApp->focusWindow();607if (window->windowState() != Qt::WindowMaximized) {608window->showMaximized();609} else {610window->showNormal();611}612});614connect(qApp, &QApplication::focusWindowChanged, this, [zoom_action] (QWindow* window) {615zoom_action->setEnabled(window != nullptr);616});617#endif619if (walletFrame) {620#ifdef Q_OS_MACOS621window_menu->addSeparator();622QAction* main_window_action = window_menu->addAction(tr("Main Window"));623connect(main_window_action, &QAction::triggered, [this] {624GUIUtil::bringToFront(this);625});626#endif627window_menu->addSeparator();628window_menu->addAction(usedSendingAddressesAction);629window_menu->addAction(usedReceivingAddressesAction);630}632window_menu->addSeparator();633for (RPCConsole::TabTypes tab_type : rpcConsole->tabs()) {634QAction* tab_action = window_menu->addAction(rpcConsole->tabTitle(tab_type));635tab_action->setShortcut(rpcConsole->tabShortcut(tab_type));636connect(tab_action, &QAction::triggered, [this, tab_type] {637rpcConsole->setTabFocus(tab_type);638showDebugWindow();639});640}642QMenu *help = appMenuBar->addMenu(tr("&Help"));643help->addAction(showHelpMessageAction);644help->addSeparator();645help->addAction(aboutAction);646help->addAction(aboutQtAction);647}649void BitcoinGUI::createToolBars()650{651if(walletFrame)652{653QToolBar *toolbar = addToolBar(tr("Tabs toolbar"));654appToolBar = toolbar;655toolbar->setMovable(false);656toolbar->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);657toolbar->addAction(overviewAction);658toolbar->addAction(sendCoinsAction);659toolbar->addAction(receiveCoinsAction);660toolbar->addAction(historyAction);661overviewAction->setChecked(true);663#ifdef ENABLE_WALLET664QWidget *spacer = new QWidget();665spacer->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);666toolbar->addWidget(spacer);668m_wallet_selector = new QComboBox();669m_wallet_selector->setSizeAdjustPolicy(QComboBox::AdjustToContents);670connect(m_wallet_selector, qOverload<int>(&QComboBox::currentIndexChanged), this, &BitcoinGUI::setCurrentWalletBySelectorIndex);672m_wallet_selector_label = new QLabel();673m_wallet_selector_label->setText(tr("Wallet:") + " ");674m_wallet_selector_label->setBuddy(m_wallet_selector);676m_wallet_selector_label_action = appToolBar->addWidget(m_wallet_selector_label);677m_wallet_selector_action = appToolBar->addWidget(m_wallet_selector);679m_wallet_selector_label_action->setVisible(false);680m_wallet_selector_action->setVisible(false);681#endif682}683}685void BitcoinGUI::setClientModel(ClientModel *_clientModel, interfaces::BlockAndHeaderTipInfo* tip_info)686{687this->clientModel = _clientModel;688if(_clientModel)689{690// Create system tray menu (or setup the dock menu) that late to prevent users from calling actions,691// while the client has not yet fully loaded692createTrayIconMenu();694// Keep up to date with client695setNetworkActive(m_node.getNetworkActive());696connect(connectionsControl, &GUIUtil::ClickableLabel::clicked, [this] {697GUIUtil::PopupMenu(m_network_context_menu, QCursor::pos());698});699connect(_clientModel, &ClientModel::numConnectionsChanged, this, &BitcoinGUI::setNumConnections);700connect(_clientModel, &ClientModel::networkActiveChanged, this, &BitcoinGUI::setNetworkActive);702modalOverlay->setKnownBestHeight(tip_info->header_height, QDateTime::fromSecsSinceEpoch(tip_info->header_time), /*presync=*/false);703setNumBlocks(tip_info->block_height, QDateTime::fromSecsSinceEpoch(tip_info->block_time), tip_info->verification_progress, SyncType::BLOCK_SYNC, SynchronizationState::INIT_DOWNLOAD);704connect(_clientModel, &ClientModel::numBlocksChanged, this, &BitcoinGUI::setNumBlocks);706// Receive and report messages from client model707connect(_clientModel, &ClientModel::message, [this](const QString &title, const QString &message, unsigned int style){708this->message(title, message, style);709});711// Show progress dialog712connect(_clientModel, &ClientModel::showProgress, this, &BitcoinGUI::showProgress);714rpcConsole->setClientModel(_clientModel, tip_info->block_height, tip_info->block_time, tip_info->verification_progress);716updateProxyIcon();718#ifdef ENABLE_WALLET719if(walletFrame)720{721walletFrame->setClientModel(_clientModel);722}723#endif // ENABLE_WALLET724unitDisplayControl->setOptionsModel(_clientModel->getOptionsModel());726OptionsModel* optionsModel = _clientModel->getOptionsModel();727if (optionsModel && trayIcon) {728// be aware of the tray icon disable state change reported by the OptionsModel object.729connect(optionsModel, &OptionsModel::showTrayIconChanged, trayIcon, &QSystemTrayIcon::setVisible);731// initialize the disable state of the tray icon with the current value in the model.732trayIcon->setVisible(optionsModel->getShowTrayIcon());733}735m_mask_values_action->setChecked(_clientModel->getOptionsModel()->getOption(OptionsModel::OptionID::MaskValues).toBool());736} else {737// Shutdown requested, disable menus738if (trayIconMenu)739{740// Disable context menu on tray icon741trayIconMenu->clear();742}743// Propagate cleared model to child objects744rpcConsole->setClientModel(nullptr);745#ifdef ENABLE_WALLET746if (walletFrame)747{748walletFrame->setClientModel(nullptr);749}750#endif // ENABLE_WALLET
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.