def update_next_button(self): from electrum_zcash.keystore import bip39_is_checksum_valid text = self.get_text() if self.is_bip39: is_seed, is_wordlist = bip39_is_checksum_valid(text) else: is_seed = bool(self._test(text)) self.ids.next.disabled = not is_seed
def on_edit(self): from electrum_zcash.bitcoin import seed_type s = self.get_seed() b = self.is_seed(s) if not self.is_bip39: t = seed_type(s) label = _('Seed Type') + ': ' + t if t else '' else: from electrum_zcash.keystore import bip39_is_checksum_valid is_checksum, is_wordlist = bip39_is_checksum_valid(s) status = ('checksum: ' + ('ok' if is_checksum else 'failed')) if is_wordlist else 'unknown wordlist' label = 'BIP39' + ' (%s)'%status self.seed_type_label.setText(label) self.parent.next_button.setEnabled(b) # to account for bip39 seeds for word in self.get_seed().split(" ")[:-1]: if word not in self.wordlist: self.seed_e.disable_suggestions() return self.seed_e.enable_suggestions()
def test(self): mnemonic = u'gravity machine north sort system female filter attitude volume fold club stay feature office ecology stable narrow fog' is_checksum_valid, is_wordlist_valid = keystore.bip39_is_checksum_valid( mnemonic) self.assertTrue(is_wordlist_valid) self.assertTrue(is_checksum_valid)