Skip to content
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

wallet: Remove unused AskPassphraseDialog::Decrypt #109

Merged
merged 3 commits into from
Nov 18, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 2 additions & 27 deletions src/qt/askpassphrasedialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,6 @@ AskPassphraseDialog::AskPassphraseDialog(Mode _mode, QWidget *parent, SecureStri
ui->passEdit3->hide();
setWindowTitle(tr("Unlock wallet"));
break;
case Decrypt: // Ask passphrase
ui->warningLabel->setText(tr("This operation needs your wallet passphrase to decrypt the wallet."));
ui->passLabel2->hide();
ui->passEdit2->hide();
ui->passLabel3->hide();
ui->passEdit3->hide();
setWindowTitle(tr("Decrypt wallet"));
break;
case ChangePass: // Ask old passphrase + new passphrase x2
setWindowTitle(tr("Change passphrase"));
ui->warningLabel->setText(tr("Enter the old passphrase and new passphrase for the wallet."));
Expand Down Expand Up @@ -133,8 +125,7 @@ void AskPassphraseDialog::accept()
"</b></qt>");
} else {
assert(model != nullptr);
if(model->setWalletEncrypted(true, newpass1))
{
if (model->setWalletEncrypted(newpass1)) {
QMessageBox::warning(this, tr("Wallet encrypted"),
"<qt>" +
tr("Your wallet is now encrypted. ") + encryption_reminder +
Expand All @@ -144,9 +135,7 @@ void AskPassphraseDialog::accept()
"For security reasons, previous backups of the unencrypted wallet file "
"will become useless as soon as you start using the new, encrypted wallet.") +
"</b></qt>");
}
else
{
} else {
QMessageBox::critical(this, tr("Wallet encryption failed"),
tr("Wallet encryption failed due to an internal error. Your wallet was not encrypted."));
}
Expand Down Expand Up @@ -176,17 +165,6 @@ void AskPassphraseDialog::accept()
QMessageBox::critical(this, tr("Wallet unlock failed"), e.what());
}
break;
case Decrypt:
if(!model->setWalletEncrypted(false, oldpass))
{
QMessageBox::critical(this, tr("Wallet decryption failed"),
tr("The passphrase entered for the wallet decryption was incorrect."));
}
else
{
QDialog::accept(); // Success
}
break;
case ChangePass:
if(newpass1 == newpass2)
{
Expand Down Expand Up @@ -221,9 +199,6 @@ void AskPassphraseDialog::textChanged()
acceptable = !ui->passEdit2->text().isEmpty() && !ui->passEdit3->text().isEmpty();
break;
case Unlock: // Old passphrase x1
case Decrypt:
acceptable = !ui->passEdit1->text().isEmpty();
break;
case ChangePass: // Old passphrase x1, new passphrase x2
acceptable = !ui->passEdit1->text().isEmpty() && !ui->passEdit2->text().isEmpty() && !ui->passEdit3->text().isEmpty();
break;
Expand Down
1 change: 0 additions & 1 deletion src/qt/askpassphrasedialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ class AskPassphraseDialog : public QDialog
Encrypt, /**< Ask passphrase twice and encrypt */
Unlock, /**< Ask passphrase and unlock */
ChangePass, /**< Ask old passphrase + new passphrase twice */
Decrypt /**< Ask passphrase and decrypt wallet */
};

explicit AskPassphraseDialog(Mode mode, QWidget *parent, SecureString* passphrase_out = nullptr);
Expand Down
4 changes: 2 additions & 2 deletions src/qt/walletframe.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -194,11 +194,11 @@ void WalletFrame::gotoLoadPSBT(bool from_clipboard)
}
}

void WalletFrame::encryptWallet(bool status)
void WalletFrame::encryptWallet()
{
WalletView *walletView = currentWalletView();
if (walletView)
walletView->encryptWallet(status);
walletView->encryptWallet();
}

void WalletFrame::backupWallet()
Expand Down
2 changes: 1 addition & 1 deletion src/qt/walletframe.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public Q_SLOTS:
void gotoLoadPSBT(bool from_clipboard = false);

/** Encrypt the wallet */
void encryptWallet(bool status);
void encryptWallet();
/** Backup the wallet */
void backupWallet();
/** Change encrypted wallet passphrase */
Expand Down
7 changes: 2 additions & 5 deletions src/qt/walletmodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -313,12 +313,9 @@ WalletModel::EncryptionStatus WalletModel::getEncryptionStatus() const
}
}

bool WalletModel::setWalletEncrypted(bool encrypted, const SecureString &passphrase)
bool WalletModel::setWalletEncrypted(const SecureString& passphrase)
{
if (encrypted) {
return m_wallet->encryptWallet(passphrase);
}
return false;
return m_wallet->encryptWallet(passphrase);
}

bool WalletModel::setWalletLocked(bool locked, const SecureString &passPhrase)
Expand Down
2 changes: 1 addition & 1 deletion src/qt/walletmodel.h
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ class WalletModel : public QObject
SendCoinsReturn sendCoins(WalletModelTransaction &transaction);

// Wallet encryption
bool setWalletEncrypted(bool encrypted, const SecureString &passphrase);
bool setWalletEncrypted(const SecureString& passphrase);
// Passphrase only needed when unlocking
bool setWalletLocked(bool locked, const SecureString &passPhrase=SecureString());
bool changePassphrase(const SecureString &oldPass, const SecureString &newPass);
Expand Down
4 changes: 2 additions & 2 deletions src/qt/walletview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -258,11 +258,11 @@ void WalletView::updateEncryptionStatus()
Q_EMIT encryptionStatusChanged();
}

void WalletView::encryptWallet(bool status)
void WalletView::encryptWallet()
{
if(!walletModel)
return;
AskPassphraseDialog dlg(status ? AskPassphraseDialog::Encrypt : AskPassphraseDialog::Decrypt, this);
AskPassphraseDialog dlg(AskPassphraseDialog::Encrypt, this);
dlg.setModel(walletModel);
dlg.exec();

Expand Down
2 changes: 1 addition & 1 deletion src/qt/walletview.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ public Q_SLOTS:
*/
void processNewTransaction(const QModelIndex& parent, int start, int /*end*/);
/** Encrypt the wallet */
void encryptWallet(bool status);
void encryptWallet();
/** Backup the wallet */
void backupWallet();
/** Change encrypted wallet passphrase */
Expand Down