mirror of
https://github.com/trezor/trezor-firmware.git
synced 2025-03-28 22:15:42 +00:00
python: implement backwards compatibility for pre-2.3.0 firmwares
This commit is contained in:
parent
cfe0e34215
commit
f7608f55ff
@ -2,7 +2,7 @@ __version__ = "0.12.0"
|
|||||||
|
|
||||||
# fmt: off
|
# fmt: off
|
||||||
MINIMUM_FIRMWARE_VERSION = {
|
MINIMUM_FIRMWARE_VERSION = {
|
||||||
"1": (1, 9, 0),
|
"1": (1, 8, 0),
|
||||||
"T": (2, 3, 0),
|
"T": (2, 1, 0),
|
||||||
}
|
}
|
||||||
# fmt: on
|
# fmt: on
|
||||||
|
@ -184,6 +184,21 @@ class TrezorClient:
|
|||||||
|
|
||||||
def _callback_passphrase(self, msg: messages.PassphraseRequest):
|
def _callback_passphrase(self, msg: messages.PassphraseRequest):
|
||||||
available_on_device = Capability.PassphraseEntry in self.features.capabilities
|
available_on_device = Capability.PassphraseEntry in self.features.capabilities
|
||||||
|
|
||||||
|
def send_passphrase(passphrase=None, on_device=None):
|
||||||
|
msg = messages.PassphraseAck(
|
||||||
|
_state=self.session_id, passphrase=passphrase, on_device=on_device
|
||||||
|
)
|
||||||
|
resp = self.call_raw(msg)
|
||||||
|
if isinstance(resp, messages.Deprecated_PassphraseStateRequest):
|
||||||
|
self.session_id = resp.state
|
||||||
|
resp = self.call_raw(messages.Deprecated_PassphraseStateAck())
|
||||||
|
return resp
|
||||||
|
|
||||||
|
# short-circuit old style entry
|
||||||
|
if msg._on_device is True:
|
||||||
|
return send_passphrase(None, None)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
passphrase = self.ui.get_passphrase(available_on_device=available_on_device)
|
passphrase = self.ui.get_passphrase(available_on_device=available_on_device)
|
||||||
except exceptions.Cancelled:
|
except exceptions.Cancelled:
|
||||||
@ -195,7 +210,7 @@ class TrezorClient:
|
|||||||
self.call_raw(messages.Cancel())
|
self.call_raw(messages.Cancel())
|
||||||
raise RuntimeError("Device is not capable of entering passphrase")
|
raise RuntimeError("Device is not capable of entering passphrase")
|
||||||
else:
|
else:
|
||||||
return self.call_raw(messages.PassphraseAck(on_device=True))
|
return send_passphrase(on_device=True)
|
||||||
|
|
||||||
# else process host-entered passphrase
|
# else process host-entered passphrase
|
||||||
passphrase = Mnemonic.normalize_string(passphrase)
|
passphrase = Mnemonic.normalize_string(passphrase)
|
||||||
@ -203,9 +218,7 @@ class TrezorClient:
|
|||||||
self.call_raw(messages.Cancel())
|
self.call_raw(messages.Cancel())
|
||||||
raise ValueError("Passphrase too long")
|
raise ValueError("Passphrase too long")
|
||||||
|
|
||||||
return self.call_raw(
|
return send_passphrase(passphrase, on_device=False)
|
||||||
messages.PassphraseAck(passphrase=passphrase, on_device=False)
|
|
||||||
)
|
|
||||||
|
|
||||||
def _callback_button(self, msg):
|
def _callback_button(self, msg):
|
||||||
__tracebackhide__ = True # for pytest # pylint: disable=W0612
|
__tracebackhide__ = True # for pytest # pylint: disable=W0612
|
||||||
|
Loading…
Reference in New Issue
Block a user