tkivy: support old-type seed phrases in wizard - electrum - Electrum Bitcoin wallet HTML git clone https://git.parazyd.org/electrum DIR Log DIR Files DIR Refs DIR Submodules --- DIR commit d58ec9a570025b66891908ac7dfd95d87fffeb19 DIR parent 384c7cacd7a58b4c6a90c0df21d176f235568401 HTML Author: ThomasV <thomasv@electrum.org> Date: Tue, 1 Mar 2016 20:23:30 +0100 kivy: support old-type seed phrases in wizard Diffstat: M gui/kivy/uix/dialogs/create_restor… | 10 ++++++++-- M gui/kivy/uix/dialogs/installwizard… | 12 +++++------- M lib/wallet.py | 1 + 3 files changed, 14 insertions(+), 9 deletions(-) --- DIR diff --git a/gui/kivy/uix/dialogs/create_restore.py b/gui/kivy/uix/dialogs/create_restore.py t@@ -452,7 +452,13 @@ class RestoreSeedDialog(WizardDialog): super(RestoreSeedDialog, self).__init__(**kwargs) self._test = kwargs['test'] from electrum.mnemonic import Mnemonic - self.mnemonic = Mnemonic('en') + from electrum.old_mnemonic import words as old_wordlist + self.words = set(Mnemonic('en').wordlist).union(set(old_wordlist)) + + def get_suggestions(self, prefix): + for w in self.words: + if w.startswith(prefix): + yield w def on_text(self, dt): self.ids.next.disabled = not bool(self._test(self.get_text())) t@@ -467,7 +473,7 @@ class RestoreSeedDialog(WizardDialog): enable_space = False self.ids.suggestions.clear_widgets() - suggestions = [x for x in self.mnemonic.get_suggestions(last_word)] + suggestions = [x for x in self.get_suggestions(last_word)] if suggestions and len(suggestions) < 10: for w in suggestions: if w == last_word: DIR diff --git a/gui/kivy/uix/dialogs/installwizard.py b/gui/kivy/uix/dialogs/installwizard.py t@@ -36,7 +36,6 @@ class InstallWizard(Widget): self.config = config self.network = network self.storage = storage - self.wallet = Wallet(self.storage) def waiting_dialog(self, task, msg, on_complete=None): '''Perform a blocking task in the background by running the passed t@@ -111,18 +110,17 @@ class InstallWizard(Widget): def add_seed(self, text, password): def task(): - 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) + if not Wallet.is_seed(text): + raise BaseException("invalid seed") + self.wallet = Wallet.from_seed(text, password, 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): - seed = self.wallet.make_seed() + from electrum.wallet import BIP32_Wallet + seed = BIP32_Wallet.make_seed() msg = _("If you forget your PIN or lose your device, your seed phrase will be the " "only way to recover your funds.") def on_ok(_dlg, _btn): DIR diff --git a/lib/wallet.py b/lib/wallet.py t@@ -1615,6 +1615,7 @@ class BIP32_Wallet(Deterministic_Wallet): def mnemonic_to_seed(self, seed, password): return Mnemonic.mnemonic_to_seed(seed, password) + @classmethod def make_seed(self, lang=None): return Mnemonic(lang).make_seed()