@@ -70,6 +70,7 @@ pub struct Config {
7070 pub pathfinding_scores_source_url : Option < String > ,
7171 pub probing_config : Option < ProbingConfig > ,
7272 pub async_payments_role : Option < AsyncPaymentsRole > ,
73+ pub enable_zero_fee_commitments : bool ,
7374 pub metrics_enabled : bool ,
7475 pub poll_metrics_interval : Option < u64 > ,
7576 pub metrics_username : Option < String > ,
@@ -144,6 +145,7 @@ struct ConfigBuilder {
144145 pathfinding_scores_source_url : Option < String > ,
145146 probing : Option < ProbingTomlConfig > ,
146147 async_payments_role : Option < String > ,
148+ enable_zero_fee_commitments : Option < bool > ,
147149 metrics_enabled : Option < bool > ,
148150 poll_metrics_interval : Option < u64 > ,
149151 metrics_username : Option < String > ,
@@ -167,6 +169,8 @@ impl ConfigBuilder {
167169 node. pathfinding_scores_source_url . or ( self . pathfinding_scores_source_url . clone ( ) ) ;
168170 self . async_payments_role =
169171 node. async_payments_role . or ( self . async_payments_role . clone ( ) ) ;
172+ self . enable_zero_fee_commitments =
173+ node. enable_zero_fee_commitments . or ( self . enable_zero_fee_commitments ) ;
170174 self . rgs_server_url = node. rgs_server_url . or ( self . rgs_server_url . clone ( ) ) ;
171175 }
172176
@@ -286,6 +290,10 @@ impl ConfigBuilder {
286290 self . async_payments_role = Some ( async_payments_role. clone ( ) ) ;
287291 }
288292
293+ if let Some ( enable_zero_fee_commitments) = args. node_enable_zero_fee_commitments {
294+ self . enable_zero_fee_commitments = Some ( enable_zero_fee_commitments) ;
295+ }
296+
289297 if args. has_probing_options ( ) {
290298 let probing = self . probing . get_or_insert_with ( ProbingTomlConfig :: default) ;
291299 if let Some ( probing_strategy) = & args. probing_strategy {
@@ -595,6 +603,7 @@ impl ConfigBuilder {
595603 pathfinding_scores_source_url,
596604 probing_config,
597605 async_payments_role,
606+ enable_zero_fee_commitments : self . enable_zero_fee_commitments . unwrap_or ( false ) ,
598607 metrics_enabled,
599608 poll_metrics_interval,
600609 metrics_username,
@@ -633,6 +642,7 @@ struct NodeConfig {
633642 alias : Option < String > ,
634643 pathfinding_scores_source_url : Option < String > ,
635644 async_payments_role : Option < String > ,
645+ enable_zero_fee_commitments : Option < bool > ,
636646 rgs_server_url : Option < String > ,
637647}
638648
@@ -1110,6 +1120,13 @@ pub struct ArgsConfig {
11101120 ) ]
11111121 node_async_payments_role : Option < String > ,
11121122
1123+ #[ arg(
1124+ long,
1125+ env = "LDK_SERVER_NODE_ENABLE_ZERO_FEE_COMMITMENTS" ,
1126+ help = "Whether to enable zero-fee commitment channels. Defaults to false."
1127+ ) ]
1128+ node_enable_zero_fee_commitments : Option < bool > ,
1129+
11131130 #[ arg(
11141131 long,
11151132 env = "LDK_SERVER_PROBING_STRATEGY" ,
@@ -1289,6 +1306,7 @@ mod tests {
12891306 alias = "LDK Server"
12901307 rgs_server_url = "https://rapidsync.lightningdevkit.org/snapshot/v2/"
12911308 async_payments_role = "client"
1309+ enable_zero_fee_commitments = true
12921310
12931311 [tls]
12941312 cert_path = "/path/to/tls.crt"
@@ -1348,6 +1366,7 @@ mod tests {
13481366 node_alias : Some ( String :: from ( "LDK Server CLI" ) ) ,
13491367 pathfinding_scores_source_url : Some ( String :: from ( "https://example.com/" ) ) ,
13501368 node_async_payments_role : Some ( String :: from ( "server" ) ) ,
1369+ node_enable_zero_fee_commitments : Some ( false ) ,
13511370 probing_strategy : None ,
13521371 probing_top_node_count : None ,
13531372 probing_max_hops : None ,
@@ -1383,6 +1402,7 @@ mod tests {
13831402 storage_dir_path : None ,
13841403 pathfinding_scores_source_url : None ,
13851404 node_async_payments_role : None ,
1405+ node_enable_zero_fee_commitments : None ,
13861406 probing_strategy : None ,
13871407 probing_top_node_count : None ,
13881408 probing_max_hops : None ,
@@ -1497,6 +1517,7 @@ mod tests {
14971517 pathfinding_scores_source_url : None ,
14981518 probing_config : None ,
14991519 async_payments_role : Some ( AsyncPaymentsRole :: Client ) ,
1520+ enable_zero_fee_commitments : true ,
15001521 metrics_enabled : false ,
15011522 poll_metrics_interval : None ,
15021523 metrics_username : None ,
@@ -1522,6 +1543,7 @@ mod tests {
15221543 assert_eq ! ( config. log_file_path, expected. log_file_path) ;
15231544 assert_eq ! ( config. pathfinding_scores_source_url, expected. pathfinding_scores_source_url) ;
15241545 assert ! ( matches!( config. async_payments_role, Some ( AsyncPaymentsRole :: Client ) ) ) ;
1546+ assert_eq ! ( config. enable_zero_fee_commitments, expected. enable_zero_fee_commitments) ;
15251547 assert_eq ! ( config. metrics_enabled, expected. metrics_enabled) ;
15261548 assert_eq ! ( config. tor_config, expected. tor_config) ;
15271549
@@ -1731,7 +1753,8 @@ mod tests {
17311753 "# ;
17321754
17331755 fs:: write ( storage_path. join ( config_file_name) , toml_config) . unwrap ( ) ;
1734- assert ! ( load_config( & args_config) . is_ok( ) ) ;
1756+ let config = load_config ( & args_config) . unwrap ( ) ;
1757+ assert ! ( !config. enable_zero_fee_commitments) ;
17351758 }
17361759
17371760 #[ test]
@@ -1939,6 +1962,7 @@ mod tests {
19391962 pathfinding_scores_source_url : Some ( "https://example.com/" . to_string ( ) ) ,
19401963 probing_config : None ,
19411964 async_payments_role : Some ( AsyncPaymentsRole :: Server ) ,
1965+ enable_zero_fee_commitments : false ,
19421966 metrics_enabled : false ,
19431967 poll_metrics_interval : None ,
19441968 metrics_username : None ,
@@ -1961,6 +1985,7 @@ mod tests {
19611985 assert ! ( config. lsps2_service_config. is_none( ) ) ;
19621986 assert_eq ! ( config. pathfinding_scores_source_url, expected. pathfinding_scores_source_url) ;
19631987 assert ! ( matches!( config. async_payments_role, Some ( AsyncPaymentsRole :: Server ) ) ) ;
1988+ assert_eq ! ( config. enable_zero_fee_commitments, expected. enable_zero_fee_commitments) ;
19641989 assert_eq ! ( config. metrics_enabled, expected. metrics_enabled) ;
19651990 assert_eq ! ( config. tor_config, expected. tor_config) ;
19661991 assert_eq ! ( config. log_max_size_bytes, expected. log_max_size_bytes) ;
@@ -2059,6 +2084,7 @@ mod tests {
20592084 pathfinding_scores_source_url : Some ( "https://example.com/" . to_string ( ) ) ,
20602085 probing_config : None ,
20612086 async_payments_role : Some ( AsyncPaymentsRole :: Server ) ,
2087+ enable_zero_fee_commitments : false ,
20622088 metrics_enabled : false ,
20632089 poll_metrics_interval : None ,
20642090 metrics_username : None ,
@@ -2085,6 +2111,7 @@ mod tests {
20852111 assert_eq ! ( config. lsps2_service_config. is_some( ) , expected. lsps2_service_config. is_some( ) ) ;
20862112 assert_eq ! ( config. pathfinding_scores_source_url, expected. pathfinding_scores_source_url) ;
20872113 assert ! ( matches!( config. async_payments_role, Some ( AsyncPaymentsRole :: Server ) ) ) ;
2114+ assert_eq ! ( config. enable_zero_fee_commitments, expected. enable_zero_fee_commitments) ;
20882115 assert_eq ! ( config. metrics_enabled, expected. metrics_enabled) ;
20892116 assert_eq ! ( config. tor_config, expected. tor_config) ;
20902117 }
@@ -2490,6 +2517,20 @@ mod tests {
24902517 assert_eq ! ( args_config. probing_cooldown_secs, Some ( 1800 ) ) ;
24912518 }
24922519
2520+ #[ test]
2521+ fn test_accepts_zero_fee_commitments_arg ( ) {
2522+ for ( value, expected) in [ ( "true" , true ) , ( "false" , false ) ] {
2523+ let args_config = ArgsConfig :: try_parse_from ( [
2524+ "ldk-server" ,
2525+ "--node-enable-zero-fee-commitments" ,
2526+ value,
2527+ ] )
2528+ . unwrap ( ) ;
2529+
2530+ assert_eq ! ( args_config. node_enable_zero_fee_commitments, Some ( expected) ) ;
2531+ }
2532+ }
2533+
24932534 #[ test]
24942535 fn test_probing_args_override_strategy_specific_file_options ( ) {
24952536 let mut builder = ConfigBuilder {
0 commit comments