electrum

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

commit 2bb08aa2807901185f68da21979912131d8de743
parent 58f11680047ee513ed542b0942588895bea88c0e
Author: ThomasV <thomasv@electrum.org>
Date:   Sat, 30 Jul 2016 15:04:15 +0200

fixes for install wizard

Diffstat:
Mlib/base_wizard.py | 21+++++++++++----------
Mplugins/trustedcoin/trustedcoin.py | 32+++++++++-----------------------
2 files changed, 20 insertions(+), 33 deletions(-)

diff --git a/lib/base_wizard.py b/lib/base_wizard.py @@ -43,17 +43,18 @@ class BaseWizard(object): self.wallet = None self.stack = [] - def run(self, action, *args): + def run(self, *args): + action = args[0] + args = args[1:] self.stack.append((action, args)) if not action: return - if hasattr(self.wallet, 'plugin'): - if hasattr(self.wallet.plugin, action): - f = getattr(self.wallet.plugin, action) - apply(f, (self.wallet, self) + args) + if hasattr(self.wallet, 'plugin') and hasattr(self.wallet.plugin, action): + f = getattr(self.wallet.plugin, action) + apply(f, (self.wallet, self) + args) elif hasattr(self, action): f = getattr(self, action) - apply(f, *args) + apply(f, args) else: raise BaseException("unknown action", action) @@ -236,7 +237,7 @@ class BaseWizard(object): def show_xpub_and_add_cosigners(self, password): xpub = self.wallet.master_public_keys.get('x1/') - self.show_xpub_dialog(xpub=xpub, run_next=lambda x: self.run('add_cosigners', (password,))) + self.show_xpub_dialog(xpub=xpub, run_next=lambda x: self.run('add_cosigners', password)) def add_cosigners(self, password): i = self.wallet.get_missing_cosigner() @@ -247,7 +248,7 @@ class BaseWizard(object): self.wallet.add_cosigner('x%d/'%i, text, password) i = self.wallet.get_missing_cosigner() if i: - self.run('add_cosigners', (password,)) + self.run('add_cosigners', password) else: self.create_addresses() @@ -255,6 +256,7 @@ class BaseWizard(object): def task(): self.wallet.create_main_account() self.wallet.synchronize() + self.wallet.storage.write() self.terminate() msg = _("Electrum is generating your addresses, please wait.") self.waiting_dialog(task, msg) @@ -265,9 +267,8 @@ class BaseWizard(object): self.show_seed_dialog(run_next=self.confirm_seed, seed_text=seed) def confirm_seed(self, seed): - assert Wallet.is_seed(seed) self.confirm_seed_dialog(run_next=self.add_password, is_valid=lambda x: x==seed) def add_password(self, text): - f = lambda x: self.create_wallet(text, x) + f = lambda pw: self.run('create_wallet', text, pw) self.request_password(run_next=f) diff --git a/plugins/trustedcoin/trustedcoin.py b/plugins/trustedcoin/trustedcoin.py @@ -349,21 +349,9 @@ class TrustedCoinPlugin(BasePlugin): self.wallet = wallet self.wizard = wizard seed = wallet.make_seed() - f = lambda x: wizard.run('confirm_seed', x) - self.wizard.show_seed_dialog(run_next=f, message="z", seed_text=seed) + self.wizard.show_seed_dialog(run_next=wizard.confirm_seed, seed_text=seed) - def confirm_seed(self, wallet, wizard, seed): - title = _('Confirm Seed') - msg = _('Please retype your seed phrase, to confirm that you properly saved it') - f = lambda x: wizard.run('add_password', x) - self.wizard.enter_seed_dialog(run_next=f, title=title, message=msg, is_valid=lambda x: x==seed) - - def add_password(self, wallet, wizard, seed): - f = lambda x: self.create_wallet(seed, x) - self.wizard.request_password(run_next=f) - - def create_wallet(self, seed, password): - wallet = self.wallet + def create_wallet(self, wallet, wizard, seed, password): wallet.storage.put('seed_version', wallet.seed_version) wallet.storage.put('use_encryption', password is not None) words = seed.split() @@ -381,8 +369,8 @@ class TrustedCoinPlugin(BasePlugin): _('If you are online, click on "%s" to continue.') % _('Next') ] msg = '\n\n'.join(msg) - self.wizard.confirm(msg) - return wallet + wizard.confirm(msg) + wizard.run('create_remote_key') @hook def do_clear(self, window): @@ -411,11 +399,9 @@ class TrustedCoinPlugin(BasePlugin): email = self.accept_terms_of_use(window) xpub_hot = wallet.master_public_keys["x1/"] xpub_cold = wallet.master_public_keys["x2/"] - # Generate third key deterministically. long_user_id, short_id = wallet.get_user_id() xpub3 = make_xpub(signing_xpub, long_user_id) - # secret must be sent by the server try: r = server.create(xpub_hot, xpub_cold, email) @@ -427,7 +413,6 @@ class TrustedCoinPlugin(BasePlugin): r = None else: raise e - if r is None: otp_secret = None else: @@ -443,7 +428,8 @@ class TrustedCoinPlugin(BasePlugin): except Exception as e: window.show_message(str(e)) return - - if self.setup_google_auth(window, short_id, otp_secret): - wallet.add_master_public_key('x3/', xpub3) - wallet.create_main_account() + if not self.setup_google_auth(window, short_id, otp_secret): + window.show_message("otp error") + return + wallet.add_master_public_key('x3/', xpub3) + window.run('create_addresses')