From 406e9f3aa9bbbd9531830b94d23c72f06280ca6f Mon Sep 17 00:00:00 2001 From: Roland <33993199+rolznz@users.noreply.github.com> Date: Wed, 31 Jul 2024 22:25:19 +0700 Subject: [PATCH] chore: include whether the channel is public or not in channel ready event (#376) * chore: include whether the channel is public or not in channel ready event * chore: add capacity and is_outbound properties to channel ready event --- lnclient/ldk/ldk.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/lnclient/ldk/ldk.go b/lnclient/ldk/ldk.go index b97ba2ab..b570b8ed 100644 --- a/lnclient/ldk/ldk.go +++ b/lnclient/ldk/ldk.go @@ -1236,11 +1236,23 @@ func (ls *LDKService) handleLdkEvent(event *ldk_node.Event) { switch eventType := (*event).(type) { case ldk_node.EventChannelReady: + channels := ls.node.ListChannels() + channelIndex := slices.IndexFunc(channels, func(c ldk_node.ChannelDetails) bool { + return c.ChannelId == eventType.ChannelId + }) + if channelIndex == -1 { + logger.Logger.WithField("event", eventType).Error("Failed to find channel by ID") + return + } + channel := channels[channelIndex] ls.eventPublisher.Publish(&events.Event{ Event: "nwc_channel_ready", Properties: map[string]interface{}{ "counterparty_node_id": eventType.CounterpartyNodeId, "node_type": config.LDKBackendType, + "public": channel.IsPublic, + "capacity": channel.ChannelValueSats, + "is_outbound": channel.IsOutbound, }, })