Fix passphrase crash

This commit is contained in:
Zach Fox 2017-10-04 11:05:17 -07:00
parent fcafbef109
commit 1ed10ecf59
3 changed files with 7 additions and 3 deletions

View file

@ -119,7 +119,9 @@ void QmlCommerce::history() {
void QmlCommerce::changePassphrase(const QString& oldPassphrase, const QString& newPassphrase) {
auto wallet = DependencyManager::get<Wallet>();
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);

View file

@ -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) {

View file

@ -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();