mnemonic: make sure newly generated seeds are not valid as bip39
This commit is contained in:
@@ -188,6 +188,7 @@ class Mnemonic(Logger):
|
||||
return i
|
||||
|
||||
def make_seed(self, *, seed_type=None, num_bits=None) -> str:
|
||||
from .keystore import bip39_is_checksum_valid
|
||||
if seed_type is None:
|
||||
seed_type = 'segwit'
|
||||
if num_bits is None:
|
||||
@@ -210,6 +211,11 @@ class Mnemonic(Logger):
|
||||
raise Exception('Cannot extract same entropy from mnemonic!')
|
||||
if is_old_seed(seed):
|
||||
continue
|
||||
# Make sure the mnemonic we generate is not also a valid bip39 seed
|
||||
# by accident. Note that this test has not always been done historically,
|
||||
# so it cannot be relied upon.
|
||||
if bip39_is_checksum_valid(seed, wordlist=self.wordlist) == (True, True):
|
||||
continue
|
||||
if is_new_seed(seed, prefix):
|
||||
break
|
||||
self.logger.info(f'{len(seed.split())} words')
|
||||
|
||||
Reference in New Issue
Block a user