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..5469e732c7 100644 --- a/interface/src/scripting/WalletScriptingInterface.h +++ b/interface/src/scripting/WalletScriptingInterface.h @@ -39,7 +39,9 @@ public: Q_INVOKABLE void refreshWalletStatus(); Q_INVOKABLE uint getWalletStatus() { return _walletStatus; } - void setWalletStatus(const uint& status) { _walletStatus = status; } + // 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: void walletStatusChanged();