This is the first article in a series deep diving into individual covenant proposals that have reached a point of maturity meriting an in-depth breakdown.
CHECKTEMPLATEVERIFY (CTV), proposed by Jeremy Rubin with BIP 119, stands out as the most mature and comprehensive covenant proposal in the Bitcoin ecosystem. Among the various covenant proposals, CTV has been designed to address concerns regarding overly flexible covenants that could potentially have adverse effects on Bitcoin.
To grasp how CTV operates, it is essential to understand the components of a Bitcoin transaction. At a high level, a Bitcoin transaction consists of inputs (unspent coins or UTXOs) and outputs (new unspent coins created upon confirmation in a block). While there are more intricate details to transactions, this overview provides a basic understanding of their structure.
Every transaction includes a version number field for the entire transaction, a marker, and a flag indicating the use of Segwit. It also comprises an input count, actual inputs, output count, actual outputs, and a nLocktime field for applying a timelock value to the entire transaction. Additionally, Segwit transactions include a Witness section containing information related to each input’s witness data.
How CTV Works
CTV introduces an opcode that allows for basic introspection and data forwarding within covenant proposals. It enables a script to compare a pre-defined 32-byte hash against a hash generated from various fields of the spending transaction. If these hashes do not match, the transaction is deemed invalid.
The fields committed to by the CTV hash include nVersion, nLocktime, Input count, a hash of nSequence fields, Output count, a hash of all outputs, and Input index. The hash essentially covers the entire transaction except for the actual inputs, offering a restricted form of introspection.
CTV scripts can be nested, enabling data forwarding across transactions. However, this data forwarding is limited by the necessity to generate nested scripts in reverse order, starting from the final transaction in the chain.
What Is CTV Useful For
CTV allows for the restriction of an output to be spent only by a specific pre-defined transaction, eliminating the need for trust in keyholders to adhere to pre-signed transactions. This enhances efficiency, scalability, and security guarantees within the ecosystem.
By simplifying the coordination process and ensuring the correct outcome through consensus enforcement, CTV offers significant value by streamlining transaction verification and execution.
Closing Thoughts
CTV represents a tightly restricted covenant proposal that enhances the efficiency and security of transactions without introducing new functionalities beyond pre-signed transactions. Its value lies in improving existing processes and protocols, making it a valuable addition to the Bitcoin ecosystem.
Several projects have explored and implemented CTV, showcasing its maturity and practical applications within the ecosystem. Considering its benefits and alignment with Bitcoin’s core principles, CTV warrants serious consideration and adoption.
