Sunday, December 22, 2024

python – Unable to get Taproot deal with utilizing bitcoinlib

I attempted a number of methods to get a Taproot deal with from a Non-public Key with bitcoinlib, however I saved getting totally different addresses than these I get with Taproot wallets akin to Unisat and OKX Pockets.

Then, after a number of makes an attempt, I discovered the command Handle.parse and with it I attempted to get all of the parameters of my deal with, as a way to replicate it.

With a lot shock, even when I create a category with the very same parameters and naturally similar non-public keys, the derived deal with is totally different.

from bitcoinlib.keys import Key, Handle

# keys are for testing functions
private_key_hex = '25eee8288d42567475d1453843ce57b16b6ba5b6c0661cb2a439fff44c4d455d'
private_key_wif="KxVSwjuqNb6qe3KTLsHG5nYA3WFEqrjyKnGbwgHAreiWsqrwffuh"

okay = Key(private_key_wif)
#okay.information()
public_key_hex = '02fdf741bc2b1efe52873d748ca438798ad0133b25c388bc50423aed26df8ffbd7'
public_key_hex_uncompressed = '04fdf741bc2b1efe52873d748ca438798ad0133b25c388bc50423aed26df8ffbd7db6b1b700bd2475709f586d7a0105d29b0e4a3017b259e01bc32b220342ab33a'

addr = Handle.parse('bc1pfkde37d8chuqa6tgwvp7rwmtl7vvd20ql6g5433xxpdah30t7nushrsrlu')
print(addr.as_dict())

testAddr = Handle(
    information = public_key_hex,
    hashed_data = None,
    prefix = 'bc',
    script_type="p2tr",
    compressed = None,
    encoding = 'bech32',
    witness_type="taproot",
    witver = 1,
    depth = None,
    change = None,
    address_index = None,
    community = 'bitcoin',
    network_overrides = None
)
print(testAddr)

I do not know if the issue is that bitcoinlib would not have bech32m encoding.

If anybody is aware of how one can clear up this situation or is aware of any workaround, it will be actually appreciated!

Related Articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest Articles