[BIP-draft] CHECKSEQUENCEVERIFY - An opcode for relative locktime



Summary:

The proposed BIP XX CHECKSEQUENCEVERIFY introduces a new opcode to Bitcoin's scripting language, which allows restricting the execution pathways of a script based on the age of the output being spent. The redefined NOP3 opcode compares the top item on the stack to the inverse of the nSequence field of the transaction input containing the scriptSig. If the inverse of nSequence is less than the sequence threshold, then it returns false, and if there are two types of relative lock-time: lock-by-block height and lock-by-block time, distinguished by whether txToInvSequence = LOCKTIME_THRESHOLD && nInvSequence >= LOCKTIME_THRESHOLD. An example of an escrow that times out automatically 30 days after being funded is provided, where Alice, Bob, and Escrow create a 2-of-3 address with the redeem script. After 30 days, Alice can sign alone, and the clock does not start ticking until the payment to the escrow address confirms. A reference implementation is also provided in a git repository.The deployment of the new rules is recommended to be done through the double-threshold switchover mechanism from BIPs 34 and 66, with the same thresholds but for nVersion = 4. It is also suggested to include other related proposals for improving Bitcoin's lock-time capabilities, including OP_CHECKLOCKTIMEVERIFY, consensus-enforced transaction replacement signaled via sequence numbers, and Median-Past-Time-Lock.The credit for inventing the application of sequence numbers to achieve relative lock-time goes to Mark Friedenbach, who also wrote the reference implementation of CHECKSEQUENCEVERIFY. The reference implementation and this BIP were based heavily on the work done by Peter Todd for the closely related BIP 65. The document is placed in the public domain.


Updated on: 2023-06-10T19:23:25.339884+00:00