common/src/main/java/lighthouse/protocol/Project.java
private DefaultRiskAnalysis.RuleViolation isInputStandard(TransactionInput input, Script scriptPubKey) {
        DefaultRiskAnalysis.RuleViolation violation = input.isStandard();
        if (violation != DefaultRiskAnalysis.RuleViolation.NONE)
            return violation;
        Script scriptSig = input.getScriptSig();
        int args = getNumExpectedScriptSigArgs(scriptPubKey);
        LinkedList<byte[]> stack = Lists.newLinkedList();
        // This is fast and cannot execute any signature checks, because we already verified with the previous
        // isStandard() call that it only contains data pushes.
        Script.executeScript(null, -1, scriptSig, stack, true);
        if (scriptPubKey.isPayToScriptHash()) {
            Script redeemScript = null;
            try {
                if (stack.isEmpty())
                    throw new VerificationException("Empty stack");   // Should never happen: can't have empty scripts.
                redeemScript = new Script(stack.getLast());
                args += getNumExpectedScriptSigArgs(redeemScript);
            } catch (VerificationException e) {
                // We can get here if the redeem script is corrupted or unparseable in some way, or if the script type
                // simply isn't recognised by getNumExpected... - Bitcoin Core appears to simply treat any garbage
                // script as non-standard.
                //
                // Regardless, a non-recognised script is always treated as OK if it has 15 or fewer sigops, even if
                // it were to leave extra stuff on the stack.
                if (redeemScript != null && Script.getSigOpCount(stack.getLast()) <= Script.MAX_P2SH_SIGOPS)
                    return DefaultRiskAnalysis.RuleViolation.NONE;
            }
        }
        if (stack.size() != args)
            return DefaultRiskAnalysis.RuleViolation.NONEMPTY_STACK;
        return DefaultRiskAnalysis.RuleViolation.NONE;
    }
// TODO: Move this into bitcoinj post-0.12
Move this into bitcoinj post-0.12
Move this into bitcoinj post - 0 . 12
private DefaultRiskAnalysis.RuleViolation isInputStandard(TransactionInput input, Script scriptPubKey) {
        DefaultRiskAnalysis.RuleViolation violation = input.isStandard();
        if (violation != DefaultRiskAnalysis.RuleViolation.NONE)
            return violation;
        Script scriptSig = input.getScriptSig();
        int args = getNumExpectedScriptSigArgs(scriptPubKey);
        LinkedList<byte[]> stack = Lists.newLinkedList();
        Script.executeScript(null, -1, scriptSig, stack, true);
        if (scriptPubKey.isPayToScriptHash()) {
            Script redeemScript = null;
            try {
                if (stack.isEmpty())
                    throw new VerificationException("Empty stack");   
                redeemScript = new Script(stack.getLast());
                args += getNumExpectedScriptSigArgs(redeemScript);
            } catch (VerificationException e) {
                 Regardless, a non-recognised script is always treated as OK if it has 15 or fewer sigops, even if
                 it were to leave extra stuff on the stack.
                if (redeemScript != null && Script.getSigOpCount(stack.getLast()) <= Script.MAX_P2SH_SIGOPS)
                    return DefaultRiskAnalysis.RuleViolation.NONE;
            }
        }
        if (stack.size() != args)
            return DefaultRiskAnalysis.RuleViolation.NONEMPTY_STACK;
        return DefaultRiskAnalysis.RuleViolation.NONE;
    }
private DefaultRiskAnalysis . RuleViolation isInputStandard ( TransactionInput input , Script scriptPubKey ) { DefaultRiskAnalysis . RuleViolation violation = input . isStandard ( ) ; if ( violation != DefaultRiskAnalysis . RuleViolation . NONE ) return violation ; Script scriptSig = input . getScriptSig ( ) ; int args = getNumExpectedScriptSigArgs ( scriptPubKey ) ; LinkedList < byte [ ] > stack = Lists . newLinkedList ( ) ; Script . executeScript ( null , - 1 , scriptSig , stack , true ) ; if ( scriptPubKey . isPayToScriptHash ( ) ) { Script redeemScript = null ; try { if ( stack . isEmpty ( ) ) throw new VerificationException ( "Empty stack" ) ; redeemScript = new Script ( stack . getLast ( ) ) ; args += getNumExpectedScriptSigArgs ( redeemScript ) ; } catch ( VerificationException e ) { if ( redeemScript != null && Script . getSigOpCount ( stack . getLast ( ) ) <= Script . MAX_P2SH_SIGOPS ) return DefaultRiskAnalysis . RuleViolation . NONE ; } } if ( stack . size ( ) != args ) return DefaultRiskAnalysis . RuleViolation . NONEMPTY_STACK ; return DefaultRiskAnalysis . RuleViolation . NONE ; }
TODO: Move this into bitcoinj post-0.12
TODO : Move this into bitcoinj post - 0 . 12
// This is fast and cannot execute any signature checks, because we already verified with the previous // isStandard() call that it only contains data pushes. // Should never happen: can't have empty scripts. // We can get here if the redeem script is corrupted or unparseable in some way, or if the script type // simply isn't recognised by getNumExpected... - Bitcoin Core appears to simply treat any garbage // script as non-standard. // // Regardless, a non-recognised script is always treated as OK if it has 15 or fewer sigops, even if // it were to leave extra stuff on the stack.