@@ -48,21 +48,87 @@ pub trait BroadcasterInterface {
48
48
/// estimation.
49
49
#[ derive( Clone , Copy , Debug , Hash , PartialEq , Eq ) ]
50
50
pub enum ConfirmationTarget {
51
- /// We'd like a transaction to confirm in the future, but don't want to commit most of the fees
52
- /// required to do so yet. The remaining fees will come via a Child-Pays-For-Parent (CPFP) fee
53
- /// bump of the transaction.
54
- ///
55
- /// The feerate returned should be the absolute minimum feerate required to enter most node
56
- /// mempools across the network. Note that if you are not able to obtain this feerate estimate,
57
- /// you should likely use the furthest-out estimate allowed by your fee estimator.
58
- MempoolMinimum ,
59
- /// We are happy with a transaction confirming slowly, at least within a day or so worth of
60
- /// blocks.
61
- Background ,
62
- /// We'd like a transaction to confirm without major delayed, i.e., within the next 12-24 blocks.
63
- Normal ,
64
- /// We'd like a transaction to confirm in the next few blocks.
65
- HighPriority ,
51
+ /// We have some funds available on chain which we need to spend prior to some expiry time at
52
+ /// which point our counterparty may be able to steal them. Generally we have in the high tens
53
+ /// to low hundreds of blocks to get our transaction on-chain, but we shouldn't risk too low a
54
+ /// fee - this should be a relatively high priority feerate.
55
+ OnChainSweep ,
56
+ /// The highest fee rate we will allow our channel counterparty to have in a non-anchor channel.
57
+ ///
58
+ /// This is the feerate on the transaction which we (or our counterparty) will broadcast in
59
+ /// order to close the channel if a channel party goes away. Because our counterparty must
60
+ /// ensure they can always broadcast the latest state, this value being too low will cause
61
+ /// immediate force-closures.
62
+ ///
63
+ /// Allowing this value to be too high can allow our counterparty to burn our HTLC outputs to
64
+ /// dust, which can result in HTLCs failing or force-closures (when the dust HTLCs exceed
65
+ /// [`ChannelConfig::max_dust_htlc_exposure`]).
66
+ ///
67
+ /// Because most nodes use a feerate estimate which is based on a relatively high priority
68
+ /// transaction entering the current mempool, setting this to a small multiple of your current
69
+ /// high priority feerate estimate should suffice.
70
+ ///
71
+ /// [`ChannelConfig::max_dust_htlc_exposure`]: crate::util::config::ChannelConfig::max_dust_htlc_exposure
72
+ MaxAllowedNonAnchorChannelRemoteFee ,
73
+ /// This needs to be sufficient to get into the mempool when the channel needs to
74
+ /// be force-closed. Setting too low may result in force-closures. Because this is for anchor
75
+ /// channels, we can always bump the fee rate later, the feerate here only needs to suffice to
76
+ /// enter the mempool.
77
+ ///
78
+ /// This is the feerate on the transaction which we (or our counterparty) will broadcast in
79
+ /// order to close the channel if a channel party goes away. Because our counterparty must
80
+ /// ensure they can always broadcast the latest state, this value being too low will cause
81
+ /// immediate force-closures.
82
+ ///
83
+ /// A good estimate is the expected mempool minimum at the time of force-closure.
84
+ MinAllowedAnchorChannelRemoteFee ,
85
+ /// The lowest fee rate we will allow our channel counterparty to have in a non-anchor channel.
86
+ /// This needs to be sufficient to get confirmed when the channel needs to be force-closed.
87
+ /// Setting too low may result in force-closures.
88
+ ///
89
+ /// This is the feerate on the transaction which we (or our counterparty) will broadcast in
90
+ /// order to close the channel if a channel party goes away. Because our counterparty must
91
+ /// ensure they can always broadcast the latest state, this value being too low will cause
92
+ /// immediate force-closures. However this value being too high can allow our counterparty to
93
+ /// burn our HTLC outputs to dust, which can result in a LDK force closing the channel to avoid
94
+ /// losing money.
95
+ ///
96
+ /// This feerate represents the fee we pick now, which must be sufficient to enter a block at an
97
+ /// arbitrary time in the future. Obviously this is not an estimate which is very easy to
98
+ /// calculate. This can leave channels subject to being unable to close if feerates rise, and in
99
+ /// general you should prefer anchor channels to ensure you can increase the feerate when the
100
+ /// transactions need broadcasting.
101
+ MinAllowedNonAnchorChannelRemoteFee ,
102
+ /// This needs to be sufficient to get into the mempool when the channel needs to
103
+ /// be force-closed. Setting too low may result in force-closures. Because this is for anchor
104
+ /// channels, it can be a low value as we can always bump the fee rate later.
105
+ ///
106
+ /// A good estimate is the expected mempool minimum at the time of force-closure. Obviously this
107
+ /// is not an estimate which is very easy to calculate because we do not know the future. Using
108
+ /// a simple long-term fee estimate or tracking of the mempool minimum is a good approach to
109
+ /// ensure you can always close the channel. A future change to Bitcoin's P2P network
110
+ /// (package relay) may obviate the need for this entirely.
111
+ AnchorChannelFee ,
112
+ /// Lightning is built around the ability to broadcast a transaction in the future to close our
113
+ /// channel and claim all pending funds. In order to do so, pre-anchor channels are built with
114
+ /// transactions which we need to be able to broadcast at some point in the future.
115
+ ///
116
+ /// This feerate represents the fee we pick now, which must be sufficient to enter a block at an
117
+ /// arbitrary time in the future. Obviously this is not an estimate which is very easy to
118
+ /// calculate, so most lightning nodes use some relatively high-priority feerate using the
119
+ /// current mempool. This leaves channels subject to being unable to close if feerates rise, and
120
+ /// in general you should prefer anchor channels to ensure you can increase the feerate when the
121
+ /// transactions need broadcasting.
122
+ NonAnchorChannelFee ,
123
+ /// When cooperative closing channel, the minimum fee rate we will accept. Recommended at least
124
+ /// within a day or so worth of blocks.
125
+ ///
126
+ /// This will also be used when initiating a cooperative close of a channel. When closing a
127
+ /// channel you can override this fee by using
128
+ /// [`ChannelManager::close_channel_with_feerate_and_script`].
129
+ ///
130
+ /// [`ChannelManager::close_channel_with_feerate_and_script`]: crate::ln::channelmanager::ChannelManager::close_channel_with_feerate_and_script
131
+ ChannelCloseMinimum ,
66
132
}
67
133
68
134
/// A trait which should be implemented to provide feerate information on a number of time
@@ -135,7 +201,7 @@ mod tests {
135
201
let test_fee_estimator = & TestFeeEstimator { sat_per_kw } ;
136
202
let fee_estimator = LowerBoundedFeeEstimator :: new ( test_fee_estimator) ;
137
203
138
- assert_eq ! ( fee_estimator. bounded_sat_per_1000_weight( ConfirmationTarget :: Background ) , FEERATE_FLOOR_SATS_PER_KW ) ;
204
+ assert_eq ! ( fee_estimator. bounded_sat_per_1000_weight( ConfirmationTarget :: AnchorChannelFee ) , FEERATE_FLOOR_SATS_PER_KW ) ;
139
205
}
140
206
141
207
#[ test]
@@ -144,6 +210,6 @@ mod tests {
144
210
let test_fee_estimator = & TestFeeEstimator { sat_per_kw } ;
145
211
let fee_estimator = LowerBoundedFeeEstimator :: new ( test_fee_estimator) ;
146
212
147
- assert_eq ! ( fee_estimator. bounded_sat_per_1000_weight( ConfirmationTarget :: Background ) , sat_per_kw) ;
213
+ assert_eq ! ( fee_estimator. bounded_sat_per_1000_weight( ConfirmationTarget :: AnchorChannelFee ) , sat_per_kw) ;
148
214
}
149
215
}
0 commit comments