From 0cc5f0f3a77e98d2ef1dfb1262609b449aa5050f Mon Sep 17 00:00:00 2001 From: MarcoFalke Date: Wed, 18 Nov 2020 11:19:34 +0100 Subject: [PATCH] Merge bitcoin-core/gui#109: wallet: Remove unused AskPassphraseDialog::Decrypt 4146a31ccbb012ff552f303113979b48c086532b qt, wallet: Drop unused parameter in WalletModel::setWalletEncrypted (Hennadii Stepanov) f886a20b02094d657ddb3d792d561d50f2107f07 qt, wallet: Drop unused parameter in Wallet{Frame|View}::encryptWallet (Hennadii Stepanov) 6e950118a31fd6a85026d934fc6adb6255e47e23 qt, wallet: Remove unused AskPassphraseDialog::Decrypt (Hennadii Stepanov) Pull request description: Grabbed from #42 with an additional commit. Fix #1. ACKs for top commit: MarcoFalke: ACK 4146a31ccbb012ff552f303113979b48c086532b promag: Code review ACK 4146a31ccbb012ff552f303113979b48c086532b. Tree-SHA512: 6070d8995525af826ad972cf1b8988ff98af0528eef285a07ec7ba0e2e92a7a6173a19dc371de94d4b437fa10f7921166e45a081de6ed2f4306e6502aafc94ee --- src/qt/askpassphrasedialog.cpp | 29 ++--------------------------- src/qt/askpassphrasedialog.h | 1 - src/qt/walletmodel.cpp | 7 ++----- src/qt/walletmodel.h | 2 +- 4 files changed, 5 insertions(+), 34 deletions(-) diff --git a/src/qt/askpassphrasedialog.cpp b/src/qt/askpassphrasedialog.cpp index 27ba8e4135..b4043e0e32 100644 --- a/src/qt/askpassphrasedialog.cpp +++ b/src/qt/askpassphrasedialog.cpp @@ -73,14 +73,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.")); @@ -148,8 +140,7 @@ void AskPassphraseDialog::accept() ""); } else { assert(model != nullptr); - if(model->setWalletEncrypted(true, newpass1)) - { + if (model->setWalletEncrypted(newpass1)) { if (model->wallet().hdEnabled()) { QMessageBox::warning(this, tr("Wallet encrypted"), "" + @@ -171,9 +162,7 @@ void AskPassphraseDialog::accept() "will become useless as soon as you start using the new, encrypted wallet.") + ""); } - } - else - { + } else { QMessageBox::critical(this, tr("Wallet encryption failed"), tr("Wallet encryption failed due to an internal error. Your wallet was not encrypted.")); } @@ -207,17 +196,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) { @@ -253,9 +231,6 @@ void AskPassphraseDialog::textChanged() break; case UnlockMixing: // Old passphrase x1 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; diff --git a/src/qt/askpassphrasedialog.h b/src/qt/askpassphrasedialog.h index 7871ee5348..3c4ace26d9 100644 --- a/src/qt/askpassphrasedialog.h +++ b/src/qt/askpassphrasedialog.h @@ -27,7 +27,6 @@ public: UnlockMixing, /**< Ask passphrase and unlock only for mixing */ 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); diff --git a/src/qt/walletmodel.cpp b/src/qt/walletmodel.cpp index e0b6bcd305..1a65521ecd 100644 --- a/src/qt/walletmodel.cpp +++ b/src/qt/walletmodel.cpp @@ -368,12 +368,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, bool fMixing) diff --git a/src/qt/walletmodel.h b/src/qt/walletmodel.h index b2a31b82b1..775d265a27 100644 --- a/src/qt/walletmodel.h +++ b/src/qt/walletmodel.h @@ -106,7 +106,7 @@ public: SendCoinsReturn sendCoins(WalletModelTransaction &transaction, bool fIsCoinJoin); // 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 fMixing=false); bool changePassphrase(const SecureString &oldPass, const SecureString &newPass);