// Wallet
connect(m_ctx->wallet, &Wallet::connectionStatusChanged, this, &MainWindow::onConnectionStatusChanged);
connect(m_ctx->wallet, &Wallet::currentSubaddressAccountChanged, this, &MainWindow::updateTitle);
+ connect(m_ctx->wallet, &Wallet::walletPassphraseNeeded, this, &MainWindow::onWalletPassphraseNeeded);
}
void MainWindow::menuToggleTabVisible(const QString &key){
m_splashDialog->hide();
}
+void MainWindow::onWalletPassphraseNeeded(bool on_device) {
+ auto button = QMessageBox::question(nullptr, "Wallet Passphrase Needed", "Enter passphrase on hardware wallet?\n\n"
+ "It is recommended to enter passphrase on "
+ "the hardware wallet for better security.",
+ QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes);
+ if (button == QMessageBox::Yes) {
+ m_ctx->wallet->onPassphraseEntered("", true, false);
+ return;
+ }
+
+ bool ok;
+ QString passphrase = QInputDialog::getText(nullptr, "Wallet Passphrase Needed", "Enter passphrase:", QLineEdit::EchoMode::Password, "", &ok);
+ if (ok) {
+ m_ctx->wallet->onPassphraseEntered(passphrase, false, false);
+ } else {
+ m_ctx->wallet->onPassphraseEntered(passphrase, false, true);
+ }
+}
+
void MainWindow::updateNetStats() {
if (!m_ctx->wallet || m_ctx->wallet->connectionStatus() == Wallet::ConnectionStatus_Disconnected
|| m_ctx->wallet->connectionStatus() == Wallet::ConnectionStatus_Synchronized)
void onDeviceError(const QString &error);
void onDeviceButtonRequest(quint64 code);
void onDeviceButtonPressed();
+ void onWalletPassphraseNeeded(bool on_device);
void menuHwDeviceClicked();
void onUpdatesAvailable(const QJsonObject &updates);
void toggleSearchbar(bool enabled);
#include "WindowManager.h"
+#include <QInputDialog>
#include <QMessageBox>
#include "constants.h"
connect(m_walletManager, &WalletManager::deviceButtonRequest, this, &WindowManager::onDeviceButtonRequest);
connect(m_walletManager, &WalletManager::deviceButtonPressed, this, &WindowManager::onDeviceButtonPressed);
connect(m_walletManager, &WalletManager::deviceError, this, &WindowManager::onDeviceError);
+ connect(m_walletManager, &WalletManager::walletPassphraseNeeded, this, &WindowManager::onWalletPassphraseNeeded);
connect(qApp, &QGuiApplication::lastWindowClosed, this, &WindowManager::quitAfterLastWindow);
qCritical() << Q_FUNC_INFO << errorMessage;
}
+void WindowManager::onWalletPassphraseNeeded(bool on_device) {
+ auto button = QMessageBox::question(nullptr, "Wallet Passphrase Needed", "Enter passphrase on hardware wallet?\n\n"
+ "It is recommended to enter passphrase on "
+ "the hardware wallet for better security.",
+ QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes);
+ if (button == QMessageBox::Yes) {
+ m_walletManager->onPassphraseEntered("", true, false);
+ return;
+ }
+
+ bool ok;
+ QString passphrase = QInputDialog::getText(nullptr, "Wallet Passphrase Needed", "Enter passphrase:", QLineEdit::EchoMode::Password, "", &ok);
+ if (ok) {
+ m_walletManager->onPassphraseEntered(passphrase, false, false);
+ } else {
+ m_walletManager->onPassphraseEntered(passphrase, false, true);
+ }
+}
+
// ######################## TRAY ########################
void WindowManager::buildTrayMenu() {
void onDeviceButtonRequest(quint64 code);
void onDeviceButtonPressed();
void onDeviceError(const QString &errorMessage);
+ void onWalletPassphraseNeeded(bool on_device);
private:
void tryCreateWallet(FeatherSeed seed, const QString &path, const QString &password, const QString &seedOffset);
class WalletPassphraseListenerImpl : public Monero::WalletListener, public PassphraseReceiver
{
public:
- WalletPassphraseListenerImpl(WalletManager * mgr): m_mgr(mgr), m_phelper(mgr) {}
+ explicit WalletPassphraseListenerImpl(WalletManager * mgr): m_mgr(mgr), m_phelper(mgr) {}
- virtual void moneySpent(const std::string &txId, uint64_t amount) override { (void)txId; (void)amount; };
- virtual void moneyReceived(const std::string &txId, uint64_t amount) override { (void)txId; (void)amount; };
- virtual void unconfirmedMoneyReceived(const std::string &txId, uint64_t amount) override { (void)txId; (void)amount; };
- virtual void newBlock(uint64_t height) override { (void) height; };
- virtual void updated() override {};
- virtual void refreshed(bool success) override {};
+ void moneySpent(const std::string &txId, uint64_t amount) override { (void)txId; (void)amount; };
+ void moneyReceived(const std::string &txId, uint64_t amount) override { (void)txId; (void)amount; };
+ void unconfirmedMoneyReceived(const std::string &txId, uint64_t amount) override { (void)txId; (void)amount; };
+ void newBlock(uint64_t height) override { (void) height; };
+ void updated() override {};
+ void refreshed(bool success) override {};
- virtual void onPassphraseEntered(const QString &passphrase, bool enter_on_device, bool entry_abort) override
+ void onPassphraseEntered(const QString &passphrase, bool enter_on_device, bool entry_abort) override
{
qDebug() << __FUNCTION__;
m_phelper.onPassphraseEntered(passphrase, enter_on_device, entry_abort);
}
-// virtual Monero::optional<std::string> onDevicePassphraseRequest(bool & on_device) override
-// {
-// qDebug() << __FUNCTION__;
-// return m_phelper.onDevicePassphraseRequest(on_device);
-// }
-//
- virtual void onDeviceButtonRequest(uint64_t code) override
+ Monero::optional<std::string> onDevicePassphraseRequest(bool & on_device) override
+ {
+ qDebug() << __FUNCTION__;
+ return m_phelper.onDevicePassphraseRequest(on_device);
+ }
+
+ void onDeviceButtonRequest(uint64_t code) override
{
qDebug() << __FUNCTION__;
emit m_mgr->deviceButtonRequest(code);
}
-//
- virtual void onDeviceButtonPressed() override
+
+ void onDeviceButtonPressed() override
{
qDebug() << __FUNCTION__;
emit m_mgr->deviceButtonPressed();
}
- virtual void onDeviceError(const std::string &message) override
+ void onDeviceError(const std::string &message) override
{
qDebug() << __FUNCTION__;
emit m_mgr->deviceError(QString::fromStdString(message));