From: tobtoht Date: Fri, 4 Jun 2021 18:48:44 +0000 (+0200) Subject: Enter password to open seed, keys dialog X-Git-Url: https://git.nutra.tk/v1?a=commitdiff_plain;h=e2a591baedab6d31262c95b5755c4f85adb4d160;p=gamesguru%2Ffeather.git Enter password to open seed, keys dialog --- diff --git a/src/MainWindow.cpp b/src/MainWindow.cpp index 8e6fd3f0..c6121649 100644 --- a/src/MainWindow.cpp +++ b/src/MainWindow.cpp @@ -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); diff --git a/src/MainWindow.h b/src/MainWindow.h index b83f0a16..6def9ddd 100644 --- a/src/MainWindow.h +++ b/src/MainWindow.h @@ -212,6 +212,7 @@ private: void addToRecentlyOpened(const QString &filename); void updateRecentlyOpenedMenu(); void updateWidgetIcons(); + bool verifyPassword(); QIcon hardwareDevicePairedIcon(); QIcon hardwareDeviceUnpairedIcon();