electrum

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

commit 531a2a5c1ffa32dc204a10b839c7203524f29630
parent 248a3a57550e3886a4745453cde4f4e8073f0b6e
Author: SomberNight <somber.night@protonmail.com>
Date:   Wed,  6 Jun 2018 22:36:53 +0200

during wallet restore allow user to retry after invalid OTP. add abort button on kivy.

Diffstat:
Mgui/kivy/main_window.py | 2+-
Mgui/kivy/uix/dialogs/installwizard.py | 21++++++++++++++++++++-
Mplugins/trustedcoin/trustedcoin.py | 23++++++++++++++++-------
3 files changed, 37 insertions(+), 9 deletions(-)

diff --git a/gui/kivy/main_window.py b/gui/kivy/main_window.py @@ -503,7 +503,7 @@ class ElectrumWindow(App): else: self.load_wallet(wallet) else: - Logger.debug('Electrum: Wallet not found. Launching install wizard') + Logger.debug('Electrum: Wallet not found or action needed. Launching install wizard') storage = WalletStorage(path, manual_upgrades=True) wizard = Factory.InstallWizard(self.electrum_config, self.plugins, storage) wizard.bind(on_wizard_complete=self.on_wizard_complete) diff --git a/gui/kivy/uix/dialogs/installwizard.py b/gui/kivy/uix/dialogs/installwizard.py @@ -1,6 +1,7 @@ from functools import partial import threading +import os from kivy.app import App from kivy.clock import Clock @@ -238,11 +239,23 @@ Builder.load_string(''' text: root.message2 BoxLayout: orientation: 'horizontal' - size_hint: 1, 0.2 + size_hint: 1, 0.3 Widget CheckBox: id:cb on_state: Clock.schedule_once(root.on_cb) + Widget + size_hint: 1, 1 + height: '48sp' + BoxLayout: + orientation: 'horizontal' + WizardButton: + id: abort + text: _('Abort creation') + on_release: root.abort_wallet_creation() + size_hint: 1, None + Widget + size_hint: 1, None <WizardNewOTPDialog> message : '' @@ -618,6 +631,12 @@ class WizardKnownOTPDialog(WizardOTPDialogBase): self.ids.otp.text = '' self.ids.next.disabled = not self.ids.cb.active + def abort_wallet_creation(self): + self._on_release = True + os.unlink(self.wizard.storage.path) + self.wizard.terminate() + self.dismiss() + class WizardNewOTPDialog(WizardOTPDialogBase): diff --git a/plugins/trustedcoin/trustedcoin.py b/plugins/trustedcoin/trustedcoin.py @@ -581,15 +581,24 @@ class TrustedCoinPlugin(BasePlugin): def do_auth(self, wizard, short_id, otp, xpub3): try: server.auth(short_id, otp) + except TrustedCoinException as e: + if e.status_code == 400: # invalid OTP + wizard.show_message(_('Invalid one-time password.')) + # ask again for otp + self.request_otp_dialog(wizard, short_id, None, xpub3) + else: + wizard.show_message(str(e)) + wizard.terminate() except Exception as e: wizard.show_message(str(e)) - return - k3 = keystore.from_xpub(xpub3) - wizard.storage.put('x3/', k3.dump()) - wizard.storage.put('use_trustedcoin', True) - wizard.storage.write() - wizard.wallet = Wallet_2fa(wizard.storage) - wizard.run('create_addresses') + wizard.terminate() + else: + k3 = keystore.from_xpub(xpub3) + wizard.storage.put('x3/', k3.dump()) + wizard.storage.put('use_trustedcoin', True) + wizard.storage.write() + wizard.wallet = Wallet_2fa(wizard.storage) + wizard.run('create_addresses') def on_reset_auth(self, wizard, short_id, seed, passphrase, xpub3): xprv1, xpub1, xprv2, xpub2 = self.xkeys_from_seed(seed, passphrase)