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