1
0

Better support for USB devices

Benefits of this rewrite include:

- support of disconnecting / reconnecting a device without having
  to close the wallet, even in a different USB socket
- support of multiple keepkey / trezor devices, both during wallet
  creation and general use
- wallet is watching-only dynamically according to whether the
  associated device is currently plugged in or not
This commit is contained in:
Neil Booth
2016-01-02 09:43:56 +09:00
parent 187b4dc9c1
commit 21bf5a8a84
11 changed files with 345 additions and 225 deletions

View File

@@ -132,13 +132,6 @@ class InstallWizard(WindowModalDialog, MessageBoxMixin, WizardBase):
the password or None for no password."""
return self.pw_dialog(msg or MSG_ENTER_PASSWORD, PasswordDialog.PW_NEW)
def query_hardware(self, choices, action):
if action == 'create':
msg = _('Select the hardware wallet to create')
else:
msg = _('Select the hardware wallet to restore')
return self.choice(msg, choices)
def choose_server(self, network):
# Show network dialog if config does not exist
if self.config.get('server') is None:
@@ -323,7 +316,7 @@ class InstallWizard(WindowModalDialog, MessageBoxMixin, WizardBase):
self.config.set_key('auto_connect', True, True)
network.auto_connect = True
def choice(self, msg, choices):
def query_choice(self, msg, choices):
vbox = QVBoxLayout()
self.set_layout(vbox)
gb2 = QGroupBox(msg)
@@ -335,7 +328,7 @@ class InstallWizard(WindowModalDialog, MessageBoxMixin, WizardBase):
group2 = QButtonGroup()
for i,c in enumerate(choices):
button = QRadioButton(gb2)
button.setText(c[1])
button.setText(c)
vbox2.addWidget(button)
group2.addButton(button)
group2.setId(button, i)
@@ -347,8 +340,7 @@ class InstallWizard(WindowModalDialog, MessageBoxMixin, WizardBase):
vbox.addLayout(Buttons(CancelButton(self), next_button))
if not self.exec_():
raise UserCancelled
wallet_type = choices[group2.checkedId()][0]
return wallet_type
return group2.checkedId()
def query_multisig(self, action):
vbox = QVBoxLayout()

View File

@@ -152,6 +152,9 @@ 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)
@@ -280,7 +283,6 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, PrintError):
self.warn_if_watching_only()
def watching_only_changed(self):
self.saved_wwo = self.wallet.is_watching_only()
title = 'Electrum %s - %s' % (self.wallet.electrum_version,
self.wallet.basename())
if self.wallet.is_watching_only():
@@ -495,6 +497,7 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, PrintError):
self.connect(sender, QtCore.SIGNAL('timersignal'), self.timer_actions)
def timer_actions(self):
# Note this runs in the GUI thread
if self.need_update.is_set():
self.need_update.clear()
self.update_wallet()
@@ -504,8 +507,6 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, PrintError):
if self.require_fee_update:
self.do_update_fee()
self.require_fee_update = False
if self.saved_wwo != self.wallet.is_watching_only():
self.watching_only_changed()
run_hook('timer_actions')
def format_amount(self, x, is_diff=False, whitespaces=False):