From 4e72719be3c40a9bdf124e088c0230da98e1a7cb Mon Sep 17 00:00:00 2001 From: kralverde Date: Wed, 27 Oct 2021 17:07:32 -0400 Subject: [PATCH] fix windows crash on not paste --- electrum/gui/qt/seed_dialog.py | 50 ++++++++++++++++++---------------- 1 file changed, 26 insertions(+), 24 deletions(-) diff --git a/electrum/gui/qt/seed_dialog.py b/electrum/gui/qt/seed_dialog.py index c59c153d9d15..5829b495046d 100644 --- a/electrum/gui/qt/seed_dialog.py +++ b/electrum/gui/qt/seed_dialog.py @@ -639,34 +639,36 @@ def get_seed(self): def on_edit(self): s = ' '.join(self.get_seed_words()) b = self.is_seed(s) - if self.seed_type == 'bip39': - from electrum.keystore import bip39_is_checksum_valid - from electrum.mnemonic import Wordlist, filenames - lang = '' - for type, file in filenames.items(): - word_list = Wordlist.from_file(file) - is_checksum, is_wordlist = bip39_is_checksum_valid(s, wordlist=word_list) - if is_wordlist: - lang = type - break + from electrum.keystore import bip39_is_checksum_valid + from electrum.mnemonic import Wordlist, filenames + + lang = '' + is_checksum = is_wordlist = False + for type, file in filenames.items(): + word_list = Wordlist.from_file(file) + is_checksum, is_wordlist = bip39_is_checksum_valid(s, wordlist=word_list) + if not is_wordlist and len(s.split()) > 1: + is_checksum, is_wordlist = bip39_is_checksum_valid(' '.join(s.split()[:-1]), wordlist=word_list) + if is_wordlist: + lang = type + break + + if lang and lang != self.lang: + if lang == 'en': + bip39_english_list = Mnemonic('en').wordlist + old_list = old_mnemonic.wordlist + only_old_list = set(old_list) - set(bip39_english_list) + self.wordlist = list(bip39_english_list) + list(only_old_list) # concat both lists + else: + self.wordlist = list(Mnemonic(lang).wordlist) + self.wordlist.sort() + self.completer.model().setStringList(self.wordlist) + self.lang = lang + if self.seed_type == 'bip39': status = ('checksum: ' + ('ok' if is_checksum else 'failed')) if is_wordlist else 'unknown wordlist' label = 'BIP39 - ' + lang + ' (%s)'%status - if lang and lang != self.lang: - if lang == 'en': - bip39_english_list = Mnemonic('en').wordlist - old_list = old_mnemonic.wordlist - only_old_list = set(old_list) - set(bip39_english_list) - self.wordlist = list(bip39_english_list) + list(only_old_list) # concat both lists - self.wordlist.sort() - self.completer.model().setStringList(self.wordlist) - self.lang = 'en' - else: - self.wordlist = list(Mnemonic(lang).wordlist) - self.wordlist.sort() - self.completer.model().setStringList(self.wordlist) - self.lang = lang elif self.seed_type == 'slip39': self.slip39_mnemonics[self.slip39_mnemonic_index] = s