Browse Source

Merge branch 'no_force_wo'

283
Neil Booth 9 years ago
parent
commit
061152245e
  1. 3
      gui/qt/main_window.py
  2. 14
      lib/plugins.py
  3. 13
      plugins/hw_wallet/hw_wallet.py
  4. 3
      plugins/hw_wallet/qt.py
  5. 1
      plugins/ledger/ledger.py
  6. 7
      plugins/trezor/plugin.py

3
gui/qt/main_window.py

@ -154,9 +154,6 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, PrintError):
self.connect(self, QtCore.SIGNAL('payment_request_error'), self.payment_request_error)
self.history_list.setFocus(True)
self.connect(self, QtCore.SIGNAL('watching_only_changed'),
self.watching_only_changed)
# network callbacks
if self.network:
self.connect(self, QtCore.SIGNAL('network'), self.on_network_qt)

14
lib/plugins.py

@ -392,14 +392,22 @@ class DeviceMgr(PrintError):
# See comment above for same code
client.handler = wallet.handler
# This will trigger a PIN/passphrase entry request
client_first_address = client.first_address(derivation)
try:
client_first_address = client.first_address(derivation)
except (UserCancelled, RuntimeError):
# Bad / cancelled PIN / passphrase
client_first_address = None
if client_first_address == first_address:
self.pair_wallet(wallet, info.device.id_)
return client
# The user input has wrong PIN or passphrase, or it is not pairable
# The user input has wrong PIN or passphrase, or cancelled input,
# or it is not pairable
raise DeviceUnpairableError(
_('Unable to pair with your %s.') % plugin.device)
_('Unable to pair with your %s.\n\n'
'Ensure you are able to pair it, or you have the seed phrase, '
'before you request bitcoins to be sent to this wallet.'
) % plugin.device)
def unpaired_device_infos(self, handler, plugin, devices=None):
'''Returns a list of DeviceInfo objects: one for each connected,

13
plugins/hw_wallet/hw_wallet.py

@ -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

3
plugins/hw_wallet/qt.py

@ -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)

1
plugins/ledger/ledger.py

@ -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

7
plugins/trezor/plugin.py

@ -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()

Loading…
Cancel
Save