1
0

qml: QEDaemon.setPassword to restore invariant wallets are unlocked

fixes https://github.com/spesmilo/electrum/issues/10415
This commit is contained in:
SomberNight
2026-01-16 17:35:43 +00:00
parent 91f286b422
commit 6d9ec72853
2 changed files with 16 additions and 2 deletions

View File

@@ -231,7 +231,7 @@ class QEDaemon(AuthMixin, QObject):
return
if self.daemon.config.WALLET_SHOULD_USE_SINGLE_PASSWORD:
self._use_single_password = self.daemon.update_password_for_directory(old_password=local_password, new_password=local_password)
self._use_single_password = self._update_password_for_directory_and_unlock_wallets(old_password=local_password, new_password=local_password)
if not self._use_single_password and self.daemon.config.WALLET_ANDROID_USE_BIOMETRIC_AUTHENTICATION:
# we need to disable biometric auth if the user creates wallets with different passwords as
# we only store one encrypted password which is not associated to a specific wallet
@@ -399,11 +399,24 @@ class QEDaemon(AuthMixin, QObject):
def setPassword(self, password):
assert self._use_single_password
assert password
if not self.daemon.update_password_for_directory(old_password=self._password, new_password=password):
if not self._update_password_for_directory_and_unlock_wallets(old_password=self._password, new_password=password):
return False
self._password = password
return True
def _update_password_for_directory_and_unlock_wallets(self, *, old_password, new_password):
# note: this assumes all wallet files are in a single directory.
# change wallet passwords:
ret = self.daemon.update_password_for_directory(old_password=old_password, new_password=new_password)
# If some wallets just had their password changed, they got "locked" by wallet.update_password().
# If the password is not unified yet, other loaded wallets might still be unlocked.
# restore the invariant that all loaded wallets in qml must be unlocked:
for w in self.daemon.get_wallets().values():
if not w.is_unlocked():
w.unlock(new_password)
assert w.is_unlocked()
return ret
@pyqtProperty(QENewWalletWizard, notify=newWalletWizardChanged)
def newWalletWizard(self):
if not self._new_wallet_wizard:

View File

@@ -765,6 +765,7 @@ class QEWallet(AuthMixin, QObject, QtEventListener):
try:
self._logger.info('setting new password')
self.wallet.update_password(current_password, password, encrypt_storage=True)
# restore the invariant that all loaded wallets in qml must be unlocked:
self.wallet.unlock(password)
return True
except InvalidPassword as e: