How to build a p2sh who's scriptsig contains a Signature

0

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?

circusdei

Posted 2019-07-22T17:07:12.667

Reputation: 69

Answers

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).

pinhead

Posted 2019-07-22T17:07:12.667

Reputation: 2 356

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 2019-07-22T19:28:01.617