Skip to content

Commit 3384a0d

Browse files
committed
Consider all channel maps in update_partial_channel_config
1 parent 96259f5 commit 3384a0d

File tree

1 file changed

+23
-15
lines changed

1 file changed

+23
-15
lines changed

lightning/src/ln/channelmanager.rs

Lines changed: 23 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3488,27 +3488,35 @@ where
34883488
let mut peer_state_lock = peer_state_mutex.lock().unwrap();
34893489
let peer_state = &mut *peer_state_lock;
34903490
for channel_id in channel_ids {
3491-
if !peer_state.channel_by_id.contains_key(channel_id) {
3491+
let context = if let Some(channel) = peer_state.inbound_v1_channel_by_id.get_mut(channel_id) {
3492+
&mut channel.context
3493+
} else if let Some(channel) = peer_state.outbound_v1_channel_by_id.get_mut(channel_id) {
3494+
&mut channel.context
3495+
} else if let Some(channel) = peer_state.channel_by_id.get_mut(channel_id) {
3496+
let mut config = channel.context.config();
3497+
config.apply(config_update);
3498+
if !channel.context.update_config(&config) {
3499+
continue;
3500+
}
3501+
if let Ok(msg) = self.get_channel_update_for_broadcast(channel) {
3502+
peer_state.pending_msg_events.push(events::MessageSendEvent::BroadcastChannelUpdate { msg });
3503+
} else if let Ok(msg) = self.get_channel_update_for_unicast(channel) {
3504+
peer_state.pending_msg_events.push(events::MessageSendEvent::SendChannelUpdate {
3505+
node_id: channel.context.get_counterparty_node_id(),
3506+
msg,
3507+
});
3508+
}
3509+
continue;
3510+
} else {
34923511
return Err(APIError::ChannelUnavailable {
34933512
err: format!("Channel with ID {} was not found for the passed counterparty_node_id {}", log_bytes!(*channel_id), counterparty_node_id),
34943513
});
3495-
}
3496-
}
3497-
for channel_id in channel_ids {
3498-
let channel = peer_state.channel_by_id.get_mut(channel_id).unwrap();
3499-
let mut config = channel.context.config();
3514+
};
3515+
let mut config = context.config();
35003516
config.apply(config_update);
3501-
if !channel.context.update_config(&config) {
3517+
if !context.update_config(&config) {
35023518
continue;
35033519
}
3504-
if let Ok(msg) = self.get_channel_update_for_broadcast(channel) {
3505-
peer_state.pending_msg_events.push(events::MessageSendEvent::BroadcastChannelUpdate { msg });
3506-
} else if let Ok(msg) = self.get_channel_update_for_unicast(channel) {
3507-
peer_state.pending_msg_events.push(events::MessageSendEvent::SendChannelUpdate {
3508-
node_id: channel.context.get_counterparty_node_id(),
3509-
msg,
3510-
});
3511-
}
35123520
}
35133521
Ok(())
35143522
}

0 commit comments

Comments
 (0)