@@ -1164,52 +1164,45 @@ where
11641164 }
11651165
11661166 let anchor_channel = channel_type. requires_anchors_zero_fee_htlc_tx ( ) ;
1167- if anchor_channel {
1168- if let Some ( anchor_channels_config) =
1169- self . config . anchor_channels_config . as_ref ( )
1170- {
1171- let cur_anchor_reserve_sats = crate :: total_anchor_channels_reserve_sats (
1172- & self . channel_manager ,
1173- & self . config ,
1174- ) ;
1175- let spendable_amount_sats = self
1176- . wallet
1177- . get_spendable_amount_sats ( cur_anchor_reserve_sats)
1178- . unwrap_or ( 0 ) ;
1179-
1180- let required_amount_sats = if anchor_channels_config
1181- . trusted_peers_no_reserve
1182- . contains ( & counterparty_node_id)
1183- {
1184- 0
1185- } else {
1186- anchor_channels_config. per_channel_reserve_sats
1187- } ;
1167+ if anchor_channel && self . config . anchor_channels_config . is_none ( ) {
1168+ log_error ! (
1169+ self . logger,
1170+ "Rejecting inbound channel from peer {} due to Anchor channels being disabled." ,
1171+ counterparty_node_id,
1172+ ) ;
1173+ self . channel_manager
1174+ . force_close_broadcasting_latest_txn (
1175+ & temporary_channel_id,
1176+ & counterparty_node_id,
1177+ "Channel request rejected" . to_string ( ) ,
1178+ )
1179+ . unwrap_or_else ( |e| {
1180+ log_error ! ( self . logger, "Failed to reject channel: {:?}" , e)
1181+ } ) ;
1182+ return Ok ( ( ) ) ;
1183+ }
11881184
1189- if spendable_amount_sats < required_amount_sats {
1190- log_error ! (
1191- self . logger,
1192- "Rejecting inbound Anchor channel from peer {} due to insufficient available on-chain reserves. Available: {}/{}sats" ,
1193- counterparty_node_id,
1194- spendable_amount_sats,
1195- required_amount_sats,
1196- ) ;
1197- self . channel_manager
1198- . force_close_broadcasting_latest_txn (
1199- & temporary_channel_id,
1200- & counterparty_node_id,
1201- "Channel request rejected" . to_string ( ) ,
1202- )
1203- . unwrap_or_else ( |e| {
1204- log_error ! ( self . logger, "Failed to reject channel: {:?}" , e)
1205- } ) ;
1206- return Ok ( ( ) ) ;
1207- }
1208- } else {
1185+ let required_reserve_sats = crate :: new_channel_anchor_reserve_sats (
1186+ & self . config ,
1187+ & counterparty_node_id,
1188+ anchor_channel,
1189+ ) ;
1190+
1191+ if required_reserve_sats > 0 {
1192+ let cur_anchor_reserve_sats = crate :: total_anchor_channels_reserve_sats (
1193+ & self . channel_manager ,
1194+ & self . config ,
1195+ ) ;
1196+ let spendable_amount_sats =
1197+ self . wallet . get_spendable_amount_sats ( cur_anchor_reserve_sats) . unwrap_or ( 0 ) ;
1198+
1199+ if spendable_amount_sats < required_reserve_sats {
12091200 log_error ! (
12101201 self . logger,
1211- "Rejecting inbound channel from peer {} due to Anchor channels being disabled. " ,
1202+ "Rejecting inbound Anchor channel from peer {} due to insufficient available on-chain reserves. Available: {}/{}sats " ,
12121203 counterparty_node_id,
1204+ spendable_amount_sats,
1205+ required_reserve_sats,
12131206 ) ;
12141207 self . channel_manager
12151208 . force_close_broadcasting_latest_txn (
0 commit comments