Replace from_bip39_seed() with from_bip43_rootseed().
This commit is contained in:
@@ -517,7 +517,9 @@ class BaseWizard(Logger):
|
|||||||
def on_restore_seed(self, seed, is_bip39, is_ext):
|
def on_restore_seed(self, seed, is_bip39, is_ext):
|
||||||
self.seed_type = 'bip39' if is_bip39 else mnemonic.seed_type(seed)
|
self.seed_type = 'bip39' if is_bip39 else mnemonic.seed_type(seed)
|
||||||
if self.seed_type == 'bip39':
|
if self.seed_type == 'bip39':
|
||||||
f = lambda passphrase: self.run('on_restore_bip39', seed, passphrase)
|
def f(passphrase):
|
||||||
|
root_seed = bip39_to_seed(seed, passphrase)
|
||||||
|
self.on_restore_bip43(root_seed)
|
||||||
self.passphrase_dialog(run_next=f, is_restoring=True) if is_ext else f('')
|
self.passphrase_dialog(run_next=f, is_restoring=True) if is_ext else f('')
|
||||||
elif self.seed_type in ['standard', 'segwit']:
|
elif self.seed_type in ['standard', 'segwit']:
|
||||||
f = lambda passphrase: self.run('create_keystore', seed, passphrase)
|
f = lambda passphrase: self.run('create_keystore', seed, passphrase)
|
||||||
@@ -530,13 +532,12 @@ class BaseWizard(Logger):
|
|||||||
else:
|
else:
|
||||||
raise Exception('Unknown seed type', self.seed_type)
|
raise Exception('Unknown seed type', self.seed_type)
|
||||||
|
|
||||||
def on_restore_bip39(self, seed, passphrase):
|
def on_restore_bip43(self, root_seed):
|
||||||
def f(derivation, script_type):
|
def f(derivation, script_type):
|
||||||
derivation = normalize_bip32_derivation(derivation)
|
derivation = normalize_bip32_derivation(derivation)
|
||||||
self.run('on_bip43', seed, passphrase, derivation, script_type)
|
self.run('on_bip43', root_seed, derivation, script_type)
|
||||||
if self.wallet_type == 'standard':
|
if self.wallet_type == 'standard':
|
||||||
def get_account_xpub(account_path):
|
def get_account_xpub(account_path):
|
||||||
root_seed = bip39_to_seed(seed, passphrase)
|
|
||||||
root_node = BIP32Node.from_rootseed(root_seed, xtype="standard")
|
root_node = BIP32Node.from_rootseed(root_seed, xtype="standard")
|
||||||
account_node = root_node.subkey_at_private_derivation(account_path)
|
account_node = root_node.subkey_at_private_derivation(account_path)
|
||||||
account_xpub = account_node.to_xpub()
|
account_xpub = account_node.to_xpub()
|
||||||
@@ -551,8 +552,8 @@ class BaseWizard(Logger):
|
|||||||
self.data['lightning_xprv'] = k.get_lightning_xprv(None)
|
self.data['lightning_xprv'] = k.get_lightning_xprv(None)
|
||||||
self.on_keystore(k)
|
self.on_keystore(k)
|
||||||
|
|
||||||
def on_bip43(self, seed, passphrase, derivation, script_type):
|
def on_bip43(self, root_seed, derivation, script_type):
|
||||||
k = keystore.from_bip39_seed(seed, passphrase, derivation, xtype=script_type)
|
k = keystore.from_bip43_rootseed(root_seed, derivation, xtype=script_type)
|
||||||
self.on_keystore(k)
|
self.on_keystore(k)
|
||||||
|
|
||||||
def get_script_type_of_wallet(self) -> Optional[str]:
|
def get_script_type_of_wallet(self) -> Optional[str]:
|
||||||
|
|||||||
@@ -911,12 +911,11 @@ def bip39_is_checksum_valid(
|
|||||||
return checksum == calculated_checksum, True
|
return checksum == calculated_checksum, True
|
||||||
|
|
||||||
|
|
||||||
def from_bip39_seed(seed, passphrase, derivation, xtype=None):
|
def from_bip43_rootseed(root_seed, derivation, xtype=None):
|
||||||
k = BIP32_KeyStore({})
|
k = BIP32_KeyStore({})
|
||||||
bip32_seed = bip39_to_seed(seed, passphrase)
|
|
||||||
if xtype is None:
|
if xtype is None:
|
||||||
xtype = xtype_from_derivation(derivation)
|
xtype = xtype_from_derivation(derivation)
|
||||||
k.add_xprv_from_seed(bip32_seed, xtype, derivation)
|
k.add_xprv_from_seed(root_seed, xtype, derivation)
|
||||||
return k
|
return k
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -275,7 +275,8 @@ class TestWalletKeystoreAddressIntegrityForMainnet(ElectrumTestCase):
|
|||||||
seed_words = 'treat dwarf wealth gasp brass outside high rent blood crowd make initial'
|
seed_words = 'treat dwarf wealth gasp brass outside high rent blood crowd make initial'
|
||||||
self.assertEqual(keystore.bip39_is_checksum_valid(seed_words), (True, True))
|
self.assertEqual(keystore.bip39_is_checksum_valid(seed_words), (True, True))
|
||||||
|
|
||||||
ks = keystore.from_bip39_seed(seed_words, '', "m/44'/0'/0'")
|
root_seed = keystore.bip39_to_seed(seed_words, '')
|
||||||
|
ks = keystore.from_bip43_rootseed(root_seed, "m/44'/0'/0'")
|
||||||
|
|
||||||
self.assertTrue(isinstance(ks, keystore.BIP32_KeyStore))
|
self.assertTrue(isinstance(ks, keystore.BIP32_KeyStore))
|
||||||
|
|
||||||
@@ -293,7 +294,8 @@ class TestWalletKeystoreAddressIntegrityForMainnet(ElectrumTestCase):
|
|||||||
seed_words = 'treat dwarf wealth gasp brass outside high rent blood crowd make initial'
|
seed_words = 'treat dwarf wealth gasp brass outside high rent blood crowd make initial'
|
||||||
self.assertEqual(keystore.bip39_is_checksum_valid(seed_words), (True, True))
|
self.assertEqual(keystore.bip39_is_checksum_valid(seed_words), (True, True))
|
||||||
|
|
||||||
ks = keystore.from_bip39_seed(seed_words, UNICODE_HORROR, "m/44'/0'/0'")
|
root_seed = keystore.bip39_to_seed(seed_words, UNICODE_HORROR)
|
||||||
|
ks = keystore.from_bip43_rootseed(root_seed, "m/44'/0'/0'")
|
||||||
|
|
||||||
self.assertTrue(isinstance(ks, keystore.BIP32_KeyStore))
|
self.assertTrue(isinstance(ks, keystore.BIP32_KeyStore))
|
||||||
|
|
||||||
@@ -311,7 +313,8 @@ class TestWalletKeystoreAddressIntegrityForMainnet(ElectrumTestCase):
|
|||||||
seed_words = 'treat dwarf wealth gasp brass outside high rent blood crowd make initial'
|
seed_words = 'treat dwarf wealth gasp brass outside high rent blood crowd make initial'
|
||||||
self.assertEqual(keystore.bip39_is_checksum_valid(seed_words), (True, True))
|
self.assertEqual(keystore.bip39_is_checksum_valid(seed_words), (True, True))
|
||||||
|
|
||||||
ks = keystore.from_bip39_seed(seed_words, '', "m/49'/0'/0'")
|
root_seed = keystore.bip39_to_seed(seed_words, '')
|
||||||
|
ks = keystore.from_bip43_rootseed(root_seed, "m/49'/0'/0'")
|
||||||
|
|
||||||
self.assertTrue(isinstance(ks, keystore.BIP32_KeyStore))
|
self.assertTrue(isinstance(ks, keystore.BIP32_KeyStore))
|
||||||
|
|
||||||
@@ -330,7 +333,8 @@ class TestWalletKeystoreAddressIntegrityForMainnet(ElectrumTestCase):
|
|||||||
seed_words = 'abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about'
|
seed_words = 'abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about'
|
||||||
self.assertEqual(keystore.bip39_is_checksum_valid(seed_words), (True, True))
|
self.assertEqual(keystore.bip39_is_checksum_valid(seed_words), (True, True))
|
||||||
|
|
||||||
ks = keystore.from_bip39_seed(seed_words, '', "m/84'/0'/0'")
|
root_seed = keystore.bip39_to_seed(seed_words, '')
|
||||||
|
ks = keystore.from_bip43_rootseed(root_seed, "m/84'/0'/0'")
|
||||||
|
|
||||||
self.assertTrue(isinstance(ks, keystore.BIP32_KeyStore))
|
self.assertTrue(isinstance(ks, keystore.BIP32_KeyStore))
|
||||||
|
|
||||||
@@ -392,7 +396,8 @@ class TestWalletKeystoreAddressIntegrityForMainnet(ElectrumTestCase):
|
|||||||
seed_words = 'treat dwarf wealth gasp brass outside high rent blood crowd make initial'
|
seed_words = 'treat dwarf wealth gasp brass outside high rent blood crowd make initial'
|
||||||
self.assertEqual(keystore.bip39_is_checksum_valid(seed_words), (True, True))
|
self.assertEqual(keystore.bip39_is_checksum_valid(seed_words), (True, True))
|
||||||
|
|
||||||
ks1 = keystore.from_bip39_seed(seed_words, '', "m/45'/0")
|
root_seed = keystore.bip39_to_seed(seed_words, '')
|
||||||
|
ks1 = keystore.from_bip43_rootseed(root_seed, "m/45'/0")
|
||||||
self.assertTrue(isinstance(ks1, keystore.BIP32_KeyStore))
|
self.assertTrue(isinstance(ks1, keystore.BIP32_KeyStore))
|
||||||
self.assertEqual(ks1.xprv, 'xprv9vyEFyXf7pYVv4eDU3hhuCEAHPHNGuxX73nwtYdpbLcqwJCPwFKknAK8pHWuHHBirCzAPDZ7UJHrYdhLfn1NkGp9rk3rVz2aEqrT93qKRD9')
|
self.assertEqual(ks1.xprv, 'xprv9vyEFyXf7pYVv4eDU3hhuCEAHPHNGuxX73nwtYdpbLcqwJCPwFKknAK8pHWuHHBirCzAPDZ7UJHrYdhLfn1NkGp9rk3rVz2aEqrT93qKRD9')
|
||||||
self.assertEqual(ks1.xpub, 'xpub69xafV4YxC6o8Yiga5EiGLAtqR7rgNgNUGiYgw3S9g9pp6XYUne1KxdcfYtxwmA3eBrzMFuYcNQKfqsXCygCo4GxQFHfywxpUbKNfYvGJka')
|
self.assertEqual(ks1.xpub, 'xpub69xafV4YxC6o8Yiga5EiGLAtqR7rgNgNUGiYgw3S9g9pp6XYUne1KxdcfYtxwmA3eBrzMFuYcNQKfqsXCygCo4GxQFHfywxpUbKNfYvGJka')
|
||||||
|
|||||||
Reference in New Issue
Block a user