def get_xkeys(self, seed, t, passphrase, derivation): assert is_any_2fa_seed_type(t) xtype = 'standard' if t == '2fa' else 'p2wsh' bip32_seed = Mnemonic.mnemonic_to_seed(seed, passphrase) rootnode = BIP32Node.from_rootseed(bip32_seed, xtype=xtype) child_node = rootnode.subkey_at_private_derivation(derivation) return child_node.to_xprv(), child_node.to_xpub()
def _do_test_bip32(self, seed: str, sequence): node = BIP32Node.from_rootseed(bfh(seed), xtype='standard') xprv, xpub = node.to_xprv(), node.to_xpub() self.assertEqual("m/", sequence[0:2]) sequence = sequence[2:] for n in sequence.split('/'): if n[-1] != "'": xpub2 = BIP32Node.from_xkey(xpub).subkey_at_public_derivation( n).to_xpub() node = BIP32Node.from_xkey(xprv).subkey_at_private_derivation(n) xprv, xpub = node.to_xprv(), node.to_xpub() if n[-1] != "'": self.assertEqual(xpub, xpub2) return xpub, xprv