Bitcoin Core  22.99.0
P2P Digital Currency
interpreter.h
Go to the documentation of this file.
1 // Copyright (c) 2009-2010 Satoshi Nakamoto
2 // Copyright (c) 2009-2021 The Bitcoin Core developers
3 // Distributed under the MIT software license, see the accompanying
4 // file COPYING or http://www.opensource.org/licenses/mit-license.php.
5 
6 #ifndef BITCOIN_SCRIPT_INTERPRETER_H
7 #define BITCOIN_SCRIPT_INTERPRETER_H
8 
9 #include <hash.h>
10 #include <script/script_error.h>
11 #include <span.h>
12 #include <primitives/transaction.h>
13 
14 #include <optional>
15 #include <vector>
16 #include <stdint.h>
17 
18 class CPubKey;
19 class XOnlyPubKey;
20 class CScript;
21 class CTransaction;
22 class CTxOut;
23 class uint256;
24 
26 enum
27 {
32 
36 };
37 
43 enum : uint32_t {
45 
46  // Evaluate P2SH subscripts (BIP16).
47  SCRIPT_VERIFY_P2SH = (1U << 0),
48 
49  // Passing a non-strict-DER signature or one with undefined hashtype to a checksig operation causes script failure.
50  // Evaluating a pubkey that is not (0x04 + 64 bytes) or (0x02 or 0x03 + 32 bytes) by checksig causes script failure.
51  // (not used or intended as a consensus rule).
53 
54  // Passing a non-strict-DER signature to a checksig operation causes script failure (BIP62 rule 1)
55  SCRIPT_VERIFY_DERSIG = (1U << 2),
56 
57  // Passing a non-strict-DER signature or one with S > order/2 to a checksig operation causes script failure
58  // (BIP62 rule 5).
59  SCRIPT_VERIFY_LOW_S = (1U << 3),
60 
61  // verify dummy stack item consumed by CHECKMULTISIG is of zero-length (BIP62 rule 7).
63 
64  // Using a non-push operator in the scriptSig causes script failure (BIP62 rule 2).
66 
67  // Require minimal encodings for all push operations (OP_0... OP_16, OP_1NEGATE where possible, direct
68  // pushes up to 75 bytes, OP_PUSHDATA up to 255 bytes, OP_PUSHDATA2 for anything larger). Evaluating
69  // any other push causes the script to fail (BIP62 rule 3).
70  // In addition, whenever a stack element is interpreted as a number, it must be of minimal length (BIP62 rule 4).
72 
73  // Discourage use of NOPs reserved for upgrades (NOP1-10)
74  //
75  // Provided so that nodes can avoid accepting or mining transactions
76  // containing executed NOP's whose meaning may change after a soft-fork,
77  // thus rendering the script invalid; with this flag set executing
78  // discouraged NOPs fails the script. This verification flag will never be
79  // a mandatory flag applied to scripts in a block. NOPs that are not
80  // executed, e.g. within an unexecuted IF ENDIF block, are *not* rejected.
81  // NOPs that have associated forks to give them new meaning (CLTV, CSV)
82  // are not subject to this rule.
84 
85  // Require that only a single stack element remains after evaluation. This changes the success criterion from
86  // "At least one stack element must remain, and when interpreted as a boolean, it must be true" to
87  // "Exactly one stack element must remain, and when interpreted as a boolean, it must be true".
88  // (BIP62 rule 6)
89  // Note: CLEANSTACK should never be used without P2SH or WITNESS.
90  // Note: WITNESS_V0 and TAPSCRIPT script execution have behavior similar to CLEANSTACK as part of their
91  // consensus rules. It is automatic there and does not need this flag.
93 
94  // Verify CHECKLOCKTIMEVERIFY
95  //
96  // See BIP65 for details.
98 
99  // support CHECKSEQUENCEVERIFY opcode
100  //
101  // See BIP112 for details
103 
104  // Support segregated witness
105  //
106  SCRIPT_VERIFY_WITNESS = (1U << 11),
107 
108  // Making v1-v16 witness program non-standard
109  //
111 
112  // Segwit script only: Require the argument of OP_IF/NOTIF to be exactly 0x01 or empty vector
113  //
114  // Note: TAPSCRIPT script execution has behavior similar to MINIMALIF as part of its consensus
115  // rules. It is automatic there and does not depend on this flag.
117 
118  // Signature(s) must be empty vector if a CHECK(MULTI)SIG operation failed
119  //
121 
122  // Public keys in segregated witness scripts must be compressed
123  //
125 
126  // Making OP_CODESEPARATOR and FindAndDelete fail any non-segwit scripts
127  //
129 
130  // Taproot/Tapscript validation (BIPs 341 & 342)
131  //
132  SCRIPT_VERIFY_TAPROOT = (1U << 17),
133 
134  // Making unknown Taproot leaf versions non-standard
135  //
137 
138  // Making unknown OP_SUCCESS non-standard
140 
141  // Making unknown public key versions (in BIP 342 scripts) non-standard
143 
144  // Constants to point to the highest flag in use. Add new flags above this line.
145  //
147 };
148 
149 bool CheckSignatureEncoding(const std::vector<unsigned char> &vchSig, unsigned int flags, ScriptError* serror);
150 
152 {
153  // BIP341 precomputed data.
154  // These are single-SHA256, see https://github.com/bitcoin/bips/blob/master/bip-0341.mediawiki#cite_note-15.
162 
163  // BIP143 precomputed data (double-SHA256).
166  bool m_bip143_segwit_ready = false;
167 
168  std::vector<CTxOut> m_spent_outputs;
170  bool m_spent_outputs_ready = false;
171 
172  PrecomputedTransactionData() = default;
173 
181  template <class T>
182  void Init(const T& tx, std::vector<CTxOut>&& spent_outputs, bool force = false);
183 
184  template <class T>
185  explicit PrecomputedTransactionData(const T& tx);
186 };
187 
188 enum class SigVersion
189 {
190  BASE = 0,
191  WITNESS_V0 = 1,
192  TAPROOT = 2,
193  TAPSCRIPT = 3,
194 };
195 
197 {
199  bool m_tapleaf_hash_init = false;
202 
207 
209  bool m_annex_init = false;
214 
219 
221  std::optional<uint256> m_output_hash;
222 };
223 
225 static constexpr size_t WITNESS_V0_SCRIPTHASH_SIZE = 32;
226 static constexpr size_t WITNESS_V0_KEYHASH_SIZE = 20;
227 static constexpr size_t WITNESS_V1_TAPROOT_SIZE = 32;
228 
229 static constexpr uint8_t TAPROOT_LEAF_MASK = 0xfe;
230 static constexpr uint8_t TAPROOT_LEAF_TAPSCRIPT = 0xc0;
231 static constexpr size_t TAPROOT_CONTROL_BASE_SIZE = 33;
232 static constexpr size_t TAPROOT_CONTROL_NODE_SIZE = 32;
233 static constexpr size_t TAPROOT_CONTROL_MAX_NODE_COUNT = 128;
235 
236 extern const CHashWriter HASHER_TAPSIGHASH;
237 extern const CHashWriter HASHER_TAPLEAF;
238 extern const CHashWriter HASHER_TAPBRANCH;
239 
240 template <class T>
241 uint256 SignatureHash(const CScript& scriptCode, const T& txTo, unsigned int nIn, int nHashType, const CAmount& amount, SigVersion sigversion, const PrecomputedTransactionData* cache = nullptr);
242 
244 {
245 public:
246  virtual bool CheckECDSASignature(const std::vector<unsigned char>& scriptSig, const std::vector<unsigned char>& vchPubKey, const CScript& scriptCode, SigVersion sigversion) const
247  {
248  return false;
249  }
250 
251  virtual bool CheckSchnorrSignature(Span<const unsigned char> sig, Span<const unsigned char> pubkey, SigVersion sigversion, ScriptExecutionData& execdata, ScriptError* serror = nullptr) const
252  {
253  return false;
254  }
255 
256  virtual bool CheckLockTime(const CScriptNum& nLockTime) const
257  {
258  return false;
259  }
260 
261  virtual bool CheckSequence(const CScriptNum& nSequence) const
262  {
263  return false;
264  }
265 
267 };
268 
273 {
274  ASSERT_FAIL,
275  FAIL,
276 };
277 
278 template<typename T>
279 bool SignatureHashSchnorr(uint256& hash_out, ScriptExecutionData& execdata, const T& tx_to, uint32_t in_pos, uint8_t hash_type, SigVersion sigversion, const PrecomputedTransactionData& cache, MissingDataBehavior mdb);
280 
281 template <class T>
283 {
284 private:
285  const T* txTo;
287  unsigned int nIn;
290 
291 protected:
292  virtual bool VerifyECDSASignature(const std::vector<unsigned char>& vchSig, const CPubKey& vchPubKey, const uint256& sighash) const;
293  virtual bool VerifySchnorrSignature(Span<const unsigned char> sig, const XOnlyPubKey& pubkey, const uint256& sighash) const;
294 
295 public:
296  GenericTransactionSignatureChecker(const T* txToIn, unsigned int nInIn, const CAmount& amountIn, MissingDataBehavior mdb) : txTo(txToIn), m_mdb(mdb), nIn(nInIn), amount(amountIn), txdata(nullptr) {}
297  GenericTransactionSignatureChecker(const T* txToIn, unsigned int nInIn, const CAmount& amountIn, const PrecomputedTransactionData& txdataIn, MissingDataBehavior mdb) : txTo(txToIn), m_mdb(mdb), nIn(nInIn), amount(amountIn), txdata(&txdataIn) {}
298  bool CheckECDSASignature(const std::vector<unsigned char>& scriptSig, const std::vector<unsigned char>& vchPubKey, const CScript& scriptCode, SigVersion sigversion) const override;
299  bool CheckSchnorrSignature(Span<const unsigned char> sig, Span<const unsigned char> pubkey, SigVersion sigversion, ScriptExecutionData& execdata, ScriptError* serror = nullptr) const override;
300  bool CheckLockTime(const CScriptNum& nLockTime) const override;
301  bool CheckSequence(const CScriptNum& nSequence) const override;
302 };
303 
306 
308 {
309 protected:
311 
312 public:
314 
315  bool CheckECDSASignature(const std::vector<unsigned char>& scriptSig, const std::vector<unsigned char>& vchPubKey, const CScript& scriptCode, SigVersion sigversion) const override
316  {
317  return m_checker.CheckECDSASignature(scriptSig, vchPubKey, scriptCode, sigversion);
318  }
319 
320  bool CheckSchnorrSignature(Span<const unsigned char> sig, Span<const unsigned char> pubkey, SigVersion sigversion, ScriptExecutionData& execdata, ScriptError* serror = nullptr) const override
321  {
322  return m_checker.CheckSchnorrSignature(sig, pubkey, sigversion, execdata, serror);
323  }
324 
325  bool CheckLockTime(const CScriptNum& nLockTime) const override
326  {
327  return m_checker.CheckLockTime(nLockTime);
328  }
329  bool CheckSequence(const CScriptNum& nSequence) const override
330  {
331  return m_checker.CheckSequence(nSequence);
332  }
333 };
334 
336 uint256 ComputeTapleafHash(uint8_t leaf_version, const CScript& script);
340 
341 bool EvalScript(std::vector<std::vector<unsigned char> >& stack, const CScript& script, unsigned int flags, const BaseSignatureChecker& checker, SigVersion sigversion, ScriptExecutionData& execdata, ScriptError* error = nullptr);
342 bool EvalScript(std::vector<std::vector<unsigned char> >& stack, const CScript& script, unsigned int flags, const BaseSignatureChecker& checker, SigVersion sigversion, ScriptError* error = nullptr);
343 bool VerifyScript(const CScript& scriptSig, const CScript& scriptPubKey, const CScriptWitness* witness, unsigned int flags, const BaseSignatureChecker& checker, ScriptError* serror = nullptr);
344 
345 size_t CountWitnessSigOps(const CScript& scriptSig, const CScript& scriptPubKey, const CScriptWitness* witness, unsigned int flags);
346 
347 bool CheckMinimalPush(const std::vector<unsigned char>& data, opcodetype opcode);
348 
349 int FindAndDelete(CScript& script, const CScript& b);
350 
351 #endif // BITCOIN_SCRIPT_INTERPRETER_H
SigVersion
SigVersion
Definition: interpreter.h:188
SignatureHash
uint256 SignatureHash(const CScript &scriptCode, const T &txTo, unsigned int nIn, int nHashType, const CAmount &amount, SigVersion sigversion, const PrecomputedTransactionData *cache=nullptr)
Definition: interpreter.cpp:1593
PrecomputedTransactionData::m_prevouts_single_hash
uint256 m_prevouts_single_hash
Definition: interpreter.h:155
WITNESS_V0_KEYHASH_SIZE
static constexpr size_t WITNESS_V0_KEYHASH_SIZE
Definition: interpreter.h:226
SIGHASH_INPUT_MASK
@ SIGHASH_INPUT_MASK
Definition: interpreter.h:35
DeferringSignatureChecker::CheckSequence
bool CheckSequence(const CScriptNum &nSequence) const override
Definition: interpreter.h:329
SCRIPT_VERIFY_DISCOURAGE_UPGRADABLE_WITNESS_PROGRAM
@ SCRIPT_VERIFY_DISCOURAGE_UPGRADABLE_WITNESS_PROGRAM
Definition: interpreter.h:110
WITNESS_V0_SCRIPTHASH_SIZE
static constexpr size_t WITNESS_V0_SCRIPTHASH_SIZE
Signature hash sizes.
Definition: interpreter.h:225
BaseSignatureChecker::~BaseSignatureChecker
virtual ~BaseSignatureChecker()
Definition: interpreter.h:266
SigVersion::BASE
@ BASE
Bare scripts and BIP16 P2SH-wrapped redeemscripts.
SCRIPT_VERIFY_CLEANSTACK
@ SCRIPT_VERIFY_CLEANSTACK
Definition: interpreter.h:92
SCRIPT_VERIFY_MINIMALIF
@ SCRIPT_VERIFY_MINIMALIF
Definition: interpreter.h:116
MissingDataBehavior
MissingDataBehavior
Enum to specify what *TransactionSignatureChecker's behavior should be when dealing with missing tran...
Definition: interpreter.h:272
TAPROOT_CONTROL_BASE_SIZE
static constexpr size_t TAPROOT_CONTROL_BASE_SIZE
Definition: interpreter.h:231
flags
int flags
Definition: bitcoin-tx.cpp:529
GenericTransactionSignatureChecker::CheckECDSASignature
bool CheckECDSASignature(const std::vector< unsigned char > &scriptSig, const std::vector< unsigned char > &vchPubKey, const CScript &scriptCode, SigVersion sigversion) const override
Definition: interpreter.cpp:1673
PrecomputedTransactionData::m_spent_amounts_single_hash
uint256 m_spent_amounts_single_hash
Definition: interpreter.h:158
PrecomputedTransactionData::m_spent_outputs
std::vector< CTxOut > m_spent_outputs
Definition: interpreter.h:168
transaction.h
HASHER_TAPBRANCH
const CHashWriter HASHER_TAPBRANCH
Hasher with tag "TapBranch" pre-fed to it.
Definition: interpreter.cpp:1488
BaseSignatureChecker::CheckECDSASignature
virtual bool CheckECDSASignature(const std::vector< unsigned char > &scriptSig, const std::vector< unsigned char > &vchPubKey, const CScript &scriptCode, SigVersion sigversion) const
Definition: interpreter.h:246
PrecomputedTransactionData::m_sequences_single_hash
uint256 m_sequences_single_hash
Definition: interpreter.h:156
SIGHASH_OUTPUT_MASK
@ SIGHASH_OUTPUT_MASK
Definition: interpreter.h:34
ScriptExecutionData::m_codeseparator_pos
uint32_t m_codeseparator_pos
Opcode position of the last executed OP_CODESEPARATOR (or 0xFFFFFFFF if none executed).
Definition: interpreter.h:206
GenericTransactionSignatureChecker::amount
const CAmount amount
Definition: interpreter.h:288
GenericTransactionSignatureChecker
Definition: interpreter.h:282
SIGHASH_SINGLE
@ SIGHASH_SINGLE
Definition: interpreter.h:30
ScriptExecutionData
Definition: interpreter.h:196
opcodetype
opcodetype
Script opcodes.
Definition: script.h:66
DeferringSignatureChecker::m_checker
BaseSignatureChecker & m_checker
Definition: interpreter.h:310
PrecomputedTransactionData::m_bip143_segwit_ready
bool m_bip143_segwit_ready
Whether the 3 fields above are initialized.
Definition: interpreter.h:166
BaseSignatureChecker
Definition: interpreter.h:243
XOnlyPubKey
Definition: pubkey.h:224
SCRIPT_VERIFY_DISCOURAGE_UPGRADABLE_NOPS
@ SCRIPT_VERIFY_DISCOURAGE_UPGRADABLE_NOPS
Definition: interpreter.h:83
ScriptExecutionData::m_annex_present
bool m_annex_present
Whether an annex is present.
Definition: interpreter.h:211
SCRIPT_VERIFY_TAPROOT
@ SCRIPT_VERIFY_TAPROOT
Definition: interpreter.h:132
PrecomputedTransactionData::PrecomputedTransactionData
PrecomputedTransactionData()=default
SIGHASH_NONE
@ SIGHASH_NONE
Definition: interpreter.h:29
ComputeTaprootMerkleRoot
uint256 ComputeTaprootMerkleRoot(Span< const unsigned char > control, const uint256 &tapleaf_hash)
Compute the BIP341 taproot script tree Merkle root from control block and leaf hash.
Definition: interpreter.cpp:1858
SCRIPT_VERIFY_SIGPUSHONLY
@ SCRIPT_VERIFY_SIGPUSHONLY
Definition: interpreter.h:65
MissingDataBehavior::FAIL
@ FAIL
Just act as if the signature was invalid.
DeferringSignatureChecker::CheckSchnorrSignature
bool CheckSchnorrSignature(Span< const unsigned char > sig, Span< const unsigned char > pubkey, SigVersion sigversion, ScriptExecutionData &execdata, ScriptError *serror=nullptr) const override
Definition: interpreter.h:320
ScriptExecutionData::m_validation_weight_left
int64_t m_validation_weight_left
How much validation weight is left (decremented for every successful non-empty signature check).
Definition: interpreter.h:218
GenericTransactionSignatureChecker::m_mdb
const MissingDataBehavior m_mdb
Definition: interpreter.h:286
SigVersion::TAPROOT
@ TAPROOT
Witness v1 with 32-byte program, not BIP16 P2SH-wrapped, key path spending; see BIP 341.
CTransaction
The basic transaction that is broadcasted on the network and contained in blocks.
Definition: transaction.h:279
BaseSignatureChecker::CheckSchnorrSignature
virtual bool CheckSchnorrSignature(Span< const unsigned char > sig, Span< const unsigned char > pubkey, SigVersion sigversion, ScriptExecutionData &execdata, ScriptError *serror=nullptr) const
Definition: interpreter.h:251
ScriptError
enum ScriptError_t ScriptError
TAPROOT_CONTROL_MAX_SIZE
static constexpr size_t TAPROOT_CONTROL_MAX_SIZE
Definition: interpreter.h:234
PrecomputedTransactionData::m_spent_scripts_single_hash
uint256 m_spent_scripts_single_hash
Definition: interpreter.h:159
CScriptWitness
Definition: script.h:557
CScriptNum
Definition: script.h:219
Span< const unsigned char >
GenericTransactionSignatureChecker::GenericTransactionSignatureChecker
GenericTransactionSignatureChecker(const T *txToIn, unsigned int nInIn, const CAmount &amountIn, const PrecomputedTransactionData &txdataIn, MissingDataBehavior mdb)
Definition: interpreter.h:297
DeferringSignatureChecker::DeferringSignatureChecker
DeferringSignatureChecker(BaseSignatureChecker &checker)
Definition: interpreter.h:313
HASHER_TAPSIGHASH
const CHashWriter HASHER_TAPSIGHASH
Hasher with tag "TapSighash" pre-fed to it.
Definition: interpreter.cpp:1486
EvalScript
bool EvalScript(std::vector< std::vector< unsigned char > > &stack, const CScript &script, unsigned int flags, const BaseSignatureChecker &checker, SigVersion sigversion, ScriptExecutionData &execdata, ScriptError *error=nullptr)
Definition: interpreter.cpp:431
SCRIPT_VERIFY_DISCOURAGE_UPGRADABLE_TAPROOT_VERSION
@ SCRIPT_VERIFY_DISCOURAGE_UPGRADABLE_TAPROOT_VERSION
Definition: interpreter.h:136
GenericTransactionSignatureChecker::CheckSchnorrSignature
bool CheckSchnorrSignature(Span< const unsigned char > sig, Span< const unsigned char > pubkey, SigVersion sigversion, ScriptExecutionData &execdata, ScriptError *serror=nullptr) const override
Definition: interpreter.cpp:1698
SCRIPT_VERIFY_DISCOURAGE_UPGRADABLE_PUBKEYTYPE
@ SCRIPT_VERIFY_DISCOURAGE_UPGRADABLE_PUBKEYTYPE
Definition: interpreter.h:142
GenericTransactionSignatureChecker::nIn
unsigned int nIn
Definition: interpreter.h:287
GenericTransactionSignatureChecker::VerifyECDSASignature
virtual bool VerifyECDSASignature(const std::vector< unsigned char > &vchSig, const CPubKey &vchPubKey, const uint256 &sighash) const
Definition: interpreter.cpp:1661
SCRIPT_VERIFY_NULLDUMMY
@ SCRIPT_VERIFY_NULLDUMMY
Definition: interpreter.h:62
SIGHASH_ANYONECANPAY
@ SIGHASH_ANYONECANPAY
Definition: interpreter.h:31
CTxOut
An output of a transaction.
Definition: transaction.h:148
PrecomputedTransactionData::m_outputs_single_hash
uint256 m_outputs_single_hash
Definition: interpreter.h:157
ComputeTapleafHash
uint256 ComputeTapleafHash(uint8_t leaf_version, const CScript &script)
Compute the BIP341 tapleaf hash from leaf version & script.
Definition: interpreter.cpp:1853
CountWitnessSigOps
size_t CountWitnessSigOps(const CScript &scriptSig, const CScript &scriptPubKey, const CScriptWitness *witness, unsigned int flags)
Definition: interpreter.cpp:2109
ScriptExecutionData::m_tapleaf_hash
uint256 m_tapleaf_hash
The tapleaf hash.
Definition: interpreter.h:201
ScriptExecutionData::m_annex_init
bool m_annex_init
Whether m_annex_present and (when needed) m_annex_hash are initialized.
Definition: interpreter.h:209
SCRIPT_VERIFY_WITNESS
@ SCRIPT_VERIFY_WITNESS
Definition: interpreter.h:106
PrecomputedTransactionData::Init
void Init(const T &tx, std::vector< CTxOut > &&spent_outputs, bool force=false)
Initialize this PrecomputedTransactionData with transaction data.
Definition: interpreter.cpp:1423
span.h
ScriptExecutionData::m_codeseparator_pos_init
bool m_codeseparator_pos_init
Whether m_codeseparator_pos is initialized.
Definition: interpreter.h:204
TAPROOT_LEAF_MASK
static constexpr uint8_t TAPROOT_LEAF_MASK
Definition: interpreter.h:229
SCRIPT_VERIFY_CHECKSEQUENCEVERIFY
@ SCRIPT_VERIFY_CHECKSEQUENCEVERIFY
Definition: interpreter.h:102
CheckSignatureEncoding
bool CheckSignatureEncoding(const std::vector< unsigned char > &vchSig, unsigned int flags, ScriptError *serror)
Definition: interpreter.cpp:200
SCRIPT_VERIFY_DISCOURAGE_OP_SUCCESS
@ SCRIPT_VERIFY_DISCOURAGE_OP_SUCCESS
Definition: interpreter.h:139
GenericTransactionSignatureChecker::CheckLockTime
bool CheckLockTime(const CScriptNum &nLockTime) const override
Definition: interpreter.cpp:1726
CAmount
int64_t CAmount
Amount in satoshis (Can be negative)
Definition: amount.h:12
PrecomputedTransactionData::m_spent_outputs_ready
bool m_spent_outputs_ready
Whether m_spent_outputs is initialized.
Definition: interpreter.h:170
SigVersion::WITNESS_V0
@ WITNESS_V0
Witness v0 (P2WPKH and P2WSH); see BIP 141.
PrecomputedTransactionData
Definition: interpreter.h:151
SCRIPT_VERIFY_MINIMALDATA
@ SCRIPT_VERIFY_MINIMALDATA
Definition: interpreter.h:71
uint256
256-bit opaque blob.
Definition: uint256.h:126
PrecomputedTransactionData::hashPrevouts
uint256 hashPrevouts
Definition: interpreter.h:164
MissingDataBehavior::ASSERT_FAIL
@ ASSERT_FAIL
Abort execution through assertion failure (for consensus code)
GenericTransactionSignatureChecker::txdata
const PrecomputedTransactionData * txdata
Definition: interpreter.h:289
SignatureHashSchnorr
bool SignatureHashSchnorr(uint256 &hash_out, ScriptExecutionData &execdata, const T &tx_to, uint32_t in_pos, uint8_t hash_type, SigVersion sigversion, const PrecomputedTransactionData &cache, MissingDataBehavior mdb)
Definition: interpreter.cpp:1503
CScript
Serialized script, used inside transaction inputs and outputs.
Definition: script.h:405
SCRIPT_VERIFY_WITNESS_PUBKEYTYPE
@ SCRIPT_VERIFY_WITNESS_PUBKEYTYPE
Definition: interpreter.h:124
PrecomputedTransactionData::hashOutputs
uint256 hashOutputs
Definition: interpreter.h:164
ScriptExecutionData::m_tapleaf_hash_init
bool m_tapleaf_hash_init
Whether m_tapleaf_hash is initialized.
Definition: interpreter.h:199
SCRIPT_VERIFY_LOW_S
@ SCRIPT_VERIFY_LOW_S
Definition: interpreter.h:59
GenericTransactionSignatureChecker::txTo
const T * txTo
Definition: interpreter.h:285
SIGHASH_ALL
@ SIGHASH_ALL
Definition: interpreter.h:28
SCRIPT_VERIFY_END_MARKER
@ SCRIPT_VERIFY_END_MARKER
Definition: interpreter.h:146
SCRIPT_VERIFY_NONE
@ SCRIPT_VERIFY_NONE
Definition: interpreter.h:44
CPubKey
An encapsulated public key.
Definition: pubkey.h:33
SigVersion::TAPSCRIPT
@ TAPSCRIPT
Witness v1 with 32-byte program, not BIP16 P2SH-wrapped, script path spending, leaf version 0xc0; see...
script_error.h
GenericTransactionSignatureChecker::CheckSequence
bool CheckSequence(const CScriptNum &nSequence) const override
Definition: interpreter.cpp:1763
SCRIPT_VERIFY_P2SH
@ SCRIPT_VERIFY_P2SH
Definition: interpreter.h:47
DeferringSignatureChecker::CheckECDSASignature
bool CheckECDSASignature(const std::vector< unsigned char > &scriptSig, const std::vector< unsigned char > &vchPubKey, const CScript &scriptCode, SigVersion sigversion) const override
Definition: interpreter.h:315
BaseSignatureChecker::CheckSequence
virtual bool CheckSequence(const CScriptNum &nSequence) const
Definition: interpreter.h:261
DeferringSignatureChecker
Definition: interpreter.h:307
ByteUnit::T
@ T
CHashWriter
A writer stream (for serialization) that computes a 256-bit hash.
Definition: hash.h:100
DeferringSignatureChecker::CheckLockTime
bool CheckLockTime(const CScriptNum &nLockTime) const override
Definition: interpreter.h:325
HASHER_TAPLEAF
const CHashWriter HASHER_TAPLEAF
Hasher with tag "TapLeaf" pre-fed to it.
Definition: interpreter.cpp:1487
TAPROOT_LEAF_TAPSCRIPT
static constexpr uint8_t TAPROOT_LEAF_TAPSCRIPT
Definition: interpreter.h:230
ScriptExecutionData::m_annex_hash
uint256 m_annex_hash
Hash of the annex data.
Definition: interpreter.h:213
WITNESS_V1_TAPROOT_SIZE
static constexpr size_t WITNESS_V1_TAPROOT_SIZE
Definition: interpreter.h:227
SCRIPT_VERIFY_DERSIG
@ SCRIPT_VERIFY_DERSIG
Definition: interpreter.h:55
CheckMinimalPush
bool CheckMinimalPush(const std::vector< unsigned char > &data, opcodetype opcode)
Definition: interpreter.cpp:228
TAPROOT_CONTROL_NODE_SIZE
static constexpr size_t TAPROOT_CONTROL_NODE_SIZE
Definition: interpreter.h:232
SCRIPT_VERIFY_CHECKLOCKTIMEVERIFY
@ SCRIPT_VERIFY_CHECKLOCKTIMEVERIFY
Definition: interpreter.h:97
PrecomputedTransactionData::m_bip341_taproot_ready
bool m_bip341_taproot_ready
Whether the 5 fields above are initialized.
Definition: interpreter.h:161
FindAndDelete
int FindAndDelete(CScript &script, const CScript &b)
Definition: interpreter.cpp:253
error
bool error(const char *fmt, const Args &... args)
Definition: system.h:49
SCRIPT_VERIFY_CONST_SCRIPTCODE
@ SCRIPT_VERIFY_CONST_SCRIPTCODE
Definition: interpreter.h:128
PrecomputedTransactionData::hashSequence
uint256 hashSequence
Definition: interpreter.h:164
GenericTransactionSignatureChecker::GenericTransactionSignatureChecker
GenericTransactionSignatureChecker(const T *txToIn, unsigned int nInIn, const CAmount &amountIn, MissingDataBehavior mdb)
Definition: interpreter.h:296
ScriptExecutionData::m_validation_weight_left_init
bool m_validation_weight_left_init
Whether m_validation_weight_left is initialized.
Definition: interpreter.h:216
ScriptExecutionData::m_output_hash
std::optional< uint256 > m_output_hash
The hash of the corresponding output.
Definition: interpreter.h:221
SCRIPT_VERIFY_NULLFAIL
@ SCRIPT_VERIFY_NULLFAIL
Definition: interpreter.h:120
VerifyScript
bool VerifyScript(const CScript &scriptSig, const CScript &scriptPubKey, const CScriptWitness *witness, unsigned int flags, const BaseSignatureChecker &checker, ScriptError *serror=nullptr)
Definition: interpreter.cpp:1972
BaseSignatureChecker::CheckLockTime
virtual bool CheckLockTime(const CScriptNum &nLockTime) const
Definition: interpreter.h:256
SCRIPT_VERIFY_STRICTENC
@ SCRIPT_VERIFY_STRICTENC
Definition: interpreter.h:52
TAPROOT_CONTROL_MAX_NODE_COUNT
static constexpr size_t TAPROOT_CONTROL_MAX_NODE_COUNT
Definition: interpreter.h:233
SIGHASH_DEFAULT
@ SIGHASH_DEFAULT
Taproot only; implied when sighash byte is missing, and equivalent to SIGHASH_ALL.
Definition: interpreter.h:33
GenericTransactionSignatureChecker::VerifySchnorrSignature
virtual bool VerifySchnorrSignature(Span< const unsigned char > sig, const XOnlyPubKey &pubkey, const uint256 &sighash) const
Definition: interpreter.cpp:1667