mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-12-11 21:22:47 +01:00
Merge bitcoin-core/gui#471: Add Wallet Restore in the GUI
bc13ec888cdoc: Add a release note about the "restore wallet" menu item (w0xlt)e7a3f698b5gui: Add Wallet Restore in the GUI (w0xlt) Pull request description: This PR adds a menu item to restore a wallet from a backup file in the GUI. Currently this option exists only in RPC interface. Motivation: It makes easier for non-technical users to restore backups. Master | PR | --- | --- <img width="307" alt="master" src="https://user-images.githubusercontent.com/94266259/141673349-0bf8a237-ecec-42e4-a0d7-1d5863940036.png"> | <img width="307" alt="pr" src="https://user-images.githubusercontent.com/94266259/141673350-972dea23-ae56-4283-a365-819da62b7067.png"> | ACKs for top commit: w0xlt: Added a release note in a new commit (bc13ec888c) to not invalidate the ACKs for the previous one. furszy: utACKbc13ec8shaavan: ACKbc13ec888chebasto: ACKbc13ec888cTree-SHA512: edc3675484238857b77e74382a4041dd5d2cbcda1e2d5bfe52c83d9d7bb7be8a243ecd97e25e994d8c30ab6d7c59ead5a1c953a46dce173666b137eeffc3c94f
This commit is contained in:
@@ -47,6 +47,7 @@
|
||||
#include <QCursor>
|
||||
#include <QDateTime>
|
||||
#include <QDragEnterEvent>
|
||||
#include <QInputDialog>
|
||||
#include <QKeySequence>
|
||||
#include <QListWidget>
|
||||
#include <QMenu>
|
||||
@@ -348,6 +349,12 @@ void BitcoinGUI::createActions()
|
||||
m_create_wallet_action->setEnabled(false);
|
||||
m_create_wallet_action->setStatusTip(tr("Create a new wallet"));
|
||||
|
||||
//: Name of the menu item that restores wallet from a backup file.
|
||||
m_restore_wallet_action = new QAction(tr("Restore Wallet…"), this);
|
||||
m_restore_wallet_action->setEnabled(false);
|
||||
//: Status tip for Restore Wallet menu item
|
||||
m_restore_wallet_action->setStatusTip(tr("Restore a wallet from a backup file"));
|
||||
|
||||
m_close_all_wallets_action = new QAction(tr("Close All Wallets…"), this);
|
||||
m_close_all_wallets_action->setStatusTip(tr("Close all wallets"));
|
||||
|
||||
@@ -412,6 +419,27 @@ void BitcoinGUI::createActions()
|
||||
action->setEnabled(false);
|
||||
}
|
||||
});
|
||||
connect(m_restore_wallet_action, &QAction::triggered, [this] {
|
||||
//: Name of the wallet data file format.
|
||||
QString name_data_file = tr("Wallet Data");
|
||||
|
||||
//: 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);
|
||||
if (backup_file.isEmpty()) return;
|
||||
|
||||
bool wallet_name_ok;
|
||||
//: Title of the Restore Wallet input dialog (where the wallet name is entered)
|
||||
QString wallet_name = QInputDialog::getText(this, tr("Restore Name"), tr("Wallet Name:"), QLineEdit::Normal, "", &wallet_name_ok);
|
||||
if (!wallet_name_ok || wallet_name.isEmpty()) return;
|
||||
|
||||
auto activity = new RestoreWalletActivity(m_wallet_controller, this);
|
||||
connect(activity, &RestoreWalletActivity::restored, this, &BitcoinGUI::setCurrentWallet, Qt::QueuedConnection);
|
||||
|
||||
auto backup_file_path = fs::PathFromString(backup_file.toStdString());
|
||||
activity->restore(backup_file_path, wallet_name.toStdString());
|
||||
});
|
||||
connect(m_close_wallet_action, &QAction::triggered, [this] {
|
||||
m_wallet_controller->closeWallet(walletFrame->currentWalletModel(), this);
|
||||
});
|
||||
@@ -450,8 +478,10 @@ void BitcoinGUI::createMenuBar()
|
||||
file->addAction(m_close_wallet_action);
|
||||
file->addAction(m_close_all_wallets_action);
|
||||
file->addSeparator();
|
||||
file->addAction(openAction);
|
||||
file->addAction(backupWalletAction);
|
||||
file->addAction(m_restore_wallet_action);
|
||||
file->addSeparator();
|
||||
file->addAction(openAction);
|
||||
file->addAction(signMessageAction);
|
||||
file->addAction(verifyMessageAction);
|
||||
file->addAction(m_load_psbt_action);
|
||||
@@ -642,6 +672,7 @@ void BitcoinGUI::setWalletController(WalletController* wallet_controller)
|
||||
m_create_wallet_action->setEnabled(true);
|
||||
m_open_wallet_action->setEnabled(true);
|
||||
m_open_wallet_action->setMenu(m_open_wallet_menu);
|
||||
m_restore_wallet_action->setEnabled(true);
|
||||
|
||||
GUIUtil::ExceptionSafeConnect(wallet_controller, &WalletController::walletAdded, this, &BitcoinGUI::addWallet);
|
||||
connect(wallet_controller, &WalletController::walletRemoved, this, &BitcoinGUI::removeWallet);
|
||||
|
||||
Reference in New Issue
Block a user