Merge pull request #12601 from howard-stearns/clear-wallet-when-picking-a-new-one

clear wallet when picking a new one
This commit is contained in:
John Conklin II 2018-03-09 10:09:41 -08:00 committed by GitHub
commit 6969f014fc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 24 additions and 12 deletions

View file

@ -174,11 +174,12 @@ Rectangle {
WalletChoice {
id: walletChoice;
proceedFunction: function (isReset) {
console.log(isReset ? "Reset wallet." : "Trying again with new wallet.");
console.log("WalletChoice", isReset ? "Reset wallet." : "Trying again with new wallet.");
Commerce.setSoftReset();
if (isReset) {
walletResetSetup();
} else {
Commerce.clearWallet();
var msg = { referrer: walletChoice.referrer }
followReferrer(msg);
}

View file

@ -138,6 +138,11 @@ void QmlCommerce::setSoftReset() {
wallet->setSoftReset();
}
void QmlCommerce::clearWallet() {
auto wallet = DependencyManager::get<Wallet>();
wallet->clear();
}
void QmlCommerce::setPassphrase(const QString& passphrase) {
auto wallet = DependencyManager::get<Wallet>();
wallet->setPassphrase(passphrase);

View file

@ -67,6 +67,7 @@ protected:
Q_INVOKABLE void setPassphrase(const QString& passphrase);
Q_INVOKABLE void changePassphrase(const QString& oldPassphrase, const QString& newPassphrase);
Q_INVOKABLE void setSoftReset();
Q_INVOKABLE void clearWallet();
Q_INVOKABLE void buy(const QString& assetId, int cost, const bool controlledFailure = false);
Q_INVOKABLE void balance();

View file

@ -343,19 +343,23 @@ Wallet::Wallet() {
auto accountManager = DependencyManager::get<AccountManager>();
connect(accountManager.data(), &AccountManager::usernameChanged, this, [&]() {
getWalletStatus();
_publicKeys.clear();
if (_securityImage) {
delete _securityImage;
}
_securityImage = nullptr;
// tell the provider we got nothing
updateImageProvider();
_passphrase->clear();
clear();
});
}
void Wallet::clear() {
_publicKeys.clear();
if (_securityImage) {
delete _securityImage;
}
_securityImage = nullptr;
// tell the provider we got nothing
updateImageProvider();
_passphrase->clear();
}
Wallet::~Wallet() {
if (_securityImage) {
delete _securityImage;

View file

@ -49,8 +49,9 @@ public:
bool getPassphraseIsCached() { return !(_passphrase->isEmpty()); }
bool walletIsAuthenticatedWithPassphrase();
bool changePassphrase(const QString& newPassphrase);
void setSoftReset() { _isOverridingServer = true; }
void setSoftReset() { _isOverridingServer = true; }
bool wasSoftReset() { bool was = _isOverridingServer; _isOverridingServer = false; return was; }
void clear();
void getWalletStatus();
enum WalletStatus {