Signature scheme for P2SH I am trying to sign a raw transaction that spends output #2 (txindex 1) from this transaction: 267c6d75851efa18afb7edeb2da00c09afc575231db84b3277fc7ea3e174ecbd

The output is a 1-of-4 multisig P2SH and I think I may have a mistake in the transaction structure used to generate the signature. The signature I calculate is different (as in cryptographically different) to the one that bitcoin core gives me using signrawtransaction.

As I see it this is the transaction structure which must be signed:

Version:   01000000
TxIn:      01 bdec74e1a37efc77324bb81d2375c5af090ca02debedb7af18fa1e85756d7c26 01000000 
subScript: 17 a9 14 37fe3f20433380be4c742c978d3a9712c509656e 87 
Sequence:  ffffffff 
TxOut:     OUTPUTDATA
Locktime:  00000000 
Hashtype:  01000000


The double-sha256 value used to calculate the signature is 9d384de385512525b4faf08c97651e410e77f2906aa8baeefdee151cc0994655 

But the Bitcoin network rejects my transaction calculated from this transaction structure. 

I will happily provide more information such as redeemScript and pubKeys/privateKeys if the mistake should not be in the transaction structure.

Any help is appreciated! Thanks!
For P2SH transactions, the redeemScript is what is put in the scriptSig for the transaction preimage, not the scriptPubKey of the output.