public static ScriptSigs CombineSignatures(Script scriptPubKey, TransactionChecker checker, ScriptSigs input1, ScriptSigs input2) { if (scriptPubKey == null) { scriptPubKey = new Script(); } var scriptSig1 = input1.ScriptSig; var scriptSig2 = input2.ScriptSig; HashVersion hashVersion = HashVersion.Original; var isWitness = input1.WitSig != WitScript.Empty || input2.WitSig != WitScript.Empty; if (isWitness) { scriptSig1 = input1.WitSig.ToScript(); scriptSig2 = input2.WitSig.ToScript(); hashVersion = HashVersion.Witness; } var context = new ScriptEvaluationContext(); context.ScriptVerify = ScriptVerify.StrictEnc; context.EvalScript(scriptSig1, checker, hashVersion); var stack1 = context.Stack.AsInternalArray(); context = new ScriptEvaluationContext(); context.ScriptVerify = ScriptVerify.StrictEnc; context.EvalScript(scriptSig2, checker, hashVersion); var stack2 = context.Stack.AsInternalArray(); var result = CombineSignatures(scriptPubKey, checker, stack1, stack2, hashVersion); if (result == null) { return(scriptSig1.Length < scriptSig2.Length ? input2 : input1); } if (!isWitness) { return new ScriptSigs() { ScriptSig = result, WitSig = WitScript.Empty } } ; else { return(new ScriptSigs() { ScriptSig = input1.ScriptSig.Length < input2.ScriptSig.Length ? input2.ScriptSig : input1.ScriptSig, WitSig = new WitScript(result) }); } }
public static ScriptSigs CombineSignatures(Script scriptPubKey, TransactionChecker checker, ScriptSigs input1, ScriptSigs input2) { if(scriptPubKey == null) scriptPubKey = new Script(); var scriptSig1 = input1.ScriptSig; var scriptSig2 = input2.ScriptSig; HashVersion hashVersion = HashVersion.Original; var isWitness = input1.WitSig != WitScript.Empty || input2.WitSig != WitScript.Empty; if(isWitness) { scriptSig1 = input1.WitSig.ToScript(); scriptSig2 = input2.WitSig.ToScript(); hashVersion = HashVersion.Witness; } var context = new ScriptEvaluationContext(); context.ScriptVerify = ScriptVerify.StrictEnc; context.EvalScript(scriptSig1, checker, hashVersion); var stack1 = context.Stack.AsInternalArray(); context = new ScriptEvaluationContext(); context.ScriptVerify = ScriptVerify.StrictEnc; context.EvalScript(scriptSig2, checker, hashVersion); var stack2 = context.Stack.AsInternalArray(); var result = CombineSignatures(scriptPubKey, checker, stack1, stack2, hashVersion); if(result == null) return scriptSig1.Length < scriptSig2.Length ? input2 : input1; if(!isWitness) return new ScriptSigs() { ScriptSig = result, WitSig = WitScript.Empty }; else { return new ScriptSigs() { ScriptSig = input1.ScriptSig.Length < input2.ScriptSig.Length ? input2.ScriptSig : input1.ScriptSig, WitSig = new WitScript(result) }; } }