4

How does one derive the Redeem Script for the new Pay-to-Witness Pubkey Hash addresses? With existing P2SH it's revealed after providing N number of Public Keys through a createmultisig function in the bitcoin client. Is it the same, just provide a single public key through a createwitness or similar function?

Is it currently available for fiddling with on testnet?

1 Answer 1

2

Feb2018: an older request, I just answer it so that future research might reveal useful data :-)

To compose the redeem script for a P2WPKH, there is a fairly simple structure, I copied this mostly from here:

Start with OP_0, followed by the keyhash. Keyhash is calculated with RIPEMD160(SHA256(public key)), similiar to "std" PKH. Do not use uncompressed pubkeys!

The P2SH redeemScript will then always have 22 bytes:

OP_0:    00
Length:  14
keyhash: (20 bytes)

The scriptPubKey is composed this way:

OP_HASH160 hash160(redeemScript) OP_EQUAL

and the address is the corresponding P2SH address with prefix 3.

Step by step explanation here :-)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.