Example #1
0
        private uint GetP2SHSigOpCount(Transaction tx, CoinView inputs)
        {
            if (tx.IsCoinBase)
            {
                return(0);
            }

            uint nSigOps = 0;

            for (uint i = 0; i < tx.Inputs.Count; i++)
            {
                var prevout = inputs.GetOutputFor(tx.Inputs[i]);
                if (prevout.ScriptPubKey.IsPayToScriptHash)
                {
                    nSigOps += prevout.ScriptPubKey.GetSigOpCount(tx.Inputs[i].ScriptSig);
                }
            }
            return(nSigOps);
        }
Example #2
0
        private long GetTransactionSigOpCost(Transaction tx, CoinView inputs, ConsensusFlags flags)
        {
            long nSigOps = GetLegacySigOpCount(tx) * WITNESS_SCALE_FACTOR;

            if (tx.IsCoinBase)
            {
                return(nSigOps);
            }

            if (flags.ScriptFlags.HasFlag(ScriptVerify.P2SH))
            {
                nSigOps += GetP2SHSigOpCount(tx, inputs) * WITNESS_SCALE_FACTOR;
            }

            for (var i = 0; i < tx.Inputs.Count; i++)
            {
                var prevout = inputs.GetOutputFor(tx.Inputs[i]);
                nSigOps += CountWitnessSigOps(tx.Inputs[i].ScriptSig, prevout.ScriptPubKey, tx.Inputs[i].WitScript, flags);
            }
            return(nSigOps);
        }