Skip to content

Commit 9e5ec7d

Browse files
committed
Consider all channel maps in update_partial_channel_config
1 parent 7ff65e2 commit 9e5ec7d

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
@@ -3494,27 +3494,35 @@ where
34943494
let mut peer_state_lock = peer_state_mutex.lock().unwrap();
34953495
let peer_state = &mut *peer_state_lock;
34963496
for channel_id in channel_ids {
3497-
if !peer_state.channel_by_id.contains_key(channel_id) {
3497+
let context = if let Some(channel) = peer_state.inbound_v1_channel_by_id.get_mut(channel_id) {
3498+
&mut channel.context
3499+
} else if let Some(channel) = peer_state.outbound_v1_channel_by_id.get_mut(channel_id) {
3500+
&mut channel.context
3501+
} else if let Some(channel) = peer_state.channel_by_id.get_mut(channel_id) {
3502+
let mut config = channel.context.config();
3503+
config.apply(config_update);
3504+
if !channel.context.update_config(&config) {
3505+
continue;
3506+
}
3507+
if let Ok(msg) = self.get_channel_update_for_broadcast(channel) {
3508+
peer_state.pending_msg_events.push(events::MessageSendEvent::BroadcastChannelUpdate { msg });
3509+
} else if let Ok(msg) = self.get_channel_update_for_unicast(channel) {
3510+
peer_state.pending_msg_events.push(events::MessageSendEvent::SendChannelUpdate {
3511+
node_id: channel.context.get_counterparty_node_id(),
3512+
msg,
3513+
});
3514+
}
3515+
continue;
3516+
} else {
34983517
return Err(APIError::ChannelUnavailable {
34993518
err: format!("Channel with ID {} was not found for the passed counterparty_node_id {}", log_bytes!(*channel_id), counterparty_node_id),
35003519
});
3501-
}
3502-
}
3503-
for channel_id in channel_ids {
3504-
let channel = peer_state.channel_by_id.get_mut(channel_id).unwrap();
3505-
let mut config = channel.context.config();
3520+
};
3521+
let mut config = context.config();
35063522
config.apply(config_update);
3507-
if !channel.context.update_config(&config) {
3523+
if !context.update_config(&config) {
35083524
continue;
35093525
}
3510-
if let Ok(msg) = self.get_channel_update_for_broadcast(channel) {
3511-
peer_state.pending_msg_events.push(events::MessageSendEvent::BroadcastChannelUpdate { msg });
3512-
} else if let Ok(msg) = self.get_channel_update_for_unicast(channel) {
3513-
peer_state.pending_msg_events.push(events::MessageSendEvent::SendChannelUpdate {
3514-
node_id: channel.context.get_counterparty_node_id(),
3515-
msg,
3516-
});
3517-
}
35183526
}
35193527
Ok(())
35203528
}

0 commit comments

Comments
 (0)