Coerce mirrored peer_connected to a boolean

Address review feedback on #1625: copy peer_connected onto the legacy
`connected` field as a real boolean (!!), so strict-equality readers such as
onchain.ts's `connected === false` behave correctly when peer_connected is
absent, instead of leaving `connected` undefined.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
saubyk 2026-07-16 22:43:28 -07:00 committed by Suheb
parent 5659ba250b
commit 512aea96e5

View file

@ -23,7 +23,9 @@ export const listPeerChannels = (req, res, next) => {
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;
// Coerce to a real boolean so strict-equality readers (e.g. onchain.ts's
// connected === false) behave correctly even when peer_connected is absent.
channel.connected = !!channel.peer_connected;
return getAlias(req.session.selectedNode, channel, 'peer_id');
});
common.runWithConcurrencyLimit(getPeerAliasesTasks, 20, () => {