<p>The existing answers to this questions are good, but I want to give a slightly different perspective.</p>

<p>An address is a shorthand notation for one specific <code>scriptPubKey</code> to use in a transaction output.</p>

<p>P2PKH addresses are shorthands for <code>OP_DUP OP_HASH160 &lt;keyhash&gt; OP_EQUALVERIFY OP_CHECKSIG</code> scripts. To spend these, you need to have a private key for a public key whose Hash160 is .</p>

<p>P2SH addresses are shorthands for <code>OP_HASH160 &lt;scripthash&gt; OP_EQUAL</code> scripts. Due to BIP16, you need a script whose Hash160 is  which you can sign for in order to spend these.</p>

<p>Taking a hash of a public key and then using that as a scripthash in a P2SH address is nonsensical as you have no script with that hash (and much less one you  can sign for). It's not very different from taking a P2PKH address and changing some byte and the checksum in it - obviously you won't be able to spend it, as <strong>it is not your address</strong> but a random other address. The same is true if you use the wrong prefix: you're randomly modifying the address in a way that results in it likely being spendable by nobody.</p>

CC BY-SA 3.0
2018-01-08T10:27:42.587Z
2018-01-08T10:33:34.807Z
2018-01-08T10:33:34.807Z
Pieter Wuille
<p>It just indicates the appropriate kind.  The version byte doesn't actually appear in the final transaction.</p>

<p>You could certainly do what you propose, though you'll have to modify your client software to achieve 4, since by default it is going to try to create a P2SH transaction when it sees version byte 0x5.  But the resulting transaction would be the same transaction as if you'd used a 0x0 address from the outset.</p>

CC BY-SA 3.0
2018-01-08T06:40:54.290Z
2018-01-08T06:40:54.290Z
Nate Eldredge
<p>Since addresses are only human abstractions and do not actually exist on the network, no, addresses do not force the type of transaction that you can create with the data provided in an address. There would be no way to enforce that. However creating a transaction that does not use the type that the address specifies is a good way to lose funds because the way to spend those outputs are different.</p>

<p>So yes, you can take a P2SH address and create a transaction with a P2PKH output that has the same data that the P2SH address provided. But the person who controls that P2SH address is not going to be able to spend the coins from the P2PKH output since the requirements for spending will be different.</p>

CC BY-SA 3.0
2018-01-08T06:41:02.907Z
2018-01-08T06:41:02.907Z
Ava Chow
<p>A <em>Bitcoin</em> address is created with <em>Base58Check</em> encoding and it requires a version prefix, such as <a href="https://en.bitcoin.it/wiki/List_of_address_prefixes" rel="nofollow noreferrer"><code>0x00</code> for a <em>P2PKH<sub>(pay-to-public-key-hash)</sub> address</em>, <code>0x05</code> for a <em>P2SH<sub>(pay-to-script-hash)</sub> address</em></a>.</p>

<p>Does the version prefix of a <em>Bitcoin</em> address <strong>force</strong> the type of transactions the address may treat, or is it just for <strong>indicating</strong> the appropriate one?</p>

<p>In other words, can one do:</p>

<ol>
<li>Generate a ECDSA key pair.</li>
<li>Create a <em>Bitcoin</em> address with it, <strong>with a version prefix <code>0x05</code></strong>.</li>
<li>The generated address is a <em>P2SH(-like) address</em>; at least its format is.</li>
<li>Make a <em><strong>P2PKH</strong> transaction</em> with it.</li>
</ol>

<transactions><address><transaction-verification>
Does the version prefix of an address force the type of transactions the address may treat?
Константин Ван
# Does the version prefix of an address force the type of transactions the address may treat?

(Asked by: username_0 on 2018-01-08)

A *Bitcoin* address is created with *Base58Check* encoding and it requires a version prefix, such as [`0x00` for a *P2PKH(pay-to-public-key-hash) address*, `0x05` for a *P2SH(pay-to-script-hash) address*](https://en.bitcoin.it/wiki/List_of_address_prefixes).

Does the version prefix of a *Bitcoin* address **force** the type of transactions the address may treat, or is it just for **indicating** the appropriate one?

In other words, can one do:

1. Generate a ECDSA key pair.
2. Create a *Bitcoin* address with it, **with a version prefix `0x05`**.
3. The generated address is a *P2SH(-like) address*; at least its format is.
4. Make a ***P2PKH** transaction* with it.

**Tags:** transactions, address, transaction-verification


---

## 3 answers

### Answer by username_3 on 2018-01-08. Score: 4 | Accepted answer

Since addresses are only human abstractions and do not actually exist on the network, no, addresses do not force the type of transaction that you can create with the data provided in an address. There would be no way to enforce that. However creating a transaction that does not use the type that the address specifies is a good way to lose funds because the way to spend those outputs are different.

So yes, you can take a P2SH address and create a transaction with a P2PKH output that has the same data that the P2SH address provided. But the person who controls that P2SH address is not going to be able to spend the coins from the P2PKH output since the requirements for spending will be different.


---

### Answer by username_1 on 2018-01-08. Score: 3

The existing answers to this questions are good, but I want to give a slightly different perspective.

An address is a shorthand notation for one specific `scriptPubKey` to use in a transaction output.

P2PKH addresses are shorthands for `OP_DUP OP_HASH160 <keyhash> OP_EQUALVERIFY OP_CHECKSIG` scripts. To spend these, you need to have a private key for a public key whose Hash160 is .

P2SH addresses are shorthands for `OP_HASH160 <scripthash> OP_EQUAL` scripts. Due to BIP16, you need a script whose Hash160 is which you can sign for in order to spend these.

Taking a hash of a public key and then using that as a scripthash in a P2SH address is nonsensical as you have no script with that hash (and much less one you can sign for). It's not very different from taking a P2PKH address and changing some byte and the checksum in it - obviously you won't be able to spend it, as **it is not your address** but a random other address. The same is true if you use the wrong prefix: you're randomly modifying the address in a way that results in it likely being spendable by nobody.


---

### Answer by username_2 on 2018-01-08. Score: 2

It just indicates the appropriate kind. The version byte doesn't actually appear in the final transaction.

You could certainly do what you propose, though you'll have to modify your client software to achieve 4, since by default it is going to try to create a P2SH transaction when it sees version byte 0x5. But the resulting transaction would be the same transaction as if you'd used a 0x0 address from the outset.


---

