@@ -377,6 +377,10 @@ void BitcoinGUI::createActions()
377377 m_mask_values_action->setStatusTip (tr (" Mask the values in the Overview tab" ));
378378 m_mask_values_action->setCheckable (true );
379379
380+ m_export_watchonly_action = new QAction (tr (" Export watch-only wallet" ), this );
381+ m_export_watchonly_action->setEnabled (false );
382+ m_export_watchonly_action->setStatusTip (tr (" Export a watch-only version of the current wallet that can be restored onto another node." ));
383+
380384 connect (quitAction, &QAction::triggered, this , &BitcoinGUI::quitRequested);
381385 connect (aboutAction, &QAction::triggered, this , &BitcoinGUI::aboutClicked);
382386 connect (aboutQtAction, &QAction::triggered, qApp, QApplication::aboutQt);
@@ -524,6 +528,18 @@ void BitcoinGUI::createActions()
524528 });
525529 connect (m_mask_values_action, &QAction::toggled, this , &BitcoinGUI::setPrivacy);
526530 connect (m_mask_values_action, &QAction::toggled, this , &BitcoinGUI::enableHistoryAction);
531+ GUIUtil::ExceptionSafeConnect (m_export_watchonly_action, &QAction::triggered, [this ](bool ) {
532+ QString destination = GUIUtil::getSaveFileName (this , tr (" Save Watch-only Wallet Export" ), QString (), QString (), nullptr );
533+ if (destination.isEmpty ()) return ;
534+ WalletModel* model = walletFrame->currentWalletModel ();
535+ if (!Assume (model)) return ;
536+ util::Result<std::string> export_res = model->wallet ().exportWatchOnlyWallet (GUIUtil::QStringToPath (destination));
537+ if (export_res) {
538+ QMessageBox::information (nullptr , tr (" Export Successful" ), tr (" The wallet has been exported to " ) + QString::fromStdString (*export_res));
539+ } else {
540+ QMessageBox::critical (nullptr , tr (" Export Error" ), QString::fromStdString (util::ErrorString (export_res).translated ));
541+ }
542+ });
527543 }
528544#endif // ENABLE_WALLET
529545
@@ -547,6 +563,7 @@ void BitcoinGUI::createMenuBar()
547563 file->addSeparator ();
548564 file->addAction (backupWalletAction);
549565 file->addAction (m_restore_wallet_action);
566+ file->addAction (m_export_watchonly_action);
550567 file->addSeparator ();
551568 file->addAction (openAction);
552569 file->addAction (signMessageAction);
@@ -832,6 +849,7 @@ void BitcoinGUI::setCurrentWallet(WalletModel* wallet_model)
832849 break ;
833850 }
834851 }
852+ m_export_watchonly_action->setEnabled (!wallet_model->wallet ().privateKeysDisabled ());
835853 updateWindowTitle ();
836854}
837855
@@ -866,6 +884,7 @@ void BitcoinGUI::setWalletActionsEnabled(bool enabled)
866884 openAction->setEnabled (enabled);
867885 m_close_wallet_action->setEnabled (enabled);
868886 m_close_all_wallets_action->setEnabled (enabled);
887+ m_export_watchonly_action->setEnabled (enabled);
869888}
870889
871890void BitcoinGUI::createTrayIcon ()
0 commit comments