From 1ed10ecf59ccb400eb43b508640d529ac0b00613 Mon Sep 17 00:00:00 2001 From: Zach Fox Date: Wed, 4 Oct 2017 11:05:17 -0700 Subject: [PATCH] Fix passphrase crash --- interface/src/commerce/QmlCommerce.cpp | 4 +++- interface/src/commerce/Wallet.cpp | 4 +++- interface/src/commerce/Wallet.h | 2 +- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/interface/src/commerce/QmlCommerce.cpp b/interface/src/commerce/QmlCommerce.cpp index dbd84594bc..9f8847e8c7 100644 --- a/interface/src/commerce/QmlCommerce.cpp +++ b/interface/src/commerce/QmlCommerce.cpp @@ -119,7 +119,9 @@ void QmlCommerce::history() { void QmlCommerce::changePassphrase(const QString& oldPassphrase, const QString& newPassphrase) { auto wallet = DependencyManager::get(); - if ((wallet->getPassphrase()->isEmpty() || wallet->getPassphrase() == oldPassphrase) && !newPassphrase.isEmpty()) { + if (wallet->getPassphrase()->isEmpty()) { + emit changePassphraseStatusResult(wallet->setPassphrase(newPassphrase)); + } else if (wallet->getPassphrase() == oldPassphrase && !newPassphrase.isEmpty()) { emit changePassphraseStatusResult(wallet->changePassphrase(newPassphrase)); } else { emit changePassphraseStatusResult(false); diff --git a/interface/src/commerce/Wallet.cpp b/interface/src/commerce/Wallet.cpp index cc2039da48..079e3a9479 100644 --- a/interface/src/commerce/Wallet.cpp +++ b/interface/src/commerce/Wallet.cpp @@ -293,13 +293,15 @@ Wallet::~Wallet() { } } -void Wallet::setPassphrase(const QString& passphrase) { +bool Wallet::setPassphrase(const QString& passphrase) { if (_passphrase) { delete _passphrase; } _passphrase = new QString(passphrase); _publicKeys.clear(); + + return true; } bool Wallet::writeSecurityImage(const QPixmap* pixmap, const QString& outputFilePath) { diff --git a/interface/src/commerce/Wallet.h b/interface/src/commerce/Wallet.h index 807080e6ea..acf9f8e45e 100644 --- a/interface/src/commerce/Wallet.h +++ b/interface/src/commerce/Wallet.h @@ -42,7 +42,7 @@ public: void setCKey(const QByteArray& ckey) { _ckey = ckey; } QByteArray getCKey() { return _ckey; } - void setPassphrase(const QString& passphrase); + bool setPassphrase(const QString& passphrase); QString* getPassphrase() { return _passphrase; } bool getPassphraseIsCached() { return !(_passphrase->isEmpty()); } bool walletIsAuthenticatedWithPassphrase();