Skip to content

Commit 7a40f2a

Browse files
committed
Merge #722: wallet: Allow user to navigate options while encrypting at creation
cccddc0 Wallet encrypt on create, allow to navigate options (Hernan Marino) Pull request description: This fixes #394. It adds a "Go back" button to the "Confirm wallet encryption" window, allowing the users to change the password if they want to. It also adds a Cancel button to the "Wallet to be encrypted" window. Prior to this change users had no option to alter the password, and were forced to either go ahead with wallet creation or cancel the whole process. Also, at the final window, they were shown a warning but with no option to cancel. The new workflow for wallet encryption and creation is similar to the following: ![videoNavigation](https://user-images.githubusercontent.com/87907936/225705434-22d3c678-fa01-4079-ba10-ca5a0e8d3922.gif) ACKs for top commit: alfonsoromanz: Re-Tested ACK cccddc0 BrandonOdiwuor: re-Tested ACK cccddc0 hebasto: ACK cccddc0, tested on Ubuntu 24.04. Tree-SHA512: d2856d75f75acbd7d51ede62b4abd317f6ed6a9b890fe0b73b63b921b4b3d61b49477e35dc74466a056a9e8c0c1598df7601111d36c57ef18fdfdf0b18f503e6
2 parents 33303b2 + cccddc0 commit 7a40f2a

File tree

1 file changed

+22
-13
lines changed

1 file changed

+22
-13
lines changed

src/qt/askpassphrasedialog.cpp

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -100,10 +100,14 @@ void AskPassphraseDialog::accept()
100100
// Cannot encrypt with empty passphrase
101101
break;
102102
}
103-
QMessageBox::StandardButton retval = QMessageBox::question(this, tr("Confirm wallet encryption"),
104-
tr("Warning: If you encrypt your wallet and lose your passphrase, you will <b>LOSE ALL OF YOUR BITCOINS</b>!") + "<br><br>" + tr("Are you sure you wish to encrypt your wallet?"),
105-
QMessageBox::Yes|QMessageBox::Cancel,
106-
QMessageBox::Cancel);
103+
QMessageBox msgBoxConfirm(QMessageBox::Question,
104+
tr("Confirm wallet encryption"),
105+
tr("Warning: If you encrypt your wallet and lose your passphrase, you will <b>LOSE ALL OF YOUR BITCOINS</b>!") + "<br><br>" + tr("Are you sure you wish to encrypt your wallet?"),
106+
QMessageBox::Cancel | QMessageBox::Yes, this);
107+
msgBoxConfirm.button(QMessageBox::Yes)->setText(tr("Continue"));
108+
msgBoxConfirm.button(QMessageBox::Cancel)->setText(tr("Back"));
109+
msgBoxConfirm.setDefaultButton(QMessageBox::Cancel);
110+
QMessageBox::StandardButton retval = (QMessageBox::StandardButton)msgBoxConfirm.exec();
107111
if(retval == QMessageBox::Yes)
108112
{
109113
if(newpass1 == newpass2)
@@ -112,10 +116,19 @@ void AskPassphraseDialog::accept()
112116
"your bitcoins from being stolen by malware infecting your computer.");
113117
if (m_passphrase_out) {
114118
m_passphrase_out->assign(newpass1);
115-
QMessageBox::warning(this, tr("Wallet to be encrypted"),
116-
"<qt>" +
117-
tr("Your wallet is about to be encrypted. ") + encryption_reminder +
118-
"</b></qt>");
119+
QMessageBox msgBoxWarning(QMessageBox::Warning,
120+
tr("Wallet to be encrypted"),
121+
"<qt>" +
122+
tr("Your wallet is about to be encrypted. ") + encryption_reminder + " " +
123+
tr("Are you sure you wish to encrypt your wallet?") +
124+
"</b></qt>",
125+
QMessageBox::Cancel | QMessageBox::Yes, this);
126+
msgBoxWarning.setDefaultButton(QMessageBox::Cancel);
127+
QMessageBox::StandardButton retval = (QMessageBox::StandardButton)msgBoxWarning.exec();
128+
if (retval == QMessageBox::Cancel) {
129+
QDialog::reject();
130+
return;
131+
}
119132
} else {
120133
assert(model != nullptr);
121134
if (model->setWalletEncrypted(newpass1)) {
@@ -141,11 +154,7 @@ void AskPassphraseDialog::accept()
141154
tr("The supplied passphrases do not match."));
142155
}
143156
}
144-
else
145-
{
146-
QDialog::reject(); // Cancelled
147-
}
148-
} break;
157+
} break;
149158
case Unlock:
150159
try {
151160
if (!model->setWalletLocked(false, oldpass)) {

0 commit comments

Comments
 (0)