I am trying to generate SegWit paper wallet address from WIF:
My WIF is L5mHKZsCLS27nSoGM3RdAwuxjvg7XhJdP25LgqdXe6zF11wpWdbT
.
I am converting WIF to compressed public key:
Compressed public key: 03fac6879502c4c939cfaadc45999c7ed7366203ad523ab83ad5502c71621a85bb
I am creating P2SH-P2WPKH address using instructions at Creation of P2SH-P2WPKH Address
using following algorithm:
- Calculate the RIPEMD160 of the SHA256 of a public key:
SHA256 of public key: cfad24b0bc2bba2c8bb2c8d619dca2b74221930793bca50df73856f0bbba10c9
RIPEMD160 of SHA256 hash: d5e5d05edfe2ed61099bf3f0d53be2775bbc6d0d
- Create P2SH redeemScript as
OP_PUSH publicKeyHash
:
redeemScript: 0014d5e5d05edfe2ed61099bf3f0d53be2775bbc6d0d
- Generate scriptPubKey as
OP_HASH160 hash160(redeemScript) OP_EQUAL
scriptPubKey: a914a19949e546c2f4d410cbb061c986b9ff3099ae7087
- Generate RIPEMD160 hash of scriptPubKey:
hash: dc62e525af22d1f0f17cc2a091cf2c9fb36bf553
- Generate address with
0x05
prefix and double SHA256 hash checksum:
result: 3MnK46gvixm8hk7mJTQTAqenniSodjXPrJ
Expected result according to segwitaddress is:
33voQqbNAYyig272KjcX8GkucWn2x25WEg
What am I doing wrong?
Update
Thanks to the accepted answer, here are correct steps to do this:
Public key - compressed:
03fac6879502c4c939cfaadc45999c7ed7366203ad523ab83ad5502c71621a85bb
SHA256(public key) =
cfad24b0bc2bba2c8bb2c8d619dca2b74221930793bca50df73856f0bbba10c9
RIPEMD160(SHA256(public key)) =
7646c030f7e75b80f0a31cdcab731e6f424f22b2
redeemScript (OP_0 pubkeyHash160):
00147646c030f7e75b80f0a31cdcab731e6f424f22b2
SHA256(redeemScript) =
a10e523968ba784d24ccd54e613d8f747d6649e42b1df4fdcec6658262620651
RIPEMD160(SHA256(redeemScript)) =
188ba16284702258959d8bb63bb9a5d979b57875
P2SH address base58(0x05 | hash | 4-byte sha256 checksum) =
33voQqbNAYyig272KjcX8GkucWn2x25WEg