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"
OP_DUP OP_HASH160 7f6ab65fa911f558ca2dde3e9d073acb02c0d5c6 OP_EQUALVERIFY OP_CHECKSIG.
Hashed result is
Step 3: Make P2SH address from hashed script
toBase58Check(c852ac34a1c76b63a279c97502c9ccc4e3cb9e8b, 5) = 3KxE77EHe1ip6WGRifwr9fZ5WBDGsLyWFz
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?