@@ -163,7 +163,9 @@ use lightning_background_processor::process_events_async;
163163pub use lightning_invoice;
164164pub use lightning_liquidity;
165165pub use lightning_types;
166- use lightning_types:: features:: NodeFeatures as LdkNodeFeatures ;
166+ use lightning_types:: features:: {
167+ ChannelTypeFeatures , InitFeatures , NodeFeatures as LdkNodeFeatures ,
168+ } ;
167169use liquidity:: LiquiditySource ;
168170use lnurl_auth:: LnurlAuth ;
169171use logger:: { log_debug, log_error, log_info, log_trace, LdkLogger , Logger } ;
@@ -219,6 +221,19 @@ impl LeakChecker {
219221 }
220222}
221223
224+ fn peer_may_negotiate_anchor_channel_type (
225+ config : & Config , their_init_features : & InitFeatures ,
226+ ) -> bool {
227+ their_init_features. supports_anchors_zero_fee_htlc_tx ( )
228+ || ( config. anchor_channels_config . enable_zero_fee_commitments
229+ && their_init_features. supports_anchor_zero_fee_commitments ( ) )
230+ }
231+
232+ fn requires_anchor_channel_type ( channel_type : & ChannelTypeFeatures ) -> bool {
233+ channel_type. requires_anchors_zero_fee_htlc_tx ( )
234+ || channel_type. requires_anchor_zero_fee_commitments ( )
235+ }
236+
222237/// The main interface object of LDK Node, wrapping the necessary LDK and BDK functionalities.
223238///
224239/// Needs to be initialized and instantiated through [`Builder::build`].
@@ -1387,7 +1402,7 @@ impl Node {
13871402 . peer_by_node_id ( peer_node_id)
13881403 . ok_or ( Error :: ConnectionFailed ) ?
13891404 . init_features ;
1390- let anchor_channel = init_features . supports_anchors_zero_fee_htlc_tx ( ) ;
1405+ let anchor_channel = peer_may_negotiate_anchor_channel_type ( & self . config , & init_features ) ;
13911406 Ok ( new_channel_anchor_reserve_sats ( & self . config , peer_node_id, anchor_channel) )
13921407 }
13931408
@@ -2450,7 +2465,7 @@ pub(crate) fn total_anchor_channels_reserve_sats(
24502465 . contains ( & c. counterparty . node_id )
24512466 && c. channel_shutdown_state
24522467 . map_or ( true , |s| s != ChannelShutdownState :: ShutdownComplete )
2453- && c. channel_type . as_ref ( ) . map_or ( false , |t| t . requires_anchors_zero_fee_htlc_tx ( ) )
2468+ && c. channel_type . as_ref ( ) . map_or ( false , requires_anchor_channel_type )
24542469 } )
24552470 . count ( ) as u64
24562471 * config. anchor_channels_config . per_channel_reserve_sats
0 commit comments