mirror of
https://github.com/LBRYFoundation/LBRY-Vault.git
synced 2025-08-31 17:31:36 +00:00
trezor: improve various messages and dialogs
This commit is contained in:
parent
8f4fe39cc9
commit
e7b87c1d24
2 changed files with 50 additions and 54 deletions
|
@ -8,16 +8,12 @@ class GuiMixin(object):
|
||||||
# Requires: self.proto, self.device
|
# Requires: self.proto, self.device
|
||||||
|
|
||||||
messages = {
|
messages = {
|
||||||
3: _("Confirm transaction outputs on %s device to continue"),
|
3: _("Confirm the transaction output on your %s device"),
|
||||||
8: _("Confirm transaction fee on %s device to continue"),
|
8: _("Confirm the total amount spent and the transaction fee on your "
|
||||||
7: _("Confirm message to sign on %s device to continue"),
|
"%s device"),
|
||||||
10: _("Confirm address on %s device to continue"),
|
7: _("Confirm on your %s device the message to sign"),
|
||||||
'change pin': _("Confirm PIN change on %s device to continue"),
|
10: _("Confirm wallet address on your %s device"),
|
||||||
'default': _("Check %s device to continue"),
|
'default': _("Check your %s device to continue"),
|
||||||
'homescreen': _("Confirm home screen change on %s device to continue"),
|
|
||||||
'label': _("Confirm label change on %s device to continue"),
|
|
||||||
'remove pin': _("Confirm removal of PIN on %s device to continue"),
|
|
||||||
'passphrase': _("Confirm on %s device to continue"),
|
|
||||||
}
|
}
|
||||||
|
|
||||||
def callback_Failure(self, msg):
|
def callback_Failure(self, msg):
|
||||||
|
@ -31,21 +27,20 @@ class GuiMixin(object):
|
||||||
raise RuntimeError(msg.message)
|
raise RuntimeError(msg.message)
|
||||||
|
|
||||||
def callback_ButtonRequest(self, msg):
|
def callback_ButtonRequest(self, msg):
|
||||||
msg_code = self.msg_code_override or msg.code
|
message = self.msg
|
||||||
message = self.messages.get(msg_code, self.messages['default'])
|
if not message:
|
||||||
|
message = self.messages.get(msg.code, self.messages['default'])
|
||||||
self.handler.show_message(message % self.device, self.cancel)
|
self.handler.show_message(message % self.device, self.cancel)
|
||||||
return self.proto.ButtonAck()
|
return self.proto.ButtonAck()
|
||||||
|
|
||||||
def callback_PinMatrixRequest(self, msg):
|
def callback_PinMatrixRequest(self, msg):
|
||||||
if msg.type == 1:
|
if msg.type == 2:
|
||||||
msg = _("Enter your current %s PIN:")
|
msg = _("Enter a new PIN for your %s:")
|
||||||
elif msg.type == 2:
|
|
||||||
msg = _("Enter a new %s PIN:")
|
|
||||||
elif msg.type == 3:
|
elif msg.type == 3:
|
||||||
msg = (_("Please re-enter your new %s PIN.\n"
|
msg = (_("Re-enter the new PIN for your %s.\n\n"
|
||||||
"Note the numbers have been shuffled!"))
|
"NOTE: the positions of the numbers have changed!"))
|
||||||
else:
|
else:
|
||||||
msg = _("Please enter %s PIN")
|
msg = _("Enter your current %s PIN:")
|
||||||
pin = self.handler.get_pin(msg % self.device)
|
pin = self.handler.get_pin(msg % self.device)
|
||||||
if not pin:
|
if not pin:
|
||||||
return self.proto.Cancel()
|
return self.proto.Cancel()
|
||||||
|
@ -81,7 +76,7 @@ class TrezorClientBase(GuiMixin, PrintError):
|
||||||
self.handler = handler
|
self.handler = handler
|
||||||
self.tx_api = plugin
|
self.tx_api = plugin
|
||||||
self.types = plugin.types
|
self.types = plugin.types
|
||||||
self.msg_code_override = None
|
self.msg = None
|
||||||
self.used()
|
self.used()
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
|
@ -99,11 +94,9 @@ class TrezorClientBase(GuiMixin, PrintError):
|
||||||
return not self.features.bootloader_mode
|
return not self.features.bootloader_mode
|
||||||
|
|
||||||
def used(self):
|
def used(self):
|
||||||
self.print_error("used")
|
|
||||||
self.last_operation = time.time()
|
self.last_operation = time.time()
|
||||||
|
|
||||||
def prevent_timeouts(self):
|
def prevent_timeouts(self):
|
||||||
self.print_error("prevent timeouts")
|
|
||||||
self.last_operation = float('inf')
|
self.last_operation = float('inf')
|
||||||
|
|
||||||
def timeout(self, cutoff):
|
def timeout(self, cutoff):
|
||||||
|
@ -141,33 +134,29 @@ class TrezorClientBase(GuiMixin, PrintError):
|
||||||
return self.get_address('Bitcoin', self.expand_path(derivation))
|
return self.get_address('Bitcoin', self.expand_path(derivation))
|
||||||
|
|
||||||
def toggle_passphrase(self):
|
def toggle_passphrase(self):
|
||||||
self.msg_code_override = 'passphrase'
|
if self.features.passphrase_protection:
|
||||||
try:
|
self.msg = _("Confirm on your %s device to disable passphrases")
|
||||||
enabled = not self.features.passphrase_protection
|
else:
|
||||||
self.apply_settings(use_passphrase=enabled)
|
self.msg = _("Confirm on your %s device to enable passphrases")
|
||||||
finally:
|
enabled = not self.features.passphrase_protection
|
||||||
self.msg_code_override = None
|
self.apply_settings(use_passphrase=enabled)
|
||||||
|
|
||||||
def change_label(self, label):
|
def change_label(self, label):
|
||||||
self.msg_code_override = 'label'
|
self.msg = _("Confirm the new label on your %s device")
|
||||||
try:
|
self.apply_settings(label=label)
|
||||||
self.apply_settings(label=label)
|
|
||||||
finally:
|
|
||||||
self.msg_code_override = None
|
|
||||||
|
|
||||||
def change_homescreen(self, homescreen):
|
def change_homescreen(self, homescreen):
|
||||||
self.msg_code_override = 'homescreen'
|
self.msg = _("Confirm on your %s device to change your home screen")
|
||||||
try:
|
self.apply_settings(homescreen=homescreen)
|
||||||
self.apply_settings(homescreen=homescreen)
|
|
||||||
finally:
|
|
||||||
self.msg_code_override = None
|
|
||||||
|
|
||||||
def set_pin(self, remove):
|
def set_pin(self, remove):
|
||||||
self.msg_code_override = 'remove pin' if remove else 'change pin'
|
if remove:
|
||||||
try:
|
self.msg = _("Confirm on your %s device to disable PIN protection")
|
||||||
self.change_pin(remove)
|
elif self.features.pin_protection:
|
||||||
finally:
|
self.msg = _("Confirm on your %s device to change your PIN")
|
||||||
self.msg_code_override = None
|
else:
|
||||||
|
self.msg = _("Confirm on your %s device to set a PIN")
|
||||||
|
self.change_pin(remove)
|
||||||
|
|
||||||
def clear_session(self):
|
def clear_session(self):
|
||||||
'''Clear the session to force pin (and passphrase if enabled)
|
'''Clear the session to force pin (and passphrase if enabled)
|
||||||
|
@ -206,6 +195,7 @@ class TrezorClientBase(GuiMixin, PrintError):
|
||||||
finally:
|
finally:
|
||||||
self.used()
|
self.used()
|
||||||
self.handler.finished()
|
self.handler.finished()
|
||||||
|
self.msg = None
|
||||||
|
|
||||||
return wrapped
|
return wrapped
|
||||||
|
|
||||||
|
|
|
@ -351,7 +351,6 @@ class SettingsDialog(WindowModalDialog):
|
||||||
# wallet can be None, needn't be window.wallet
|
# wallet can be None, needn't be window.wallet
|
||||||
wallet = devmgr.wallet_by_id(device_id)
|
wallet = devmgr.wallet_by_id(device_id)
|
||||||
hs_rows, hs_cols = (64, 128)
|
hs_rows, hs_cols = (64, 128)
|
||||||
self.current_label=None
|
|
||||||
|
|
||||||
def invoke_client(method, *args, **kw_args):
|
def invoke_client(method, *args, **kw_args):
|
||||||
unpair_after = kw_args.pop('unpair_after', False)
|
unpair_after = kw_args.pop('unpair_after', False)
|
||||||
|
@ -369,7 +368,7 @@ class SettingsDialog(WindowModalDialog):
|
||||||
thread.add(task, on_success=update)
|
thread.add(task, on_success=update)
|
||||||
|
|
||||||
def update(features):
|
def update(features):
|
||||||
self.current_label = features.label
|
self.features = features
|
||||||
set_label_enabled()
|
set_label_enabled()
|
||||||
bl_hash = features.bootloader_hash.encode('hex')
|
bl_hash = features.bootloader_hash.encode('hex')
|
||||||
bl_hash = "\n".join([bl_hash[:32], bl_hash[32:]])
|
bl_hash = "\n".join([bl_hash[:32], bl_hash[32:]])
|
||||||
|
@ -400,23 +399,30 @@ class SettingsDialog(WindowModalDialog):
|
||||||
language_label.setText(features.language)
|
language_label.setText(features.language)
|
||||||
|
|
||||||
def set_label_enabled():
|
def set_label_enabled():
|
||||||
label_apply.setEnabled(label_edit.text() != self.current_label)
|
label_apply.setEnabled(label_edit.text() != self.features.label)
|
||||||
|
|
||||||
def rename():
|
def rename():
|
||||||
invoke_client('change_label', unicode(label_edit.text()))
|
invoke_client('change_label', unicode(label_edit.text()))
|
||||||
|
|
||||||
def toggle_passphrase():
|
def toggle_passphrase():
|
||||||
title = _("Confirm Toggle Passphrase Protection")
|
title = _("Confirm Toggle Passphrase Protection")
|
||||||
msg = _("This will cause your Electrum wallet to be unpaired "
|
currently_enabled = self.features.passphrase_protection
|
||||||
"unless your passphrase was or will be empty.\n\n"
|
if currently_enabled:
|
||||||
"This is because addresses will no "
|
msg = _("After disabling passphrases, you can only pair this "
|
||||||
"longer correspond to those used by your %s.\n\n"
|
"Electrum wallet if it had an empty passphrase. "
|
||||||
"You will need to create a new Electrum wallet "
|
"If its passphrase was not empty, you will need to "
|
||||||
"with the install wizard so that they match.\n\n"
|
"create a new wallet with the install wizard. You "
|
||||||
"Are you sure you want to proceed?") % plugin.device
|
"can use this wallet again at any time by re-enabling "
|
||||||
|
"passphrases and entering its passphrase.")
|
||||||
|
else:
|
||||||
|
msg = _("Your current Electrum wallet can only be used with "
|
||||||
|
"an empty passphrase. You must create a separate "
|
||||||
|
"wallet with the install wizard for other passphrases "
|
||||||
|
"as each one generates a new set of addresses.")
|
||||||
|
msg += "\n\n" + _("Are you sure you want to proceed?")
|
||||||
if not self.question(msg, title=title):
|
if not self.question(msg, title=title):
|
||||||
return
|
return
|
||||||
invoke_client('toggle_passphrase', unpair_after=True)
|
invoke_client('toggle_passphrase', unpair_after=currently_enabled)
|
||||||
|
|
||||||
def change_homescreen():
|
def change_homescreen():
|
||||||
from PIL import Image # FIXME
|
from PIL import Image # FIXME
|
||||||
|
|
Loading…
Add table
Reference in a new issue