1
0

hw_wallet: don't make watching only if cannot pair

Instead issue a warning.  Being watching-only disables
various functionality that should instead just ask again
for the PIN to be input.
This commit is contained in:
Neil Booth
2016-02-07 17:16:29 +09:00
parent bb3de0eb63
commit 9490debf0f
6 changed files with 15 additions and 26 deletions

View File

@@ -39,29 +39,21 @@ class BIP44_HW_Wallet(BIP44_Wallet):
# handler. The handler is per-window and preserved across
# device reconnects
self.handler = None
self.force_watching_only = False
def set_session_timeout(self, seconds):
self.print_error("setting session timeout to %d seconds" % seconds)
self.session_timeout = seconds
self.storage.put('session_timeout', seconds)
def set_force_watching_only(self, value):
if value != self.force_watching_only:
self.force_watching_only = value
self.handler.watching_only_changed()
def unpaired(self):
'''A device paired with the wallet was diconnected. This can be
called in any thread context.'''
self.print_error("unpaired")
self.set_force_watching_only(True)
def paired(self):
'''A device paired with the wallet was (re-)connected. This can be
called in any thread context.'''
self.print_error("paired")
self.set_force_watching_only(False)
def timeout(self):
'''Called when the wallet session times out. Note this is called from
@@ -81,9 +73,10 @@ class BIP44_HW_Wallet(BIP44_Wallet):
return False
def is_watching_only(self):
'''The wallet is watching-only if its trezor device is unpaired.'''
'''The wallet is not watching-only; the user will be prompted for
pin and passphrase as appropriate when needed.'''
assert not self.has_seed()
return self.force_watching_only
return False
def can_change_password(self):
return False

View File

@@ -53,9 +53,6 @@ class QtHandlerBase(QObject, PrintError):
def top_level_window(self):
return self.win.top_level_window()
def watching_only_changed(self):
self.win.emit(SIGNAL('watching_only_changed'))
def query_choice(self, msg, labels):
self.done.clear()
self.qcSig.emit(msg, labels)

View File

@@ -37,7 +37,6 @@ class BTChipWallet(BIP44_HW_Wallet):
# device reconnects
self.handler = None
self.force_watching_only = False
self.device_checked = False
self.signing = False

View File

@@ -134,12 +134,7 @@ class TrezorCompatiblePlugin(HW_PluginBase):
assert self.main_thread != threading.current_thread()
devmgr = self.device_manager()
try:
client = devmgr.client_for_wallet(self, wallet, force_pair)
except:
wallet.set_force_watching_only(True)
raise
client = devmgr.client_for_wallet(self, wallet, force_pair)
if client:
self.print_error("set last_operation")
wallet.last_operation = time.time()