Merge bitcoin-core/gui#957: fix: add .dat file extension automatically when exporting watchonly

75a4e6c678 gui: fix allow restore wallets without .dat file extension (Pol Espinasa)
6ed7e05e20 gui: fix add .dat file extension automatically when exporting watchonly (Pol Espinasa)

Pull request description:

  fixes https://github.com/bitcoin-core/gui/issues/956

  Unlike `backup wallet`, `export watch-only wallet` was not automatically adding the file extension to the exported file, making restoring difficult if the user doesn't manually add the file extension after exporting.

  Allows also to restore a wallet from a non specified `.dat` file extension. This is achieved by removing the filter in the select file screen, matching the RPC behavior.

ACKs for top commit:
  hebasto:
    ACK 75a4e6c678.

Tree-SHA512: 7c45d51205f9abf2b67233e8abd3297e49a4230eb32aa4118b37ab9da0a8d692aae4b67a8880881e5fab42256d1cf52ccf1b289b8f23f85930354130c192b33d
This commit is contained in:
Hennadii Stepanov
2026-08-15 11:39:53 +01:00

View File

@@ -444,7 +444,7 @@ void BitcoinGUI::createActions()
//: The title for Restore Wallet File Windows
QString title_windows = tr("Load Wallet Backup");
QString backup_file = GUIUtil::getOpenFileName(this, title_windows, QString(), name_data_file + QLatin1String(" (*.dat)"), nullptr);
QString backup_file = GUIUtil::getOpenFileName(this, title_windows, QString(), name_data_file + QLatin1String(" (*.dat *.wallet);;") + tr("All Files") + QLatin1String(" (*)"), nullptr);
if (backup_file.isEmpty()) return;
bool wallet_name_ok;
@@ -529,7 +529,11 @@ void BitcoinGUI::createActions()
connect(m_mask_values_action, &QAction::toggled, this, &BitcoinGUI::setPrivacy);
connect(m_mask_values_action, &QAction::toggled, this, &BitcoinGUI::enableHistoryAction);
GUIUtil::ExceptionSafeConnect(m_export_watchonly_action, &QAction::triggered, [this](bool) {
QString destination = GUIUtil::getSaveFileName(this, tr("Save Watch-only Wallet Export"), QString(), QString(), nullptr);
QString destination = GUIUtil::getSaveFileName(this,
tr("Save Watch-only Wallet Export"), QString(),
//: Name of the wallet data file format.
tr("Wallet Data") + QLatin1String(" (*.dat)"), nullptr);
if (destination.isEmpty()) return;
WalletModel* model = walletFrame->currentWalletModel();
if (!Assume(model)) return;