Basic vault prototype using OP_CAT

Basic vault prototype using OP_CAT

Original Postby rijndael

Posted on: February 15, 2024 22:18 UTC

The exploration of OP_CAT for asserting transaction fields and properties has led to the development of a basic vault demonstrated through a working demo, which can be found on GitHub at taproot-wizards/purrfect_vault.

This demo showcases the application of OP_CAT in various scenarios through scripts located in the src/vault/ file. The primary focus is on enforcing consistency and validation across transactions within this vault system, utilizing the CAT-checksig technique and other specific conditions.

In the "Trigger Withdrawal" process, the system mandates the presence of two inputs (a contract input and a fee-paying input) and two outputs (a contract output with the withdrawal amount and a target address with a minimal amount). A critical validation step ensures that the first input's amount and scriptpubkey match those of the first output, maintaining transaction integrity. Additionally, it specifies that the second output must contain exactly 546 sats without imposing restrictions on its scriptpubkey, alongside enforcing an exact count of two inputs and outputs.

The "Complete Withdrawal" transaction introduces more intricate checks, particularly in ensuring that the current transaction's first output matches the scriptpubkey of the trigger transaction's second output. This involves manipulating and hashing the serialized data of the previous transaction to validate continuity and state inspection between transactions. Moreover, this stage incorporates a CSV relative timelock of 20 blocks on the first input, further adding to the security mechanisms in place.

Lastly, the "Cancel Withdrawal" transaction simplifies the process by requiring two inputs and a single output, emphasizing the matching elements between an input and an output to ensure simplicity and security. Despite some acknowledged limitations and areas for refinement within the demo, the utilization of OP_CAT to assert states and enforce rules across transactions presents an insightful look into potential applications and enhancements in blockchain transaction protocols.