Пример #1
0
        //
        // Check transaction inputs, and make sure any
        // pay-to-script-hash transactions are evaluating IsStandard scripts
        //
        // Why bother? To avoid denial-of-service attacks; an attacker
        // can submit a standard HASH... OP_EQUAL transaction,
        // which will get accepted into blocks. The redemption
        // script can be anything; an attacker could use a very
        // expensive-to-check-upon-redemption script like:
        //   DUP CHECKSIG DROP ... repeated 100 times... OP_1
        //
        public static bool AreInputsStandard(Transaction tx, CoinsView coinsView)
        {
            if(tx.IsCoinBase)
                return true; // Coinbases don't use vin normally

            for(int i = 0 ; i < tx.Inputs.Count ; i++)
            {
                TxOut prev = coinsView.GetOutputFor(tx.Inputs[i]);
                if(prev == null)
                    return false;
                if(!IsStandardScriptSig(tx.Inputs[i].ScriptSig, prev.ScriptPubKey))
                    return false;
            }

            return true;
        }
Пример #2
0
        //
        // Check transaction inputs, and make sure any
        // pay-to-script-hash transactions are evaluating IsStandard scripts
        //
        // Why bother? To avoid denial-of-service attacks; an attacker
        // can submit a standard HASH... OP_EQUAL transaction,
        // which will get accepted into blocks. The redemption
        // script can be anything; an attacker could use a very
        // expensive-to-check-upon-redemption script like:
        //   DUP CHECKSIG DROP ... repeated 100 times... OP_1
        //
        public static bool AreInputsStandard(Transaction tx, CoinsView coinsView)
        {
            if (tx.IsCoinBase)
            {
                return(true);                // Coinbases don't use vin normally
            }
            foreach (var input in tx.Inputs)
            {
                TxOut prev = coinsView.GetOutputFor(input);
                if (prev == null)
                {
                    return(false);
                }
                if (!IsStandardScriptSig(input.ScriptSig, prev.ScriptPubKey))
                {
                    return(false);
                }
            }

            return(true);
        }
 public virtual bool AreInputsStandard(Network network, Transaction tx, CoinsView coinsView)
 {
     return(StandardScripts.AreInputsStandard(network, tx, coinsView));
 }