Skip to content

Commit 910d148

Browse files
committed
Consider all channel maps in update_partial_channel_config
1 parent 0bd24ac commit 910d148

File tree

1 file changed

+24
-17
lines changed

1 file changed

+24
-17
lines changed

lightning/src/ln/channelmanager.rs

Lines changed: 24 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3541,27 +3541,34 @@ where
35413541
let mut peer_state_lock = peer_state_mutex.lock().unwrap();
35423542
let peer_state = &mut *peer_state_lock;
35433543
for channel_id in channel_ids {
3544-
if !peer_state.channel_by_id.contains_key(channel_id) {
3544+
if let Some(channel) = peer_state.channel_by_id.get_mut(channel_id) {
3545+
let mut config = channel.context.config();
3546+
config.apply(config_update);
3547+
if !channel.context.update_config(&config) {
3548+
continue;
3549+
}
3550+
if let Ok(msg) = self.get_channel_update_for_broadcast(channel) {
3551+
peer_state.pending_msg_events.push(events::MessageSendEvent::BroadcastChannelUpdate { msg });
3552+
} else if let Ok(msg) = self.get_channel_update_for_unicast(channel) {
3553+
peer_state.pending_msg_events.push(events::MessageSendEvent::SendChannelUpdate {
3554+
node_id: channel.context.get_counterparty_node_id(),
3555+
msg,
3556+
});
3557+
}
3558+
continue;
3559+
}
3560+
3561+
let context = if let Some(channel) = peer_state.inbound_v1_channel_by_id.get_mut(channel_id) {
3562+
&mut channel.context
3563+
} else if let Some(channel) = peer_state.outbound_v1_channel_by_id.get_mut(channel_id) {
3564+
&mut channel.context
3565+
} else {
35453566
return Err(APIError::ChannelUnavailable {
35463567
err: format!("Channel with ID {} was not found for the passed counterparty_node_id {}", log_bytes!(*channel_id), counterparty_node_id),
35473568
});
3548-
}
3549-
}
3550-
for channel_id in channel_ids {
3551-
let channel = peer_state.channel_by_id.get_mut(channel_id).unwrap();
3552-
let mut config = channel.context.config();
3569+
};
3570+
let mut config = context.config();
35533571
config.apply(config_update);
3554-
if !channel.context.update_config(&config) {
3555-
continue;
3556-
}
3557-
if let Ok(msg) = self.get_channel_update_for_broadcast(channel) {
3558-
peer_state.pending_msg_events.push(events::MessageSendEvent::BroadcastChannelUpdate { msg });
3559-
} else if let Ok(msg) = self.get_channel_update_for_unicast(channel) {
3560-
peer_state.pending_msg_events.push(events::MessageSendEvent::SendChannelUpdate {
3561-
node_id: channel.context.get_counterparty_node_id(),
3562-
msg,
3563-
});
3564-
}
35653572
}
35663573
Ok(())
35673574
}

0 commit comments

Comments
 (0)