<p>You can find the execution of a similar pay to script hash (P2SH) transaction here:
<a href="https://bitcoin.stackexchange.com/questions/42521/pay-to-script-hash-execution">Pay to Script Hash Execution</a></p>

<p>Basically the scriptSig is evaluated first, it pushes an empty array of bytes onto the stack because of the OP_FALSE code, and then pushes the signature 3045....001 onto the stack, and finally pushes the redemption script 5141...1ae on. Then we move on to the scriptPubKey evaluation, the encoded redemption script is taken off the stack and hashed, and the hash is compared to the hash e9c3...60a. if these are equal, we move on to the actual evaluation of the redemption script. This means the stack is taken back to the point before the scriptPubKey execution, so we have:</p>

<pre><code> 5141...1ae
 3045....001
 (empty value)
</code></pre>

<p>The top element is popped off, decoded, and then evaluated. In this case, it is a OP_CHECKMULTISIG script, the decoded version is on the webpage you linked as well as in your question, but this multisig only has one public key and one signature, so it's basically equivalent to paying straight to that one address. The OP_CHECKMULTISIG will check the signature 3045...001 against the public key, and if it matches, the transaction is valid. The empty data pushed on at the start by OP_FALSE is simply there due to CHECKMULTISIG taking one more element off than it needs, due to a bug, so it's just an unused bit of data needed to make it work.</p>

<p>I'm not sure what you mean by it being a script. It is a script, it is just encoded in the 5141...1ae. You can decode it with the <code>decodescript</code> call on bitcoin RPC. </p>

CC BY-SA 3.0
2017-07-29T04:37:13.610Z
Isn't there any block explorer that shows me the script? I don't have these command line tools to decode the script
Guerlando OCs
CC BY-SA 3.0
2017-07-29T07:23:26.043Z
https://chainquery.com/bitcoin-api/decodescript
meshcollider
CC BY-SA 3.0
2017-07-28T07:32:43.177Z
2017-07-28T07:32:43.177Z
meshcollider
<p>I'm reading this:</p>

<blockquote>
  <p>Transaction
  40eee3ae1760e3a8532263678cdf64569e6ad06abc133af64f735e52562bccc8 paid
  to P2SH address 3P14159f73E4gFr7JterCCQh9QjiTjiZrG. You can see the
  redeem script in transaction
  7edb32d4ffd7a385b763c7a8e56b6358bcd729e747290624e18acdbe6209fc45 which
  spends that output, using OP_FALSE  { OP_1  OP_1
  OP_CHECKMULTISIG }.</p>
</blockquote>

<p>from <a href="https://en.bitcoin.it/wiki/Pay_to_script_hash" rel="nofollow noreferrer">https://en.bitcoin.it/wiki/Pay_to_script_hash</a></p>

<p>I'm trying to check the validity of the transactions by hand to see if I understand what's happening. I first found the first transaction: <a href="https://blockchain.info/tx/40eee3ae1760e3a8532263678cdf64569e6ad06abc133af64f735e52562bccc8" rel="nofollow noreferrer">https://blockchain.info/tx/40eee3ae1760e3a8532263678cdf64569e6ad06abc133af64f735e52562bccc8</a></p>

<p>As I understood, it is locking these outputs to the output script</p>

<pre><code>OP_HASH160 e9c3dd0c07aac76179ebc76a6c78d4d67c6c160a OP_EQUAL 
</code></pre>

<p>The text tells me to look at the other transaction: <a href="https://blockchain.info/tx/7edb32d4ffd7a385b763c7a8e56b6358bcd729e747290624e18acdbe6209fc45" rel="nofollow noreferrer">https://blockchain.info/tx/7edb32d4ffd7a385b763c7a8e56b6358bcd729e747290624e18acdbe6209fc45</a></p>

<p>which spends this output. It means that this transaction presents a script (with data) that satisfies <code>OP_HASH160 e9c3dd0c07aac76179ebc76a6c78d4d67c6c160a OP_EQUAL</code>. Let's see the input of this transaction:</p>

<pre><code>OP_FALSE 3045022100ad0851c69dd756b45190b5a8e97cb4ac3c2b0fa2f2aae23aed6ca97ab33bf88302200b248593abc1259512793e7dea61036c601775ebb23640a0120b0dba2c34b79001 5141042f90074d7a5bf30c72cf3a8dfd1381bdbd30407010e878f3a11269d5f74a58788505cdca22ea6eab7cfb40dc0e07aba200424ab0d79122a653ad0c7ec9896bdf51ae
</code></pre>

<p>I should take the <code>OP_HASH160</code> of this to verify it's equal to <code>e9c3dd0c07aac76179ebc76a6c78d4d67c6c160a</code>, right? Remember that <code>OP_HASH160</code> means: ripemd160(sha256(something)). Should I concatenate that OP_FALSE int he beggining? Also, shouldn't it be a script? Where are the other op_codes beasides <code>OP_FALSE</code>?</p>

CC BY-SA 3.0
2017-07-28T08:40:12.463Z
https://webbtc.com/script/7edb32d4ffd7a385b763c7a8e56b6358bcd729e747290624e18acdbe6209fc45:0
amaclin
<transactions><script><hash><p2sh>
Verifying a P2SH transaction script by hand. How should I concatenate OP CODES in order to hash the script?
Guerlando OCs
# Verifying a P2SH transaction script by hand. How should I concatenate OP CODES in order to hash the script?

(Asked by: username_0 on 2017-07-28)

I'm reading this:

> Transaction
> 40eee3ae1760e3a8532263678cdf64569e6ad06abc133af64f735e52562bccc8 paid
> to P2SH address 3P14159f73E4gFr7JterCCQh9QjiTjiZrG. You can see the
> redeem script in transaction
> 7edb32d4ffd7a385b763c7a8e56b6358bcd729e747290624e18acdbe6209fc45 which
> spends that output, using OP\_FALSE { OP\_1 OP\_1
> OP\_CHECKMULTISIG }.

from <https://en.bitcoin.it/wiki/Pay_to_script_hash>

I'm trying to check the validity of the transactions by hand to see if I understand what's happening. I first found the first transaction: <https://blockchain.info/tx/40eee3ae1760e3a8532263678cdf64569e6ad06abc133af64f735e52562bccc8>

As I understood, it is locking these outputs to the output script

```
OP_HASH160 e9c3dd0c07aac76179ebc76a6c78d4d67c6c160a OP_EQUAL 

```

The text tells me to look at the other transaction: <https://blockchain.info/tx/7edb32d4ffd7a385b763c7a8e56b6358bcd729e747290624e18acdbe6209fc45>

which spends this output. It means that this transaction presents a script (with data) that satisfies `OP_HASH160 e9c3dd0c07aac76179ebc76a6c78d4d67c6c160a OP_EQUAL`. Let's see the input of this transaction:

```
OP_FALSE 3045022100ad0851c69dd756b45190b5a8e97cb4ac3c2b0fa2f2aae23aed6ca97ab33bf88302200b248593abc1259512793e7dea61036c601775ebb23640a0120b0dba2c34b79001 5141042f90074d7a5bf30c72cf3a8dfd1381bdbd30407010e878f3a11269d5f74a58788505cdca22ea6eab7cfb40dc0e07aba200424ab0d79122a653ad0c7ec9896bdf51ae

```

I should take the `OP_HASH160` of this to verify it's equal to `e9c3dd0c07aac76179ebc76a6c78d4d67c6c160a`, right? Remember that `OP_HASH160` means: ripemd160(sha256(something)). Should I concatenate that OP\_FALSE int he beggining? Also, shouldn't it be a script? Where are the other op\_codes beasides `OP_FALSE`?

**Tags:** transactions, script, hash, p2sh

> **Comments:**
> **username_1**: https://webbtc.com/script/7edb32d4ffd7a385b763c7a8e56b6358bcd729e747290624e18acdbe6209fc45:0  

---

## 1 answers

### Answer by username_2 on 2017-07-28. Score: 3 | Accepted answer

You can find the execution of a similar pay to script hash (P2SH) transaction here:
[Pay to Script Hash Execution](https://bitcoin.stackexchange.com/questions/42521/pay-to-script-hash-execution)

Basically the scriptSig is evaluated first, it pushes an empty array of bytes onto the stack because of the OP\_FALSE code, and then pushes the signature 3045....001 onto the stack, and finally pushes the redemption script 5141...1ae on. Then we move on to the scriptPubKey evaluation, the encoded redemption script is taken off the stack and hashed, and the hash is compared to the hash e9c3...60a. if these are equal, we move on to the actual evaluation of the redemption script. This means the stack is taken back to the point before the scriptPubKey execution, so we have:

```
 5141...1ae
 3045....001
 (empty value)

```

The top element is popped off, decoded, and then evaluated. In this case, it is a OP\_CHECKMULTISIG script, the decoded version is on the webpage you linked as well as in your question, but this multisig only has one public key and one signature, so it's basically equivalent to paying straight to that one address. The OP\_CHECKMULTISIG will check the signature 3045...001 against the public key, and if it matches, the transaction is valid. The empty data pushed on at the start by OP\_FALSE is simply there due to CHECKMULTISIG taking one more element off than it needs, due to a bug, so it's just an unused bit of data needed to make it work.

I'm not sure what you mean by it being a script. It is a script, it is just encoded in the 5141...1ae. You can decode it with the `decodescript` call on bitcoin RPC.

> **Comments:**
> **username_0**: Isn't there any block explorer that shows me the script? I don't have these command line tools to decode the script  
> **username_2**: https://chainquery.com/bitcoin-api/decodescript  

---

