@@ -262,7 +262,7 @@ where
262262 LoggerRef :: Target : Logger ,
263263 PersistRef :: Target : Persist < ChannelSigner > ,
264264{
265- let mut anchor_channels_with_balance = new_hash_set ( ) ;
265+ let mut anchor_channels = new_hash_set ( ) ;
266266 // Calculate the number of in-progress anchor channels by inspecting ChannelMonitors with balance.
267267 // This includes channels that are in the process of being resolved on-chain.
268268 for ( outpoint, channel_id) in chain_monitor. list_monitors ( ) {
@@ -274,18 +274,17 @@ where
274274 if channel_monitor. channel_type_features ( ) . supports_anchors_zero_fee_htlc_tx ( )
275275 && !channel_monitor. get_claimable_balances ( ) . is_empty ( )
276276 {
277- anchor_channels_with_balance . insert ( channel_id) ;
277+ anchor_channels . insert ( channel_id) ;
278278 }
279279 }
280- // Count channels that are in the middle of negotiation as well.
281- let num_anchor_channels = anchor_channels_with_balance. len ( )
282- + a_channel_manager
283- . get_cm ( )
284- . list_channels ( )
285- . into_iter ( )
286- . filter ( |c| c. channel_type . is_none ( ) )
287- . count ( ) ;
288- get_supportable_anchor_channels ( context, utxos) > num_anchor_channels as u64
280+ // Also include channels that are in the middle of negotiation or anchor channels that don't have
281+ // a ChannelMonitor yet.
282+ for channel in a_channel_manager. get_cm ( ) . list_channels ( ) {
283+ if channel. channel_type . map_or ( true , |ct| ct. supports_anchors_zero_fee_htlc_tx ( ) ) {
284+ anchor_channels. insert ( channel. channel_id ) ;
285+ }
286+ }
287+ get_supportable_anchor_channels ( context, utxos) > anchor_channels. len ( ) as u64
289288}
290289
291290#[ cfg( test) ]
0 commit comments