BitSharp.Core.Rules.CoreRules.CountP2SHSigOps C# (CSharp) Method

CountP2SHSigOps() private method

private CountP2SHSigOps ( ValidatableTx validatableTx, int inputIndex ) : int
validatableTx BitSharp.Core.Domain.ValidatableTx
inputIndex int
return int
        private int CountP2SHSigOps(ValidatableTx validatableTx, int inputIndex)
        {
            if (validatableTx.IsCoinbase)
                return 0;

            var prevTxOutput = validatableTx.PrevTxOutputs[inputIndex];
            if (prevTxOutput.IsPayToScriptHash())
            {
                var script = validatableTx.Transaction.Inputs[inputIndex].ScriptSignature;

                ImmutableArray<byte>? data = null;

                // find the last item pushed onto the stack in the P2SH script signature...
                var index = 0;
                while (index < script.Length)
                {
                    ScriptOp op;
                    if (!GetOp(script, ref index, out op, out data))
                        return 0;
                    else if (op > ScriptOp.OP_16)
                        return 0;
                }

                if (data == null)
                    return 0;

                // ...and count its sig ops
                return CountLegacySigOps(data.Value, accurate: true);
            }
            else
                return 0;
        }

Same methods

CoreRules::CountP2SHSigOps ( ValidatableTx validatableTx ) : int