during wallet restore allow user to retry after invalid OTP. add abort button on kivy.
This commit is contained in:
@@ -503,7 +503,7 @@ class ElectrumWindow(App):
|
|||||||
else:
|
else:
|
||||||
self.load_wallet(wallet)
|
self.load_wallet(wallet)
|
||||||
else:
|
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)
|
storage = WalletStorage(path, manual_upgrades=True)
|
||||||
wizard = Factory.InstallWizard(self.electrum_config, self.plugins, storage)
|
wizard = Factory.InstallWizard(self.electrum_config, self.plugins, storage)
|
||||||
wizard.bind(on_wizard_complete=self.on_wizard_complete)
|
wizard.bind(on_wizard_complete=self.on_wizard_complete)
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
|
|
||||||
from functools import partial
|
from functools import partial
|
||||||
import threading
|
import threading
|
||||||
|
import os
|
||||||
|
|
||||||
from kivy.app import App
|
from kivy.app import App
|
||||||
from kivy.clock import Clock
|
from kivy.clock import Clock
|
||||||
@@ -238,11 +239,23 @@ Builder.load_string('''
|
|||||||
text: root.message2
|
text: root.message2
|
||||||
BoxLayout:
|
BoxLayout:
|
||||||
orientation: 'horizontal'
|
orientation: 'horizontal'
|
||||||
size_hint: 1, 0.2
|
size_hint: 1, 0.3
|
||||||
Widget
|
Widget
|
||||||
CheckBox:
|
CheckBox:
|
||||||
id:cb
|
id:cb
|
||||||
on_state: Clock.schedule_once(root.on_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>
|
<WizardNewOTPDialog>
|
||||||
message : ''
|
message : ''
|
||||||
@@ -618,6 +631,12 @@ class WizardKnownOTPDialog(WizardOTPDialogBase):
|
|||||||
self.ids.otp.text = ''
|
self.ids.otp.text = ''
|
||||||
self.ids.next.disabled = not self.ids.cb.active
|
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):
|
class WizardNewOTPDialog(WizardOTPDialogBase):
|
||||||
|
|
||||||
|
|||||||
@@ -581,15 +581,24 @@ class TrustedCoinPlugin(BasePlugin):
|
|||||||
def do_auth(self, wizard, short_id, otp, xpub3):
|
def do_auth(self, wizard, short_id, otp, xpub3):
|
||||||
try:
|
try:
|
||||||
server.auth(short_id, otp)
|
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:
|
except Exception as e:
|
||||||
wizard.show_message(str(e))
|
wizard.show_message(str(e))
|
||||||
return
|
wizard.terminate()
|
||||||
k3 = keystore.from_xpub(xpub3)
|
else:
|
||||||
wizard.storage.put('x3/', k3.dump())
|
k3 = keystore.from_xpub(xpub3)
|
||||||
wizard.storage.put('use_trustedcoin', True)
|
wizard.storage.put('x3/', k3.dump())
|
||||||
wizard.storage.write()
|
wizard.storage.put('use_trustedcoin', True)
|
||||||
wizard.wallet = Wallet_2fa(wizard.storage)
|
wizard.storage.write()
|
||||||
wizard.run('create_addresses')
|
wizard.wallet = Wallet_2fa(wizard.storage)
|
||||||
|
wizard.run('create_addresses')
|
||||||
|
|
||||||
def on_reset_auth(self, wizard, short_id, seed, passphrase, xpub3):
|
def on_reset_auth(self, wizard, short_id, seed, passphrase, xpub3):
|
||||||
xprv1, xpub1, xprv2, xpub2 = self.xkeys_from_seed(seed, passphrase)
|
xprv1, xpub1, xprv2, xpub2 = self.xkeys_from_seed(seed, passphrase)
|
||||||
|
|||||||
Reference in New Issue
Block a user