Bitcoin Core  24.99.0
P2P Digital Currency
txvalidationcache_tests.cpp
Go to the documentation of this file.
1 // Copyright (c) 2011-2022 The Bitcoin Core developers
2 // Distributed under the MIT software license, see the accompanying
3 // file COPYING or http://www.opensource.org/licenses/mit-license.php.
4 
5 #include <consensus/validation.h>
6 #include <key.h>
7 #include <script/sign.h>
9 #include <script/standard.h>
10 #include <test/util/setup_common.h>
11 #include <txmempool.h>
12 #include <validation.h>
13 
14 #include <boost/test/unit_test.hpp>
15 
18  : TestChain100Setup{CBaseChainParams::REGTEST, {"-testactivationheight=dersig@102"}} {}
19 };
20 
21 bool CheckInputScripts(const CTransaction& tx, TxValidationState& state,
22  const CCoinsViewCache& inputs, unsigned int flags, bool cacheSigStore,
23  bool cacheFullScriptStore, PrecomputedTransactionData& txdata,
24  std::vector<CScriptCheck>* pvChecks) EXCLUSIVE_LOCKS_REQUIRED(cs_main);
25 
26 BOOST_AUTO_TEST_SUITE(txvalidationcache_tests)
27 
28 BOOST_FIXTURE_TEST_CASE(tx_mempool_block_doublespend, Dersig100Setup)
29 {
30  // Make sure skipping validation of transactions that were
31  // validated going into the memory pool does not allow
32  // double-spends in blocks to pass validation when they should not.
33 
34  CScript scriptPubKey = CScript() << ToByteVector(coinbaseKey.GetPubKey()) << OP_CHECKSIG;
35 
36  const auto ToMemPool = [this](const CMutableTransaction& tx) {
37  LOCK(cs_main);
38 
39  const MempoolAcceptResult result = m_node.chainman->ProcessTransaction(MakeTransactionRef(tx));
41  };
42 
43  // Create a double-spend of mature coinbase txn:
44  std::vector<CMutableTransaction> spends;
45  spends.resize(2);
46  for (int i = 0; i < 2; i++)
47  {
48  spends[i].nVersion = 1;
49  spends[i].vin.resize(1);
50  spends[i].vin[0].prevout.hash = m_coinbase_txns[0]->GetHash();
51  spends[i].vin[0].prevout.n = 0;
52  spends[i].vout.resize(1);
53  spends[i].vout[0].nValue = 11*CENT;
54  spends[i].vout[0].scriptPubKey = scriptPubKey;
55 
56  // Sign:
57  std::vector<unsigned char> vchSig;
58  uint256 hash = SignatureHash(scriptPubKey, spends[i], 0, SIGHASH_ALL, 0, SigVersion::BASE);
59  BOOST_CHECK(coinbaseKey.Sign(hash, vchSig));
60  vchSig.push_back((unsigned char)SIGHASH_ALL);
61  spends[i].vin[0].scriptSig << vchSig;
62  }
63 
64  CBlock block;
65 
66  // Test 1: block with both of those transactions should be rejected.
67  block = CreateAndProcessBlock(spends, scriptPubKey);
68  {
69  LOCK(cs_main);
70  BOOST_CHECK(m_node.chainman->ActiveChain().Tip()->GetBlockHash() != block.GetHash());
71  }
72 
73  // Test 2: ... and should be rejected if spend1 is in the memory pool
74  BOOST_CHECK(ToMemPool(spends[0]));
75  block = CreateAndProcessBlock(spends, scriptPubKey);
76  {
77  LOCK(cs_main);
78  BOOST_CHECK(m_node.chainman->ActiveChain().Tip()->GetBlockHash() != block.GetHash());
79  }
80  BOOST_CHECK_EQUAL(m_node.mempool->size(), 1U);
82  BOOST_CHECK_EQUAL(m_node.mempool->size(), 0U);
83 
84  // Test 3: ... and should be rejected if spend2 is in the memory pool
85  BOOST_CHECK(ToMemPool(spends[1]));
86  block = CreateAndProcessBlock(spends, scriptPubKey);
87  {
88  LOCK(cs_main);
89  BOOST_CHECK(m_node.chainman->ActiveChain().Tip()->GetBlockHash() != block.GetHash());
90  }
91  BOOST_CHECK_EQUAL(m_node.mempool->size(), 1U);
93  BOOST_CHECK_EQUAL(m_node.mempool->size(), 0U);
94 
95  // Final sanity test: first spend in *m_node.mempool, second in block, that's OK:
96  std::vector<CMutableTransaction> oneSpend;
97  oneSpend.push_back(spends[0]);
98  BOOST_CHECK(ToMemPool(spends[1]));
99  block = CreateAndProcessBlock(oneSpend, scriptPubKey);
100  {
101  LOCK(cs_main);
102  BOOST_CHECK(m_node.chainman->ActiveChain().Tip()->GetBlockHash() == block.GetHash());
103  }
104  // spends[1] should have been removed from the mempool when the
105  // block with spends[0] is accepted:
106  BOOST_CHECK_EQUAL(m_node.mempool->size(), 0U);
107 }
108 
109 // Run CheckInputScripts (using CoinsTip()) on the given transaction, for all script
110 // flags. Test that CheckInputScripts passes for all flags that don't overlap with
111 // the failing_flags argument, but otherwise fails.
112 // CHECKLOCKTIMEVERIFY and CHECKSEQUENCEVERIFY (and future NOP codes that may
113 // get reassigned) have an interaction with DISCOURAGE_UPGRADABLE_NOPS: if
114 // the script flags used contain DISCOURAGE_UPGRADABLE_NOPS but don't contain
115 // CHECKLOCKTIMEVERIFY (or CHECKSEQUENCEVERIFY), but the script does contain
116 // OP_CHECKLOCKTIMEVERIFY (or OP_CHECKSEQUENCEVERIFY), then script execution
117 // should fail.
118 // Capture this interaction with the upgraded_nop argument: set it when evaluating
119 // any script flag that is implemented as an upgraded NOP code.
120 static void ValidateCheckInputsForAllFlags(const CTransaction &tx, uint32_t failing_flags, bool add_to_cache, CCoinsViewCache& active_coins_tip) EXCLUSIVE_LOCKS_REQUIRED(::cs_main)
121 {
123 
124  FastRandomContext insecure_rand(true);
125 
126  for (int count = 0; count < 10000; ++count) {
127  TxValidationState state;
128 
129  // Randomly selects flag combinations
130  uint32_t test_flags = (uint32_t) insecure_rand.randrange((SCRIPT_VERIFY_END_MARKER - 1) << 1);
131 
132  // Filter out incompatible flag choices
133  if ((test_flags & SCRIPT_VERIFY_CLEANSTACK)) {
134  // CLEANSTACK requires P2SH and WITNESS, see VerifyScript() in
135  // script/interpreter.cpp
137  }
138  if ((test_flags & SCRIPT_VERIFY_WITNESS)) {
139  // WITNESS requires P2SH
140  test_flags |= SCRIPT_VERIFY_P2SH;
141  }
142  bool ret = CheckInputScripts(tx, state, &active_coins_tip, test_flags, true, add_to_cache, txdata, nullptr);
143  // CheckInputScripts should succeed iff test_flags doesn't intersect with
144  // failing_flags
145  bool expected_return_value = !(test_flags & failing_flags);
146  BOOST_CHECK_EQUAL(ret, expected_return_value);
147 
148  // Test the caching
149  if (ret && add_to_cache) {
150  // Check that we get a cache hit if the tx was valid
151  std::vector<CScriptCheck> scriptchecks;
152  BOOST_CHECK(CheckInputScripts(tx, state, &active_coins_tip, test_flags, true, add_to_cache, txdata, &scriptchecks));
153  BOOST_CHECK(scriptchecks.empty());
154  } else {
155  // Check that we get script executions to check, if the transaction
156  // was invalid, or we didn't add to cache.
157  std::vector<CScriptCheck> scriptchecks;
158  BOOST_CHECK(CheckInputScripts(tx, state, &active_coins_tip, test_flags, true, add_to_cache, txdata, &scriptchecks));
159  BOOST_CHECK_EQUAL(scriptchecks.size(), tx.vin.size());
160  }
161  }
162 }
163 
165 {
166  // Test that passing CheckInputScripts with one set of script flags doesn't imply
167  // that we would pass again with a different set of flags.
168  CScript p2pk_scriptPubKey = CScript() << ToByteVector(coinbaseKey.GetPubKey()) << OP_CHECKSIG;
169  CScript p2sh_scriptPubKey = GetScriptForDestination(ScriptHash(p2pk_scriptPubKey));
170  CScript p2pkh_scriptPubKey = GetScriptForDestination(PKHash(coinbaseKey.GetPubKey()));
171  CScript p2wpkh_scriptPubKey = GetScriptForDestination(WitnessV0KeyHash(coinbaseKey.GetPubKey()));
172 
173  FillableSigningProvider keystore;
174  BOOST_CHECK(keystore.AddKey(coinbaseKey));
175  BOOST_CHECK(keystore.AddCScript(p2pk_scriptPubKey));
176 
177  // flags to test: SCRIPT_VERIFY_CHECKLOCKTIMEVERIFY, SCRIPT_VERIFY_CHECKSEQUENCE_VERIFY, SCRIPT_VERIFY_NULLDUMMY, uncompressed pubkey thing
178 
179  // Create 2 outputs that match the three scripts above, spending the first
180  // coinbase tx.
181  CMutableTransaction spend_tx;
182 
183  spend_tx.nVersion = 1;
184  spend_tx.vin.resize(1);
185  spend_tx.vin[0].prevout.hash = m_coinbase_txns[0]->GetHash();
186  spend_tx.vin[0].prevout.n = 0;
187  spend_tx.vout.resize(4);
188  spend_tx.vout[0].nValue = 11*CENT;
189  spend_tx.vout[0].scriptPubKey = p2sh_scriptPubKey;
190  spend_tx.vout[1].nValue = 11*CENT;
191  spend_tx.vout[1].scriptPubKey = p2wpkh_scriptPubKey;
192  spend_tx.vout[2].nValue = 11*CENT;
193  spend_tx.vout[2].scriptPubKey = CScript() << OP_CHECKLOCKTIMEVERIFY << OP_DROP << ToByteVector(coinbaseKey.GetPubKey()) << OP_CHECKSIG;
194  spend_tx.vout[3].nValue = 11*CENT;
195  spend_tx.vout[3].scriptPubKey = CScript() << OP_CHECKSEQUENCEVERIFY << OP_DROP << ToByteVector(coinbaseKey.GetPubKey()) << OP_CHECKSIG;
196 
197  // Sign, with a non-DER signature
198  {
199  std::vector<unsigned char> vchSig;
200  uint256 hash = SignatureHash(p2pk_scriptPubKey, spend_tx, 0, SIGHASH_ALL, 0, SigVersion::BASE);
201  BOOST_CHECK(coinbaseKey.Sign(hash, vchSig));
202  vchSig.push_back((unsigned char) 0); // padding byte makes this non-DER
203  vchSig.push_back((unsigned char)SIGHASH_ALL);
204  spend_tx.vin[0].scriptSig << vchSig;
205  }
206 
207  // Test that invalidity under a set of flags doesn't preclude validity
208  // under other (eg consensus) flags.
209  // spend_tx is invalid according to DERSIG
210  {
211  LOCK(cs_main);
212 
213  TxValidationState state;
214  PrecomputedTransactionData ptd_spend_tx;
215 
216  BOOST_CHECK(!CheckInputScripts(CTransaction(spend_tx), state, &m_node.chainman->ActiveChainstate().CoinsTip(), SCRIPT_VERIFY_P2SH | SCRIPT_VERIFY_DERSIG, true, true, ptd_spend_tx, nullptr));
217 
218  // If we call again asking for scriptchecks (as happens in
219  // ConnectBlock), we should add a script check object for this -- we're
220  // not caching invalidity (if that changes, delete this test case).
221  std::vector<CScriptCheck> scriptchecks;
222  BOOST_CHECK(CheckInputScripts(CTransaction(spend_tx), state, &m_node.chainman->ActiveChainstate().CoinsTip(), SCRIPT_VERIFY_P2SH | SCRIPT_VERIFY_DERSIG, true, true, ptd_spend_tx, &scriptchecks));
223  BOOST_CHECK_EQUAL(scriptchecks.size(), 1U);
224 
225  // Test that CheckInputScripts returns true iff DERSIG-enforcing flags are
226  // not present. Don't add these checks to the cache, so that we can
227  // test later that block validation works fine in the absence of cached
228  // successes.
230  }
231 
232  // And if we produce a block with this tx, it should be valid (DERSIG not
233  // enabled yet), even though there's no cache entry.
234  CBlock block;
235 
236  block = CreateAndProcessBlock({spend_tx}, p2pk_scriptPubKey);
237  LOCK(cs_main);
238  BOOST_CHECK(m_node.chainman->ActiveChain().Tip()->GetBlockHash() == block.GetHash());
239  BOOST_CHECK(m_node.chainman->ActiveChainstate().CoinsTip().GetBestBlock() == block.GetHash());
240 
241  // Test P2SH: construct a transaction that is valid without P2SH, and
242  // then test validity with P2SH.
243  {
244  CMutableTransaction invalid_under_p2sh_tx;
245  invalid_under_p2sh_tx.nVersion = 1;
246  invalid_under_p2sh_tx.vin.resize(1);
247  invalid_under_p2sh_tx.vin[0].prevout.hash = spend_tx.GetHash();
248  invalid_under_p2sh_tx.vin[0].prevout.n = 0;
249  invalid_under_p2sh_tx.vout.resize(1);
250  invalid_under_p2sh_tx.vout[0].nValue = 11*CENT;
251  invalid_under_p2sh_tx.vout[0].scriptPubKey = p2pk_scriptPubKey;
252  std::vector<unsigned char> vchSig2(p2pk_scriptPubKey.begin(), p2pk_scriptPubKey.end());
253  invalid_under_p2sh_tx.vin[0].scriptSig << vchSig2;
254 
255  ValidateCheckInputsForAllFlags(CTransaction(invalid_under_p2sh_tx), SCRIPT_VERIFY_P2SH, true, m_node.chainman->ActiveChainstate().CoinsTip());
256  }
257 
258  // Test CHECKLOCKTIMEVERIFY
259  {
260  CMutableTransaction invalid_with_cltv_tx;
261  invalid_with_cltv_tx.nVersion = 1;
262  invalid_with_cltv_tx.nLockTime = 100;
263  invalid_with_cltv_tx.vin.resize(1);
264  invalid_with_cltv_tx.vin[0].prevout.hash = spend_tx.GetHash();
265  invalid_with_cltv_tx.vin[0].prevout.n = 2;
266  invalid_with_cltv_tx.vin[0].nSequence = 0;
267  invalid_with_cltv_tx.vout.resize(1);
268  invalid_with_cltv_tx.vout[0].nValue = 11*CENT;
269  invalid_with_cltv_tx.vout[0].scriptPubKey = p2pk_scriptPubKey;
270 
271  // Sign
272  std::vector<unsigned char> vchSig;
273  uint256 hash = SignatureHash(spend_tx.vout[2].scriptPubKey, invalid_with_cltv_tx, 0, SIGHASH_ALL, 0, SigVersion::BASE);
274  BOOST_CHECK(coinbaseKey.Sign(hash, vchSig));
275  vchSig.push_back((unsigned char)SIGHASH_ALL);
276  invalid_with_cltv_tx.vin[0].scriptSig = CScript() << vchSig << 101;
277 
278  ValidateCheckInputsForAllFlags(CTransaction(invalid_with_cltv_tx), SCRIPT_VERIFY_CHECKLOCKTIMEVERIFY, true, m_node.chainman->ActiveChainstate().CoinsTip());
279 
280  // Make it valid, and check again
281  invalid_with_cltv_tx.vin[0].scriptSig = CScript() << vchSig << 100;
282  TxValidationState state;
284  BOOST_CHECK(CheckInputScripts(CTransaction(invalid_with_cltv_tx), state, m_node.chainman->ActiveChainstate().CoinsTip(), SCRIPT_VERIFY_CHECKLOCKTIMEVERIFY, true, true, txdata, nullptr));
285  }
286 
287  // TEST CHECKSEQUENCEVERIFY
288  {
289  CMutableTransaction invalid_with_csv_tx;
290  invalid_with_csv_tx.nVersion = 2;
291  invalid_with_csv_tx.vin.resize(1);
292  invalid_with_csv_tx.vin[0].prevout.hash = spend_tx.GetHash();
293  invalid_with_csv_tx.vin[0].prevout.n = 3;
294  invalid_with_csv_tx.vin[0].nSequence = 100;
295  invalid_with_csv_tx.vout.resize(1);
296  invalid_with_csv_tx.vout[0].nValue = 11*CENT;
297  invalid_with_csv_tx.vout[0].scriptPubKey = p2pk_scriptPubKey;
298 
299  // Sign
300  std::vector<unsigned char> vchSig;
301  uint256 hash = SignatureHash(spend_tx.vout[3].scriptPubKey, invalid_with_csv_tx, 0, SIGHASH_ALL, 0, SigVersion::BASE);
302  BOOST_CHECK(coinbaseKey.Sign(hash, vchSig));
303  vchSig.push_back((unsigned char)SIGHASH_ALL);
304  invalid_with_csv_tx.vin[0].scriptSig = CScript() << vchSig << 101;
305 
306  ValidateCheckInputsForAllFlags(CTransaction(invalid_with_csv_tx), SCRIPT_VERIFY_CHECKSEQUENCEVERIFY, true, m_node.chainman->ActiveChainstate().CoinsTip());
307 
308  // Make it valid, and check again
309  invalid_with_csv_tx.vin[0].scriptSig = CScript() << vchSig << 100;
310  TxValidationState state;
312  BOOST_CHECK(CheckInputScripts(CTransaction(invalid_with_csv_tx), state, &m_node.chainman->ActiveChainstate().CoinsTip(), SCRIPT_VERIFY_CHECKSEQUENCEVERIFY, true, true, txdata, nullptr));
313  }
314 
315  // TODO: add tests for remaining script flags
316 
317  // Test that passing CheckInputScripts with a valid witness doesn't imply success
318  // for the same tx with a different witness.
319  {
320  CMutableTransaction valid_with_witness_tx;
321  valid_with_witness_tx.nVersion = 1;
322  valid_with_witness_tx.vin.resize(1);
323  valid_with_witness_tx.vin[0].prevout.hash = spend_tx.GetHash();
324  valid_with_witness_tx.vin[0].prevout.n = 1;
325  valid_with_witness_tx.vout.resize(1);
326  valid_with_witness_tx.vout[0].nValue = 11*CENT;
327  valid_with_witness_tx.vout[0].scriptPubKey = p2pk_scriptPubKey;
328 
329  // Sign
330  SignatureData sigdata;
331  BOOST_CHECK(ProduceSignature(keystore, MutableTransactionSignatureCreator(valid_with_witness_tx, 0, 11 * CENT, SIGHASH_ALL), spend_tx.vout[1].scriptPubKey, sigdata));
332  UpdateInput(valid_with_witness_tx.vin[0], sigdata);
333 
334  // This should be valid under all script flags.
335  ValidateCheckInputsForAllFlags(CTransaction(valid_with_witness_tx), 0, true, m_node.chainman->ActiveChainstate().CoinsTip());
336 
337  // Remove the witness, and check that it is now invalid.
338  valid_with_witness_tx.vin[0].scriptWitness.SetNull();
339  ValidateCheckInputsForAllFlags(CTransaction(valid_with_witness_tx), SCRIPT_VERIFY_WITNESS, true, m_node.chainman->ActiveChainstate().CoinsTip());
340  }
341 
342  {
343  // Test a transaction with multiple inputs.
345 
346  tx.nVersion = 1;
347  tx.vin.resize(2);
348  tx.vin[0].prevout.hash = spend_tx.GetHash();
349  tx.vin[0].prevout.n = 0;
350  tx.vin[1].prevout.hash = spend_tx.GetHash();
351  tx.vin[1].prevout.n = 1;
352  tx.vout.resize(1);
353  tx.vout[0].nValue = 22*CENT;
354  tx.vout[0].scriptPubKey = p2pk_scriptPubKey;
355 
356  // Sign
357  for (int i = 0; i < 2; ++i) {
358  SignatureData sigdata;
359  BOOST_CHECK(ProduceSignature(keystore, MutableTransactionSignatureCreator(tx, i, 11 * CENT, SIGHASH_ALL), spend_tx.vout[i].scriptPubKey, sigdata));
360  UpdateInput(tx.vin[i], sigdata);
361  }
362 
363  // This should be valid under all script flags
364  ValidateCheckInputsForAllFlags(CTransaction(tx), 0, true, m_node.chainman->ActiveChainstate().CoinsTip());
365 
366  // Check that if the second input is invalid, but the first input is
367  // valid, the transaction is not cached.
368  // Invalidate vin[1]
369  tx.vin[1].scriptWitness.SetNull();
370 
371  TxValidationState state;
373  // This transaction is now invalid under segwit, because of the second input.
374  BOOST_CHECK(!CheckInputScripts(CTransaction(tx), state, &m_node.chainman->ActiveChainstate().CoinsTip(), SCRIPT_VERIFY_P2SH | SCRIPT_VERIFY_WITNESS, true, true, txdata, nullptr));
375 
376  std::vector<CScriptCheck> scriptchecks;
377  // Make sure this transaction was not cached (ie because the first
378  // input was valid)
379  BOOST_CHECK(CheckInputScripts(CTransaction(tx), state, &m_node.chainman->ActiveChainstate().CoinsTip(), SCRIPT_VERIFY_P2SH | SCRIPT_VERIFY_WITNESS, true, true, txdata, &scriptchecks));
380  // Should get 2 script checks back -- caching is on a whole-transaction basis.
381  BOOST_CHECK_EQUAL(scriptchecks.size(), 2U);
382  }
383 }
384 
int ret
node::NodeContext m_node
Definition: bitcoin-gui.cpp:37
int flags
Definition: bitcoin-tx.cpp:526
CBaseChainParams defines the base parameters (shared between bitcoin-cli and bitcoind) of a given ins...
uint256 GetHash() const
Definition: block.cpp:11
Definition: block.h:69
CCoinsView that adds a memory cache for transactions to another CCoinsView.
Definition: coins.h:213
Serialized script, used inside transaction inputs and outputs.
Definition: script.h:411
The basic transaction that is broadcasted on the network and contained in blocks.
Definition: transaction.h:295
Fast randomness source.
Definition: random.h:144
uint64_t randrange(uint64_t range) noexcept
Generate a random integer in the range [0..range).
Definition: random.h:202
Fillable signing provider that keeps keys in an address->secret map.
virtual bool AddCScript(const CScript &redeemScript)
virtual bool AddKey(const CKey &key)
A signature creator for transactions.
Definition: sign.h:40
iterator begin()
Definition: prevector.h:292
iterator end()
Definition: prevector.h:294
256-bit opaque blob.
Definition: uint256.h:105
RecursiveMutex cs_main
Mutex to guard access to validation specific variables, such as reading or changing the chainstate.
Definition: cs_main.cpp:8
BOOST_AUTO_TEST_SUITE(cuckoocache_tests)
Test Suite for CuckooCache.
BOOST_AUTO_TEST_SUITE_END()
uint256 SignatureHash(const CScript &scriptCode, const T &txTo, unsigned int nIn, int nHashType, const CAmount &amount, SigVersion sigversion, const PrecomputedTransactionData *cache)
@ BASE
Bare scripts and BIP16 P2SH-wrapped redeemscripts.
@ SCRIPT_VERIFY_P2SH
Definition: interpreter.h:47
@ SCRIPT_VERIFY_WITNESS
Definition: interpreter.h:106
@ SCRIPT_VERIFY_LOW_S
Definition: interpreter.h:59
@ SCRIPT_VERIFY_CHECKLOCKTIMEVERIFY
Definition: interpreter.h:97
@ SCRIPT_VERIFY_STRICTENC
Definition: interpreter.h:52
@ SCRIPT_VERIFY_DERSIG
Definition: interpreter.h:55
@ SCRIPT_VERIFY_END_MARKER
Definition: interpreter.h:146
@ SCRIPT_VERIFY_CLEANSTACK
Definition: interpreter.h:92
@ SCRIPT_VERIFY_CHECKSEQUENCEVERIFY
Definition: interpreter.h:102
@ SIGHASH_ALL
Definition: interpreter.h:28
#define BOOST_CHECK_EQUAL(v1, v2)
Definition: object.cpp:18
#define BOOST_CHECK(expr)
Definition: object.cpp:17
static CTransactionRef MakeTransactionRef(Tx &&txIn)
Definition: transaction.h:422
std::vector< unsigned char > ToByteVector(const T &in)
Definition: script.h:63
@ OP_CHECKSIG
Definition: script.h:186
@ OP_CHECKLOCKTIMEVERIFY
Definition: script.h:193
@ OP_DROP
Definition: script.h:120
@ OP_CHECKSEQUENCEVERIFY
Definition: script.h:195
static constexpr CAmount CENT
Definition: setup_common.h:74
bool ProduceSignature(const SigningProvider &provider, const BaseSignatureCreator &creator, const CScript &fromPubKey, SignatureData &sigdata)
Produce a script signature using a generic signature creator.
Definition: sign.cpp:470
void UpdateInput(CTxIn &input, const SignatureData &data)
Definition: sign.cpp:643
CScript GetScriptForDestination(const CTxDestination &dest)
Generate a Bitcoin scriptPubKey for the given CTxDestination.
Definition: standard.cpp:334
A mutable version of CTransaction.
Definition: transaction.h:380
uint256 GetHash() const
Compute the hash of this CMutableTransaction.
Definition: transaction.cpp:68
std::vector< CTxOut > vout
Definition: transaction.h:382
std::vector< CTxIn > vin
Definition: transaction.h:381
Validation result for a single transaction mempool acceptance.
Definition: validation.h:117
const ResultType m_result_type
Result type.
Definition: validation.h:126
Testing fixture that pre-creates a 100-block REGTEST-mode block chain.
Definition: setup_common.h:128
std::unique_ptr< CTxMemPool > mempool
Definition: context.h:50
std::unique_ptr< ChainstateManager > chainman
Definition: context.h:54
#define LOCK(cs)
Definition: sync.h:258
#define WITH_LOCK(cs, code)
Run code while locking a mutex.
Definition: sync.h:302
static int count
#define EXCLUSIVE_LOCKS_REQUIRED(...)
Definition: threadsafety.h:49
@ CONFLICT
Removed for conflict with in-block transaction.
bool CheckInputScripts(const CTransaction &tx, TxValidationState &state, const CCoinsViewCache &inputs, unsigned int flags, bool cacheSigStore, bool cacheFullScriptStore, PrecomputedTransactionData &txdata, std::vector< CScriptCheck > *pvChecks) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
Check whether all of this transaction's input scripts succeed.
BOOST_FIXTURE_TEST_CASE(tx_mempool_block_doublespend, Dersig100Setup)
static void ValidateCheckInputsForAllFlags(const CTransaction &tx, uint32_t failing_flags, bool add_to_cache, CCoinsViewCache &active_coins_tip) EXCLUSIVE_LOCKS_REQUIRED(