<p>The <a href="https://github.com/bitcoin/bips/blob/master/bip-0016.mediawiki" rel="nofollow">document</a> you linked to provides all the information you need.</p>

<p>Specifically, for an output to be recognized as pay-to-scripthash, its scriptPubKey must match the format</p>

<pre><code>OP_HASH160 [20-byte-hash-value] OP_EQUAL
</code></pre>

<p>The scriptSig of the redeeming input is validated using different rules:</p>

<blockquote>
  <ol>
  <li>Validation fails if there are any operations other than "push data" operations in the scriptSig.</li>
  <li>Normal validation is done: an initial stack is created from the signatures and {serialized script}, and the hash of the script is computed and validation fails immediately if it does not match the hash in the outpoint.</li>
  <li>{serialized script} is popped off the initial stack, and the transaction is validated again using the popped stack and the deserialized script as the scriptPubKey.</li>
  </ol>
</blockquote>

<p>Older clients would accept such inputs, but they would not validate the included script. Therefore, the addition of these rules is a soft fork.</p>

CC BY-SA 3.0
2014-10-01T09:48:28.263Z
2014-10-01T09:48:28.263Z
abacabadabacaba
<p><a href="https://github.com/bitcoin/bips/blob/master/bip-0016.mediawiki" rel="nofollow">BIP0016</a> acknowledges it works by <code>"recognizing one 'special' form of scriptPubKey"</code>, so P2SH transactions are actually special cases.</p>

<p>What are the exact rules to detect these special cases?</p>

<multi-signature><p2sh>
BIP0016 pay-to-scripthash transaction detection
kaoD
# BIP0016 pay-to-scripthash transaction detection

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

[BIP0016](https://github.com/bitcoin/bips/blob/master/bip-0016.mediawiki) acknowledges it works by `"recognizing one 'special' form of scriptPubKey"`, so P2SH transactions are actually special cases.

What are the exact rules to detect these special cases?

**Tags:** multi-signature, p2sh


---

## 1 answers

### Answer by username_1 on 2014-10-01. Score: 1

The [document](https://github.com/bitcoin/bips/blob/master/bip-0016.mediawiki) you linked to provides all the information you need.

Specifically, for an output to be recognized as pay-to-scripthash, its scriptPubKey must match the format

```
OP_HASH160 [20-byte-hash-value] OP_EQUAL

```

The scriptSig of the redeeming input is validated using different rules:

> 1. Validation fails if there are any operations other than "push data" operations in the scriptSig.
> 2. Normal validation is done: an initial stack is created from the signatures and {serialized script}, and the hash of the script is computed and validation fails immediately if it does not match the hash in the outpoint.
> 3. {serialized script} is popped off the initial stack, and the transaction is validated again using the popped stack and the deserialized script as the scriptPubKey.

Older clients would accept such inputs, but they would not validate the included script. Therefore, the addition of these rules is a soft fork.


---

