@@ -109,7 +109,7 @@ BOOST_FIXTURE_TEST_CASE(tx_mempool_block_doublespend, TestChain100Setup)
109
109
// should fail.
110
110
// Capture this interaction with the upgraded_nop argument: set it when evaluating
111
111
// any script flag that is implemented as an upgraded NOP code.
112
- static void ValidateCheckInputsForAllFlags (const CTransaction &tx, uint32_t failing_flags, bool add_to_cache) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
112
+ static void ValidateCheckInputsForAllFlags (const CTransaction &tx, uint32_t failing_flags, bool add_to_cache, CCoinsViewCache& active_coins_tip ) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
113
113
{
114
114
PrecomputedTransactionData txdata;
115
115
// If we add many more flags, this loop can get too expensive, but we can
@@ -126,7 +126,7 @@ static void ValidateCheckInputsForAllFlags(const CTransaction &tx, uint32_t fail
126
126
// WITNESS requires P2SH
127
127
test_flags |= SCRIPT_VERIFY_P2SH;
128
128
}
129
- bool ret = CheckInputScripts (tx, state, &:: ChainstateActive (). CoinsTip () , test_flags, true , add_to_cache, txdata, nullptr );
129
+ bool ret = CheckInputScripts (tx, state, &active_coins_tip , test_flags, true , add_to_cache, txdata, nullptr );
130
130
// CheckInputScripts should succeed iff test_flags doesn't intersect with
131
131
// failing_flags
132
132
bool expected_return_value = !(test_flags & failing_flags);
@@ -136,13 +136,13 @@ static void ValidateCheckInputsForAllFlags(const CTransaction &tx, uint32_t fail
136
136
if (ret && add_to_cache) {
137
137
// Check that we get a cache hit if the tx was valid
138
138
std::vector<CScriptCheck> scriptchecks;
139
- BOOST_CHECK (CheckInputScripts (tx, state, &:: ChainstateActive (). CoinsTip () , test_flags, true , add_to_cache, txdata, &scriptchecks));
139
+ BOOST_CHECK (CheckInputScripts (tx, state, &active_coins_tip , test_flags, true , add_to_cache, txdata, &scriptchecks));
140
140
BOOST_CHECK (scriptchecks.empty ());
141
141
} else {
142
142
// Check that we get script executions to check, if the transaction
143
143
// was invalid, or we didn't add to cache.
144
144
std::vector<CScriptCheck> scriptchecks;
145
- BOOST_CHECK (CheckInputScripts (tx, state, &:: ChainstateActive (). CoinsTip () , test_flags, true , add_to_cache, txdata, &scriptchecks));
145
+ BOOST_CHECK (CheckInputScripts (tx, state, &active_coins_tip , test_flags, true , add_to_cache, txdata, &scriptchecks));
146
146
BOOST_CHECK_EQUAL (scriptchecks.size (), tx.vin .size ());
147
147
}
148
148
}
@@ -218,7 +218,7 @@ BOOST_FIXTURE_TEST_CASE(checkinputs_test, TestChain100Setup)
218
218
// not present. Don't add these checks to the cache, so that we can
219
219
// test later that block validation works fine in the absence of cached
220
220
// successes.
221
- ValidateCheckInputsForAllFlags (CTransaction (spend_tx), SCRIPT_VERIFY_DERSIG | SCRIPT_VERIFY_LOW_S | SCRIPT_VERIFY_STRICTENC, false );
221
+ ValidateCheckInputsForAllFlags (CTransaction (spend_tx), SCRIPT_VERIFY_DERSIG | SCRIPT_VERIFY_LOW_S | SCRIPT_VERIFY_STRICTENC, false , :: ChainstateActive (). CoinsTip () );
222
222
}
223
223
224
224
// And if we produce a block with this tx, it should be valid (DERSIG not
@@ -244,7 +244,7 @@ BOOST_FIXTURE_TEST_CASE(checkinputs_test, TestChain100Setup)
244
244
std::vector<unsigned char > vchSig2 (p2pk_scriptPubKey.begin (), p2pk_scriptPubKey.end ());
245
245
invalid_under_p2sh_tx.vin [0 ].scriptSig << vchSig2;
246
246
247
- ValidateCheckInputsForAllFlags (CTransaction (invalid_under_p2sh_tx), SCRIPT_VERIFY_P2SH, true );
247
+ ValidateCheckInputsForAllFlags (CTransaction (invalid_under_p2sh_tx), SCRIPT_VERIFY_P2SH, true , :: ChainstateActive (). CoinsTip () );
248
248
}
249
249
250
250
// Test CHECKLOCKTIMEVERIFY
@@ -267,7 +267,7 @@ BOOST_FIXTURE_TEST_CASE(checkinputs_test, TestChain100Setup)
267
267
vchSig.push_back ((unsigned char )SIGHASH_ALL);
268
268
invalid_with_cltv_tx.vin [0 ].scriptSig = CScript () << vchSig << 101 ;
269
269
270
- ValidateCheckInputsForAllFlags (CTransaction (invalid_with_cltv_tx), SCRIPT_VERIFY_CHECKLOCKTIMEVERIFY, true );
270
+ ValidateCheckInputsForAllFlags (CTransaction (invalid_with_cltv_tx), SCRIPT_VERIFY_CHECKLOCKTIMEVERIFY, true , :: ChainstateActive (). CoinsTip () );
271
271
272
272
// Make it valid, and check again
273
273
invalid_with_cltv_tx.vin [0 ].scriptSig = CScript () << vchSig << 100 ;
@@ -295,7 +295,7 @@ BOOST_FIXTURE_TEST_CASE(checkinputs_test, TestChain100Setup)
295
295
vchSig.push_back ((unsigned char )SIGHASH_ALL);
296
296
invalid_with_csv_tx.vin [0 ].scriptSig = CScript () << vchSig << 101 ;
297
297
298
- ValidateCheckInputsForAllFlags (CTransaction (invalid_with_csv_tx), SCRIPT_VERIFY_CHECKSEQUENCEVERIFY, true );
298
+ ValidateCheckInputsForAllFlags (CTransaction (invalid_with_csv_tx), SCRIPT_VERIFY_CHECKSEQUENCEVERIFY, true , :: ChainstateActive (). CoinsTip () );
299
299
300
300
// Make it valid, and check again
301
301
invalid_with_csv_tx.vin [0 ].scriptSig = CScript () << vchSig << 100 ;
@@ -324,11 +324,11 @@ BOOST_FIXTURE_TEST_CASE(checkinputs_test, TestChain100Setup)
324
324
UpdateInput (valid_with_witness_tx.vin [0 ], sigdata);
325
325
326
326
// This should be valid under all script flags.
327
- ValidateCheckInputsForAllFlags (CTransaction (valid_with_witness_tx), 0 , true );
327
+ ValidateCheckInputsForAllFlags (CTransaction (valid_with_witness_tx), 0 , true , :: ChainstateActive (). CoinsTip () );
328
328
329
329
// Remove the witness, and check that it is now invalid.
330
330
valid_with_witness_tx.vin [0 ].scriptWitness .SetNull ();
331
- ValidateCheckInputsForAllFlags (CTransaction (valid_with_witness_tx), SCRIPT_VERIFY_WITNESS, true );
331
+ ValidateCheckInputsForAllFlags (CTransaction (valid_with_witness_tx), SCRIPT_VERIFY_WITNESS, true , :: ChainstateActive (). CoinsTip () );
332
332
}
333
333
334
334
{
@@ -353,7 +353,7 @@ BOOST_FIXTURE_TEST_CASE(checkinputs_test, TestChain100Setup)
353
353
}
354
354
355
355
// This should be valid under all script flags
356
- ValidateCheckInputsForAllFlags (CTransaction (tx), 0 , true );
356
+ ValidateCheckInputsForAllFlags (CTransaction (tx), 0 , true , :: ChainstateActive (). CoinsTip () );
357
357
358
358
// Check that if the second input is invalid, but the first input is
359
359
// valid, the transaction is not cached.
0 commit comments