-
Notifications
You must be signed in to change notification settings - Fork 312
Add Wallet Restore in the GUI #471
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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); | ||
Comment on lines
+433
to
+434
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. A translator comment followed by a line with more than one |
||
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); | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.