Skip to content

Commit d43b5f8

Browse files
committed
funding: inform aux controller about channel ready/finalize
1 parent 8c9b82f commit d43b5f8

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

funding/manager.go

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2742,6 +2742,22 @@ func (f *Manager) funderProcessFundingSigned(peer lnpeer.Peer,
27422742
}
27432743
}
27442744

2745+
// Before we proceed, if we have a funding hook that wants a
2746+
// notification that it's safe to broadcast the funding transaction,
2747+
// then we'll send that now.
2748+
err = fn.MapOptionZ(
2749+
f.cfg.AuxFundingController,
2750+
func(controller AuxFundingController) error {
2751+
return controller.ChannelFinalized(cid.tempChanID)
2752+
},
2753+
)
2754+
if err != nil {
2755+
cid := newChanIdentifier(msg.ChanID)
2756+
f.sendWarning(peer, cid, err)
2757+
2758+
return
2759+
}
2760+
27452761
// Now that we have a finalized reservation for this funding flow,
27462762
// we'll send the to be active channel to the ChainArbitrator so it can
27472763
// watch for any on-chain actions before the channel has fully
@@ -3995,6 +4011,19 @@ func (f *Manager) handleChannelReady(peer lnpeer.Peer, //nolint:funlen
39954011
PubNonce: remoteNonce,
39964012
}),
39974013
)
4014+
4015+
err = fn.MapOptionZ(
4016+
f.cfg.AuxFundingController,
4017+
func(controller AuxFundingController) error {
4018+
return controller.ChannelReady(channel)
4019+
},
4020+
)
4021+
if err != nil {
4022+
cid := newChanIdentifier(msg.ChanID)
4023+
f.sendWarning(peer, cid, err)
4024+
4025+
return
4026+
}
39984027
}
39994028

40004029
// The channel_ready message contains the next commitment point we'll
@@ -4081,6 +4110,17 @@ func (f *Manager) handleChannelReadyReceived(channel *channeldb.OpenChannel,
40814110
log.Debugf("Channel(%v) with ShortChanID %v: successfully "+
40824111
"added to router graph", chanID, scid)
40834112

4113+
err = fn.MapOptionZ(
4114+
f.cfg.AuxFundingController,
4115+
func(controller AuxFundingController) error {
4116+
return controller.ChannelReady(channel)
4117+
},
4118+
)
4119+
if err != nil {
4120+
return fmt.Errorf("failed notifying aux funding controller "+
4121+
"about channel ready: %w", err)
4122+
}
4123+
40844124
// Give the caller a final update notifying them that the channel is
40854125
fundingPoint := channel.FundingOutpoint
40864126
cp := &lnrpc.ChannelPoint{

0 commit comments

Comments
 (0)