Fix CLN channel connection status shown inconsistently (#1606)

CLN's listpeerchannels reports connection state as peer_connected, but the
open/pending channel list columns read the legacy `connected` field, which the
backend never populated. It was therefore always empty, so the list always
rendered "Disconnected" while the detail panel (which reads peer_connected)
showed the true state — the contradiction reported in #1606.

Normalize `connected = peer_connected` in the backend listPeerChannels response
so legacy consumers stay in sync, and point the list columns at peer_connected
directly. Add regression specs asserting the connected column follows
peer_connected even when the legacy field disagrees.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
saubyk 2026-07-16 22:26:45 -07:00 committed by Suheb
parent 42cb3c76e8
commit 16d48417d8
5 changed files with 53 additions and 2 deletions

View file

@ -21,6 +21,9 @@ export const listPeerChannels = (req, res, next) => {
const getPeerAliasesTasks = body.channels.map((channel) => () => {
channel.to_them_msat = channel.total_msat - channel.to_us_msat;
channel.balancedness = (channel.total_msat === 0) ? 1 : (1 - Math.abs((channel.to_us_msat - channel.to_them_msat) / channel.total_msat)).toFixed(3);
// listpeerchannels reports connection state as peer_connected. Mirror it onto the
// legacy 'connected' field so backward-compat consumers stay in sync (issue #1606).
channel.connected = channel.peer_connected;
return getAlias(req.session.selectedNode, channel, 'peer_id');
});
common.runWithConcurrencyLimit(getPeerAliasesTasks, 20, () => {