Exemplo n.º 1
0
        /// <summary>
        /// Gets the count of regular SigOps in the script program (counting multisig ops as 20)
        /// </summary>
        public static int GetSigOpCount(byte[] program)
        {
            var script = new Script();

            try
            {
                script.Parse(program, 0, program.Length);
            }
            catch (ScriptException)
            {
                // Ignore errors and count up to the parse-able length
            }
            return(GetSigOpCount(script.chunks, false));
        }
Exemplo n.º 2
0
        /// <summary>
        /// Gets the count of P2SH Sig Ops in the Script scriptSig
        /// </summary>
        public static long GetP2SHSigOpCount(byte[] scriptSig)
        {
            Script script = new Script();

            try
            {
                script.Parse(scriptSig, 0, scriptSig.Length);
            }
            catch (ScriptException e)
            {
                // Ignore errors and count up to the parse-able length
            }
            for (int i = script.chunks.Count - 1; i >= 0; i--)
            {
                if (!script.chunks[i].IsOpCode)
                {
                    Script subScript = new Script();
                    subScript.Parse(script.chunks[i].Data, 0, script.chunks[i].Data.Length);
                    return(GetSigOpCount(subScript.chunks, true));
                }
            }
            return(0);
        }
Exemplo n.º 3
0
 /// <summary>
 /// Gets the count of regular SigOps in the script program (counting multisig ops as 20)
 /// </summary>
 public static int GetSigOpCount(byte[] program)
 {
     var script = new Script();
     try
     {
         script.Parse(program, 0, program.Length);
     }
     catch (ScriptException)
     {
         // Ignore errors and count up to the parse-able length
     }
     return GetSigOpCount(script.chunks, false);
 }
Exemplo n.º 4
0
 /// <summary>
 /// Gets the count of P2SH Sig Ops in the Script scriptSig
 /// </summary>
 public static long GetP2SHSigOpCount(byte[] scriptSig)
 {
     Script script = new Script();
     try
     {
         script.Parse(scriptSig, 0, scriptSig.Length);
     }
     catch (ScriptException e)
     {
         // Ignore errors and count up to the parse-able length
     }
     for (int i = script.chunks.Count - 1; i >= 0; i--)
     {
         if (!script.chunks[i].IsOpCode)
         {
             Script subScript = new Script();
             subScript.Parse(script.chunks[i].Data, 0, script.chunks[i].Data.Length);
             return GetSigOpCount(subScript.chunks, true);
         }
     }
     return 0;
 }