Skip to content

Commit

Permalink
gui: Check for private keys disabled before attempting unlock
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
achow101 committed Oct 24, 2023
1 parent 4370482 commit 517c7f9
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/qt/walletmodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -449,6 +449,13 @@ void WalletModel::unsubscribeFromCoreSignals()
// WalletModel::UnlockContext implementation
WalletModel::UnlockContext WalletModel::requestUnlock()
{
// Bugs in earlier versions may have resulted in wallets with private keys disabled to become "encrypted"
// (encryption keys are present, but not actually doing anything).
// To avoid issues with such wallets, check if the wallet has private keys disabled, and if so, return a context
// that indicates the wallet is not encrypted.
if (m_wallet->privateKeysDisabled()) {
return UnlockContext(this, /*valid=*/true, /*relock=*/false);
}
bool was_locked = getEncryptionStatus() == Locked;
if(was_locked)
{
Expand Down

0 comments on commit 517c7f9

Please sign in to comment.