Skip to content

Commit

Permalink
fix windows crash on not paste
Browse files Browse the repository at this point in the history
  • Loading branch information
Electrum-RVN-SIG committed Oct 27, 2021
1 parent 48af47e commit 4e72719
Showing 1 changed file with 26 additions and 24 deletions.
50 changes: 26 additions & 24 deletions electrum/gui/qt/seed_dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 4e72719

Please sign in to comment.