mirror of
https://github.com/LBRYFoundation/LBRY-Vault.git
synced 2025-08-27 23:41:35 +00:00
Trezor: improve install wizard
Add explanatory help about passphrases, with warning, like in trezor dialog box.
This commit is contained in:
parent
0d14781463
commit
cefd128020
2 changed files with 35 additions and 28 deletions
|
@ -315,27 +315,28 @@ class TrezorCompatiblePlugin(BasePlugin, ThreadJob):
|
||||||
devices = devmgr.unpaired_devices(handler)
|
devices = devmgr.unpaired_devices(handler)
|
||||||
|
|
||||||
states = [_("wiped"), _("initialized")]
|
states = [_("wiped"), _("initialized")]
|
||||||
good_devices, descrs = [], []
|
infos = []
|
||||||
for device in devices:
|
for device in devices:
|
||||||
client = self.device_manager().create_client(device, handler, self)
|
client = self.device_manager().create_client(device, handler, self)
|
||||||
if not client:
|
if not client:
|
||||||
continue
|
continue
|
||||||
state = states[client.is_initialized()]
|
state = states[client.is_initialized()]
|
||||||
label = client.label() or _("An unnamed device")
|
label = client.label() or _("An unnamed device")
|
||||||
good_devices.append(device)
|
descr = "%s: device ID %s (%s)" % (label, device.id_, state)
|
||||||
descrs.append("%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):
|
def select_device(self, wallet):
|
||||||
'''Called when creating a new wallet. Select the device to use. If
|
'''Called when creating a new wallet. Select the device to use. If
|
||||||
the device is uninitialized, go through the intialization
|
the device is uninitialized, go through the intialization
|
||||||
process.'''
|
process.'''
|
||||||
msg = _("Please select which %s device to use:") % self.device
|
msg = _("Please select which %s device to use:") % self.device
|
||||||
devices, labels = self.unpaired_devices(wallet.handler)
|
infos = self.unpaired_devices(wallet.handler)
|
||||||
device = devices[wallet.handler.query_choice(msg, labels)]
|
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_)
|
self.device_manager().pair_wallet(wallet, device.id_)
|
||||||
if not client.is_initialized():
|
if not init:
|
||||||
self.initialize_device(wallet)
|
self.initialize_device(wallet)
|
||||||
|
|
||||||
def on_restore_wallet(self, wallet, wizard):
|
def on_restore_wallet(self, wallet, wizard):
|
||||||
|
|
|
@ -15,6 +15,18 @@ from electrum.util import PrintError
|
||||||
from electrum.wallet import Wallet, BIP44_Wallet
|
from electrum.wallet import Wallet, BIP44_Wallet
|
||||||
from electrum.wizard import UserCancelled
|
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;
|
# By far the trickiest thing about this handler is the window stack;
|
||||||
# MacOSX is very fussy the modal dialogs are perfectly parented
|
# MacOSX is very fussy the modal dialogs are perfectly parented
|
||||||
|
@ -195,12 +207,16 @@ class QtHandler(PrintError):
|
||||||
else:
|
else:
|
||||||
vbox.addLayout(hbox_pin)
|
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)
|
cb_phrase.setChecked(False)
|
||||||
|
vbox.addWidget(passphrase_msg)
|
||||||
|
vbox.addWidget(passphrase_warning)
|
||||||
vbox.addWidget(cb_phrase)
|
vbox.addWidget(cb_phrase)
|
||||||
|
|
||||||
title = _("Initialization settings for your %s:") % device
|
wizard.set_main_layout(vbox, next_enabled=next_enabled)
|
||||||
wizard.set_main_layout(vbox, next_enabled=next_enabled, title=title)
|
|
||||||
|
|
||||||
if method in [TIM_NEW, TIM_RECOVER]:
|
if method in [TIM_NEW, TIM_RECOVER]:
|
||||||
item = bg.checkedId()
|
item = bg.checkedId()
|
||||||
|
@ -262,12 +278,13 @@ def qt_plugin_class(base_plugin_class):
|
||||||
handler = window.wallet.handler
|
handler = window.wallet.handler
|
||||||
device_id = self.device_manager().wallet_id(window.wallet)
|
device_id = self.device_manager().wallet_id(window.wallet)
|
||||||
if not device_id:
|
if not device_id:
|
||||||
devices, labels = self.unpaired_devices(handler)
|
infos = self.unpaired_devices(handler)
|
||||||
if devices:
|
if infos:
|
||||||
|
labels = [info[1] for info in infos]
|
||||||
msg = _("Select a %s device:") % self.device
|
msg = _("Select a %s device:") % self.device
|
||||||
choice = self.query_choice(window, msg, labels)
|
choice = self.query_choice(window, msg, labels)
|
||||||
if choice is not None:
|
if choice is not None:
|
||||||
device_id = devices[choice].id_
|
device_id = infos[choice][0].id_
|
||||||
else:
|
else:
|
||||||
handler.show_error(_("No devices found"))
|
handler.show_error(_("No devices found"))
|
||||||
return device_id
|
return device_id
|
||||||
|
@ -365,7 +382,7 @@ class SettingsDialog(WindowModalDialog):
|
||||||
if not self.question(msg, title=title):
|
if not self.question(msg, title=title):
|
||||||
return
|
return
|
||||||
invoke_client('toggle_passphrase')
|
invoke_client('toggle_passphrase')
|
||||||
devmgr.unpair(device_id)
|
devmgr.unpair_id(device_id)
|
||||||
|
|
||||||
def change_homescreen():
|
def change_homescreen():
|
||||||
from PIL import Image # FIXME
|
from PIL import Image # FIXME
|
||||||
|
@ -403,7 +420,7 @@ class SettingsDialog(WindowModalDialog):
|
||||||
icon=QMessageBox.Critical):
|
icon=QMessageBox.Critical):
|
||||||
return
|
return
|
||||||
invoke_client('wipe_device')
|
invoke_client('wipe_device')
|
||||||
devmgr.unpair(device_id)
|
devmgr.unpair_id(device_id)
|
||||||
|
|
||||||
def slider_moved():
|
def slider_moved():
|
||||||
mins = timeout_slider.sliderPosition()
|
mins = timeout_slider.sliderPosition()
|
||||||
|
@ -545,19 +562,8 @@ class SettingsDialog(WindowModalDialog):
|
||||||
# Advanced tab - toggle passphrase protection
|
# Advanced tab - toggle passphrase protection
|
||||||
passphrase_button = QPushButton()
|
passphrase_button = QPushButton()
|
||||||
passphrase_button.clicked.connect(toggle_passphrase)
|
passphrase_button.clicked.connect(toggle_passphrase)
|
||||||
passphrase_msg = QLabel(
|
passphrase_msg = WWLabel(PASSPHRASE_MSG)
|
||||||
_("Passphrases allow you to access new wallets, each "
|
passphrase_warning = WWLabel(PASSPHRASE_NOT_PIN)
|
||||||
"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_warning.setStyleSheet("color: red")
|
passphrase_warning.setStyleSheet("color: red")
|
||||||
advanced_glayout.addWidget(passphrase_button, 3, 2)
|
advanced_glayout.addWidget(passphrase_button, 3, 2)
|
||||||
advanced_glayout.addWidget(passphrase_msg, 4, 0, 1, 5)
|
advanced_glayout.addWidget(passphrase_msg, 4, 0, 1, 5)
|
||||||
|
|
Loading…
Add table
Reference in a new issue