@@ -15,6 +15,7 @@ const DEFAULT_LDK_WALLET_SYNC_INTERVAL_SECS: u64 = 30;
15
15
const DEFAULT_FEE_RATE_CACHE_UPDATE_INTERVAL_SECS : u64 = 60 * 10 ;
16
16
const DEFAULT_PROBING_LIQUIDITY_LIMIT_MULTIPLIER : u64 = 3 ;
17
17
const DEFAULT_LOG_LEVEL : LogLevel = LogLevel :: Debug ;
18
+ const DEFAULT_ANCHOR_PER_CHANNEL_RESERVE_SATS : u64 = 25_000 ;
18
19
19
20
// The 'stop gap' parameter used by BDK's wallet sync. This seems to configure the threshold
20
21
// number of derivation indexes after which BDK stops looking for new scripts belonging to the wallet.
@@ -104,6 +105,17 @@ pub struct Config {
104
105
///
105
106
/// Any messages below this level will be excluded from the logs.
106
107
pub log_level : LogLevel ,
108
+ /// Configuration options pertaining to 'Anchor' channels, i.e., channels for which the
109
+ /// `option_anchors_zero_fee_htlc_tx` channel type is negotiated.
110
+ ///
111
+ /// If set to `None`, new channels will be negotiated with the legacy `option_static_remotekey` channel type.
112
+ ///
113
+ /// TODO: improve docs/explanation of Anchor channels.
114
+ ///
115
+ /// See [`BOLT 3`] for more information.
116
+ ///
117
+ /// [`BOLT3`]: https://github.com/lightning/bolts/blob/master/03-transactions.md#htlc-timeout-and-htlc-success-transactions
118
+ pub anchor_channels_config : Option < AnchorChannelsConfig > ,
107
119
}
108
120
109
121
impl Default for Config {
@@ -120,6 +132,44 @@ impl Default for Config {
120
132
trusted_peers_0conf : Vec :: new ( ) ,
121
133
probing_liquidity_limit_multiplier : DEFAULT_PROBING_LIQUIDITY_LIMIT_MULTIPLIER ,
122
134
log_level : DEFAULT_LOG_LEVEL ,
135
+ anchor_channels_config : Some ( AnchorChannelsConfig :: default ( ) ) ,
136
+ }
137
+ }
138
+ }
139
+
140
+ /// Configuration options pertaining to 'Anchor' channels, i.e., channels for which the
141
+ /// `option_anchors_zero_fee_htlc_tx` channel type is negotiated.
142
+ ///
143
+ /// ### Defaults
144
+ ///
145
+ /// | Parameter | Value |
146
+ /// |--------------------------|--------|
147
+ /// | trusted_peers_no_reserve | [] |
148
+ /// | per_channel_reserve_sats | 25000 |
149
+ ///
150
+ #[ derive( Debug , Clone ) ]
151
+ pub struct AnchorChannelsConfig {
152
+ /// A list of peers which we trust to spend the anchor output *for us* on channel closing.
153
+ ///
154
+ /// Channels with these peers won't count towards the retained on-chain reserve.
155
+ ///
156
+ /// **Note:** Trusting the channel counterparty to spend the anchor output is potentially
157
+ /// insecure as the channel may not be closed if they refuse to do so, potentially leaving the
158
+ /// user funds stuck.
159
+ pub trusted_peers_no_reserve : Vec < PublicKey > ,
160
+ /// The amount of satoshis we keep as an emergency reserve in our on-chain wallet in order to
161
+ /// be able to spend the Anchor output on channel close.
162
+ ///
163
+ /// Note that, depending on the fee market at the time of closure, this amount might or might
164
+ /// not suffice to successfully spend the Anchor output.
165
+ pub per_channel_reserve_sats : u64 ,
166
+ }
167
+
168
+ impl Default for AnchorChannelsConfig {
169
+ fn default ( ) -> Self {
170
+ Self {
171
+ trusted_peers_no_reserve : Vec :: new ( ) ,
172
+ per_channel_reserve_sats : DEFAULT_ANCHOR_PER_CHANNEL_RESERVE_SATS ,
123
173
}
124
174
}
125
175
}
0 commit comments