<p>You might want to review BIP16 (pay to script hash)
<a href="https://github.com/bitcoin/bips/blob/master/bip-0016.mediawiki" rel="nofollow noreferrer">https://github.com/bitcoin/bips/blob/master/bip-0016.mediawiki</a></p>

<p>The signature is not included in the redeem script, typically just the public key. (Your script could be anything, all I know is it has a <code>CHECKSIGVERIFY</code> in it, so I'm answering broadly...)</p>

<p>The INPUT SCRIPT aka <code>scriptSig</code> of the transaction SPENDING from the P2SH output would then need to contain the signature and the entire serialized redeem script (the preimage to the script hash in the output).</p>

CC BY-SA 4.0
2019-07-22T19:28:01.617Z
After more reading, it looks like the redeemScript is the serialized script of the spending TX...and after dumping some variables, looks like my underlying issue is an incomplete preImage.
circusdei
CC BY-SA 4.0
2019-07-22T18:38:46.817Z
2019-07-22T18:38:46.817Z
pinhead
<p>I have created a P2SH address, funded it, and am attempting to move the funds with a TX.</p>

<p>The redeemScript for the TX requires the TX signature (OP_CHECKSIGVERIFY), but in order to create this signature, the TX preImage must be created and hashed.  However, the preImage for a P2SH contains the TX redeemScript itself...this seems to create a loop wherein this functionality is not possible.</p>

<p>Am I doing something incorrectly, or am I overthinking things?</p>

<bitcoin-cash><p2sh><scrypt><input-script>
How to build a p2sh who's scriptsig contains a Signature
circusdei
# How to build a p2sh who's scriptsig contains a Signature

(Asked by: username_0 on 2019-07-22)

I have created a P2SH address, funded it, and am attempting to move the funds with a TX.

The redeemScript for the TX requires the TX signature (OP\_CHECKSIGVERIFY), but in order to create this signature, the TX preImage must be created and hashed. However, the preImage for a P2SH contains the TX redeemScript itself...this seems to create a loop wherein this functionality is not possible.

Am I doing something incorrectly, or am I overthinking things?

**Tags:** bitcoin-cash, p2sh, scrypt, input-script


---

## 1 answers

### Answer by username_1 on 2019-07-22. Score: 1

You might want to review BIP16 (pay to script hash)
<https://github.com/bitcoin/bips/blob/master/bip-0016.mediawiki>

The signature is not included in the redeem script, typically just the public key. (Your script could be anything, all I know is it has a `CHECKSIGVERIFY` in it, so I'm answering broadly...)

The INPUT SCRIPT aka `scriptSig` of the transaction SPENDING from the P2SH output would then need to contain the signature and the entire serialized redeem script (the preimage to the script hash in the output).

> **Comments:**
> **username_0**: After more reading, it looks like the redeemScript is the serialized script of the spending TX...and after dumping some variables, looks like my underlying issue is an incomplete preImage.  

---

