Merge pull request #8385 from SomberNight/20230504_qml_ks_password
qml: always ask for the password on wallet-open, even for ks-enc-only wallets
This commit is contained in:
@@ -668,7 +668,7 @@ class QEWallet(AuthMixin, QObject, QtEventListener):
|
|||||||
@pyqtSlot(str, result=bool)
|
@pyqtSlot(str, result=bool)
|
||||||
def verifyPassword(self, password):
|
def verifyPassword(self, password):
|
||||||
try:
|
try:
|
||||||
self.wallet.storage.check_password(password)
|
self.wallet.check_password(password)
|
||||||
return True
|
return True
|
||||||
except InvalidPassword as e:
|
except InvalidPassword as e:
|
||||||
return False
|
return False
|
||||||
|
|||||||
@@ -1,14 +1,20 @@
|
|||||||
import os
|
import os
|
||||||
|
from typing import TYPE_CHECKING
|
||||||
|
|
||||||
from PyQt5.QtCore import pyqtProperty, pyqtSignal, pyqtSlot, QObject
|
from PyQt5.QtCore import pyqtProperty, pyqtSignal, pyqtSlot, QObject
|
||||||
|
|
||||||
from electrum.logging import get_logger
|
from electrum.logging import get_logger
|
||||||
from electrum.storage import WalletStorage, StorageEncryptionVersion
|
from electrum.storage import WalletStorage, StorageEncryptionVersion
|
||||||
from electrum.wallet_db import WalletDB
|
from electrum.wallet_db import WalletDB
|
||||||
|
from electrum.wallet import Wallet
|
||||||
from electrum.bip32 import normalize_bip32_derivation, xpub_type
|
from electrum.bip32 import normalize_bip32_derivation, xpub_type
|
||||||
from electrum.util import InvalidPassword, WalletFileException
|
from electrum.util import InvalidPassword, WalletFileException
|
||||||
from electrum import keystore
|
from electrum import keystore
|
||||||
|
|
||||||
|
if TYPE_CHECKING:
|
||||||
|
from electrum.simple_config import SimpleConfig
|
||||||
|
|
||||||
|
|
||||||
class QEWalletDB(QObject):
|
class QEWalletDB(QObject):
|
||||||
_logger = get_logger(__name__)
|
_logger = get_logger(__name__)
|
||||||
|
|
||||||
@@ -29,6 +35,7 @@ class QEWalletDB(QObject):
|
|||||||
|
|
||||||
from .qeapp import ElectrumQmlApplication
|
from .qeapp import ElectrumQmlApplication
|
||||||
self.daemon = ElectrumQmlApplication._daemon
|
self.daemon = ElectrumQmlApplication._daemon
|
||||||
|
self._config = self.daemon.config # type: SimpleConfig
|
||||||
|
|
||||||
self.reset()
|
self.reset()
|
||||||
|
|
||||||
@@ -144,9 +151,24 @@ class QEWalletDB(QObject):
|
|||||||
except InvalidPassword as e:
|
except InvalidPassword as e:
|
||||||
self.validPassword = False
|
self.validPassword = False
|
||||||
self.invalidPassword.emit()
|
self.invalidPassword.emit()
|
||||||
|
else: # storage not encrypted; but it might still have a keystore pw
|
||||||
|
# FIXME hack... load both db and full wallet, just to tell if it has keystore pw.
|
||||||
|
# this also completely ignores db.requires_split(), db.get_action(), etc
|
||||||
|
db = WalletDB(self._storage.read(), manual_upgrades=False)
|
||||||
|
wallet = Wallet(db, self._storage, config=self._config)
|
||||||
|
self.needsPassword = wallet.has_password()
|
||||||
|
if self.needsPassword:
|
||||||
|
try:
|
||||||
|
wallet.check_password('' if not self._password else self._password)
|
||||||
|
self.validPassword = True
|
||||||
|
except InvalidPassword as e:
|
||||||
|
self.validPassword = False
|
||||||
|
self._storage = None
|
||||||
|
self.invalidPassword.emit()
|
||||||
|
|
||||||
if not self._storage.is_past_initial_decryption():
|
if self._storage:
|
||||||
self._storage = None
|
if not self._storage.is_past_initial_decryption():
|
||||||
|
self._storage = None
|
||||||
|
|
||||||
def load_db(self):
|
def load_db(self):
|
||||||
# needs storage accessible
|
# needs storage accessible
|
||||||
|
|||||||
Reference in New Issue
Block a user