Skip to content

Commit c7e6e10

Browse files
committed
fix(python): skip stale protocol v1 responses
1 parent 89f3301 commit c7e6e10

2 files changed

Lines changed: 6 additions & 2 deletions

File tree

python/.changelog.d/6859.fixed

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Skip stale protocol v1 responses.

python/src/trezorlib/protocol_v1.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -359,6 +359,7 @@ def probe(
359359
if isinstance(resp, messages.Failure):
360360
if resp.code == messages.FailureType.InvalidProtocol:
361361
return False
362+
sync_responses(transport, mapping=mapping, _cancel=False)
362363
return True
363364

364365

@@ -368,11 +369,13 @@ def sync_responses(
368369
*,
369370
mapping: ProtobufMapping = mapping.DEFAULT_MAPPING,
370371
retries: int = 10,
372+
_cancel: bool = True,
371373
) -> None:
372374
"""Sync responses from the transport."""
373375
# cancel anything on screen -- on T1B1 this is the only way to exit e.g. a PIN prompt.
374-
cancel_msg = mapping.encode(messages.Cancel())
375-
write(transport, *cancel_msg)
376+
if _cancel:
377+
cancel_msg = mapping.encode(messages.Cancel())
378+
write(transport, *cancel_msg)
376379

377380
# prepare an unique message to wait for
378381
sync_string = "SYNC" + secrets.token_hex(8)

0 commit comments

Comments
 (0)