Skip to content

Commit 517c7f9

Browse files
committed
gui: Check for private keys disabled before attempting unlock
Before trying to unlock a wallet, first check if it has private keys disabled. If so, there is no need to unlock. Note that such wallets are not expected to occur in typical usage. However bugs in previous versions allowed such wallets to be created, and so we need to handle them.
1 parent 4370482 commit 517c7f9

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/qt/walletmodel.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -449,6 +449,13 @@ void WalletModel::unsubscribeFromCoreSignals()
449449
// WalletModel::UnlockContext implementation
450450
WalletModel::UnlockContext WalletModel::requestUnlock()
451451
{
452+
// Bugs in earlier versions may have resulted in wallets with private keys disabled to become "encrypted"
453+
// (encryption keys are present, but not actually doing anything).
454+
// To avoid issues with such wallets, check if the wallet has private keys disabled, and if so, return a context
455+
// that indicates the wallet is not encrypted.
456+
if (m_wallet->privateKeysDisabled()) {
457+
return UnlockContext(this, /*valid=*/true, /*relock=*/false);
458+
}
452459
bool was_locked = getEncryptionStatus() == Locked;
453460
if(was_locked)
454461
{

0 commit comments

Comments
 (0)