Skip to content

wallet: Remove unused AskPassphraseDialog::Decrypt #2299

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 2 commits into from
Aug 28, 2021
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
44 changes: 7 additions & 37 deletions src/qt/askpassphrasedialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,6 @@ AskPassphraseDialog::AskPassphraseDialog(Mode mode, QWidget* parent)
ui->repeatNewPassphraseEdit->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->newPassphraseLabel->hide();
ui->newPassphraseEdit->hide();
ui->repeatNewPassphraseLabel->hide();
ui->repeatNewPassphraseEdit->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 and new passphrase to the wallet."));
Expand Down Expand Up @@ -112,12 +104,9 @@ void AskPassphraseDialog::accept()
tr("Warning: If you encrypt your wallet and lose your passphrase, you will <b>LOSE ALL OF YOUR COINS</b>!") + "<br><br>" + tr("Are you sure you wish to encrypt your wallet?"),
QMessageBox::Yes|QMessageBox::Cancel,
QMessageBox::Cancel);
if(retval == QMessageBox::Yes)
{
if(newpass1 == newpass2)
{
if(model->setWalletEncrypted(true, newpass1))
{
if(retval == QMessageBox::Yes) {
if(newpass1 == newpass2) {
if(model->setWalletEncrypted(newpass1)) {
QMessageBox::warning(this, tr("Wallet encrypted"),
"<qt>" +
tr("Gridcoin will close now to finish the encryption process. "
Expand All @@ -131,24 +120,19 @@ void AskPassphraseDialog::accept()
"</b></qt>");
QApplication::quit();
}
else
{
else {
QMessageBox::critical(this, tr("Wallet encryption failed"),
tr("Wallet encryption failed due to an internal error. Your wallet was not encrypted."));
}
QDialog::accept(); // Success
}
else
{
} else {
QMessageBox::critical(this, tr("Wallet encryption failed"),
tr("The supplied passphrases do not match."));
}
}
else
{
} else {
QDialog::reject(); // Cancelled
}
} break;
} break;
case UnlockStaking:
case Unlock:
if(!model->setWalletLocked(false, oldpass))
Expand All @@ -162,17 +146,6 @@ void AskPassphraseDialog::accept()
QDialog::accept(); // Success
}
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 @@ -208,9 +181,6 @@ void AskPassphraseDialog::textChanged()
break;
case UnlockStaking:
case Unlock: // Old passphrase x1
case Decrypt:
acceptable = !ui->oldPassphraseEdit->text().isEmpty();
break;
case ChangePass: // Old passphrase x1, new passphrase x2
acceptable = !ui->oldPassphraseEdit->text().isEmpty() && !ui->newPassphraseEdit->text().isEmpty() && !ui->repeatNewPassphraseEdit->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 @@ -21,7 +21,6 @@ class AskPassphraseDialog : public QDialog
UnlockStaking, /**< Ask passphrase and unlock */
Unlock, /**< Ask passphrase and unlock */
ChangePass, /**< Ask old passphrase + new passphrase twice */
Decrypt /**< Ask passphrase and decrypt wallet */
};

explicit AskPassphraseDialog(Mode mode, QWidget* parent = nullptr);
Expand Down
11 changes: 5 additions & 6 deletions src/qt/bitcoingui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,7 @@ void BitcoinGUI::createActions()
researcherAction->setToolTip(tr("Open BOINC and beacon settings for Gridcoin"));
toggleHideAction = new QAction(tr("&Show / Hide"), this);
encryptWalletAction = new QAction(tr("&Encrypt Wallet..."), this);
encryptWalletAction->setToolTip(tr("Encrypt or decrypt wallet"));
encryptWalletAction->setToolTip(tr("Encrypt wallet"));
encryptWalletAction->setCheckable(true);
backupWalletAction = new QAction(tr("&Backup Wallet/Config..."), this);
backupWalletAction->setToolTip(tr("Backup wallet/config to another location"));
Expand Down Expand Up @@ -1480,7 +1480,7 @@ void BitcoinGUI::setEncryptionStatus(int status)
changePassphraseAction->setEnabled(true);
unlockWalletAction->setVisible(false);
lockWalletAction->setVisible(true);
encryptWalletAction->setEnabled(false); // TODO: decrypt currently not supported
encryptWalletAction->setEnabled(false);
break;
case WalletModel::Locked:
labelEncryptionIcon->setPixmap(GRC::ScaleStatusIcon(this, ":/icons/status_encryption_locked_" + sSheet));
Expand All @@ -1489,17 +1489,16 @@ void BitcoinGUI::setEncryptionStatus(int status)
changePassphraseAction->setEnabled(true);
unlockWalletAction->setVisible(true);
lockWalletAction->setVisible(false);
encryptWalletAction->setEnabled(false); // TODO: decrypt currently not supported
encryptWalletAction->setEnabled(false);
break;
}
}

void BitcoinGUI::encryptWallet(bool status)
void BitcoinGUI::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/bitcoingui.h
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ private slots:
*/
void incomingTransaction(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
11 changes: 1 addition & 10 deletions src/qt/walletmodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -323,18 +323,9 @@ WalletModel::EncryptionStatus WalletModel::getEncryptionStatus() const
}
}

bool WalletModel::setWalletEncrypted(bool encrypted, const SecureString &passphrase)
bool WalletModel::setWalletEncrypted(const SecureString& passphrase)
{
if(encrypted)
{
// Encrypt
return wallet->EncryptWallet(passphrase);
}
else
{
// Decrypt -- TODO; not supported yet
return false;
}
}

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 @@ -91,7 +91,7 @@ class WalletModel : public QObject
SendCoinsReturn sendCoins(const QList<SendCoinsRecipient>& recipients, const CCoinControl* coinControl = nullptr);

// 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