Closed Andy19999999999999 closed 3 years ago
Hey Andy, to calculate a P2WSH address you need a script. I see you are using the very basic
But the right one is correct not cryptotools.
If you use the same script you'll get the same result
if hex1=hex2 then address1=addres2 How you see it is not so.
I am trying to explain to you that this line of your code is wrong:
script = push(public.encode(compressed=True)) + OP.CHECKSIG.byte
Excuse me, maybe I don't understand something. This line is from your sample "Create keys/addresses (including segwit)":
script = push(public.encode(compressed=True)) + OP.CHECKSIG.byte script_to_address(script, 'P2WSH') 'bc1q8yh8l8ft3220q328hlapqhflpzy6xvkq6u36mctk8gq5pyxm3rwqv5h5dg'
Yes that's a nonsense script I made up as an example, no one generates addresses with that script it's just for demonstration purposes. You need to substitute your own script.
Thank you I see.
from cryptotools.BTC import generate_keypair, pubkey_to_address, push, script_to_address, OP
private, public = generate_keypair() print(private.hex()) print(private.wif()) print(private.wif(compressed=True))
script = push(public.encode(compressed=True)) + OP.CHECKSIG.byte print(public.hex()) print(public.hex(compressed=True)) print(pubkey_to_address(public, 'P2PKH')) print(public.to_address('P2PKH', compressed=True)) print(public.to_address('P2WPKH')) print(script_to_address(script, 'P2WSH')) print(script_to_address(script, 'P2WSH-P2SH')) print(script_to_address(script, 'P2SH'))