6 #ifndef BITCOIN_SCRIPT_INTERPRETER_H 7 #define BITCOIN_SCRIPT_INTERPRETER_H 182 void Init(
const T& tx, std::vector<CTxOut>&& spent_outputs,
bool force =
false);
298 bool CheckECDSASignature(
const std::vector<unsigned char>& scriptSig,
const std::vector<unsigned char>& vchPubKey,
const CScript& scriptCode,
SigVersion sigversion)
const override;
352 #endif // BITCOIN_SCRIPT_INTERPRETER_H virtual bool CheckECDSASignature(const std::vector< unsigned char > &scriptSig, const std::vector< unsigned char > &vchPubKey, const CScript &scriptCode, SigVersion sigversion) const
static const std::string sighash
Witness v0 (P2WPKH and P2WSH); see BIP 141.
virtual bool CheckLockTime(const CScriptNum &nLockTime) const
const BaseSignatureChecker & m_checker
virtual ~BaseSignatureChecker()
bool CheckLockTime(const CScriptNum &nLockTime) const override
Witness v1 with 32-byte program, not BIP16 P2SH-wrapped, key path spending; see BIP 341...
bool VerifyScript(const CScript &scriptSig, const CScript &scriptPubKey, const CScriptWitness *witness, unsigned int flags, const BaseSignatureChecker &checker, ScriptError *serror=nullptr)
const HashWriter HASHER_TAPLEAF
Hasher with tag "TapLeaf" pre-fed to it.
enum ScriptError_t ScriptError
virtual bool VerifySchnorrSignature(Span< const unsigned char > sig, const XOnlyPubKey &pubkey, const uint256 &sighash) const
const MissingDataBehavior m_mdb
static constexpr size_t WITNESS_V1_TAPROOT_SIZE
std::optional< uint256 > m_output_hash
The hash of the corresponding output.
bool CheckSchnorrSignature(Span< const unsigned char > sig, Span< const unsigned char > pubkey, SigVersion sigversion, ScriptExecutionData &execdata, ScriptError *serror=nullptr) const override
uint256 m_spent_amounts_single_hash
virtual bool CheckSchnorrSignature(Span< const unsigned char > sig, Span< const unsigned char > pubkey, SigVersion sigversion, ScriptExecutionData &execdata, ScriptError *serror=nullptr) const
bool m_annex_present
Whether an annex is present.
uint256 SignatureHash(const CScript &scriptCode, const T &txTo, unsigned int nIn, int nHashType, const CAmount &amount, SigVersion sigversion, const PrecomputedTransactionData *cache=nullptr)
uint256 ComputeTapleafHash(uint8_t leaf_version, Span< const unsigned char > script)
Compute the BIP341 tapleaf hash from leaf version & script.
DeferringSignatureChecker(const BaseSignatureChecker &checker)
int64_t m_validation_weight_left
How much validation weight is left (decremented for every successful non-empty signature check)...
std::vector< CTxOut > m_spent_outputs
static constexpr uint8_t TAPROOT_LEAF_TAPSCRIPT
bool CheckSignatureEncoding(const std::vector< unsigned char > &vchSig, unsigned int flags, ScriptError *serror)
Bare scripts and BIP16 P2SH-wrapped redeemscripts.
Witness v1 with 32-byte program, not BIP16 P2SH-wrapped, script path spending, leaf version 0xc0; see...
static constexpr size_t TAPROOT_CONTROL_BASE_SIZE
Taproot only; implied when sighash byte is missing, and equivalent to SIGHASH_ALL.
uint32_t m_codeseparator_pos
Opcode position of the last executed OP_CODESEPARATOR (or 0xFFFFFFFF if none executed).
bool CheckECDSASignature(const std::vector< unsigned char > &scriptSig, const std::vector< unsigned char > &vchPubKey, const CScript &scriptCode, SigVersion sigversion) const override
static constexpr size_t TAPROOT_CONTROL_NODE_SIZE
uint256 ComputeTapbranchHash(Span< const unsigned char > a, Span< const unsigned char > b)
Compute the BIP341 tapbranch hash from two branches.
int64_t CAmount
Amount in satoshis (Can be negative)
bool m_annex_init
Whether m_annex_present and (when needed) m_annex_hash are initialized.
uint256 m_tapleaf_hash
The tapleaf hash.
bool CheckSequence(const CScriptNum &nSequence) const override
virtual bool VerifyECDSASignature(const std::vector< unsigned char > &vchSig, const CPubKey &vchPubKey, const uint256 &sighash) const
Abort execution through assertion failure (for consensus code)
const PrecomputedTransactionData * txdata
void Init(const T &tx, std::vector< CTxOut > &&spent_outputs, bool force=false)
Initialize this PrecomputedTransactionData with transaction data.
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)
static constexpr uint8_t TAPROOT_LEAF_MASK
A writer stream (for serialization) that computes a 256-bit hash.
An encapsulated public key.
bool m_bip143_segwit_ready
Whether the 3 fields above are initialized.
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.
uint256 m_outputs_single_hash
bool CheckLockTime(const CScriptNum &nLockTime) const override
Just act as if the signature was invalid.
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)
MissingDataBehavior
Enum to specify what *TransactionSignatureChecker's behavior should be when dealing with missing tran...
bool CheckECDSASignature(const std::vector< unsigned char > &scriptSig, const std::vector< unsigned char > &vchPubKey, const CScript &scriptCode, SigVersion sigversion) const override
An output of a transaction.
static constexpr size_t WITNESS_V0_SCRIPTHASH_SIZE
Signature hash sizes.
bool m_bip341_taproot_ready
Whether the 5 fields above are initialized.
static constexpr size_t TAPROOT_CONTROL_MAX_SIZE
bool m_codeseparator_pos_init
Whether m_codeseparator_pos is initialized.
const HashWriter HASHER_TAPBRANCH
Hasher with tag "TapBranch" pre-fed to it.
bool CheckSchnorrSignature(Span< const unsigned char > sig, Span< const unsigned char > pubkey, SigVersion sigversion, ScriptExecutionData &execdata, ScriptError *serror=nullptr) const override
GenericTransactionSignatureChecker(const T *txToIn, unsigned int nInIn, const CAmount &amountIn, MissingDataBehavior mdb)
static constexpr size_t TAPROOT_CONTROL_MAX_NODE_COUNT
size_t CountWitnessSigOps(const CScript &scriptSig, const CScript &scriptPubKey, const CScriptWitness *witness, unsigned int flags)
bool error(const char *fmt, const Args &... args)
Serialized script, used inside transaction inputs and outputs.
static constexpr size_t WITNESS_V0_KEYHASH_SIZE
bool m_spent_outputs_ready
Whether m_spent_outputs is initialized.
const HashWriter HASHER_TAPSIGHASH
Hasher with tag "TapSighash" pre-fed to it.
virtual bool CheckSequence(const CScriptNum &nSequence) const
bool m_tapleaf_hash_init
Whether m_tapleaf_hash is initialized.
int FindAndDelete(CScript &script, const CScript &b)
GenericTransactionSignatureChecker(const T *txToIn, unsigned int nInIn, const CAmount &amountIn, const PrecomputedTransactionData &txdataIn, MissingDataBehavior mdb)
PrecomputedTransactionData()=default
The basic transaction that is broadcasted on the network and contained in blocks. ...
bool CheckSequence(const CScriptNum &nSequence) const override
uint256 m_spent_scripts_single_hash
uint256 m_sequences_single_hash
uint256 m_prevouts_single_hash
uint256 m_annex_hash
Hash of the annex data.
bool m_validation_weight_left_init
Whether m_validation_weight_left is initialized.