protected override bool CheckScriptSigCore(Script scriptSig, Op[] scriptSigOps, Script scriptPubKey, Op[] scriptPubKeyOps)
 {
     if (!scriptSig.IsPushOnly)
     {
         return(false);
     }
     if (scriptSigOps[0].Code != OpcodeType.OP_0)
     {
         return(false);
     }
     if (scriptSigOps.Length == 1)
     {
         return(false);
     }
     if (!scriptSigOps.Skip(1).All(s => TransactionSignature.ValidLength(s.PushData.Length) || s.Code == OpcodeType.OP_0))
     {
         return(false);
     }
     if (scriptPubKeyOps != null)
     {
         if (!CheckScriptPubKeyCore(scriptPubKey, scriptPubKeyOps))
         {
             return(false);
         }
         var sigCountExpected = scriptPubKeyOps[0].GetInt();
         if (sigCountExpected == null)
         {
             return(false);
         }
         return(sigCountExpected == scriptSigOps.Length + 1);
     }
     return(true);
 }
        public TransactionSignature ExtractScriptSigParameters(Script scriptSig)
        {
            var ops = scriptSig.ToOps().ToArray();

            if (!CheckScriptSigCore(scriptSig, ops, null, null))
            {
                return(null);
            }

            var data = ops[0].PushData;

            if (!TransactionSignature.ValidLength(data.Length))
            {
                return(null);
            }
            try
            {
                return(new TransactionSignature(data));
            }
            catch (FormatException)
            {
                return(null);
            }
        }