|
| 1 | +--- |
| 2 | +title: "Anchor Outputs Channels Are Here" |
| 3 | +description: "LDK v0.0.116 added support for opening channels with anchor outputs." |
| 4 | +date: "2023-08-01" |
| 5 | +authors: |
| 6 | + - Wilmer Paulino |
| 7 | +tags: |
| 8 | + - Channels |
| 9 | + - Anchor Outputs |
| 10 | + - Fees |
| 11 | +--- |
| 12 | + |
| 13 | +`v0.0.116` of LDK with added support for opening channels with [anchor |
| 14 | +outputs](https://bitcoinops.org/en/topics/anchor-outputs) is live. This much-requested feature |
| 15 | +brings multiple security and usability improvements to Lightning channels. |
| 16 | + |
| 17 | +Lightning channels rely on pre-signed transactions that participants broadcast to the network if |
| 18 | +they wish to close a channel unilaterally, e.g., when their counterparty is offline. Before |
| 19 | +introducing anchor outputs to the Lightning protocol, participants continually negotiated their |
| 20 | +commitment transaction’s fees based on the current block-space demand. This fee negotiation |
| 21 | +unfortunately came with its own set of problems. If participants disagreed on the proposed fee |
| 22 | +range, a unilateral close made the channel unusable. Underestimating the required fee could result |
| 23 | +in loss of funds if an HTLC needed to be resolved on-chain, and overestimating would misallocate the |
| 24 | +channel balance towards fees, potentially rendering the channel useless. |
| 25 | + |
| 26 | +With anchor outputs, participants can now contribute the majority of fees required at the time of |
| 27 | +broadcast by bumping the commitment transaction's fee via a child transaction using the |
| 28 | +[Child-Pays-For-Parent (CPFP)](https://bitcoinops.org/en/topics/cpfp) fee-bumping mechanism. A small |
| 29 | +portion of fees must still be allocated to commitment transactions to ensure they can enter nodes' |
| 30 | +mempools independently. This will be required until [package |
| 31 | +relay](https://bitcoinops.org/en/topics/package-relay) is deployed network-wide. At that point, we |
| 32 | +can have a fixed 1 sat/vB commitment transaction that is likely to do away with the fee negotiation |
| 33 | +once and for all, eliminating the most common cause of unilateral closes that we see today. |
| 34 | + |
| 35 | +Given LDK's modularized design, support for anchor outputs posed a few challenges. As a |
| 36 | +Lightning-only library, we do not include an on-chain wallet as a traditional node implementation |
| 37 | +would, requiring manual integration work by the application developer. However, we were able to |
| 38 | +leverage our existing [event-based |
| 39 | +API](https://docs.rs/lightning/latest/lightning/events/index.html) to communicate that a commitment |
| 40 | +or HTLC transaction's fee needs to be bumped. The handling of these events is often non-trivial, so |
| 41 | +we added a utility |
| 42 | +([`BumpTransactionEventHandler`](https://docs.rs/lightning/latest/lightning/events/bump_transaction/struct.BumpTransactionEventHandler.html)) |
| 43 | +to simplify required integration work. With this utility, an application developer only needs to |
| 44 | +provide a view into their on-chain wallet for LDK to access confirmed UTXOs and sign them. |
| 45 | + |
| 46 | +Note that node operators need to maintain a reserve of confirmed funds if they wish to exit a |
| 47 | +channel unilaterally. LDK will not ensure this reserve is enforced, but we’re exploring [possible |
| 48 | +ways to do so](https://github.com/lightningdevkit/rust-lightning/issues/2320). Without such |
| 49 | +enforcement, a node may open or accept more channels than its provisioned reserve allows it to |
| 50 | +handle, potentially resulting in a loss of funds if any HTLCs need to be resolved on-chain. In the |
| 51 | +meantime, application developers must determine whether their use case warrants such enforcement, |
| 52 | +then implement it themselves. For example, a mobile user connected to a LSP could always defer to |
| 53 | +the LSP to broadcast the latest state so that the user wouldn’t need to maintain a reserve. |
| 54 | + |
| 55 | +While the feature is now available, we still consider it experimental. We're always seeking feedback |
| 56 | +on how to improve our API and provide a better developer experience. |
| 57 | + |
0 commit comments