Quantcast
Channel: Private key exported from Electrum, unable to recreate Address with Python - Bitcoin Stack Exchange
Viewing all articles
Browse latest Browse all 3

Answer by Basj for Private key exported from Electrum, unable to recreate Address with Python

$
0
0

Based on the accepted answer's suggestion to use privkey_to_pubkey, I analyzed its code, and so this works as well:

pvt = 'Kzuucz58MiTbbedeVuqBaPYwG1TQrV3n2NYU2dJRZ7HEHnHsUXWx'pvtdecoded = base58.b58decode(pvt)pvthex = binascii.hexlify(pvtdecoded)[2:-10]     # remove the first initial byte for version and 4 final bytes for checksumpvt2 = bitcoin.decode_privkey(pvthex, 'hex')     # decode as a decimal# generate pubkey from pvtkey with elliptic curve multiplicationpublic_key = bitcoin.fast_multiply(bitcoin.G, pvt2)public_key = bitcoin.encode_pubkey(public_key, 'hex_compressed')addr = bitcoin.pubkey_to_address(public_key)print addr    # 1JkZLnmFfpVFLT2ZMtKzc6BuXMdmY41EHA

Viewing all articles
Browse latest Browse all 3

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>