22.8 C
New York
Wednesday, April 23, 2025

What values does CHECKTEMPLATEVERIFY hash


The obligatory attributes (nVersion, nLockTime, vin size, nSequence, vout size, outputs, and enter index) are all the time dedicated to within the DefaultCheckTemplateVerifyHash.

The scriptSig hash is optionally available and solely included if scriptSigs are current within the inputs. If absent, it’s completely elided from the computation.
This design ensures that the transaction matches the precise template whereas permitting optionally available attributes for optimization and suppleness in contexts like SegWit.

Attributes that have to be checked (Necessary):

Transaction Model (nVersion):
The model of the transaction have to be included within the hash. This ensures that any modifications to the transaction model are explicitly dedicated.

Transaction Locktime (nLockTime):
The locktime is included to forestall arbitrary delays in spending the output or malleating the TXID.

Enter Rely (vin size):
The variety of inputs within the transaction should precisely match the enter depend dedicated within the template hash.

Sequence Numbers (nSequence):
The sequence numbers of all inputs are hashed and included. This ensures that relative locktimes in inputs are preserved and prevents malleability.

Output Rely (vout size):
The variety of outputs within the transaction should precisely match the dedicated output depend.

Outputs (vout):
The outputs (quantities and scriptPubKeys) are hashed and included within the hash. This ensures that the spending transaction produces precisely the desired outputs.

Enter Index (nIn):
The present enter index being spent is included within the hash to forestall malleability and guarantee uniqueness of the spending transaction.

ScriptSig Hash (if current):
If any of the inputs have non-empty scriptSigs, the hash of all scriptSigs is included. This ensures that the spending transaction is dedicated to these precise scriptSigs.

Attributes which might be optionally available:

ScriptSig Hash (if absent):
If all inputs have empty scriptSigs (e.g., in SegWit transactions), the scriptSig hash is omitted from the computation.

Precomputed Knowledge:
For optimization and stopping Denial-of-Service (DoS) vulnerabilities, precomputed hashes for sequences, outputs, and scriptSigs (if any) are cached. Whereas this isn’t strictly a part of the validation logic, implementations should use cached knowledge to enhance efficiency.

Different examples right here:
https://github.com/jamesob/simple-ctv-vault/blob/7dd6c4ca25debb2140cdefb79b302c65d1b24937/essential.py#L570

And right here:
https://github.com/stutxo/op_ctv_payment_pool/blob/f85377eb3cbd2684adbbb5dfa5a86a1221444bd7/src/ctv_scripts.rs#L30

Value testing the spec as properly: https://github.com/bitcoin/bips/blob/grasp/bip-0119.mediawiki

Related Articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest Articles