From 9eaf510ac6c2924a8e2c5719d33a5543c970416f Mon Sep 17 00:00:00 2001 From: Neil Booth Date: Sun, 3 Jan 2016 09:18:29 +0900 Subject: [PATCH] Test if initialized to determine watching only Prepares for device wipe functionality --- plugins/trezor/client.py | 6 ++++++ plugins/trezor/plugin.py | 7 ++++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/plugins/trezor/client.py b/plugins/trezor/client.py index d362032c8..d55f09dc5 100644 --- a/plugins/trezor/client.py +++ b/plugins/trezor/client.py @@ -80,11 +80,17 @@ def trezor_client_class(protocol_mixin, base_client, proto): return "%s/%s/%s" % (self.label(), self.device_id(), self.path[0]) def label(self): + '''The name given by the user to the device.''' return self.features.label def device_id(self): + '''The device serial number.''' return self.features.device_id + def is_initialized(self): + '''True if initialized, False if wiped.''' + return self.features.initialized + def handler(self): assert self.wallet and self.wallet.handler return self.wallet.handler diff --git a/plugins/trezor/plugin.py b/plugins/trezor/plugin.py index 0ae43d74f..a02db2c16 100644 --- a/plugins/trezor/plugin.py +++ b/plugins/trezor/plugin.py @@ -49,10 +49,11 @@ class TrezorCompatibleWallet(BIP44_Wallet): return False def is_watching_only(self): - '''The wallet is watching-only if its trezor device is not - connected. This result is dynamic and changes over time.''' + '''The wallet is watching-only if its trezor device is not connected, + or if it is connected but uninitialized.''' assert not self.has_seed() - return self.plugin.lookup_client(self) is None + client = self.plugin.lookup_client(self) + return not (client and client.is_initialized()) def can_change_password(self): return False