<p>While I agree with Pieter that you generally should not do this, there is some technical understanding to be gained by knowing how this could be done.  The following is for reference:</p>

<h1>P2PKH</h1>

<p>A P2PKH address <em>A</em> is created from the public key <em>K</em> by the following:</p>

<blockquote>
  <p><em>A</em> = BASE58CHECK( 0x00 HASH160( <em>K</em> ) )</p>
</blockquote>

<p>Where HASH160( <em>K</em> ) is equivalent to RIPEMD160( SHA256( <em>K</em> ) ) and 0x00 represents the version byte (for P2PKH)</p>

<h1>P2SH</h1>

<p>With P2SH addresses, instead of hashing the public key, you hash a <strong><em>transaction script</em></strong>.</p>

<p>A 1 of 1 multisig transaction is created by concatenating the following byte values: </p>

<p><code>OP_0 0x14 HASH160( K )</code></p>

<p>Therefore, to create a <code>P2SH</code> address which utilizes a 1 to 1 multisig transaction, you construct it as follows:</p>

<blockquote>
  <p>BASE58CHECK( 0x05 HASH160( OP_0 0x14 HASH160( <em>K</em> ) ) )</p>
</blockquote>

<p>Where 0x05 is the version byte for script hash addresses and 0x14 is the amount of bytes to expect in the HASH160( <em>K</em> ).</p>

<p><a href="https://en.bitcoin.it/wiki/Script#Opcodes" rel="nofollow noreferrer">Bitcoin Script Reference</a></p>

CC BY-SA 4.0
2018-06-04T19:29:32.167Z
2018-06-05T04:35:12.517Z
2018-06-05T04:35:12.517Z
JBaczuk
<blockquote>
  <p>Is it possible to covert a p2pkh adrress to a p2sh adress?</p>
</blockquote>

<p>Don't.</p>

<p>Addresses are determined by the wallet. It's the receiver's wallet saying "I will accept payment when it arrives at address X". Sending it to another address may mean the wallet doesn't recognize it. Worst case, if the receiver has some hardware security module that stores the key, it may literally be impossible to even recover the funds when sent to the wrong address.</p>

<p>This is no different from owing a friend some money, and "repaying" them by burying an envelope with cash in their lawn. You may technically consider that a transfer of funds to them, but if it's not done in a matter known or even recognizable by them, it's very hard to consider it a payment.</p>

<p>As a sender, you shouldn't care about what type of address the receiver gives you, and certainly not try to guess how you can modify it.</p>

<p>As a receiver, if you want to give out a P2SH address (presumably because you want multisig security or segwit?), just upgrade your wallet to software that supports said feature and create a new address.</p>

<blockquote>
  <p>Also will the balance of the p2pkh address carry over to p2sh address?</p>
</blockquote>

<p>No, addresses don't have balances.</p>

CC BY-SA 3.0
2018-03-21T22:49:46.837Z
2018-03-21T22:56:12.517Z
2018-03-21T22:56:12.517Z
Pieter Wuille
<p>Is it possible to convert a p2pkh address to a p2sh address?</p>

<p>Also, will the balance of the p2pkh address carry over to the p2sh address?</p>

<p2sh><address-format><p2pkh>
Is it possible to convert an address from p2pkh to p2sh?
John
# Is it possible to convert an address from p2pkh to p2sh?

(Asked by: username_0 on 2018-03-21)

Is it possible to convert a p2pkh address to a p2sh address?

Also, will the balance of the p2pkh address carry over to the p2sh address?

**Tags:** p2sh, address-format, p2pkh


---

## 2 answers

### Answer by username_2 on 2018-03-21. Score: 16 | Accepted answer

> Is it possible to covert a p2pkh adrress to a p2sh adress?

Don't.

Addresses are determined by the wallet. It's the receiver's wallet saying "I will accept payment when it arrives at address X". Sending it to another address may mean the wallet doesn't recognize it. Worst case, if the receiver has some hardware security module that stores the key, it may literally be impossible to even recover the funds when sent to the wrong address.

This is no different from owing a friend some money, and "repaying" them by burying an envelope with cash in their lawn. You may technically consider that a transfer of funds to them, but if it's not done in a matter known or even recognizable by them, it's very hard to consider it a payment.

As a sender, you shouldn't care about what type of address the receiver gives you, and certainly not try to guess how you can modify it.

As a receiver, if you want to give out a P2SH address (presumably because you want multisig security or segwit?), just upgrade your wallet to software that supports said feature and create a new address.

> Also will the balance of the p2pkh address carry over to p2sh address?

No, addresses don't have balances.


---

### Answer by username_1 on 2018-06-04. Score: 2

While I agree with Pieter that you generally should not do this, there is some technical understanding to be gained by knowing how this could be done. The following is for reference:

# P2PKH

A P2PKH address *A* is created from the public key *K* by the following:

> *A* = BASE58CHECK( 0x00 HASH160( *K* ) )

Where HASH160( *K* ) is equivalent to RIPEMD160( SHA256( *K* ) ) and 0x00 represents the version byte (for P2PKH)

# P2SH

With P2SH addresses, instead of hashing the public key, you hash a ***transaction script***.

A 1 of 1 multisig transaction is created by concatenating the following byte values:

`OP_0 0x14 HASH160( K )`

Therefore, to create a `P2SH` address which utilizes a 1 to 1 multisig transaction, you construct it as follows:

> BASE58CHECK( 0x05 HASH160( OP\_0 0x14 HASH160( *K* ) ) )

Where 0x05 is the version byte for script hash addresses and 0x14 is the amount of bytes to expect in the HASH160( *K* ).

[Bitcoin Script Reference](https://en.bitcoin.it/wiki/Script#Opcodes)


---

