@@ -136,6 +136,9 @@ use lightning::ln::channel_state::ChannelShutdownState;
136136use lightning:: ln:: channelmanager:: PaymentId ;
137137use lightning:: ln:: msgs:: SocketAddress ;
138138use lightning:: routing:: gossip:: NodeAlias ;
139+ use lightning:: util:: anchor_channel_reserves:: {
140+ get_reserve_per_channel, AnchorChannelReserveContext ,
141+ } ;
139142use lightning:: util:: persist:: KVStoreSync ;
140143use lightning_background_processor:: process_events_async;
141144use liquidity:: { LSPS1Liquidity , LiquiditySource } ;
@@ -1069,7 +1072,7 @@ impl Node {
10691072 if init_features. requires_anchors_zero_fee_htlc_tx ( )
10701073 && !c. trusted_peers_no_reserve . contains ( & node_id)
10711074 {
1072- c . per_channel_reserve_sats
1075+ get_reserve_per_channel ( & AnchorChannelReserveContext :: default ( ) ) . to_sat ( )
10731076 } else {
10741077 0
10751078 }
@@ -1132,13 +1135,11 @@ impl Node {
11321135 /// channel counterparty on channel open. This can be useful to start out with the balance not
11331136 /// entirely shifted to one side, therefore allowing to receive payments from the getgo.
11341137 ///
1135- /// If Anchor channels are enabled, this will ensure the configured
1136- /// [`AnchorChannelsConfig::per_channel_reserve_sats`] is available and will be retained before
1137- /// opening the channel.
1138+ /// If Anchor channels are enabled, this will ensure the reserved amount per
1139+ /// channel is available and will be retained before opening the channel.
11381140 ///
11391141 /// Returns a [`UserChannelId`] allowing to locally keep track of the channel.
11401142 ///
1141- /// [`AnchorChannelsConfig::per_channel_reserve_sats`]: crate::config::AnchorChannelsConfig::per_channel_reserve_sats
11421143 pub fn open_channel (
11431144 & self , node_id : PublicKey , address : SocketAddress , channel_amount_sats : u64 ,
11441145 push_to_counterparty_msat : Option < u64 > , channel_config : Option < ChannelConfig > ,
@@ -1167,13 +1168,11 @@ impl Node {
11671168 /// channel counterparty on channel open. This can be useful to start out with the balance not
11681169 /// entirely shifted to one side, therefore allowing to receive payments from the getgo.
11691170 ///
1170- /// If Anchor channels are enabled, this will ensure the configured
1171- /// [`AnchorChannelsConfig::per_channel_reserve_sats`] is available and will be retained before
1172- /// opening the channel.
1171+ /// If Anchor channels are enabled, this will ensure the reserved amount per
1172+ /// channel is available and will be retained before opening the channel.
11731173 ///
11741174 /// Returns a [`UserChannelId`] allowing to locally keep track of the channel.
11751175 ///
1176- /// [`AnchorChannelsConfig::per_channel_reserve_sats`]: crate::config::AnchorChannelsConfig::per_channel_reserve_sats
11771176 pub fn open_announced_channel (
11781177 & self , node_id : PublicKey , address : SocketAddress , channel_amount_sats : u64 ,
11791178 push_to_counterparty_msat : Option < u64 > , channel_config : Option < ChannelConfig > ,
@@ -1580,6 +1579,8 @@ impl_writeable_tlv_based!(NodeMetrics, {
15801579pub ( crate ) fn total_anchor_channels_reserve_sats (
15811580 channel_manager : & ChannelManager , config : & Config ,
15821581) -> u64 {
1582+ let reserve_sat_per_channel = get_anchor_reserve_per_channel ( ) ;
1583+
15831584 config. anchor_channels_config . as_ref ( ) . map_or ( 0 , |anchor_channels_config| {
15841585 channel_manager
15851586 . list_channels ( )
@@ -1593,6 +1594,12 @@ pub(crate) fn total_anchor_channels_reserve_sats(
15931594 . map_or ( false , |t| t. requires_anchors_zero_fee_htlc_tx ( ) )
15941595 } )
15951596 . count ( ) as u64
1596- * anchor_channels_config . per_channel_reserve_sats
1597+ * reserve_sat_per_channel
15971598 } )
15981599}
1600+
1601+ /// Returns the configured anchor channel reserve per channel in satoshis.
1602+ pub fn get_anchor_reserve_per_channel ( ) -> u64 {
1603+ let context = AnchorChannelReserveContext :: default ( ) ;
1604+ get_reserve_per_channel ( & context) . to_sat ( )
1605+ }
0 commit comments