<p>I'm assuming you're talking about P2SH addresses here, since that's really the only time this matters.</p>

<p>For standard P2SH addresses, you cannot find the spending requirements by just looking at the address. Let's look at <a href="https://blockchain.info/address/3DzSVk4veMCkNbNT9CdETeE26uWxmNbBnD" rel="nofollow noreferrer">3DzSVk4veMCkNbNT9CdETeE26uWxmNbBnD</a> from a recent block as an example.</p>

<p>The output script of this address is <code>a91486ed17bfa7bd80cf87cf7e80abd9289079b78c5b87</code>. This alone simply amounts to <code>HASH160 PUSHDATA(20)[86ed17bfa7bd80cf87cf7e80abd9289079b78c5b] EQUAL</code>. This means that to spend the tx, you need to provide some input, that once run through HASH160 equals <code>86ed17bfa7bd80cf87cf7e80abd9289079b78c5b</code>.</p>

<p>This is the general format for any P2SH output script. To actually know what kind of script it is, you need the redeem script, which can be found in your wallet. If the address is not one of your own, the redeemscript is revealed when an output to that address is first spent.</p>

<p>Looking at <a href="https://blockchain.info/tx/20f5ceacb85ddc77143a06566364f895b0e54119ca328ee9a67e5070c0c55a31" rel="nofollow noreferrer">this tx</a> for the above address, we can find the redeemscript as <code>5221038934160de8ad1dd529329f5bf51e3086cc0f6d19e10fb4120385f23d871c0c1d21021659435e23e3891d39ec2b0266b3c14a68cb4e45adb8543f31508310c98722d952ae</code> (the final push in the script for the input).</p>

<p>Running the above redeemscript through the <code>decodescript</code> command gives us:</p>

<pre><code>2 038934160de8ad1dd529329f5bf51e3086cc0f6d19e10fb4120385f23d871c0c1d 021659435e23e3891d39ec2b0266b3c14a68cb4e45adb8543f31508310c98722d9 2 OP_CHECKMULTISIG
</code></pre>

<p>This identifies the script as a 2of2 multisig.</p>

<p>This could very easily have been any other form of script, such as 2of3 multisig, or not multisig at all. It could even be a segwit address wrapped in a p2sh address. However, just by looking at the address, you cannot determine the type of script. You must have the redeemscript to determine the spending requirements.</p>

CC BY-SA 3.0
2018-03-24T15:33:31.427Z
2018-03-24T15:33:31.427Z
Raghav Sood
<p>How do you find out the requirements to spend an output script?</p>

<p>Do you decode the hash?</p>

CC BY-SA 3.0
2018-03-24T16:21:38.540Z
The question is not very precise, maybe some background info here: https://bitcoin.stackexchange.com/questions/69062/why-does-bitcoin-uses-a-script-language/69077#69077, and for sure in Andreas book „Mastering Bitcoin“.
pebwindkraft
<script><output>
How to find out the requirements for spending an output script?
Errol
# How to find out the requirements for spending an output script?

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

How do you find out the requirements to spend an output script?

Do you decode the hash?

**Tags:** script, output

> **Comments:**
> **username_1**: The question is not very precise, maybe some background info here: https://bitcoin.stackexchange.com/questions/69062/why-does-bitcoin-uses-a-script-language/69077#69077, and for sure in Andreas book „Mastering Bitcoin“.  

---

## 1 answers

### Answer by username_2 on 2018-03-24. Score: 4 | Accepted answer

I'm assuming you're talking about P2SH addresses here, since that's really the only time this matters.

For standard P2SH addresses, you cannot find the spending requirements by just looking at the address. Let's look at [3DzSVk4veMCkNbNT9CdETeE26uWxmNbBnD](https://blockchain.info/address/3DzSVk4veMCkNbNT9CdETeE26uWxmNbBnD) from a recent block as an example.

The output script of this address is `a91486ed17bfa7bd80cf87cf7e80abd9289079b78c5b87`. This alone simply amounts to `HASH160 PUSHDATA(20)[86ed17bfa7bd80cf87cf7e80abd9289079b78c5b] EQUAL`. This means that to spend the tx, you need to provide some input, that once run through HASH160 equals `86ed17bfa7bd80cf87cf7e80abd9289079b78c5b`.

This is the general format for any P2SH output script. To actually know what kind of script it is, you need the redeem script, which can be found in your wallet. If the address is not one of your own, the redeemscript is revealed when an output to that address is first spent.

Looking at [this tx](https://blockchain.info/tx/20f5ceacb85ddc77143a06566364f895b0e54119ca328ee9a67e5070c0c55a31) for the above address, we can find the redeemscript as `5221038934160de8ad1dd529329f5bf51e3086cc0f6d19e10fb4120385f23d871c0c1d21021659435e23e3891d39ec2b0266b3c14a68cb4e45adb8543f31508310c98722d952ae` (the final push in the script for the input).

Running the above redeemscript through the `decodescript` command gives us:

```
2 038934160de8ad1dd529329f5bf51e3086cc0f6d19e10fb4120385f23d871c0c1d 021659435e23e3891d39ec2b0266b3c14a68cb4e45adb8543f31508310c98722d9 2 OP_CHECKMULTISIG

```

This identifies the script as a 2of2 multisig.

This could very easily have been any other form of script, such as 2of3 multisig, or not multisig at all. It could even be a segwit address wrapped in a p2sh address. However, just by looking at the address, you cannot determine the type of script. You must have the redeemscript to determine the spending requirements.


---

