From eac9c99e322438245ac9f5084849f98c2312534e Mon Sep 17 00:00:00 2001 From: Jochen Hoenicke Date: Sun, 26 Jun 2016 18:44:24 +0200 Subject: [PATCH] Bug fixes - Ignore u2f interface instead of failing. - Fix set_mnenomic in debug client - Don't encode utf-8 mnenomics to byte arrays. --- trezorlib/client.py | 10 +++++----- trezorlib/messages_pb2.py | 2 +- trezorlib/transport_hid.py | 2 -- 3 files changed, 6 insertions(+), 8 deletions(-) diff --git a/trezorlib/client.py b/trezorlib/client.py index 9bf1c5d..64594f1 100644 --- a/trezorlib/client.py +++ b/trezorlib/client.py @@ -91,14 +91,14 @@ class expect(object): def normalize_nfc(txt): if sys.version_info[0] < 3: if isinstance(txt, unicode): - return unicodedata.normalize('NFC', txt).encode('utf-8') + return unicodedata.normalize('NFC', txt) if isinstance(txt, str): - return unicodedata.normalize('NFC', txt.decode('utf-8')).encode('utf-8') + return unicodedata.normalize('NFC', txt.decode('utf-8')) else: if isinstance(txt, bytes): - return unicodedata.normalize('NFC', txt.decode('utf-8')).encode('utf-8') + return unicodedata.normalize('NFC', txt.decode('utf-8')) if isinstance(txt, str): - return unicodedata.normalize('NFC', txt).encode('utf-8') + return unicodedata.normalize('NFC', txt) raise Exception('unicode/str or bytes/str expected') @@ -283,7 +283,7 @@ class DebugLinkMixin(object): self.passphrase = normalize_nfc(passphrase) def set_mnemonic(self, mnemonic): - self.mnemonic = normalize_nfc(mnemonic) + self.mnemonic = normalize_nfc(mnemonic).split(' ') def call_raw(self, msg): diff --git a/trezorlib/messages_pb2.py b/trezorlib/messages_pb2.py index b51f413..7041e07 100644 --- a/trezorlib/messages_pb2.py +++ b/trezorlib/messages_pb2.py @@ -14,7 +14,7 @@ from google.protobuf import descriptor_pb2 _sym_db = _symbol_database.Default() -import types_pb2 +from . import types_pb2 DESCRIPTOR = _descriptor.FileDescriptor( diff --git a/trezorlib/transport_hid.py b/trezorlib/transport_hid.py index 593c6da..c920945 100644 --- a/trezorlib/transport_hid.py +++ b/trezorlib/transport_hid.py @@ -49,8 +49,6 @@ class HidTransport(Transport): devices[serial_number][0] = path elif interface_number == 1: # debug link devices[serial_number][1] = path - else: - raise Exception("Unknown USB interface number: %d" % interface_number) # List of two-tuples (path_normal, path_debuglink) return list(devices.values())