def update_next_button(self):
     from electrum_mona.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
Esempio n. 2
0
 def on_edit(self):
     from electrum_mona.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_mona.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)
Esempio n. 3
0
    def on_edit(self):
        s = ' '.join(self.get_seed_words())
        b = self.is_seed(s)
        if self.seed_type == 'bip39':
            from electrum_mona.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
        elif self.seed_type == 'slip39':
            self.slip39_mnemonics[self.slip39_mnemonic_index] = s
            try:
                slip39.decode_mnemonic(s)
            except slip39.Slip39Error as e:
                share_status = str(e)
                current_mnemonic_invalid = True
            else:
                share_status = _('Valid.')
                current_mnemonic_invalid = False

            label = _('SLIP39 share') + ' #%d: %s' % (self.slip39_mnemonic_index + 1, share_status)

            # No need to process mnemonics if the current mnemonic remains invalid after editing.
            if not (self.slip39_current_mnemonic_invalid and current_mnemonic_invalid):
                self.slip39_seed, seed_status = slip39.process_mnemonics(self.slip39_mnemonics)
                self.seed_status.setText(seed_status)
            self.slip39_current_mnemonic_invalid = current_mnemonic_invalid

            b = self.slip39_seed is not None
            self.update_share_buttons()
        else:
            t = seed_type(s)
            label = _('Seed Type') + ': ' + t if t else ''

        self.seed_type_label.setText(label)
        self.parent.next_button.setEnabled(b)

        # disable suggestions if user already typed an unknown word
        for word in self.get_seed_words()[:-1]:
            if word not in self.wordlist:
                self.seed_e.disable_suggestions()
                return
        self.seed_e.enable_suggestions()
Esempio n. 4
0
    def on_edit(self):
        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_mona.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)

        # disable suggestions if user already typed an unknown word
        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()
Esempio n. 5
0
 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)