@@ -146,6 +146,9 @@ use lightning::ln::channelmanager::PaymentId;
146146use lightning:: ln:: funding:: SpliceContribution ;
147147use lightning:: ln:: msgs:: SocketAddress ;
148148use lightning:: routing:: gossip:: NodeAlias ;
149+ use lightning:: util:: anchor_channel_reserves:: {
150+ get_reserve_per_channel, AnchorChannelReserveContext ,
151+ } ;
149152use lightning:: util:: persist:: KVStoreSync ;
150153use lightning_background_processor:: process_events_async;
151154use liquidity:: { LSPS1Liquidity , LiquiditySource } ;
@@ -1181,7 +1184,7 @@ impl Node {
11811184 if init_features. requires_anchors_zero_fee_htlc_tx ( )
11821185 && !c. trusted_peers_no_reserve . contains ( peer_node_id)
11831186 {
1184- c . per_channel_reserve_sats
1187+ get_reserve_per_channel ( & AnchorChannelReserveContext :: default ( ) ) . to_sat ( )
11851188 } else {
11861189 0
11871190 }
@@ -1208,13 +1211,11 @@ impl Node {
12081211 /// channel counterparty on channel open. This can be useful to start out with the balance not
12091212 /// entirely shifted to one side, therefore allowing to receive payments from the getgo.
12101213 ///
1211- /// If Anchor channels are enabled, this will ensure the configured
1212- /// [`AnchorChannelsConfig::per_channel_reserve_sats`] is available and will be retained before
1213- /// opening the channel.
1214+ /// If Anchor channels are enabled, this will ensure the reserved amount per
1215+ /// channel is available and will be retained before opening the channel.
12141216 ///
12151217 /// Returns a [`UserChannelId`] allowing to locally keep track of the channel.
12161218 ///
1217- /// [`AnchorChannelsConfig::per_channel_reserve_sats`]: crate::config::AnchorChannelsConfig::per_channel_reserve_sats
12181219 pub fn open_channel (
12191220 & self , node_id : PublicKey , address : SocketAddress , channel_amount_sats : u64 ,
12201221 push_to_counterparty_msat : Option < u64 > , channel_config : Option < ChannelConfig > ,
@@ -1243,13 +1244,11 @@ impl Node {
12431244 /// channel counterparty on channel open. This can be useful to start out with the balance not
12441245 /// entirely shifted to one side, therefore allowing to receive payments from the getgo.
12451246 ///
1246- /// If Anchor channels are enabled, this will ensure the configured
1247- /// [`AnchorChannelsConfig::per_channel_reserve_sats`] is available and will be retained before
1248- /// opening the channel.
1247+ /// If Anchor channels are enabled, this will ensure the reserved amount per
1248+ /// channel is available and will be retained before opening the channel.
12491249 ///
12501250 /// Returns a [`UserChannelId`] allowing to locally keep track of the channel.
12511251 ///
1252- /// [`AnchorChannelsConfig::per_channel_reserve_sats`]: crate::config::AnchorChannelsConfig::per_channel_reserve_sats
12531252 pub fn open_announced_channel (
12541253 & self , node_id : PublicKey , address : SocketAddress , channel_amount_sats : u64 ,
12551254 push_to_counterparty_msat : Option < u64 > , channel_config : Option < ChannelConfig > ,
@@ -1862,6 +1861,8 @@ impl_writeable_tlv_based!(NodeMetrics, {
18621861pub ( crate ) fn total_anchor_channels_reserve_sats (
18631862 channel_manager : & ChannelManager , config : & Config ,
18641863) -> u64 {
1864+ let reserve_sat_per_channel = get_anchor_reserve_per_channel ( ) ;
1865+
18651866 config. anchor_channels_config . as_ref ( ) . map_or ( 0 , |anchor_channels_config| {
18661867 channel_manager
18671868 . list_channels ( )
@@ -1875,6 +1876,12 @@ pub(crate) fn total_anchor_channels_reserve_sats(
18751876 . map_or ( false , |t| t. requires_anchors_zero_fee_htlc_tx ( ) )
18761877 } )
18771878 . count ( ) as u64
1878- * anchor_channels_config . per_channel_reserve_sats
1879+ * reserve_sat_per_channel
18791880 } )
18801881}
1882+
1883+ /// Returns the configured anchor channel reserve per channel in satoshis.
1884+ pub fn get_anchor_reserve_per_channel ( ) -> u64 {
1885+ let context = AnchorChannelReserveContext :: default ( ) ;
1886+ get_reserve_per_channel ( & context) . to_sat ( )
1887+ }
0 commit comments