|
11 | 11 | //!
|
12 | 12 | //! [`Event`]: crate::events::Event
|
13 | 13 |
|
| 14 | +//! LDK offers the ability to its users to open Lightning [anchor-output](https://bitcoinops.org/en/topics/anchor-outputs/) |
| 15 | +//! channels (`option_anchors_zero_fee_htlc_tx`) with its counterparties. |
| 16 | +//! |
| 17 | +//! Anchor output channels are requiring from the user the provisioning and maintenance of fee-bumping reserves to accommodate |
| 18 | +//! fee rate increase to the commitment (via a Child-Pay-For-Parent) or the second-stage HTLC transactions (via Replace-by-Fee). |
| 19 | +//! Those fee-bumping reserves should be a collection of UTXOs, of which the state and signing capabilites should be maintained |
| 20 | +//! on a "hot" host. A "hot" host is a computing machine with 24/7 Internet connectivity as fee-bumping UTXOs might need to be |
| 21 | +//! signed as soon as a pending HTLC is detected. A LDK user can implement management of fee-bumping reserves through the |
| 22 | +//! [`CoinSelectionSource`] and [`WalletSource`] traits. |
| 23 | +//! |
| 24 | +//! The total value of the fee-bumping reserve must be high enough to ensure channel transactions are confirmed |
| 25 | +//! in a timely fashion, even in the face of full mempool and high fee rates. Transactions might have a dynamic |
| 26 | +//! weight due to carrying HTLCs. |
| 27 | +//! |
| 28 | +//! A _predictive_ worst-case `feerate_per_kw` based on historically observed network mempools congestion must be selected. |
| 29 | +//! I.e the prediction has to include an additional safety margin. A factor of 2 is a conservative estimation. |
| 30 | +//! |
| 31 | +//! The user is always involved in any decision to open an anchor channel and in the context of fee-bumping reserves |
| 32 | +//! management the user should track them as `current_opened_channels` (the outcome of `ChannelManager::list_channels()`). |
| 33 | +//! As of 0.0.116 release, LDK does not have a max number of opened channels enforced by default. |
| 34 | +//! |
| 35 | +//! The maximum number of HTLC outputs per-commitment transaction on both directions must be selected, i.e |
| 36 | +//! `max_htlc_allsides`. As of 0.0.116 release, LDK has a BOLT3's `max_accepted_htlcs` of 50 (`DEFAULT_MAX_HTLCS`) |
| 37 | +//! and the value can be adjusted with the config setting `our_max_accepted_htlcs`. There is no LDK mechanism to |
| 38 | +//! limit the number of forward HTLCs (i.e offered HTLC outputs on a commitment transaction). As such `max_htlc_allsides` |
| 39 | +//! is `our_max_accepted_htlcs` + `483` (BOLT3 maximum for outgoing HTLCs). |
| 40 | +//! |
| 41 | +//! Each channel included in the `current_opened_channels` set has a combined transaction weight surface computed in |
| 42 | +//! the following (according to [BOLT3 annex](https://github.com/lightning/bolts/blob/master/03-transactions.md#appendix-a-expected-weights): |
| 43 | +//! - `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 |
| 44 | +//! - `b`: 172 WU * `max_htlc_allsides` |
| 45 | +//! - `c`: 666 WU * `our_max_accepted_htlcs` |
| 46 | +//! - `d`: 706 WU * 483 |
| 47 | +//! |
| 48 | +//! If the Lightning node does not accept HTLC routing (i.e incoming HTLCs), the compomnent `c` can be assigned a 0 value. |
| 49 | +//! |
| 50 | +//! The sum of `a` + `b` + `c` + `d` is called `max_channel_weight_surface`, a worst-case estimation of the transaction |
| 51 | +//! weight surface to fee-bump. |
| 52 | +//! |
| 53 | +//! To obtain the amount in satoshis that must be maintained as fee-bumping reserves, the following equation can be resolved: |
| 54 | +//! |
| 55 | +//! `current_opened_channel` * `max_channel_weight_surface` * `worst_case_feerate_per_kw` / 1000 |
| 56 | +//! |
| 57 | +//! The `worst_case_feerate_per_kw` is a conservative estimation of the level of fee-bumping reserves that must be |
| 58 | +//! maintained. A Lightning node operator may ponder this level of reserves with its subjective timevalue cost of the |
| 59 | +//! immobilized satoshis capital. |
| 60 | +//! |
| 61 | +//! Those fee-bumping reserves recommendations do not assume Taproot channel type usage, where the weight of the channel |
| 62 | +//! transactions weight are modified due to P2TR scriptpubkeys and corresponding witness spends. Those recommendations |
| 63 | +//! should be also revised in function of interactions with transaction standardness policy and its evolutions (e.g number |
| 64 | +//! of transactions allowed to be relayed as a package and as such how many LN commitment one CPFP can cover). |
| 65 | +
|
14 | 66 | use alloc::collections::BTreeMap;
|
15 | 67 | use core::ops::Deref;
|
16 | 68 |
|
|
0 commit comments