def _do_test_bip32(self, seed, sequence): xprv, xpub = bip32_root(bfh(seed), 'standard') self.assertEqual("m/", sequence[0:2]) path = 'm' sequence = sequence[2:] for n in sequence.split('/'): child_path = path + '/' + n if n[-1] != "'": xpub2 = bip32_public_derivation(xpub, path, child_path) xprv, xpub = bip32_private_derivation(xprv, path, child_path) if n[-1] != "'": self.assertEqual(xpub, xpub2) path = child_path return xpub, xprv
def _get_key_address(self): root_xpub = self.wallet.keystore.xpub xpub = bip32_public_derivation(root_xpub, 'm/', 'm/0/0') pubk = bh2u(point_to_ser(ser_to_point(bfh(self._xpub_to_gpg_pub(xpub))), compressed=True)) addr = pubkey_to_address('p2pkh', pubk) return addr
#!./venv/bin/python from electrum import bitcoin import sys lines = [x.strip() for x in sys.stdin.readlines()] if len(lines) != 1: print("wrong input") sys.exit(1) index = int(sys.argv[1]) xpub = bitcoin.bip32_public_derivation(lines[0], "", str(index)) print(xpub)