diff --git a/funding/aux_funding.go b/funding/aux_funding.go index 9f041c4e0..a9299af63 100644 --- a/funding/aux_funding.go +++ b/funding/aux_funding.go @@ -30,6 +30,11 @@ type AuxFundingController interface { // tapscript root that should be used when creating any musig2 sessions // for a channel. DeriveTapscriptRoot(PendingChanID) (fn.Option[chainhash.Hash], error) + + // ChannelReady is called when a channel has been fully opened and is + // ready to be used. This can be used to perform any final setup or + // cleanup. + ChannelReady(openChan *channeldb.OpenChannel) error } // descFromPendingChanID takes a pending channel ID, that may already be diff --git a/funding/manager.go b/funding/manager.go index bfbe89527..ed37e0937 100644 --- a/funding/manager.go +++ b/funding/manager.go @@ -4008,6 +4008,19 @@ func (f *Manager) handleChannelReady(peer lnpeer.Peer, //nolint:funlen PubNonce: remoteNonce, }), ) + + err = fn.MapOptionZ( + f.cfg.AuxFundingController, + func(controller AuxFundingController) error { + return controller.ChannelReady(channel) + }, + ) + if err != nil { + cid := newChanIdentifier(msg.ChanID) + f.sendWarning(peer, cid, err) + + return + } } // The channel_ready message contains the next commitment point we'll @@ -4094,6 +4107,17 @@ func (f *Manager) handleChannelReadyReceived(channel *channeldb.OpenChannel, log.Debugf("Channel(%v) with ShortChanID %v: successfully "+ "added to router graph", chanID, scid) + err = fn.MapOptionZ( + f.cfg.AuxFundingController, + func(controller AuxFundingController) error { + return controller.ChannelReady(channel) + }, + ) + if err != nil { + return fmt.Errorf("failed notifying aux funding controller "+ + "about channel ready: %w", err) + } + // Give the caller a final update notifying them that the channel is fundingPoint := channel.FundingOutpoint cp := &lnrpc.ChannelPoint{