Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

python 3.11 #414

Open
KrashKrash opened this issue Nov 11, 2023 · 4 comments
Open

python 3.11 #414

KrashKrash opened this issue Nov 11, 2023 · 4 comments

Comments

@KrashKrash
Copy link

doesnt work after python 3.7, its a great library. please update it so its usable in python 3.12, 3.11, 3.10

@richardkiss
Copy link
Owner

What issue are you seeing? I just ran all the tests on 3.11.6 and they passed. Also did a pip install. Anything else you're trying that's failing?

@KrashKrash
Copy link
Author

I did the pip install. but it doesnt work on 3.12, i downgrade to 3.11, it doesnt work too. im now on python 3.10, it installs fine but dont work with python. i would love to show my code but i had delete it and work with the ecdsa, base58, bitcoin library instead. i think it was the part where i wanted to decode base58 to derive the public key of a bitcoin address

@KrashKrash
Copy link
Author

ok found it.. here is a sample of my code.

from pycoin.key.BIP32Node import BIP32Node
from pycoin.serialize import b2h

def derive_private_key(address):
try:
# Create a BIP32Node object from the Bitcoin address
bip32node = BIP32Node.from_address(address)

    # Derive the private key from the BIP32Node object
    private_key = bip32node.secret_exponent()
            
    return b2h(private_key).zfill(64)
except Exception as e:
    print(f"Error while deriving the private key: {e}")
    return None

Get the BTC address as input from the user

btc_address = input("Enter a Bitcoin address: ")

@richardkiss
Copy link
Owner

Using BIP32Node directly is deprecated. Use it through the network corresponding to the coin network you're interested in. For example:

from pycoin.symbols.btc import network
bip_key = network.keys.bip32_seed(b"foo")
bip_key_as_text = bip_key.as_text(as_private=True)
bip_key_parsed = network.parse(bip_key_as_text)
private_key = bip_key_parsed.secret_exponent()
print(hex(private_key))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants