## NBitcoin get signature, use spending P2SH transaction with non-standard script

2

After creating a new NBitcoin transaction (with a single pay-to-script hash input and multiple outputs), is there any way to calculate the transaction signature and manually put it in the inputs[0].ScriptSig, along with other parameters used by the script?

A related issue is whether (and how) non-standard scripts can be used in P2SH transactions.

0

It seems the first question can be accomplished with something like:

//after creating newtx and specifying input and outputs
newtx.Inputs[0].ScriptSig = privatekey.ScriptPubKey;
newtx.Sign(privatekey, false);  //puts signature and pubkey in ScriptSig
//use those plus additional parameters in script
newtx.Inputs[0].ScriptSig = new Script(
newtx.Inputs[0].ScriptSig + " " +
//leave signature and pubkey as first parameters pushed onto stack
//then add script whose hash was in original P2SH trans
Op.GetPushOp(scriptIn.ToBytes()));


The scriptIn is the same as the usual P2KH script preceded by a check for the hash of another parameter

scriptIn = new Script(
"OP_HASH160 "