@@ -48,21 +48,63 @@ 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.
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 to low hundreds of blocks
53
+ /// to get our transaction on-chain, but we shouldn't risk too low a fee - this should be a relatively high priority
54
+ /// feerate.
55
+ OnChainSweep ,
56
+ /// The highest fee rate we will allow our channel counterparty to have in a non-anchor channel.
54
57
///
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 ,
58
+ /// This is the feerate on the transaction which we (or our counterparty) will broadcast in order to
59
+ /// close the channel if a channel party goes away. Because our counterparty must ensure they can
60
+ /// always broadcast the latest state, this value being too low will cause immediate force-closures.
61
+ ///
62
+ /// Allowing this value to be too high can allow our counterparty to burn our HTLC outputs to dust, which
63
+ /// can result in HTLCs failing or force-closures (when the dust HTLCs exceed
64
+ /// [`ChannelConfig::max_dust_htlc_exposure`]).
65
+ ///
66
+ /// Because most nodes use a feerate estimate which is based on a relatively high priority transaction
67
+ /// entering the current mempool, setting this to a small multiple of your current high priority feerate estimate
68
+ /// should suffice.
69
+ ///
70
+ /// [`ChannelConfig::max_dust_htlc_exposure`]: crate::ln::channelmanager::ChannelConfig::max_dust_htlc_exposure
71
+ MaxAllowedNonAnchorChannelRemoteFee ,
72
+ /// This needs to be sufficient to get into the mempool/get confirmed when the channel needs to
73
+ /// be force-closed. Setting too low may result in force-closures. Because this is for anchor
74
+ /// channels, it can be a low value as we can always bump the fee rate later.
75
+ ///
76
+ /// A good estimate is the expected mempool minimum at the time of force-closure.
77
+ MinAllowedAnchorChannelRemoteFee ,
78
+ /// The lowest fee rate we will allow our channel counterparty to have in a non-anchor channel.
79
+ /// This needs to be sufficient to get into the mempool/get confirmed when the channel needs to
80
+ /// be force-closed. Setting too low may result in force-closures.
81
+ ///
82
+ /// A good estimate is at least within a day (144) or so worth of blocks.
83
+ MinAllowedNonAnchorChannelRemoteFee ,
84
+ /// Fee rate to use for anchor channels. This is safe to be the mempool minimum when the channel
85
+ /// needs to be force-closed.
86
+ ///
87
+ /// This is the feerate for the pre-signed transactions which we will broadcast in the event of
88
+ /// a force-closure, and needs to be sufficient at that time.
89
+ AnchorChannelFee ,
90
+ /// Lightning is built around the ability to broadcast a transaction in the future to close our channel
91
+ /// and claim all pending funds. In order to do so, pre-anchor channels are built with transactions which
92
+ /// we need to be able to broadcast at some point in the future.
93
+ ///
94
+ /// This feerate represents the fee we pick now, which must be sufficient to enter a block at an arbitrary
95
+ /// time in the future. Obviously this is not an estimate which is very easy to calculate, so most lightning
96
+ /// nodes use some relatively high-priority feerate using the current mempool. This leaves channels
97
+ /// subject to being unable to close if feerates rise, and in general you should prefer anchor channels to
98
+ /// ensure you can increase the feerate when the transactions need broadcasting.
99
+ NonAnchorChannelFee ,
100
+ /// When cooperative closing channel, the minimum fee rate we will accept. Recommended at least
101
+ /// within a day or so worth of blocks.
102
+ ///
103
+ /// This will also be used when initiating a cooperative close of a channel. When closing a channel
104
+ /// you can override this fee by using [`ChannelManager::close_channel_with_feerate_and_script`].
105
+ ///
106
+ /// [`ChannelManager::close_channel_with_feerate_and_script`]: crate::ln::channelmanager::ChannelManager::close_channel_with_feerate_and_script
107
+ ChannelCloseMinimum ,
66
108
}
67
109
68
110
/// A trait which should be implemented to provide feerate information on a number of time
@@ -135,7 +177,7 @@ mod tests {
135
177
let test_fee_estimator = & TestFeeEstimator { sat_per_kw } ;
136
178
let fee_estimator = LowerBoundedFeeEstimator :: new ( test_fee_estimator) ;
137
179
138
- assert_eq ! ( fee_estimator. bounded_sat_per_1000_weight( ConfirmationTarget :: Background ) , FEERATE_FLOOR_SATS_PER_KW ) ;
180
+ assert_eq ! ( fee_estimator. bounded_sat_per_1000_weight( ConfirmationTarget :: AnchorChannelFee ) , FEERATE_FLOOR_SATS_PER_KW ) ;
139
181
}
140
182
141
183
#[ test]
@@ -144,6 +186,6 @@ mod tests {
144
186
let test_fee_estimator = & TestFeeEstimator { sat_per_kw } ;
145
187
let fee_estimator = LowerBoundedFeeEstimator :: new ( test_fee_estimator) ;
146
188
147
- assert_eq ! ( fee_estimator. bounded_sat_per_1000_weight( ConfirmationTarget :: Background ) , sat_per_kw) ;
189
+ assert_eq ! ( fee_estimator. bounded_sat_per_1000_weight( ConfirmationTarget :: AnchorChannelFee ) , sat_per_kw) ;
148
190
}
149
191
}
0 commit comments