Arbitrary Bitcoin Contracts over LN



Summary:

In a recent email exchange, Christian Decker and Rusty Russell discussed the need for `OP_CSV` guard to protect from CLTV-branches and nLocktimed spending transactions which may leak on-chain. The two-stage HTLC resolution introduced a first stage acting as the `OP_CSV` guard that keeps the second stage clean. The CSV belongs in the output script, not the input script. A CLTV-branch whose timeout expires before attempting on-chain mediation can lead to a race. There is no CSV in an HTLC, however. The HTLC-timeout/HTLC-success transactions (which spend from the above script), have a CSV. The CSV occurs on a transaction that is dependent on a CLTV under Poon-Dryja. The CSV does not interfere with CLTV, and its condition in the second transaction becomes complicated, requiring cleverness like eliding A from A && B && C to keep witnesses and script size down.


Updated on: 2023-05-25T02:02:16.163952+00:00