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