diff --git a/python/src/trezorlib/client.py b/python/src/trezorlib/client.py index bb62de02bb..ed1a433505 100644 --- a/python/src/trezorlib/client.py +++ b/python/src/trezorlib/client.py @@ -63,7 +63,7 @@ class TrezorClient: _last_active_session: SessionV1 | None = None _session_id_counter: int = 0 - + _default_pairing_method: int = messages.ThpPairingMethod.CodeEntry def __init__( self, transport: Transport, @@ -101,10 +101,12 @@ class TrezorClient: else: raise Exception("Unknown protocol version") - def do_pairing(self) -> None: + def do_pairing(self, pairing_method: int | None = None) -> None: from .transport.session import SessionV2 assert self.protocol_version == ProtocolVersion.V2 + if pairing_method is None: + pairing_method = self._default_pairing_method session = SessionV2(client=self, id=b"\x00") session.call( messages.ThpPairingRequest(host_name="Trezorlib"), @@ -112,9 +114,7 @@ class TrezorClient: skip_firmware_version_check=True, ) session.call( - messages.ThpSelectMethod( - selected_pairing_method=messages.ThpPairingMethod.SkipPairing - ), + messages.ThpSelectMethod(selected_pairing_method=pairing_method), expect=messages.ThpEndResponse, skip_firmware_version_check=True, ) diff --git a/python/src/trezorlib/debuglink.py b/python/src/trezorlib/debuglink.py index a4aaecfdeb..4206f911cc 100644 --- a/python/src/trezorlib/debuglink.py +++ b/python/src/trezorlib/debuglink.py @@ -1097,7 +1097,7 @@ class TrezorClientDebugLink(TrezorClient): # and know the supported debug capabilities if self.protocol_version is ProtocolVersion.V2: assert isinstance(self.protocol, ProtocolV2Channel) - self.do_pairing() + self.do_pairing(pairing_method=messages.ThpPairingMethod.SkipPairing) # self.protocol = self.protocol.get_channel() self.debug.model = self.model self.debug.version = self.version