@@ -230,6 +230,12 @@ BOOST_AUTO_TEST_CASE(tx_valid)
230
230
if (!CheckTxScripts (tx, mapprevOutScriptPubKeys, mapprevOutValues, ~verify_flags, txdata, strTest, /* expect_valid */ true )) {
231
231
BOOST_ERROR (" Tx unexpectedly failed: " << strTest);
232
232
}
233
+ // Check that flags are maximal: transaction should fail if any unset flags are set.
234
+ for (auto flags_excluding_one: ExcludeIndividualFlags (verify_flags)) {
235
+ if (!CheckTxScripts (tx, mapprevOutScriptPubKeys, mapprevOutValues, ~flags_excluding_one, txdata, strTest, /* expect_valid */ false )) {
236
+ BOOST_ERROR (" Too many flags unset: " << strTest);
237
+ }
238
+ }
233
239
}
234
240
}
235
241
}
@@ -292,9 +298,16 @@ BOOST_AUTO_TEST_CASE(tx_invalid)
292
298
PrecomputedTransactionData txdata (tx);
293
299
unsigned int verify_flags = ParseScriptFlags (test[2 ].get_str ());
294
300
301
+ // Not using FillFlags() in the main test, in order to detect invalid verifyFlags combination
295
302
if (!CheckTxScripts (tx, mapprevOutScriptPubKeys, mapprevOutValues, verify_flags, txdata, strTest, /* expect_valid */ false )) {
296
303
BOOST_ERROR (" Tx unexpectedly passed: " << strTest);
297
304
}
305
+ // Check that flags are minimal: transaction should succeed if any set flags are unset.
306
+ for (auto flags_excluding_one: ExcludeIndividualFlags (verify_flags)) {
307
+ if (!CheckTxScripts (tx, mapprevOutScriptPubKeys, mapprevOutValues, flags_excluding_one, txdata, strTest, /* expect_valid */ true )) {
308
+ BOOST_ERROR (" Too many flags set: " << strTest);
309
+ }
310
+ }
298
311
}
299
312
}
300
313
}
0 commit comments