electrum

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

commit 5f0a7db5989f6c41fc01a5bee375259507415cf0
parent 2226667437634bd45b40290084ad97e9895bbd08
Author: ThomasV <thomasv@electrum.org>
Date:   Sun, 20 Dec 2015 17:37:07 +0100

kivy: password dialog and wizard fixes

Diffstat:
Mgui/kivy/main.kv | 7+++++++
Mgui/kivy/main_window.py | 24+++++-------------------
Mgui/kivy/uix/dialogs/amount_dialog.py | 5-----
Mgui/kivy/uix/dialogs/create_restore.py | 4+---
Mgui/kivy/uix/dialogs/installwizard.py | 23+++++++++++++----------
Agui/kivy/uix/dialogs/password_dialog.py | 84+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Mgui/kivy/uix/dialogs/wallets.py | 5++++-
Dgui/kivy/uix/ui_screens/password.kv | 51---------------------------------------------------
8 files changed, 114 insertions(+), 89 deletions(-)

diff --git a/gui/kivy/main.kv b/gui/kivy/main.kv @@ -243,6 +243,13 @@ background_active: 'atlas://gui/kivy/theming/light/textinput_active' +<KButton@Button>: + size_hint: 1, None + height: '48dp' + on_release: + self.parent.update_amount(self.text) + + <TabbedPanelStrip>: on_parent: diff --git a/gui/kivy/main_window.py b/gui/kivy/main_window.py @@ -483,17 +483,6 @@ class ElectrumWindow(App): amount, fee = self.wallet.get_max_amount(self.electrum_config, inputs, None) return format_satoshis_plain(amount, self.decimal_point()) - def update_password(self, label, c): - text = label.password - if c == '<': - text = text[:-1] - elif c == 'Clear': - text = '' - else: - text += c - label.password = text - - def format_amount(self, x, is_diff=False, whitespaces=False): return format_satoshis(x, is_diff, 0, self.decimal_point(), whitespaces) @@ -503,8 +492,8 @@ class ElectrumWindow(App): @profiler def update_wallet(self, *dt): self._trigger_update_status() - if self.wallet.up_to_date or not self.network or not self.network.is_connected(): - self.update_tabs() + #if self.wallet.up_to_date or not self.network or not self.network.is_connected(): + self.update_tabs() @profiler @@ -736,12 +725,9 @@ class ElectrumWindow(App): self.show_error("PIN numbers do not match") def password_dialog(self, title, f, args): - popup = Builder.load_file('gui/kivy/uix/ui_screens/password.kv') - popup.title = title - def callback(): - pw = popup.ids.kb.password + from uix.dialogs.password_dialog import PasswordDialog + def callback(pw): Clock.schedule_once(lambda x: apply(f, args + (pw,)), 0.1) - popup.on_dismiss = callback + popup = PasswordDialog(title, callback) popup.open() - diff --git a/gui/kivy/uix/dialogs/amount_dialog.py b/gui/kivy/uix/dialogs/amount_dialog.py @@ -5,11 +5,6 @@ from kivy.lang import Builder from decimal import Decimal Builder.load_string(''' -<KButton@Button>: - size_hint: 1, None - height: '48dp' - on_release: - self.parent.update_amount(self.text) <AmountDialog@Popup> id: popup diff --git a/gui/kivy/uix/dialogs/create_restore.py b/gui/kivy/uix/dialogs/create_restore.py @@ -43,7 +43,6 @@ Builder.load_string(''' on_release: if self.root: self.root.dispatch('on_release', self) - <-CreateAccountDialog> text_color: .854, .925, .984, 1 auto_dismiss: False @@ -457,8 +456,7 @@ class RestoreSeedDialog(CreateAccountDialog): self._trigger_check_seed = Clock.create_trigger(self.check_seed) def check_seed(self, dt): - self.ids.next.disabled = not bool(self._wizard.is_any( - self.ids.text_input_seed)) + self.ids.next.disabled = not bool(self._wizard.is_any(self.ids.text_input_seed)) def on_parent(self, instance, value): if value: diff --git a/gui/kivy/uix/dialogs/installwizard.py b/gui/kivy/uix/dialogs/installwizard.py @@ -73,7 +73,9 @@ class InstallWizard(Widget): def is_any(self, seed_e): text = self.get_seed_text(seed_e) return (Wallet.is_seed(text) or - Wallet.is_mpk(text) or + Wallet.is_old_mpk(text) or + Wallet.is_xpub(text) or + Wallet.is_xprv(text) or Wallet.is_address(text) or Wallet.is_private_key(text)) @@ -129,8 +131,8 @@ class InstallWizard(Widget): if Wallet.is_seed(seed): return self.password_dialog(wallet=wallet, mode='restore', seed=seed) - elif Wallet.is_mpk(seed): - wallet = Wallet.from_mpk(seed, self.storage) + elif Wallet.is_xpub(seed): + wallet = Wallet.from_xpub(seed, self.storage) elif Wallet.is_address(seed): wallet = Wallet.from_address(seed, self.storage) elif Wallet.is_private_key(seed): @@ -257,18 +259,19 @@ class InstallWizard(Widget): new_password = None if mode == 'restore': - wallet = Wallet.from_seed(seed, self.storage) - password = (unicode(ti_password.text) - if wallet and wallet.use_encryption else - None) + password = unicode(ti_password.text) + # if wallet and wallet.use_encryption else + # None) + if not password: + password = None + wallet = Wallet.from_text(seed, password, self.storage) def on_complete(*l): - wallet.create_accounts(new_password) self.load_network(wallet, mode='restore') _dlg.close() - self.waiting_dialog(lambda: wallet.add_seed(seed, new_password), - msg=_("saving seed"), + self.waiting_dialog(wallet.synchronize, + msg=_("generating addresses"), on_complete=on_complete) return diff --git a/gui/kivy/uix/dialogs/password_dialog.py b/gui/kivy/uix/dialogs/password_dialog.py @@ -0,0 +1,84 @@ +from kivy.app import App +from kivy.factory import Factory +from kivy.properties import ObjectProperty +from kivy.lang import Builder +from decimal import Decimal + +Builder.load_string(''' + +<PasswordDialog@Popup> + id: popup + title: _('Enter PIN Code') + size_hint: 0.9, 0.9 + + BoxLayout: + + orientation: 'vertical' + size_hint: 0.8, 1 + + Label: + id: a + text: ' * '*len(kb.password) + ' o '*(6-len(kb.password)) + size_hint: 1, None + height: '48dp' + + GridLayout: + id: kb + update_amount: popup.update_password + password: '' + on_password: popup.on_password(self.password) + size_hint: 1, None + height: '300dp' + cols: 3 + KButton: + text: '1' + KButton: + text: '2' + KButton: + text: '3' + KButton: + text: '4' + KButton: + text: '5' + KButton: + text: '6' + KButton: + text: '7' + KButton: + text: '8' + KButton: + text: '9' + KButton: + text: 'Clear' + KButton: + text: '0' + KButton: + text: '<' + + Widget: + size_hint: 1, 1 +''') + + +class PasswordDialog(Factory.Popup): + + def __init__(self, title, cb): + Factory.Popup.__init__(self) + self.title = title + self.callback = cb + + def update_password(self, c): + kb = self.ids.kb + text = kb.password + if c == '<': + text = text[:-1] + elif c == 'Clear': + text = '' + else: + text += c + kb.password = text + + def on_password(self, pw): + if len(pw) == 6: + self.dismiss() + self.callback(pw) diff --git a/gui/kivy/uix/dialogs/wallets.py b/gui/kivy/uix/dialogs/wallets.py @@ -40,10 +40,13 @@ Builder.load_string(''' size_hint_y: None FileChooserListView: id: wallet_selector + dirselect: False + filter_dirs: True + filter: '*.*' path: os.path.dirname(app.wallet.storage.path) on_selection: wallet_name.text = os.path.basename(self.selection[0]) if self.selection else '' - size_hint_y: 0.5 + size_hint_y: 0.4 Widget size_hint_y: 0.1 diff --git a/gui/kivy/uix/ui_screens/password.kv b/gui/kivy/uix/ui_screens/password.kv @@ -1,51 +0,0 @@ -Popup: - id: popup - title: _('Enter PIN Code') - size_hint: 0.9, 0.9 - - BoxLayout: - - orientation: 'vertical' - size_hint: 0.8, 1 - - Label: - id: a - text: ' * '*len(kb.password) + ' o '*(6-len(kb.password)) - size_hint: 1, None - height: '48dp' - - GridLayout: - id: kb - update_text: app.update_password - password: '' - on_password: if len(self.password) == 6: popup.dismiss() - size_hint: 1, None - height: '300dp' - cols: 3 - KButton: - text: '1' - KButton: - text: '2' - KButton: - text: '3' - KButton: - text: '4' - KButton: - text: '5' - KButton: - text: '6' - KButton: - text: '7' - KButton: - text: '8' - KButton: - text: '9' - KButton: - text: 'Clear' - KButton: - text: '0' - KButton: - text: '<' - - Widget: - size_hint: 1, 1