From 0a99730fbadce32d1b54263a976a6c049bb761f6 Mon Sep 17 00:00:00 2001 From: Aditya Kulkarni Date: Thu, 31 Oct 2019 09:55:48 -0700 Subject: [PATCH] Handle blank passwords/cancel. Fixes #10 --- src/controller.cpp | 3 +++ src/mainwindow.cpp | 16 +++++++++++++++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/src/controller.cpp b/src/controller.cpp index 392043c..9c46529 100644 --- a/src/controller.cpp +++ b/src/controller.cpp @@ -462,6 +462,9 @@ void Controller::unlockIfEncrypted(std::function cb, std::functionunlockWallet(password, [=](json reply) { if (isJsonSuccess(reply)) { cb(); + + // Refresh the wallet so the encryption status is now in sync. + refresh(true); } else { QMessageBox::critical(main, main->tr("Wallet Decryption Failed"), QString::fromStdString(reply["error"].get()), diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index e7cb1ed..02eb930 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -296,8 +296,22 @@ void MainWindow::removeWalletEncryption() { return; } + bool ok; QString password = QInputDialog::getText(this, tr("Wallet Password"), - tr("Please enter your wallet password"), QLineEdit::Password); + tr("Please enter your wallet password"), QLineEdit::Password, "", &ok); + + // If cancel was pressed, just return + if (!ok) { + return; + } + + if (password.isEmpty()) { + QMessageBox::critical(this, tr("Wallet Decryption Failed"), + tr("Please enter a password to decrypt your wallet!"), + QMessageBox::Ok + ); + return; + } rpc->removeWalletEncryption(password, [=] (json res) { if (isJsonSuccess(res)) {