electrum

Electrum Bitcoin wallet
git clone https://git.parazyd.org/electrum
Log | Files | Refs | Submodules

commit 248a3a57550e3886a4745453cde4f4e8073f0b6e
parent 9ceb73f014ed44ba16cb23e1d848d05bbfacd472
Author: SomberNight <somber.night@protonmail.com>
Date:   Tue,  5 Jun 2018 15:14:22 +0200

otp/email dialog handles pressing enter. do not offer to show seed for 2fa wallet.

Diffstat:
Mgui/kivy/uix/dialogs/installwizard.py | 55++++++++++++++++++++++++++++++++++---------------------
Mgui/kivy/uix/ui_screens/status.kv | 5+++--
Mplugins/trustedcoin/trustedcoin.py | 2+-
3 files changed, 38 insertions(+), 24 deletions(-)

diff --git a/gui/kivy/uix/dialogs/installwizard.py b/gui/kivy/uix/dialogs/installwizard.py @@ -207,6 +207,8 @@ Builder.load_string(''' WizardTextInput: id: email on_text: Clock.schedule_once(root.on_text) + multiline: False + on_text_validate: Clock.schedule_once(root.on_enter) <WizardKnownOTPDialog> message : '' @@ -224,6 +226,8 @@ Builder.load_string(''' WizardTextInput: id: otp on_text: Clock.schedule_once(root.on_text) + multiline: False + on_text_validate: Clock.schedule_once(root.on_enter) Widget size_hint: 1, 1 Label: @@ -261,6 +265,8 @@ Builder.load_string(''' WizardTextInput: id: otp on_text: Clock.schedule_once(root.on_text) + multiline: False + on_text_validate: Clock.schedule_once(root.on_enter) <MButton@Button>: size_hint: 1, None @@ -576,12 +582,8 @@ class WizardMultisigDialog(WizardDialog): n = self.ids.n.value return m, n -class WizardKnownOTPDialog(WizardDialog): - def __init__(self, wizard, **kwargs): - WizardDialog.__init__(self, wizard, **kwargs) - self.message = _("This wallet is already registered with TrustedCoin. To finalize wallet creation, please enter your Google Authenticator Code.") - self.message2 =_("If you have lost your Google Authenticator account, check the box below to request a new secret. You will need to retype your seed.") +class WizardOTPDialogBase(WizardDialog): def get_otp(self): otp = self.ids.otp.text @@ -592,6 +594,23 @@ class WizardKnownOTPDialog(WizardDialog): except: return + def on_text(self, dt): + self.ids.next.disabled = self.get_otp() is None + + def on_enter(self, dt): + # press next + next = self.ids.next + if not next.disabled: + next.dispatch('on_release') + + +class WizardKnownOTPDialog(WizardOTPDialogBase): + + def __init__(self, wizard, **kwargs): + WizardOTPDialogBase.__init__(self, wizard, **kwargs) + self.message = _("This wallet is already registered with TrustedCoin. To finalize wallet creation, please enter your Google Authenticator Code.") + self.message2 =_("If you have lost your Google Authenticator account, check the box below to request a new secret. You will need to retype your seed.") + def get_params(self, button): return (self.get_otp(), self.ids.cb.active) @@ -599,31 +618,17 @@ class WizardKnownOTPDialog(WizardDialog): self.ids.otp.text = '' self.ids.next.disabled = not self.ids.cb.active - def on_text(self, dt): - self.ids.next.disabled = self.get_otp() is None -class WizardNewOTPDialog(WizardDialog): +class WizardNewOTPDialog(WizardOTPDialogBase): def __init__(self, wizard, **kwargs): - WizardDialog.__init__(self, wizard, **kwargs) + WizardOTPDialogBase.__init__(self, wizard, **kwargs) otp_secret = kwargs['otp_secret'] uri = "otpauth://totp/%s?secret=%s"%('trustedcoin.com', otp_secret) self.message = "Please scan the following QR code in Google Authenticator. You may also use the secret key: %s"%otp_secret self.message2 = _('Then, enter your Google Authenticator code:') self.ids.qr.set_data(uri) - def get_otp(self): - otp = self.ids.otp.text - if len(otp) != 6: - return - try: - return int(otp) - except: - return - - def on_text(self, dt): - self.ids.next.disabled = self.get_otp() is None - def get_params(self, button): return (self.get_otp(), False) @@ -637,11 +642,19 @@ class WizardTOSDialog(WizardDialog): self.message2 = _('Enter your email address:') class WizardEmailDialog(WizardDialog): + def get_params(self, button): return (self.ids.email.text,) + def on_text(self, dt): self.ids.next.disabled = not is_valid_email(self.ids.email.text) + def on_enter(self, dt): + # press next + next = self.ids.next + if not next.disabled: + next.dispatch('on_release') + class WizardConfirmDialog(WizardDialog): def __init__(self, wizard, **kwargs): diff --git a/gui/kivy/uix/ui_screens/status.kv b/gui/kivy/uix/ui_screens/status.kv @@ -4,6 +4,7 @@ Popup: unconfirmed: 0 unmatured: 0 watching_only: app.wallet.is_watching_only() + has_seed: app.wallet.has_seed() on_parent: self.confirmed, self.unconfirmed, self.unmatured = app.wallet.get_balance() BoxLayout: @@ -70,8 +71,8 @@ Popup: Button: size_hint: 0.5, None height: '48dp' - text: '' if root.watching_only else (_('Hide seed') if seed_label.text else _('Show seed')) - disabled: root.watching_only + text: '' if not root.has_seed else (_('Hide seed') if seed_label.text else _('Show seed')) + disabled: not root.has_seed on_release: setattr(seed_label, 'text', '') if seed_label.text else app.show_seed(seed_label) Button: diff --git a/plugins/trustedcoin/trustedcoin.py b/plugins/trustedcoin/trustedcoin.py @@ -81,7 +81,7 @@ KIVY_DISCLAIMER = [ "To use it, you must have a separate device with Google Authenticator."), _("This service uses a multi-signature wallet, where you own 2 of 3 keys. " "The third key is stored on a remote server that signs transactions on " - "your behalf.A small fee will be charged on each transaction that uses the " + "your behalf. A small fee will be charged on each transaction that uses the " "remote server."), _("Note that your coins are not locked in this service. You may withdraw " "your funds at any time and at no cost, without the remote server, by "