@@ -135,45 +135,20 @@ bool AreInputsStandard(const CTransaction& tx, const CCoinsViewCache& mapInputs)
135135 const CScript& prevScript = prev.scriptPubKey ;
136136 if (!Solver (prevScript, whichType, vSolutions))
137137 return false ;
138- int nArgsExpected = ScriptSigArgsExpected (whichType, vSolutions);
139- if (nArgsExpected < 0 )
140- return false ;
141-
142- // Transactions with extra stuff in their scriptSigs are
143- // non-standard. Note that this EvalScript() call will
144- // be quick, because if there are any operations
145- // beside "push data" in the scriptSig
146- // IsStandardTx() will have already returned false
147- // and this method isn't called.
148- std::vector<std::vector<unsigned char > > stack;
149- if (!EvalScript (stack, tx.vin [i].scriptSig , SCRIPT_VERIFY_NONE, BaseSignatureChecker ()))
150- return false ;
151138
152139 if (whichType == TX_SCRIPTHASH)
153140 {
141+ std::vector<std::vector<unsigned char > > stack;
142+ // convert the scriptSig into a stack, so we can inspect the redeemScript
143+ if (!EvalScript (stack, tx.vin [i].scriptSig , SCRIPT_VERIFY_NONE, BaseSignatureChecker (), 0 ))
144+ return false ;
154145 if (stack.empty ())
155146 return false ;
156147 CScript subscript (stack.back ().begin (), stack.back ().end ());
157- std::vector<std::vector<unsigned char > > vSolutions2;
158- txnouttype whichType2;
159- if (Solver (subscript, whichType2, vSolutions2))
160- {
161- int tmpExpected = ScriptSigArgsExpected (whichType2, vSolutions2);
162- if (tmpExpected < 0 )
163- return false ;
164- nArgsExpected += tmpExpected;
165- }
166- else
167- {
168- // Any other Script with less than 15 sigops OK:
169- unsigned int sigops = subscript.GetSigOpCount (true );
170- // ... extra data left on the stack after execution is OK, too:
171- return (sigops <= MAX_P2SH_SIGOPS);
148+ if (subscript.GetSigOpCount (true ) > MAX_P2SH_SIGOPS) {
149+ return false ;
172150 }
173151 }
174-
175- if (stack.size () != (unsigned int )nArgsExpected)
176- return false ;
177152 }
178153
179154 return true ;
0 commit comments