@@ -132,45 +132,20 @@ bool AreInputsStandard(const CTransaction& tx, const CCoinsViewCache& mapInputs)
132132 const CScript& prevScript = prev.scriptPubKey ;
133133 if (!Solver (prevScript, whichType, vSolutions))
134134 return false ;
135- int nArgsExpected = ScriptSigArgsExpected (whichType, vSolutions);
136- if (nArgsExpected < 0 )
137- return false ;
138-
139- // Transactions with extra stuff in their scriptSigs are
140- // non-standard. Note that this EvalScript() call will
141- // be quick, because if there are any operations
142- // beside "push data" in the scriptSig
143- // IsStandardTx() will have already returned false
144- // and this method isn't called.
145- std::vector<std::vector<unsigned char > > stack;
146- if (!EvalScript (stack, tx.vin [i].scriptSig , SCRIPT_VERIFY_NONE, BaseSignatureChecker ()))
147- return false ;
148135
149136 if (whichType == TX_SCRIPTHASH)
150137 {
138+ std::vector<std::vector<unsigned char > > stack;
139+ // convert the scriptSig into a stack, so we can inspect the redeemScript
140+ if (!EvalScript (stack, tx.vin [i].scriptSig , SCRIPT_VERIFY_NONE, BaseSignatureChecker (), 0 ))
141+ return false ;
151142 if (stack.empty ())
152143 return false ;
153144 CScript subscript (stack.back ().begin (), stack.back ().end ());
154- std::vector<std::vector<unsigned char > > vSolutions2;
155- txnouttype whichType2;
156- if (Solver (subscript, whichType2, vSolutions2))
157- {
158- int tmpExpected = ScriptSigArgsExpected (whichType2, vSolutions2);
159- if (tmpExpected < 0 )
160- return false ;
161- nArgsExpected += tmpExpected;
162- }
163- else
164- {
165- // Any other Script with less than 15 sigops OK:
166- unsigned int sigops = subscript.GetSigOpCount (true );
167- // ... extra data left on the stack after execution is OK, too:
168- return (sigops <= MAX_P2SH_SIGOPS);
145+ if (subscript.GetSigOpCount (true ) > MAX_P2SH_SIGOPS) {
146+ return false ;
169147 }
170148 }
171-
172- if (stack.size () != (unsigned int )nArgsExpected)
173- return false ;
174149 }
175150
176151 return true ;
0 commit comments