@@ -194,7 +194,7 @@ bool IsStandardTx(const CTransaction& tx, const std::optional<unsigned>& max_dat
194
194
*
195
195
* Note that only the non-witness portion of the transaction is checked here.
196
196
*/
197
- bool AreInputsStandard (const CTransaction& tx, const CCoinsViewCache& mapInputs, const std::string& reason_prefix, std::string& out_reason)
197
+ bool AreInputsStandard (const CTransaction& tx, const CCoinsViewCache& mapInputs, const std::string& reason_prefix, std::string& out_reason, const ignore_rejects_type& ignore_rejects )
198
198
{
199
199
if (tx.IsCoinBase ()) {
200
200
return true ; // Coinbases don't use vin normally
@@ -206,32 +206,37 @@ bool AreInputsStandard(const CTransaction& tx, const CCoinsViewCache& mapInputs,
206
206
std::vector<std::vector<unsigned char > > vSolutions;
207
207
TxoutType whichType = Solver (prev.scriptPubKey , vSolutions);
208
208
if (whichType == TxoutType::NONSTANDARD) {
209
- out_reason = reason_prefix + " script-unknown" ;
210
- return false ;
209
+ MaybeReject (" script-unknown" );
211
210
} else if (whichType == TxoutType::WITNESS_UNKNOWN) {
212
211
// WITNESS_UNKNOWN failures are typically also caught with a policy
213
212
// flag in the script interpreter, but it can be helpful to catch
214
213
// this type of NONSTANDARD transaction earlier in transaction
215
214
// validation.
216
- out_reason = reason_prefix + " witness-unknown" ;
217
- return false ;
215
+ MaybeReject (" witness-unknown" );
218
216
} else if (whichType == TxoutType::SCRIPTHASH) {
217
+ if (!tx.vin [i].scriptSig .IsPushOnly ()) {
218
+ // The only way we got this far, is if the user ignored scriptsig-not-pushonly.
219
+ // However, this case is invalid, and will be caught later on.
220
+ // But for now, we don't want to run the [possibly expensive] script here.
221
+ continue ;
222
+ }
219
223
std::vector<std::vector<unsigned char > > stack;
220
224
// convert the scriptSig into a stack, so we can inspect the redeemScript
221
225
if (!EvalScript (stack, tx.vin [i].scriptSig , SCRIPT_VERIFY_NONE, BaseSignatureChecker (), SigVersion::BASE))
222
226
{
227
+ // This case is also invalid or a bug
223
228
out_reason = reason_prefix + " scriptsig-failure" ;
224
229
return false ;
225
230
}
226
231
if (stack.empty ())
227
232
{
233
+ // Also invalid
228
234
out_reason = reason_prefix + " scriptcheck-missing" ;
229
235
return false ;
230
236
}
231
237
CScript subscript (stack.back ().begin (), stack.back ().end ());
232
238
if (subscript.GetSigOpCount (true ) > MAX_P2SH_SIGOPS) {
233
- out_reason = reason_prefix + " scriptcheck-sigops" ;
234
- return false ;
239
+ MaybeReject (" scriptcheck-sigops" );
235
240
}
236
241
}
237
242
}
0 commit comments