|
| 1 | +# Fee-Bumping Reserves Recommendations for Anchor Outputs Channels |
| 2 | + |
| 3 | +The Lightning Dev Kit offers the ability to its users to open Lightning [anchor outputs](https://bitcoinops.org/en/topics/anchor-outputs/) channels (`option_anchors_zero_fee_htlc_tx`) with its counterparties. |
| 4 | + |
| 5 | +Under the Lightning security model, commitment and second-stage HTLC transactions (BOLT3's `HTLC-timeout` and `HTLC-preimage` and the corresponding spends on counterparty commitment transaction) must be realized |
| 6 | +in a time-sensitive manner if there are pending HTLCs. Lack of chain confirmation before HTLC expiration timelocks can constitute a loss of funds, as the counterparty can claim the HTLC output with a [competing |
| 7 | +transaction](https://bitcoinops.org/en/blog/waiting-for-confirmation/#policy-as-an-interface). Failure of confirmation might be provoked by blockspace demand spikes provoked by unrelated Bitcoin on-chain transaction |
| 8 | +issuers. Anchor output enables to remedy to this issue by allowing a Lightning node to dynamically adjust the feerate of its commitment and second-stage HTLC transactions in an unilateral way. |
| 9 | + |
| 10 | +However, anchor output channels are requiring from the user the provision and maintenance of fee-bumping reserves to attach feerate increase to the commitment (via a Child-Pay-For-Parent) or the |
| 11 | +second-stage HTLC transactions (via `SIGHASH_SINGLE | SIGHASH_ANYONECANPAY`). Those fee-bumping reserves should be a collection of UTXOs, of which the state and signing capabilites should be maintained |
| 12 | +on a "warm" host. A LDK user can implement management of fee-bumping reserves through the `CoinSelectionSource` and `WalletSource` traits. |
| 13 | + |
| 14 | +The accumulated satoshis value of the collection of the UTXOs must be maintained to cover sufficient transaction weight surface at high-level of network mempools feerates. |
| 15 | + |
| 16 | +A _predictive_ worst-case `feerate_per_kw` based on historical network mempools traffic must be selected. Predictive worst-case must be understood as the worst-historical network mempools |
| 17 | +feerate with an additional safety margin. A factor of 2 is a conservative estimation. |
| 18 | + |
| 19 | +The number of opened anchor outputs channels must be selected, i.e `current_opened_channels`. As of 0.0.116 release, LDK does not have a max number of opened channels enforced by default. |
| 20 | + |
| 21 | +The maximum number of HTLC outputs per-commitment transaction on both directions must be selected, i.e `max_htlc_allsides`. As of 0.0.116 release, LDK has a BOLT3's `max_accepted_htlcs` of |
| 22 | +50 (`DEFAULT_MAX_HTLCS`) and the value can be adjusted with the config setting `our_max_accepted_htlcs`. There is no LDK mechanism to limit the number of forward HTLCs (i.e offered HTLC outputs on |
| 23 | +a commitment transaction). As such `max_htlc_allsides` is `our_max_accepted_htlcs` + `483` (BOLT3 maximum for outgoing HTLCs). |
| 24 | + |
| 25 | +Each channel included in the `current_opened_channels` set has a combined transaction weight surface computed in the following (according to [BOLT3 annex](https://github.com/lightning/bolts/blob/master/03-transactions.md#appendix-a-expected-weights): |
| 26 | +- `a`: 900 WU for the base commitment fields with the 4 outputs (`output_paying_to_remote`, `output_paying_to_local`, `output_anchor`, `output_anchor`) present |
| 27 | +- `b`: 172 WU * `max_htlc_allsides` |
| 28 | +- `c`: 666 WU * `our_max_accepted_htlcs` |
| 29 | +- `d`: 706 WU * 483 |
| 30 | + |
| 31 | +If the Lightning node does not accept HTLC routing (i.e incoming HTLCs), the compomnent `c` can be assigned a 0 value. |
| 32 | + |
| 33 | +The sum of `a` + `b` + `c` + `d` is called `max_channel_weight_surface`, a worst-case estimation of the transaction weight surface to fee-bump. |
| 34 | + |
| 35 | +To obtain the amount in satoshis that must be maintained as fee-bumping reserves, the following equation can be resolved: |
| 36 | + |
| 37 | + `current_opened_channel` * `max_channel_weight_surface` * `worst_case_feerate_per_kw` / 1000 |
| 38 | + |
| 39 | +The `worst_case_feerate_per_kw` is a conservative estimation of the level of fee-bumping reserves that must be maintained. A Lightning node operator may ponder this level of |
| 40 | +reserves with its subjective timevalue cost of the immobilized satoshis capital. |
| 41 | + |
| 42 | +Those fee-bumping reserves recommendations do assume Taproot channel type usage, where the weight of the channel transactions weight are modified due to P2TR scriptpubkeys and corresponding |
| 43 | +witness spends. |
0 commit comments