How to get the Extended Public Key

How to get the Extended Public Key

Hello I have the following code that generates a Public Key, Private Key and BTC Address.

import hashlib
import ecdsa
from base58 import b58encode_check, b58decode_check
import os


def pubkey_to_address(pubkey: bytes) -> str:
    if 'ripemd160' not in hashlib.algorithms_available:
        raise RuntimeError('missing ripemd160 hash algorithm')

    sha = hashlib.sha256(pubkey).digest()
    ripe = hashlib.new('ripemd160', sha).digest()
    return b58encode_check(b'\x00' + ripe)


def generate_new_keys() -> list:
    signing_key = ecdsa.SigningKey.generate(curve=ecdsa.SECP256k1)
    verifying_key = signing_key.get_verifying_key()
    my_address = pubkey_to_address(verifying_key.to_string())

    return signing_key.to_string(), verifying_key, my_address

So when I use this function (generate_new_keys) I will get all the important keys.

Now I'd like to get my Extended Public Key to generate more subaddresses. Any idea where to start?

I've tried this library but It seems unsafe for BTC: https://github.com/ranaroussi/pywallet

https://ift.tt/2qdyMte

Comments

Popular posts from this blog

Bitcoin Core errors with database block

Bitfinex & Market Synergy To Offer Institutional Calibre Cryptocurrency Connectivity