Skip to content

Commit 54532f4

Browse files
author
MarcoFalke
committed
Merge bitcoin-core#109: wallet: Remove unused AskPassphraseDialog::Decrypt
4146a31 qt, wallet: Drop unused parameter in WalletModel::setWalletEncrypted (Hennadii Stepanov) f886a20 qt, wallet: Drop unused parameter in Wallet{Frame|View}::encryptWallet (Hennadii Stepanov) 6e95011 qt, wallet: Remove unused AskPassphraseDialog::Decrypt (Hennadii Stepanov) Pull request description: Grabbed from bitcoin-core#42 with an additional commit. Fix #1. ACKs for top commit: MarcoFalke: ACK 4146a31 promag: Code review ACK 4146a31. Tree-SHA512: 6070d8995525af826ad972cf1b8988ff98af0528eef285a07ec7ba0e2e92a7a6173a19dc371de94d4b437fa10f7921166e45a081de6ed2f4306e6502aafc94ee
2 parents 4ae0409 + 4146a31 commit 54532f4

File tree

8 files changed

+11
-40
lines changed

8 files changed

+11
-40
lines changed

src/qt/askpassphrasedialog.cpp

Lines changed: 2 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -58,14 +58,6 @@ AskPassphraseDialog::AskPassphraseDialog(Mode _mode, QWidget *parent, SecureStri
5858
ui->passEdit3->hide();
5959
setWindowTitle(tr("Unlock wallet"));
6060
break;
61-
case Decrypt: // Ask passphrase
62-
ui->warningLabel->setText(tr("This operation needs your wallet passphrase to decrypt the wallet."));
63-
ui->passLabel2->hide();
64-
ui->passEdit2->hide();
65-
ui->passLabel3->hide();
66-
ui->passEdit3->hide();
67-
setWindowTitle(tr("Decrypt wallet"));
68-
break;
6961
case ChangePass: // Ask old passphrase + new passphrase x2
7062
setWindowTitle(tr("Change passphrase"));
7163
ui->warningLabel->setText(tr("Enter the old passphrase and new passphrase for the wallet."));
@@ -133,8 +125,7 @@ void AskPassphraseDialog::accept()
133125
"</b></qt>");
134126
} else {
135127
assert(model != nullptr);
136-
if(model->setWalletEncrypted(true, newpass1))
137-
{
128+
if (model->setWalletEncrypted(newpass1)) {
138129
QMessageBox::warning(this, tr("Wallet encrypted"),
139130
"<qt>" +
140131
tr("Your wallet is now encrypted. ") + encryption_reminder +
@@ -144,9 +135,7 @@ void AskPassphraseDialog::accept()
144135
"For security reasons, previous backups of the unencrypted wallet file "
145136
"will become useless as soon as you start using the new, encrypted wallet.") +
146137
"</b></qt>");
147-
}
148-
else
149-
{
138+
} else {
150139
QMessageBox::critical(this, tr("Wallet encryption failed"),
151140
tr("Wallet encryption failed due to an internal error. Your wallet was not encrypted."));
152141
}
@@ -176,17 +165,6 @@ void AskPassphraseDialog::accept()
176165
QMessageBox::critical(this, tr("Wallet unlock failed"), e.what());
177166
}
178167
break;
179-
case Decrypt:
180-
if(!model->setWalletEncrypted(false, oldpass))
181-
{
182-
QMessageBox::critical(this, tr("Wallet decryption failed"),
183-
tr("The passphrase entered for the wallet decryption was incorrect."));
184-
}
185-
else
186-
{
187-
QDialog::accept(); // Success
188-
}
189-
break;
190168
case ChangePass:
191169
if(newpass1 == newpass2)
192170
{
@@ -221,9 +199,6 @@ void AskPassphraseDialog::textChanged()
221199
acceptable = !ui->passEdit2->text().isEmpty() && !ui->passEdit3->text().isEmpty();
222200
break;
223201
case Unlock: // Old passphrase x1
224-
case Decrypt:
225-
acceptable = !ui->passEdit1->text().isEmpty();
226-
break;
227202
case ChangePass: // Old passphrase x1, new passphrase x2
228203
acceptable = !ui->passEdit1->text().isEmpty() && !ui->passEdit2->text().isEmpty() && !ui->passEdit3->text().isEmpty();
229204
break;

src/qt/askpassphrasedialog.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ class AskPassphraseDialog : public QDialog
2626
Encrypt, /**< Ask passphrase twice and encrypt */
2727
Unlock, /**< Ask passphrase and unlock */
2828
ChangePass, /**< Ask old passphrase + new passphrase twice */
29-
Decrypt /**< Ask passphrase and decrypt wallet */
3029
};
3130

3231
explicit AskPassphraseDialog(Mode mode, QWidget *parent, SecureString* passphrase_out = nullptr);

src/qt/walletframe.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -196,11 +196,11 @@ void WalletFrame::gotoLoadPSBT(bool from_clipboard)
196196
}
197197
}
198198

199-
void WalletFrame::encryptWallet(bool status)
199+
void WalletFrame::encryptWallet()
200200
{
201201
WalletView *walletView = currentWalletView();
202202
if (walletView)
203-
walletView->encryptWallet(status);
203+
walletView->encryptWallet();
204204
}
205205

206206
void WalletFrame::backupWallet()

src/qt/walletframe.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ public Q_SLOTS:
8686
void gotoLoadPSBT(bool from_clipboard = false);
8787

8888
/** Encrypt the wallet */
89-
void encryptWallet(bool status);
89+
void encryptWallet();
9090
/** Backup the wallet */
9191
void backupWallet();
9292
/** Change encrypted wallet passphrase */

src/qt/walletmodel.cpp

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -313,12 +313,9 @@ WalletModel::EncryptionStatus WalletModel::getEncryptionStatus() const
313313
}
314314
}
315315

316-
bool WalletModel::setWalletEncrypted(bool encrypted, const SecureString &passphrase)
316+
bool WalletModel::setWalletEncrypted(const SecureString& passphrase)
317317
{
318-
if (encrypted) {
319-
return m_wallet->encryptWallet(passphrase);
320-
}
321-
return false;
318+
return m_wallet->encryptWallet(passphrase);
322319
}
323320

324321
bool WalletModel::setWalletLocked(bool locked, const SecureString &passPhrase)

src/qt/walletmodel.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ class WalletModel : public QObject
105105
SendCoinsReturn sendCoins(WalletModelTransaction &transaction);
106106

107107
// Wallet encryption
108-
bool setWalletEncrypted(bool encrypted, const SecureString &passphrase);
108+
bool setWalletEncrypted(const SecureString& passphrase);
109109
// Passphrase only needed when unlocking
110110
bool setWalletLocked(bool locked, const SecureString &passPhrase=SecureString());
111111
bool changePassphrase(const SecureString &oldPass, const SecureString &newPass);

src/qt/walletview.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -258,11 +258,11 @@ void WalletView::updateEncryptionStatus()
258258
Q_EMIT encryptionStatusChanged();
259259
}
260260

261-
void WalletView::encryptWallet(bool status)
261+
void WalletView::encryptWallet()
262262
{
263263
if(!walletModel)
264264
return;
265-
AskPassphraseDialog dlg(status ? AskPassphraseDialog::Encrypt : AskPassphraseDialog::Decrypt, this);
265+
AskPassphraseDialog dlg(AskPassphraseDialog::Encrypt, this);
266266
dlg.setModel(walletModel);
267267
dlg.exec();
268268

src/qt/walletview.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ public Q_SLOTS:
9292
*/
9393
void processNewTransaction(const QModelIndex& parent, int start, int /*end*/);
9494
/** Encrypt the wallet */
95-
void encryptWallet(bool status);
95+
void encryptWallet();
9696
/** Backup the wallet */
9797
void backupWallet();
9898
/** Change encrypted wallet passphrase */

0 commit comments

Comments
 (0)