Ejemplo n.º 1
0
        protected override bool CheckScriptSigCore(Network network, 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);
                }

                (PubKey[] pubKeys, int sigCountExpected) = ((StraxBaseNetwork)network).Federations.GetFederation(scriptPubKeyOps[0].PushData).GetFederationDetails();
                return(sigCountExpected == scriptSigOps.Length + 1);
            }

            return(true);
        }
Ejemplo n.º 2
0
 protected override bool CheckScriptSigCore(Network network, 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);
         }
         int?sigCountExpected = scriptPubKeyOps[0].GetInt();
         if (sigCountExpected == null)
         {
             return(false);
         }
         return(sigCountExpected == scriptSigOps.Length + 1);
     }
     return(true);
 }
Ejemplo n.º 3
0
        public TransactionSignature ExtractScriptSigParameters(Network network, Script scriptSig)
        {
            Op[] ops = scriptSig.ToOps().ToArray();
            if (!CheckScriptSigCore(network, scriptSig, ops, null, null))
            {
                return(null);
            }

            byte[] data = ops[0].PushData;
            if (!TransactionSignature.ValidLength(data.Length))
            {
                return(null);
            }
            try
            {
                return(new TransactionSignature(data));
            }
            catch (FormatException)
            {
                return(null);
            }
        }