<p>I solved this, redeemscript wasn't prefixed with pushdata which is necessary as the whole script gets pushed.</p>

CC BY-SA 3.0
2014-09-07T18:54:52.007Z
Congratulations then. You can now [accept](http://meta.stackexchange.com/questions/5234/how-does-accepting-an-answer-work) your answer.
knaperek
CC BY-SA 3.0
2017-12-22T07:02:04.030Z
Hmm I did the same mistake. So u guess my coins are stuck in the bad p2sh address.. Testnet coins.
Jus12
CC BY-SA 3.0
2014-08-07T02:56:43.317Z
2014-08-07T02:56:43.317Z
Matt
<p>I'm trying to redeem a 2of2 p2sh unspent output. I have the complete multisig redeem script, a single input and a single p2pkh output.</p>

<p>My understanding is that I should replace the ScriptPubKey of that single input with the unhashed redeemscript, serialize the Tx with SigHashAll at the end, and sign it with each of the required public keys.</p>

<p>This should yield an input with a signed ScriptPub of OP_0 [Sig][Sig][RedeemScript]. However, this fails to yield a valid signature. I'm using compressed keys in the redeemscript.</p>

<p>Each Sig is of the form OP_PUSHDATA/Size+1[DER encode Signature]</p>

<p>Is there something else particular about the way the transaction needs to be serialized and signed? Should I only be using uncompressed keys?</p>

<p2sh>
P2SH transaction signing
Matt
# P2SH transaction signing

(Asked by: username_0 on 2014-08-04)

I'm trying to redeem a 2of2 p2sh unspent output. I have the complete multisig redeem script, a single input and a single p2pkh output.

My understanding is that I should replace the ScriptPubKey of that single input with the unhashed redeemscript, serialize the Tx with SigHashAll at the end, and sign it with each of the required public keys.

This should yield an input with a signed ScriptPub of OP\_0 [Sig][Sig][RedeemScript]. However, this fails to yield a valid signature. I'm using compressed keys in the redeemscript.

Each Sig is of the form OP\_PUSHDATA/Size+1[DER encode Signature]

Is there something else particular about the way the transaction needs to be serialized and signed? Should I only be using uncompressed keys?

**Tags:** p2sh


---

## 1 answers

### Answer by username_0 on 2014-08-07. Score: 1 | Accepted answer

I solved this, redeemscript wasn't prefixed with pushdata which is necessary as the whole script gets pushed.

> **Comments:**
> **username_1**: Congratulations then. You can now [accept](http://meta.stackexchange.com/questions/5234/how-does-accepting-an-answer-work) your answer.  
> **username_2**: Hmm I did the same mistake. So u guess my coins are stuck in the bad p2sh address.. Testnet coins.  

---

