Open rockygsm opened 2 years ago
update: keyx1 = Key(bytes_to_wif(bytes.fromhex('hexdata'),compressed=False)) seems fastest way currently. still 8% to 10% down from compressed address.
so you know , how to get native segwit address, key.segwit_address returns only nested p2sh segwit address, not native one that starts from bc1
@rockygsm Is there any way to generate the Native segwit address, and tabroot address. I hope if not, it will be supported soon.
public_key_to_address
can display the uncompressed address without creating a new Key
instance.
>>> from bit import Key
>>> from bit.format import public_key_to_address
>>> k = Key.from_hex('0000000000000000000000000000000000000000000000000000000000000001')
>>> k.address
'1BgGZ9tcN4rm9KBzDn7KprQz87SZ26SAMH'
# compressed P2PKH
>>> public_key_to_address(k._pk.public_key.format(compressed=True),'main')
'1BgGZ9tcN4rm9KBzDn7KprQz87SZ26SAMH'
# compressed P2PKH
>>> public_key_to_address(k._pk.public_key.format(compressed=False),'main')
'1EHNa6Q4Jz2uvNExL497mE43ikXhwF6kZm'
# uncompressed P2PKH
Is there any way to generate the Native segwit address
from bit import PrivateKey
def get_bech32_address():
byte_public_key_comp = PrivateKey("your_private_key")._pk.public_key.format()
witprog = ripemd160_sha256(byte_public_key_comp)
bech32_address = encode('bc', 0, witprog)
return bech32_address
print("SegWit Native:", get_bech32_address())
Hello i am using
Key.from_hex('hexdata').address
return compressed address your python lib work fastest then any other. but what is solution for getting uncompressed as i seen all source not found any sort way way i used isbut its not fast like compressed i am missing something ? its possible to implement something like Key.address(False) to display uncompressed address ?