commit d68f42df95ab2db862fcbd8329981400337f1844
parent 4f0631d78d3e923e3e60fb42a4d4442c199958b9
Author: ThomasV <thomasv@electrum.org>
Date: Sat, 16 Jan 2016 15:05:49 +0100
add qr code scanner to kivy wizard
Diffstat:
2 files changed, 29 insertions(+), 29 deletions(-)
diff --git a/gui/kivy/uix/dialogs/create_restore.py b/gui/kivy/uix/dialogs/create_restore.py
@@ -175,6 +175,10 @@ Builder.load_string('''
id: back
text: _('Back')
root: root
+ Button:
+ id: scan
+ text: _('QR')
+ on_release: root.scan_seed()
CreateAccountButton:
id: next
text: _('Next')
@@ -320,10 +324,16 @@ class RestoreSeedDialog(CreateAccountDialog):
def get_seed_text(self):
ti = self.ids.text_input_seed
- text = unicode(ti.text.lower()).strip()
+ text = unicode(ti.text).strip()
text = ' '.join(text.split())
return text
+ def scan_seed(self):
+ def on_complete(text):
+ self.ids.text_input_seed.text = text
+ app = App.get_running_app()
+ app.scan_qr(on_complete)
+
def on_parent(self, instance, value):
if value:
tis = self.ids.text_input_seed
diff --git a/gui/kivy/uix/dialogs/installwizard.py b/gui/kivy/uix/dialogs/installwizard.py
@@ -7,14 +7,15 @@ from kivy.core.window import Window
from kivy.clock import Clock
from kivy.factory import Factory
-Factory.register('CreateRestoreDialog',
- module='electrum_gui.kivy.uix.dialogs.create_restore')
-
import sys
import threading
from functools import partial
import weakref
+from create_restore import CreateRestoreDialog, ShowSeedDialog, RestoreSeedDialog
+from password_dialog import PasswordDialog
+
+
# global Variables
app = App.get_running_app()
@@ -59,10 +60,6 @@ class InstallWizard(Widget):
t = threading.Thread(target = target)
t.start()
- def is_any(self, seed_e):
- text = self.get_seed_text(seed_e)
- return Wallet.is_any(text)
-
def run(self, action, *args):
'''Entry point of our Installation wizard'''
if not action:
@@ -86,38 +83,37 @@ class InstallWizard(Widget):
self.run('restore')
else:
self.dispatch('on_wizard_complete', None)
- Factory.CreateRestoreDialog(on_release=on_release).open()
+ CreateRestoreDialog(on_release=on_release).open()
def restore(self):
- from create_restore import RestoreSeedDialog
self.is_restore = True
def on_seed(_dlg, btn):
+ _dlg.close()
if btn is _dlg.ids.back:
- _dlg.close()
self.run('new')
return
text = _dlg.get_seed_text()
- need_password = Wallet.should_encrypt(text)
- _dlg.close()
- if need_password:
+ if Wallet.should_encrypt(text):
self.run('enter_pin', (text,))
else:
- self.wallet = Wallet.from_text(text)
+ self.run('add_seed', (text, None))
# fixme: sync
msg = _('You may also enter an extended public key, to create a watching-only wallet')
- RestoreSeedDialog(test=Wallet.is_any, message=msg, on_release=partial(on_seed)).open()
+ RestoreSeedDialog(test=Wallet.is_any, message=msg, on_release=on_seed).open()
- def add_seed(self, seed, password):
+ def add_seed(self, text, password):
def task():
- self.wallet.add_seed(seed, password)
- self.wallet.create_master_keys(password)
+ if Wallet.is_seed(text):
+ self.wallet.add_seed(text, password)
+ self.wallet.create_master_keys(password)
+ else:
+ self.wallet = Wallet.from_text(text, None, self.storage)
self.wallet.create_main_account()
self.wallet.synchronize()
msg= _("Electrum is generating your addresses, please wait.")
self.waiting_dialog(task, msg, self.terminate)
def create(self):
- from create_restore import ShowSeedDialog
self.is_restore = False
seed = self.wallet.make_seed()
msg = _("If you forget your PIN or lose your device, your seed phrase will be the "
@@ -131,30 +127,24 @@ class InstallWizard(Widget):
ShowSeedDialog(message=msg, seed_text=seed, on_release=on_ok).open()
def confirm_seed(self, seed):
- from create_restore import RestoreSeedDialog
+ assert Wallet.is_seed(seed)
def on_seed(_dlg, btn):
if btn is _dlg.ids.back:
_dlg.close()
self.run('create')
return
_dlg.close()
- if Wallet.should_encrypt(seed):
- self.run('enter_pin', (seed,))
- else:
- self.wallet = Wallet.from_text(seed)
- # fixme: sync
+ self.run('enter_pin', (seed,))
msg = _('Please retype your seed phrase, to confirm that you properly saved it')
- RestoreSeedDialog(test=lambda x: x==seed, message=msg, on_release=partial(on_seed)).open()
+ RestoreSeedDialog(test=lambda x: x==seed, message=msg, on_release=on_seed).open()
def enter_pin(self, seed):
- from password_dialog import PasswordDialog
def callback(pin):
self.run('confirm_pin', (seed, pin))
popup = PasswordDialog('Choose a PIN code', callback)
popup.open()
def confirm_pin(self, seed, pin):
- from password_dialog import PasswordDialog
def callback(conf):
if conf == pin:
self.run('add_seed', (seed, pin))