trezor: init_device before failing PIN/passphrase entry
This commit is contained in:
@@ -57,6 +57,7 @@ class Trezor(interface.Device):
|
||||
cli_handler = conn.callback_PinMatrixRequest
|
||||
|
||||
def new_handler(msg):
|
||||
try:
|
||||
if _is_open_tty(sys.stdin):
|
||||
result = cli_handler(msg) # CLI-based PIN handler
|
||||
else:
|
||||
@@ -72,6 +73,9 @@ class Trezor(interface.Device):
|
||||
raise self._defs.PinException(
|
||||
None, 'Invalid scrambled PIN: {!r}'.format(result.pin))
|
||||
return result
|
||||
except: # noqa
|
||||
conn.init_device()
|
||||
raise
|
||||
|
||||
conn.callback_PinMatrixRequest = new_handler
|
||||
|
||||
@@ -81,6 +85,7 @@ class Trezor(interface.Device):
|
||||
cli_handler = conn.callback_PassphraseRequest
|
||||
|
||||
def new_handler(msg):
|
||||
try:
|
||||
if self.__class__.cached_passphrase_ack:
|
||||
log.debug('re-using cached %s passphrase', self)
|
||||
return self.__class__.cached_passphrase_ack
|
||||
@@ -95,6 +100,9 @@ class Trezor(interface.Device):
|
||||
|
||||
self.__class__.cached_passphrase_ack = ack
|
||||
return ack
|
||||
except: # noqa
|
||||
conn.init_device()
|
||||
raise
|
||||
|
||||
conn.callback_PassphraseRequest = new_handler
|
||||
|
||||
|
||||
Reference in New Issue
Block a user