Browse Source

Trezor: improve install wizard

Add explanatory help about passphrases, with warning, like
in trezor dialog box.
283
Neil Booth 9 years ago
parent
commit
cefd128020
  1. 15
      plugins/trezor/plugin.py
  2. 48
      plugins/trezor/qt_generic.py

15
plugins/trezor/plugin.py

@ -315,27 +315,28 @@ class TrezorCompatiblePlugin(BasePlugin, ThreadJob):
devices = devmgr.unpaired_devices(handler)
states = [_("wiped"), _("initialized")]
good_devices, descrs = [], []
infos = []
for device in devices:
client = self.device_manager().create_client(device, handler, self)
if not client:
continue
state = states[client.is_initialized()]
label = client.label() or _("An unnamed device")
good_devices.append(device)
descrs.append("%s: device ID %s (%s)" % (label, device.id_, state))
descr = "%s: device ID %s (%s)" % (label, device.id_, state)
infos.append((device, descr, client.is_initialized()))
return good_devices, descrs
return infos
def select_device(self, wallet):
'''Called when creating a new wallet. Select the device to use. If
the device is uninitialized, go through the intialization
process.'''
msg = _("Please select which %s device to use:") % self.device
devices, labels = self.unpaired_devices(wallet.handler)
device = devices[wallet.handler.query_choice(msg, labels)]
infos = self.unpaired_devices(wallet.handler)
labels = [info[1] for info in infos]
device, descr, init = infos[wallet.handler.query_choice(msg, labels)]
self.device_manager().pair_wallet(wallet, device.id_)
if not client.is_initialized():
if not init:
self.initialize_device(wallet)
def on_restore_wallet(self, wallet, wizard):

48
plugins/trezor/qt_generic.py

@ -15,6 +15,18 @@ from electrum.util import PrintError
from electrum.wallet import Wallet, BIP44_Wallet
from electrum.wizard import UserCancelled
PASSPHRASE_HELP_SHORT =_(
"Passphrases allow you to access new wallets, each "
"hidden behind a particular case-sensitive passphrase.")
PASSPHRASE_HELP = PASSPHRASE_HELP_SHORT + " " + _(
"You need to create a separate Electrum wallet for each passphrase "
"you use as they each generate different addresses. Changing "
"your passphrase does not lose other wallets, each is still "
"accessible behind its own passphrase.")
PASSPHRASE_NOT_PIN = _(
"If you forget a passphrase you will be unable to access any "
"bitcoins in the wallet behind it. A passphrase is not a PIN. "
"Only change this if you are sure you understand it.")
# By far the trickiest thing about this handler is the window stack;
# MacOSX is very fussy the modal dialogs are perfectly parented
@ -195,12 +207,16 @@ class QtHandler(PrintError):
else:
vbox.addLayout(hbox_pin)
cb_phrase = QCheckBox(_('Enable Passphrase protection'))
passphrase_msg = WWLabel(PASSPHRASE_HELP_SHORT)
passphrase_warning = WWLabel(PASSPHRASE_NOT_PIN)
passphrase_warning.setStyleSheet("color: red")
cb_phrase = QCheckBox(_('Enable passphrases'))
cb_phrase.setChecked(False)
vbox.addWidget(passphrase_msg)
vbox.addWidget(passphrase_warning)
vbox.addWidget(cb_phrase)
title = _("Initialization settings for your %s:") % device
wizard.set_main_layout(vbox, next_enabled=next_enabled, title=title)
wizard.set_main_layout(vbox, next_enabled=next_enabled)
if method in [TIM_NEW, TIM_RECOVER]:
item = bg.checkedId()
@ -262,12 +278,13 @@ def qt_plugin_class(base_plugin_class):
handler = window.wallet.handler
device_id = self.device_manager().wallet_id(window.wallet)
if not device_id:
devices, labels = self.unpaired_devices(handler)
if devices:
infos = self.unpaired_devices(handler)
if infos:
labels = [info[1] for info in infos]
msg = _("Select a %s device:") % self.device
choice = self.query_choice(window, msg, labels)
if choice is not None:
device_id = devices[choice].id_
device_id = infos[choice][0].id_
else:
handler.show_error(_("No devices found"))
return device_id
@ -365,7 +382,7 @@ class SettingsDialog(WindowModalDialog):
if not self.question(msg, title=title):
return
invoke_client('toggle_passphrase')
devmgr.unpair(device_id)
devmgr.unpair_id(device_id)
def change_homescreen():
from PIL import Image # FIXME
@ -403,7 +420,7 @@ class SettingsDialog(WindowModalDialog):
icon=QMessageBox.Critical):
return
invoke_client('wipe_device')
devmgr.unpair(device_id)
devmgr.unpair_id(device_id)
def slider_moved():
mins = timeout_slider.sliderPosition()
@ -545,19 +562,8 @@ class SettingsDialog(WindowModalDialog):
# Advanced tab - toggle passphrase protection
passphrase_button = QPushButton()
passphrase_button.clicked.connect(toggle_passphrase)
passphrase_msg = QLabel(
_("Passphrases allow you to access new wallets, each "
"hidden behind a particular case-sensitive passphrase. You "
"need to create a separate Electrum wallet for each passphrase "
"you use as they each generate different addresses. Changing "
"your passphrase does not lose other wallets, each is still "
"accessible behind its own passphrase."))
passphrase_msg.setWordWrap(True)
passphrase_warning = QLabel(
_("If you forget a passphrase you will be unable to access any "
"bitcoins in the wallet behind it. A passphrase is not a PIN. "
"Only change this if you are sure you understand it."))
passphrase_warning.setWordWrap(True)
passphrase_msg = WWLabel(PASSPHRASE_MSG)
passphrase_warning = WWLabel(PASSPHRASE_NOT_PIN)
passphrase_warning.setStyleSheet("color: red")
advanced_glayout.addWidget(passphrase_button, 3, 2)
advanced_glayout.addWidget(passphrase_msg, 4, 0, 1, 5)

Loading…
Cancel
Save