Skip to content

Commit dee68e3

Browse files
committed
[Refactor] Use isWalletUnlocked() to check valid in requestUnlock()
1 parent 556a176 commit dee68e3

File tree

2 files changed

+4
-5
lines changed

2 files changed

+4
-5
lines changed

src/qt/pivx/topbar.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,6 @@ void TopBar::openPassPhraseDialog(AskPassphraseDialog::Mode mode, AskPassphraseD
205205
void TopBar::encryptWallet()
206206
{
207207
return openPassPhraseDialog(AskPassphraseDialog::Mode::Encrypt, AskPassphraseDialog::Context::Encrypt);
208-
209208
}
210209

211210
void TopBar::unlockWallet()

src/qt/walletmodel.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ void WalletModel::updateStatus()
196196
bool WalletModel::isWalletUnlocked() const
197197
{
198198
EncryptionStatus status = getEncryptionStatus();
199-
return status == Unencrypted || status == Unlocked;
199+
return (status == Unencrypted || status == Unlocked);
200200
}
201201

202202
bool WalletModel::isWalletLocked(bool fFullUnlocked) const
@@ -913,8 +913,7 @@ WalletModel::UnlockContext WalletModel::requestUnlock()
913913
Q_EMIT requireUnlock();
914914
}
915915
// If wallet is still locked, unlock was failed or cancelled, mark context as invalid
916-
const WalletModel::EncryptionStatus status_after = getEncryptionStatus();
917-
bool valid = (status_after != Locked && status_after != UnlockedForStaking);
916+
bool valid = isWalletUnlocked();
918917

919918
return UnlockContext(this, valid, status_before);
920919
}
@@ -929,9 +928,10 @@ WalletModel::UnlockContext::UnlockContext(WalletModel *_wallet, bool _valid, con
929928

930929
WalletModel::UnlockContext::~UnlockContext()
931930
{
932-
if (valid && relock) {
931+
if (valid && relock && wallet) {
933932
if (was_status == Locked) wallet->setWalletLocked(true);
934933
else if (was_status == UnlockedForStaking) wallet->lockForStakingOnly();
934+
wallet->updateStatus();
935935
}
936936
}
937937

0 commit comments

Comments
 (0)