]> Nutra Git (v2) - gamesguru/feather.git/commitdiff
Enter password to open seed, keys dialog
authortobtoht <thotbot@protonmail.com>
Fri, 4 Jun 2021 18:48:44 +0000 (20:48 +0200)
committertobtoht <thotbot@protonmail.com>
Sat, 10 Jul 2021 15:50:06 +0000 (17:50 +0200)
src/MainWindow.cpp
src/MainWindow.h

index 8e6fd3f01f576a7c57dbc5203dc72705f80869b7..c6121649c9c7ac7cba8df5251ceaf64848ee144f 100644 (file)
@@ -701,6 +701,10 @@ void MainWindow::showSeedDialog() {
         return;
     }
 
+    if (!this->verifyPassword()) {
+        return;
+    }
+
     SeedDialog dialog{m_ctx, this};
     dialog.exec();
 }
@@ -772,6 +776,10 @@ void MainWindow::showRestoreHeightDialog() {
 }
 
 void MainWindow::showKeysDialog() {
+    if (!this->verifyPassword()) {
+        return;
+    }
+
     KeysDialog dialog{m_ctx, this};
     dialog.exec();
 }
@@ -1557,6 +1565,22 @@ void MainWindow::updateRecentlyOpenedMenu() {
     ui->menuRecently_open->addAction(m_clearRecentlyOpenAction);
 }
 
+bool MainWindow::verifyPassword() {
+    bool ok;
+    while (true) {
+        QString password = QInputDialog::getText(this, "Enter password", "Please enter your password:", QLineEdit::EchoMode::Password, "", &ok);
+        if (!ok) { // Dialog cancelled
+            return false;
+        }
+        if (password != m_ctx->wallet->getPassword()) {
+            QMessageBox::warning(this, "Error", "Incorrect password");
+            continue;
+        }
+        break;
+    }
+    return true;
+}
+
 void MainWindow::toggleSearchbar(bool visible) {
     config()->set(Config::showSearchbar, visible);
 
index b83f0a1699a5a08eabdeaf6f8d8081268aa32084..6def9dddf5412a9cf7ca836e4500e3e57de3f032 100644 (file)
@@ -212,6 +212,7 @@ private:
     void addToRecentlyOpened(const QString &filename);
     void updateRecentlyOpenedMenu();
     void updateWidgetIcons();
+    bool verifyPassword();
 
     QIcon hardwareDevicePairedIcon();
     QIcon hardwareDeviceUnpairedIcon();