@@ -267,7 +267,7 @@ where
267267 LoggerRef :: Target : Logger ,
268268 PersistRef :: Target : Persist < ChannelSigner > ,
269269{
270- let mut anchor_channels_with_balance = new_hash_set ( ) ;
270+ let mut anchor_channels = new_hash_set ( ) ;
271271 // Calculate the number of in-progress anchor channels by inspecting ChannelMonitors with balance.
272272 // This includes channels that are in the process of being resolved on-chain.
273273 for ( outpoint, channel_id) in chain_monitor. list_monitors ( ) {
@@ -279,18 +279,17 @@ where
279279 if channel_monitor. channel_type_features ( ) . supports_anchors_zero_fee_htlc_tx ( )
280280 && !channel_monitor. get_claimable_balances ( ) . is_empty ( )
281281 {
282- anchor_channels_with_balance . insert ( channel_id) ;
282+ anchor_channels . insert ( channel_id) ;
283283 }
284284 }
285- // Count channels that are in the middle of negotiation as well.
286- let num_anchor_channels = anchor_channels_with_balance. len ( )
287- + a_channel_manager
288- . get_cm ( )
289- . list_channels ( )
290- . into_iter ( )
291- . filter ( |c| c. channel_type . is_none ( ) )
292- . count ( ) ;
293- get_supportable_anchor_channels ( context, utxos) > num_anchor_channels as u64
285+ // Also include channels that are in the middle of negotiation or anchor channels that don't have
286+ // a ChannelMonitor yet.
287+ for channel in a_channel_manager. get_cm ( ) . list_channels ( ) {
288+ if channel. channel_type . map_or ( true , |ct| ct. supports_anchors_zero_fee_htlc_tx ( ) ) {
289+ anchor_channels. insert ( channel. channel_id ) ;
290+ }
291+ }
292+ get_supportable_anchor_channels ( context, utxos) > anchor_channels. len ( ) as u64
294293}
295294
296295#[ cfg( test) ]
0 commit comments