@@ -143,6 +143,7 @@ pub(crate) const LNURL_AUTH_TIMEOUT_SECS: u64 = 15;
143143/// | `announcement_addresses` | None |
144144/// | `node_alias` | None |
145145/// | `trusted_peers_0conf` | [] |
146+ /// | `enable_v2_channel_close` | false |
146147/// | `probing_liquidity_limit_multiplier` | 3 |
147148/// | `anchor_channels_config` | AnchorChannelsConfig::default() |
148149/// | `route_parameters` | None |
@@ -182,6 +183,10 @@ pub struct Config {
182183 /// funding transaction ends up never being confirmed on-chain. Zero-confirmation channels
183184 /// should therefore only be accepted from trusted peers.
184185 pub trusted_peers_0conf : Vec < PublicKey > ,
186+ /// Whether to enable the `option_simple_close` protocol for cooperative channel closures.
187+ ///
188+ /// The protocol will only be used when supported by the channel counterparty.
189+ pub enable_v2_channel_close : bool ,
185190 /// The liquidity factor by which we filter the outgoing channels used for sending probes.
186191 ///
187192 /// Channels with available liquidity less than the required amount times this value won't be
@@ -222,6 +227,7 @@ impl Default for Config {
222227 listening_addresses : None ,
223228 announcement_addresses : None ,
224229 trusted_peers_0conf : Vec :: new ( ) ,
230+ enable_v2_channel_close : false ,
225231 probing_liquidity_limit_multiplier : DEFAULT_PROBING_LIQUIDITY_LIMIT_MULTIPLIER ,
226232 anchor_channels_config : AnchorChannelsConfig :: default ( ) ,
227233 tor_config : None ,
@@ -428,6 +434,7 @@ pub(crate) fn default_user_config(config: &Config) -> UserConfig {
428434 user_config. channel_handshake_config . negotiate_anchor_zero_fee_commitments =
429435 config. anchor_channels_config . enable_zero_fee_commitments ;
430436 user_config. reject_inbound_splices = false ;
437+ user_config. enable_v2_channel_close = config. enable_v2_channel_close ;
431438
432439 if may_announce_channel ( config) . is_err ( ) {
433440 user_config. accept_forwards_to_priv_channels = false ;
@@ -776,9 +783,9 @@ mod tests {
776783 use std:: str:: FromStr ;
777784
778785 use super :: {
779- clamp_full_scan_stop_gap, may_announce_channel, AnnounceError , Config , ElectrumSyncConfig ,
780- EsploraSyncConfig , NodeAlias , SocketAddress , DEFAULT_FULL_SCAN_STOP_GAP ,
781- MAX_FULL_SCAN_STOP_GAP , MIN_FULL_SCAN_STOP_GAP ,
786+ clamp_full_scan_stop_gap, default_user_config , may_announce_channel, AnnounceError , Config ,
787+ ElectrumSyncConfig , EsploraSyncConfig , NodeAlias , SocketAddress ,
788+ DEFAULT_FULL_SCAN_STOP_GAP , MAX_FULL_SCAN_STOP_GAP , MIN_FULL_SCAN_STOP_GAP ,
782789 } ;
783790
784791 #[ test]
@@ -844,4 +851,16 @@ mod tests {
844851 assert_eq ! ( clamp_full_scan_stop_gap( 0 ) , MIN_FULL_SCAN_STOP_GAP ) ;
845852 assert_eq ! ( clamp_full_scan_stop_gap( MAX_FULL_SCAN_STOP_GAP + 1 ) , MAX_FULL_SCAN_STOP_GAP ) ;
846853 }
854+
855+ #[ test]
856+ fn v2_channel_close_config ( ) {
857+ let default_config = Config :: default ( ) ;
858+ assert ! ( !default_user_config( & default_config) . enable_v2_channel_close) ;
859+
860+ let enabled_config = Config { enable_v2_channel_close : true , ..Config :: default ( ) } ;
861+ assert ! (
862+ default_user_config( & enabled_config) . enable_v2_channel_close,
863+ "v2 channel close opt-in must be forwarded to LDK"
864+ ) ;
865+ }
847866}
0 commit comments