]> Nutra Git (v2) - gamesguru/feather.git/commitdiff
wallet_api: do not cache wallet password
authortobtoht <tob@featherwallet.org>
Tue, 31 Jan 2023 16:00:50 +0000 (17:00 +0100)
committertobtoht <tob@featherwallet.org>
Tue, 31 Jan 2023 16:00:50 +0000 (17:00 +0100)
monero
src/MainWindow.cpp
src/dialog/PasswordChangeDialog.cpp
src/libwalletqt/Wallet.cpp
src/libwalletqt/Wallet.h

diff --git a/monero b/monero
index 18bdad879d9f25f35f065354aedf1236e6b0a60b..57e241748fb8caec0033f84cb14ef7861132c4e6 160000 (submodule)
--- a/monero
+++ b/monero
@@ -1 +1 @@
-Subproject commit 18bdad879d9f25f35f065354aedf1236e6b0a60b
+Subproject commit 57e241748fb8caec0033f84cb14ef7861132c4e6
index b9e316fe7d0d5aa58b5a12051dd63322c38f2ff2..64e63067ded9050882e93d5bfc591174c77276b0 100644 (file)
@@ -798,7 +798,8 @@ void MainWindow::showPasswordDialog() {
 }
 
 void MainWindow::updatePasswordIcon() {
-    QIcon icon = m_ctx->wallet->getPassword().isEmpty() ? icons()->icon("unlock.svg") : icons()->icon("lock.svg");
+    bool emptyPassword = m_ctx->wallet->verifyPassword("");
+    QIcon icon = emptyPassword ? icons()->icon("unlock.svg") : icons()->icon("lock.svg");
     m_statusBtnPassword->setIcon(icon);
 }
 
@@ -1650,7 +1651,8 @@ bool MainWindow::verifyPassword(bool sensitive) {
         if (ret == QDialog::Rejected) {
             return false;
         }
-        if (passwordDialog.password != m_ctx->wallet->getPassword()) {
+
+        if (!m_ctx->wallet->verifyPassword(passwordDialog.password)) {
             incorrectPassword = true;
             continue;
         }
@@ -1725,7 +1727,7 @@ void MainWindow::unlockWallet(const QString &password) {
         return;
     }
 
-    if (password != m_ctx->wallet->getPassword()) {
+    if (!m_ctx->wallet->verifyPassword(password)) {
         m_walletUnlockWidget->incorrectPassword();
         return;
     }
index f7c99206f857383e1899cb7fe52e40e1157453a4..a2cf5265ce210868350e786ea991c211f6d3090c 100644 (file)
@@ -13,8 +13,7 @@ PasswordChangeDialog::PasswordChangeDialog(QWidget *parent, Wallet *wallet)
 {
     ui->setupUi(this);
 
-    bool noPassword = wallet->getPassword().isEmpty();
-
+    bool noPassword = wallet->verifyPassword("");
     QString warning_str = noPassword ? "Your wallet is not password protected. Use this dialog to add a password to your wallet." :
                          "Your wallet is password protected and encrypted. Use this dialog to change your password.";
     ui->label_warning->setText(warning_str);
@@ -50,14 +49,14 @@ void PasswordChangeDialog::setPassword() {
     QString currentPassword = ui->lineEdit_currentPassword->text();
     QString newPassword = ui->lineEdit_newPassword->text();
 
-    if (currentPassword != m_wallet->getPassword()) {
+    if (!m_wallet->verifyPassword(currentPassword)) {
         QMessageBox::warning(this, "Error", "Incorrect password");
         ui->lineEdit_currentPassword->setText("");
         ui->lineEdit_currentPassword->setFocus();
         return;
     }
 
-    if (m_wallet->setPassword(newPassword)) {
+    if (m_wallet->setPassword(currentPassword, newPassword)) {
         QMessageBox::information(this, "Information", "Password changed successfully");
         this->accept();
     }
index 6ecccdfb940631ca6800130bbd0d4e501c1ba867..6cbbc8942f9df846261ce66800c98caf0f9190e9 100644 (file)
@@ -164,14 +164,14 @@ QString Wallet::errorString() const
     return QString::fromStdString(m_walletImpl->errorString());
 }
 
-bool Wallet::setPassword(const QString &password)
+bool Wallet::setPassword(const QString &oldPassword, const QString &newPassword)
 {
-    return m_walletImpl->setPassword(password.toStdString());
+    return m_walletImpl->setPassword(oldPassword.toStdString(), newPassword.toStdString());
 }
 
-QString Wallet::getPassword()
+bool Wallet::verifyPassword(const QString &password)
 {
-    return QString::fromStdString(m_walletImpl->getPassword());
+    return m_walletImpl->verifyPassword(password.toStdString());
 }
 
 QString Wallet::address(quint32 accountIndex, quint32 addressIndex) const
@@ -198,9 +198,9 @@ QString Wallet::keysPath() const
     return QDir::toNativeSeparators(QString::fromStdString(m_walletImpl->keysFilename()));;
 }
 
-void Wallet::store(const QString &path)
+void Wallet::store()
 {
-    m_walletImpl->store(path.toStdString());
+    m_walletImpl->store();
 }
 
 bool Wallet::init(const QString &daemonAddress, bool trustedDaemon, quint64 upperTransactionLimit, bool isRecovering, bool isRecoveringFromDevice, quint64 restoreHeight, const QString& proxyAddress)
@@ -1416,7 +1416,7 @@ Wallet::~Wallet()
     //Monero::WalletManagerFactory::getWalletManager()->closeWallet(m_walletImpl);
     if(status() == Status_Critical || status() == Status_BadPassword)
         qDebug("Not storing wallet cache");
-    else if( m_walletImpl->store(""))
+    else if( m_walletImpl->store())
         qDebug("Wallet cache stored successfully");
     else
         qDebug("Error storing wallet cache");
index e30b4e65b324290c28cbbcd2a11fa6f1dc9564c1..84ee30f522dd717827476fbefa222c29baf57731 100644 (file)
@@ -144,10 +144,10 @@ public:
     QString errorString() const;
 
     //! changes the password using existing parameters (path, seed, seed lang)
-    bool setPassword(const QString &password);
+    bool setPassword(const QString &oldPassword, const QString &newPassword);
 
-    //! get current wallet password
-    QString getPassword();
+    //! verify wallet password
+    bool verifyPassword(const QString &password);
 
     //! returns wallet's public address
     QString address(quint32 accountIndex, quint32 addressIndex) const;
@@ -163,7 +163,7 @@ public:
 
     //! saves wallet to the file by given path
     //! empty path stores in current location
-    void store(const QString &path = "");
+    void store();
    // void storeAsync(const QJSValue &callback, const QString &path = "");
 
     //! initializes wallet asynchronously