hw wallet encryption unlock: clear session on incorrect passphrase
This commit is contained in:
@@ -246,8 +246,6 @@ class InstallWizard(QDialog, MessageBoxMixin, BaseWizard):
|
|||||||
try:
|
try:
|
||||||
self.run('choose_hw_device', HWD_SETUP_DECRYPT_WALLET)
|
self.run('choose_hw_device', HWD_SETUP_DECRYPT_WALLET)
|
||||||
except InvalidPassword as e:
|
except InvalidPassword as e:
|
||||||
# FIXME if we get here because of mistyped passphrase
|
|
||||||
# then that passphrase gets "cached"
|
|
||||||
QMessageBox.information(
|
QMessageBox.information(
|
||||||
None, _('Error'),
|
None, _('Error'),
|
||||||
_('Failed to decrypt using this hardware device.') + '\n' +
|
_('Failed to decrypt using this hardware device.') + '\n' +
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ from .keystore import bip44_derivation
|
|||||||
from .wallet import Imported_Wallet, Standard_Wallet, Multisig_Wallet, wallet_types
|
from .wallet import Imported_Wallet, Standard_Wallet, Multisig_Wallet, wallet_types
|
||||||
from .storage import STO_EV_USER_PW, STO_EV_XPUB_PW, get_derivation_used_for_hw_device_encryption
|
from .storage import STO_EV_USER_PW, STO_EV_XPUB_PW, get_derivation_used_for_hw_device_encryption
|
||||||
from .i18n import _
|
from .i18n import _
|
||||||
from .util import UserCancelled
|
from .util import UserCancelled, InvalidPassword
|
||||||
|
|
||||||
# hardware device setup purpose
|
# hardware device setup purpose
|
||||||
HWD_SETUP_NEW_WALLET, HWD_SETUP_DECRYPT_WALLET = range(0, 2)
|
HWD_SETUP_NEW_WALLET, HWD_SETUP_DECRYPT_WALLET = range(0, 2)
|
||||||
@@ -259,7 +259,15 @@ class BaseWizard(object):
|
|||||||
derivation = get_derivation_used_for_hw_device_encryption()
|
derivation = get_derivation_used_for_hw_device_encryption()
|
||||||
xpub = self.plugin.get_xpub(device_info.device.id_, derivation, 'standard', self)
|
xpub = self.plugin.get_xpub(device_info.device.id_, derivation, 'standard', self)
|
||||||
password = keystore.Xpub.get_pubkey_from_xpub(xpub, ())
|
password = keystore.Xpub.get_pubkey_from_xpub(xpub, ())
|
||||||
self.storage.decrypt(password)
|
try:
|
||||||
|
self.storage.decrypt(password)
|
||||||
|
except InvalidPassword:
|
||||||
|
# try to clear session so that user can type another passphrase
|
||||||
|
devmgr = self.plugins.device_manager
|
||||||
|
client = devmgr.client_by_id(device_info.device.id_)
|
||||||
|
if hasattr(client, 'clear_session'): # FIXME not all hw wallet plugins have this
|
||||||
|
client.clear_session()
|
||||||
|
raise
|
||||||
else:
|
else:
|
||||||
raise Exception('unknown purpose: %s' % purpose)
|
raise Exception('unknown purpose: %s' % purpose)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user