0
0
Fork 0
mirror of https://github.com/bitcoin/bitcoin.git synced 2025-03-05 14:06:27 -05:00

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.
This commit is contained in:
Andrew Chow 2023-10-24 17:23:36 -04:00
parent 43704827b4
commit 517c7f9cba

View file

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