There is a known form of address that called P2SH-wrapped SegWit, wrapping SegWit address as Base58 (P2SH) address.
Thinking about such address type, I come up with the question: Is P2SH-wrapped P2PKH possible?
I know that it is completely useless and meaningless, but I want to think about it now.

Step 1: Decide an address to convert

Let's use the address 1CciesT23BNionJeXrbxmjc7ywfiyM4oLW as it is used as a sample here.

Step 2: Convert it into "output script", then hash it using "hash160"

I got OP_DUP OP_HASH160 7f6ab65fa911f558ca2dde3e9d073acb02c0d5c6 OP_EQUALVERIFY OP_CHECKSIG.
Hashed result is c852ac34a1c76b63a279c97502c9ccc4e3cb9e8b.

Step 3: Make P2SH address from hashed script

toBase58Check(c852ac34a1c76b63a279c97502c9ccc4e3cb9e8b, 5) = 3KxE77EHe1ip6WGRifwr9fZ5WBDGsLyWFz
The result 3KxE77EHe1ip6WGRifwr9fZ5WBDGsLyWFz is what I want.

Here is the code to reproduce this address generation.


Is that possible to spend coins sent to 3KxE77EHe1ip6WGRifwr9fZ5WBDGsLyWFz (P2SH-wrapped P2PKH address), like how we spend coins sent to P2PKH addresses?

1 Answer 1


It's definitely possible and you've done the nesting correctly. Also, aside from being "useless and meaningless", it's more expensive since the scriptSig for redeeming outputs sent to this address will have to contain the 26 bytes of the redeemScript (the p2pkh script itself) and the push operation of it, along with the public key and signature.

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.