From ca86eacf4fb996dc3e1af1a21e3c76d733a6a753 Mon Sep 17 00:00:00 2001 From: Eugene Siegel Date: Wed, 15 Jan 2025 13:17:48 -0500 Subject: [PATCH] channelnotifier: add FundingTimeout and NotifyFundingTimeout This signal will be used in the server.go code to potentially demote temporary-access peers to restricted-access peers. --- channelnotifier/channelnotifier.go | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/channelnotifier/channelnotifier.go b/channelnotifier/channelnotifier.go index b03d91313..720b48687 100644 --- a/channelnotifier/channelnotifier.go +++ b/channelnotifier/channelnotifier.go @@ -80,6 +80,14 @@ type FullyResolvedChannelEvent struct { ChannelPoint *wire.OutPoint } +// FundingTimeoutEvent represents a new event where a pending-open channel has +// timed out from the PoV of the funding manager because the funding tx +// has not confirmed in the allotted time. +type FundingTimeoutEvent struct { + // ChannelPoint is the channelpoint for the newly inactive channel. + ChannelPoint *wire.OutPoint +} + // New creates a new channel notifier. The ChannelNotifier gets channel // events from peers and from the chain arbitrator, and dispatches them to // its clients. @@ -184,6 +192,16 @@ func (c *ChannelNotifier) NotifyFullyResolvedChannelEvent( } } +// NotifyFundingTimeoutEvent notifies the channelEventNotifier goroutine that +// a funding timeout has occurred for a certain channel point. +func (c *ChannelNotifier) NotifyFundingTimeout(chanPoint wire.OutPoint) { + // Send this event to all channel event subscribers. + event := FundingTimeoutEvent{ChannelPoint: &chanPoint} + if err := c.ntfnServer.SendUpdate(event); err != nil { + log.Warnf("Unable to send funding timeout update: %v", err) + } +} + // NotifyActiveLinkEvent notifies the channelEventNotifier goroutine that a // link has been added to the switch. func (c *ChannelNotifier) NotifyActiveLinkEvent(chanPoint wire.OutPoint) {