From 106688ea541a746bc7d9c5c833937d50ee4c0ce7 Mon Sep 17 00:00:00 2001 From: Marko Bencun Date: Tue, 14 Jul 2020 16:44:29 +0200 Subject: [PATCH 1/4] bitbox02: implement get_soft_device_id so multisig runs more smoothly Without it, if you have say a 1-of-2 multisig with two BitBox02s, you would run into trouble if the first keystore would try to match to the wrong inserted BitBox02 (wrong order, or the first one is not inserted, etc. ). With the soft device id, the device manager can figure it on its own which keystore belongs to which connected bb02. --- electrum/plugins/bitbox02/bitbox02.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/electrum/plugins/bitbox02/bitbox02.py b/electrum/plugins/bitbox02/bitbox02.py index a0a36ff05..339604127 100644 --- a/electrum/plugins/bitbox02/bitbox02.py +++ b/electrum/plugins/bitbox02/bitbox02.py @@ -85,6 +85,15 @@ class BitBox02Client(HardwareClientBase): return False return True + def get_soft_device_id(self) -> Optional[str]: + if self.handler is None: + # Can't do the pairing without the handler. This happens at wallet creation time, when + # listing the devices. + return None + if self.bitbox02_device is None: + self.pairing_dialog(wizard=False) + return self.bitbox02_device.root_fingerprint().hex() + def pairing_dialog(self, wizard: bool = True): def pairing_step(code: str, device_response: Callable[[], bool]) -> bool: msg = "Please compare and confirm the pairing code on your BitBox02:\n" + code From 5457abfab533b5a4189295ce943e737ca2d4f59d Mon Sep 17 00:00:00 2001 From: Marko Bencun Date: Tue, 14 Jul 2020 17:04:21 +0200 Subject: [PATCH 2/4] bitbox02: drop unused `wizard` argument --- electrum/plugins/bitbox02/bitbox02.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/electrum/plugins/bitbox02/bitbox02.py b/electrum/plugins/bitbox02/bitbox02.py index 339604127..0ab421021 100644 --- a/electrum/plugins/bitbox02/bitbox02.py +++ b/electrum/plugins/bitbox02/bitbox02.py @@ -91,10 +91,10 @@ class BitBox02Client(HardwareClientBase): # listing the devices. return None if self.bitbox02_device is None: - self.pairing_dialog(wizard=False) + self.pairing_dialog() return self.bitbox02_device.root_fingerprint().hex() - def pairing_dialog(self, wizard: bool = True): + def pairing_dialog(self): def pairing_step(code: str, device_response: Callable[[], bool]) -> bool: msg = "Please compare and confirm the pairing code on your BitBox02:\n" + code self.handler.show_message(msg) @@ -206,7 +206,7 @@ class BitBox02Client(HardwareClientBase): def get_xpub(self, bip32_path: str, xtype: str, *, display: bool = False) -> str: if self.bitbox02_device is None: - self.pairing_dialog(wizard=False) + self.pairing_dialog() if self.bitbox02_device is None: raise Exception( From c0ad40b5624b33119d74c970f310bf9e082a0647 Mon Sep 17 00:00:00 2001 From: Marko Bencun Date: Wed, 15 Jul 2020 12:59:48 +0200 Subject: [PATCH 3/4] bitbox02: implement label() So the device can be identified more easily in dialogs. --- electrum/plugins/bitbox02/bitbox02.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/electrum/plugins/bitbox02/bitbox02.py b/electrum/plugins/bitbox02/bitbox02.py index 0ab421021..3f1235aa9 100644 --- a/electrum/plugins/bitbox02/bitbox02.py +++ b/electrum/plugins/bitbox02/bitbox02.py @@ -244,6 +244,15 @@ class BitBox02Client(HardwareClientBase): display=display, ) + def label(self) -> str: + if self.handler is None: + # Can't do the pairing without the handler. This happens at wallet creation time, when + # listing the devices. + return super().label() + if self.bitbox02_device is None: + self.pairing_dialog() + return self.bitbox02_device.device_info()["name"] + def request_root_fingerprint_from_device(self) -> str: if self.bitbox02_device is None: raise Exception( From 061305cd97bdee5b09e12fad831497e7e205df06 Mon Sep 17 00:00:00 2001 From: Marko Bencun Date: Wed, 15 Jul 2020 13:13:03 +0200 Subject: [PATCH 4/4] bitbox02: add fingerprint to label See comment in commit. --- electrum/plugins/bitbox02/bitbox02.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/electrum/plugins/bitbox02/bitbox02.py b/electrum/plugins/bitbox02/bitbox02.py index 3f1235aa9..e3f43ec46 100644 --- a/electrum/plugins/bitbox02/bitbox02.py +++ b/electrum/plugins/bitbox02/bitbox02.py @@ -251,7 +251,12 @@ class BitBox02Client(HardwareClientBase): return super().label() if self.bitbox02_device is None: self.pairing_dialog() - return self.bitbox02_device.device_info()["name"] + # We add the fingerprint to the label, as if there are two devices with the same label, the + # device manager can mistake one for another and fail. + return "%s (%s)" % ( + self.bitbox02_device.device_info()["name"], + self.bitbox02_device.root_fingerprint().hex(), + ) def request_root_fingerprint_from_device(self) -> str: if self.bitbox02_device is None: