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