ThomasV 7 years ago
parent
commit
2239cb9624
  1. 6
      lib/bitcoin.py
  2. 16
      plugins/trustedcoin/trustedcoin.py

6
lib/bitcoin.py

@ -973,9 +973,3 @@ def bip32_private_key(sequence, k, chain):
k, chain = CKD_priv(k, chain, i)
return SecretToASecret(k, True)
def xkeys_from_seed(seed, passphrase, derivation):
from .mnemonic import Mnemonic
xprv, xpub = bip32_root(Mnemonic.mnemonic_to_seed(seed, passphrase), 0)
xprv, xpub = bip32_private_derivation(xprv, "m/", derivation)
return xprv, xpub

16
plugins/trustedcoin/trustedcoin.py

@ -385,17 +385,25 @@ class TrustedCoinPlugin(BasePlugin):
f = lambda x: wizard.request_passphrase(seed, x)
wizard.show_seed_dialog(run_next=f, seed_text=seed)
def get_xkeys(self, seed, passphrase, derivation):
from electrum.mnemonic import Mnemonic
from electrum.keystore import bip32_root, bip32_private_derivation
bip32_seed = Mnemonic.mnemonic_to_seed(seed, passphrase)
xprv, xpub = bip32_root(bip32_seed, 'standard')
xprv, xpub = bip32_private_derivation(xprv, "m/", derivation)
return xprv, xpub
def xkeys_from_seed(self, seed, passphrase):
words = seed.split()
n = len(words)
# old version use long seed phrases
if n >= 24:
assert passphrase == ''
xprv1, xpub1 = keystore.xkeys_from_seed(' '.join(words[0:12]), '', "m/")
xprv2, xpub2 = keystore.xkeys_from_seed(' '.join(words[12:]), '', "m/")
xprv1, xpub1 = self.get_xkeys(' '.join(words[0:12]), '', "m/")
xprv2, xpub2 = self.get_xkeys(' '.join(words[12:]), '', "m/")
elif n==12:
xprv1, xpub1 = keystore.xkeys_from_seed(seed, passphrase, "m/0'/")
xprv2, xpub2 = keystore.xkeys_from_seed(seed, passphrase, "m/1'/")
xprv1, xpub1 = self.get_xkeys(seed, passphrase, "m/0'/")
xprv2, xpub2 = self.get_xkeys(seed, passphrase, "m/1'/")
else:
raise BaseException('unrecognized seed length')
return xprv1, xpub1, xprv2, xpub2

Loading…
Cancel
Save