From 623e6395be15677d2394587489e36ed58020de17 Mon Sep 17 00:00:00 2001 From: Zach Fox Date: Tue, 12 Dec 2017 12:09:40 -0800 Subject: [PATCH 1/2] Set Wallet Status to 'Ready' after correctly authenticating wallet --- interface/src/commerce/Wallet.cpp | 8 +++----- interface/src/scripting/WalletScriptingInterface.cpp | 5 +++++ interface/src/scripting/WalletScriptingInterface.h | 2 +- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/interface/src/commerce/Wallet.cpp b/interface/src/commerce/Wallet.cpp index 69914e97a4..00941d6c50 100644 --- a/interface/src/commerce/Wallet.cpp +++ b/interface/src/commerce/Wallet.cpp @@ -315,7 +315,6 @@ Wallet::Wallet() { } walletScriptingInterface->setWalletStatus(status); - emit walletStatusResult(status); }); auto accountManager = DependencyManager::get(); @@ -491,6 +490,7 @@ bool Wallet::walletIsAuthenticatedWithPassphrase() { } if (_publicKeys.count() > 0) { // we _must_ be authenticated if the publicKeys are there + DependencyManager::get()->setWalletStatus((uint)WalletStatus::WALLET_STATUS_READY); return true; } @@ -503,6 +503,7 @@ bool Wallet::walletIsAuthenticatedWithPassphrase() { // be sure to add the public key so we don't do this over and over _publicKeys.push_back(publicKey.toBase64()); + DependencyManager::get()->setWalletStatus((uint)WalletStatus::WALLET_STATUS_READY); return true; } } @@ -801,15 +802,12 @@ void Wallet::account() { void Wallet::getWalletStatus() { auto walletScriptingInterface = DependencyManager::get(); - uint status; if (DependencyManager::get()->isLoggedIn()) { // This will set account info for the wallet, allowing us to decrypt and display the security image. account(); } else { - status = (uint)WalletStatus::WALLET_STATUS_NOT_LOGGED_IN; - emit walletStatusResult(status); - walletScriptingInterface->setWalletStatus(status); + walletScriptingInterface->setWalletStatus((uint)WalletStatus::WALLET_STATUS_NOT_LOGGED_IN); return; } } diff --git a/interface/src/scripting/WalletScriptingInterface.cpp b/interface/src/scripting/WalletScriptingInterface.cpp index 8b4279af02..71a7076bdf 100644 --- a/interface/src/scripting/WalletScriptingInterface.cpp +++ b/interface/src/scripting/WalletScriptingInterface.cpp @@ -22,3 +22,8 @@ void WalletScriptingInterface::refreshWalletStatus() { auto wallet = DependencyManager::get(); wallet->getWalletStatus(); } + +void WalletScriptingInterface::setWalletStatus(const uint& status) { + _walletStatus = status; + emit DependencyManager::get()->walletStatusResult(status); +} \ No newline at end of file diff --git a/interface/src/scripting/WalletScriptingInterface.h b/interface/src/scripting/WalletScriptingInterface.h index d7f9d9242e..a9948a68c6 100644 --- a/interface/src/scripting/WalletScriptingInterface.h +++ b/interface/src/scripting/WalletScriptingInterface.h @@ -39,7 +39,7 @@ public: Q_INVOKABLE void refreshWalletStatus(); Q_INVOKABLE uint getWalletStatus() { return _walletStatus; } - void setWalletStatus(const uint& status) { _walletStatus = status; } + void setWalletStatus(const uint& status); signals: void walletStatusChanged(); From efd5c0ccb7d1d4a40d88784bfa6c36b3b8e8edc5 Mon Sep 17 00:00:00 2001 From: Zach Fox Date: Wed, 13 Dec 2017 11:53:26 -0800 Subject: [PATCH 2/2] Add comment as per CR --- interface/src/scripting/WalletScriptingInterface.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/interface/src/scripting/WalletScriptingInterface.h b/interface/src/scripting/WalletScriptingInterface.h index a9948a68c6..5469e732c7 100644 --- a/interface/src/scripting/WalletScriptingInterface.h +++ b/interface/src/scripting/WalletScriptingInterface.h @@ -39,6 +39,8 @@ public: Q_INVOKABLE void refreshWalletStatus(); Q_INVOKABLE uint getWalletStatus() { return _walletStatus; } + // setWalletStatus() should never be made Q_INVOKABLE. If it were, + // scripts could cause the Wallet to incorrectly report its status. void setWalletStatus(const uint& status); signals: