<p>The redeem script is part of the scriptSig for the input you are trying to spend. Here is the format for a <a href="https://en.bitcoin.it/wiki/Transaction#Pay-to-Script-Hash" rel="nofollow noreferrer"><code>P2SH</code> transaction</a>:</p>

<pre><code>scriptPubKey: OP_HASH160 &lt;scriptHash&gt; OP_EQUAL 
scriptSig: ..signatures... &lt;serialized script&gt;
</code></pre>

<p>The script is hashed and compared with the script hash in the <code>scriptPubKey</code>.</p>

CC BY-SA 4.0
2018-09-18T13:27:18.157Z
2018-09-18T13:27:18.157Z
JBaczuk
<p>I want to manually create a transaction to spend the output of a P2SH tx, but I don't know where the redeem script should be placed in the new transaction?  I followed an online tutorial <a href="https://klmoney.wordpress.com/bitcoin-dissecting-transactions-part-2-building-a-transaction-by-hand/" rel="nofollow noreferrer">Building a Transaction By Hand</a></p>

<p>In order to sign the transaction, you need to build this tx message as the picture shows. But when there is a redeem script, where should i put this redeem script? </p>

<p><a href="https://i.sstatic.net/u3GyZ.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/u3GyZ.png" alt=" Transaction Message That Will Be Signed"></a></p>

<bitcoin-core><bitcoind><p2sh>
Manually create a transaction to spend the output of a P2SH tx
Xiaoyang Zhu Simon Zhu
# Manually create a transaction to spend the output of a P2SH tx

(Asked by: username_0 on 2018-09-18)

I want to manually create a transaction to spend the output of a P2SH tx, but I don't know where the redeem script should be placed in the new transaction? I followed an online tutorial [Building a Transaction By Hand](https://klmoney.wordpress.com/bitcoin-dissecting-transactions-part-2-building-a-transaction-by-hand/)

In order to sign the transaction, you need to build this tx message as the picture shows. But when there is a redeem script, where should i put this redeem script?

[![ Transaction Message That Will Be Signed](https://i.sstatic.net/u3GyZ.png)](https://i.sstatic.net/u3GyZ.png)

**Tags:** bitcoin-core, bitcoind, p2sh


---

## 1 answers

### Answer by username_1 on 2018-09-18. Score: 0

The redeem script is part of the scriptSig for the input you are trying to spend. Here is the format for a P2SH transaction:
scriptPubKey: OP_HASH160  OP_EQUAL 
scriptSig: ..signatures... 

The script is hashed and compared with the script hash in the scriptPubKey.


---

