mirror of
https://github.com/feather-wallet/feather.git
synced 2025-01-24 03:25:51 +00:00
Trezor: add passphrase support
This commit is contained in:
parent
a01a66a85e
commit
2bba5c4787
5 changed files with 61 additions and 18 deletions
|
@ -377,6 +377,7 @@ void MainWindow::initWalletContext() {
|
||||||
// Wallet
|
// Wallet
|
||||||
connect(m_ctx->wallet, &Wallet::connectionStatusChanged, this, &MainWindow::onConnectionStatusChanged);
|
connect(m_ctx->wallet, &Wallet::connectionStatusChanged, this, &MainWindow::onConnectionStatusChanged);
|
||||||
connect(m_ctx->wallet, &Wallet::currentSubaddressAccountChanged, this, &MainWindow::updateTitle);
|
connect(m_ctx->wallet, &Wallet::currentSubaddressAccountChanged, this, &MainWindow::updateTitle);
|
||||||
|
connect(m_ctx->wallet, &Wallet::walletPassphraseNeeded, this, &MainWindow::onWalletPassphraseNeeded);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::menuToggleTabVisible(const QString &key){
|
void MainWindow::menuToggleTabVisible(const QString &key){
|
||||||
|
@ -1190,6 +1191,25 @@ void MainWindow::onDeviceButtonPressed() {
|
||||||
m_splashDialog->hide();
|
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() {
|
void MainWindow::updateNetStats() {
|
||||||
if (!m_ctx->wallet || m_ctx->wallet->connectionStatus() == Wallet::ConnectionStatus_Disconnected
|
if (!m_ctx->wallet || m_ctx->wallet->connectionStatus() == Wallet::ConnectionStatus_Disconnected
|
||||||
|| m_ctx->wallet->connectionStatus() == Wallet::ConnectionStatus_Synchronized)
|
|| m_ctx->wallet->connectionStatus() == Wallet::ConnectionStatus_Synchronized)
|
||||||
|
|
|
@ -174,6 +174,7 @@ private slots:
|
||||||
void onDeviceError(const QString &error);
|
void onDeviceError(const QString &error);
|
||||||
void onDeviceButtonRequest(quint64 code);
|
void onDeviceButtonRequest(quint64 code);
|
||||||
void onDeviceButtonPressed();
|
void onDeviceButtonPressed();
|
||||||
|
void onWalletPassphraseNeeded(bool on_device);
|
||||||
void menuHwDeviceClicked();
|
void menuHwDeviceClicked();
|
||||||
void onUpdatesAvailable(const QJsonObject &updates);
|
void onUpdatesAvailable(const QJsonObject &updates);
|
||||||
void toggleSearchbar(bool enabled);
|
void toggleSearchbar(bool enabled);
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
|
|
||||||
#include "WindowManager.h"
|
#include "WindowManager.h"
|
||||||
|
|
||||||
|
#include <QInputDialog>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
|
|
||||||
#include "constants.h"
|
#include "constants.h"
|
||||||
|
@ -24,6 +25,7 @@ WindowManager::WindowManager() {
|
||||||
connect(m_walletManager, &WalletManager::deviceButtonRequest, this, &WindowManager::onDeviceButtonRequest);
|
connect(m_walletManager, &WalletManager::deviceButtonRequest, this, &WindowManager::onDeviceButtonRequest);
|
||||||
connect(m_walletManager, &WalletManager::deviceButtonPressed, this, &WindowManager::onDeviceButtonPressed);
|
connect(m_walletManager, &WalletManager::deviceButtonPressed, this, &WindowManager::onDeviceButtonPressed);
|
||||||
connect(m_walletManager, &WalletManager::deviceError, this, &WindowManager::onDeviceError);
|
connect(m_walletManager, &WalletManager::deviceError, this, &WindowManager::onDeviceError);
|
||||||
|
connect(m_walletManager, &WalletManager::walletPassphraseNeeded, this, &WindowManager::onWalletPassphraseNeeded);
|
||||||
|
|
||||||
connect(qApp, &QGuiApplication::lastWindowClosed, this, &WindowManager::quitAfterLastWindow);
|
connect(qApp, &QGuiApplication::lastWindowClosed, this, &WindowManager::quitAfterLastWindow);
|
||||||
|
|
||||||
|
@ -393,6 +395,25 @@ void WindowManager::onDeviceError(const QString &errorMessage) {
|
||||||
qCritical() << Q_FUNC_INFO << errorMessage;
|
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 ########################
|
// ######################## TRAY ########################
|
||||||
|
|
||||||
void WindowManager::buildTrayMenu() {
|
void WindowManager::buildTrayMenu() {
|
||||||
|
|
|
@ -41,6 +41,7 @@ private slots:
|
||||||
void onDeviceButtonRequest(quint64 code);
|
void onDeviceButtonRequest(quint64 code);
|
||||||
void onDeviceButtonPressed();
|
void onDeviceButtonPressed();
|
||||||
void onDeviceError(const QString &errorMessage);
|
void onDeviceError(const QString &errorMessage);
|
||||||
|
void onWalletPassphraseNeeded(bool on_device);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void tryCreateWallet(FeatherSeed seed, const QString &path, const QString &password, const QString &seedOffset);
|
void tryCreateWallet(FeatherSeed seed, const QString &path, const QString &password, const QString &seedOffset);
|
||||||
|
|
|
@ -9,40 +9,40 @@
|
||||||
class WalletPassphraseListenerImpl : public Monero::WalletListener, public PassphraseReceiver
|
class WalletPassphraseListenerImpl : public Monero::WalletListener, public PassphraseReceiver
|
||||||
{
|
{
|
||||||
public:
|
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; };
|
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; };
|
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; };
|
void unconfirmedMoneyReceived(const std::string &txId, uint64_t amount) override { (void)txId; (void)amount; };
|
||||||
virtual void newBlock(uint64_t height) override { (void) height; };
|
void newBlock(uint64_t height) override { (void) height; };
|
||||||
virtual void updated() override {};
|
void updated() override {};
|
||||||
virtual void refreshed(bool success) 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__;
|
qDebug() << __FUNCTION__;
|
||||||
m_phelper.onPassphraseEntered(passphrase, enter_on_device, entry_abort);
|
m_phelper.onPassphraseEntered(passphrase, enter_on_device, entry_abort);
|
||||||
}
|
}
|
||||||
|
|
||||||
// virtual Monero::optional<std::string> onDevicePassphraseRequest(bool & on_device) override
|
Monero::optional<std::string> onDevicePassphraseRequest(bool & on_device) override
|
||||||
// {
|
{
|
||||||
// qDebug() << __FUNCTION__;
|
qDebug() << __FUNCTION__;
|
||||||
// return m_phelper.onDevicePassphraseRequest(on_device);
|
return m_phelper.onDevicePassphraseRequest(on_device);
|
||||||
// }
|
}
|
||||||
//
|
|
||||||
virtual void onDeviceButtonRequest(uint64_t code) override
|
void onDeviceButtonRequest(uint64_t code) override
|
||||||
{
|
{
|
||||||
qDebug() << __FUNCTION__;
|
qDebug() << __FUNCTION__;
|
||||||
emit m_mgr->deviceButtonRequest(code);
|
emit m_mgr->deviceButtonRequest(code);
|
||||||
}
|
}
|
||||||
//
|
|
||||||
virtual void onDeviceButtonPressed() override
|
void onDeviceButtonPressed() override
|
||||||
{
|
{
|
||||||
qDebug() << __FUNCTION__;
|
qDebug() << __FUNCTION__;
|
||||||
emit m_mgr->deviceButtonPressed();
|
emit m_mgr->deviceButtonPressed();
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void onDeviceError(const std::string &message) override
|
void onDeviceError(const std::string &message) override
|
||||||
{
|
{
|
||||||
qDebug() << __FUNCTION__;
|
qDebug() << __FUNCTION__;
|
||||||
emit m_mgr->deviceError(QString::fromStdString(message));
|
emit m_mgr->deviceError(QString::fromStdString(message));
|
||||||
|
|
Loading…
Reference in a new issue