mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-09-17 19:12:44 +02:00
peer: conditionally create new RBF chan closer
This commit is contained in:
@@ -409,6 +409,12 @@ func makeNegotiateCloser(chanCloser *chancloser.ChanCloser) chanCloserFsm {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func makeRbfCloser(rbfCloser *chancloser.RbfChanCloser) chanCloserFsm {
|
||||||
|
return fn.NewRight[*chancloser.ChanCloser, *chancloser.RbfChanCloser](
|
||||||
|
rbfCloser,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
// Brontide is an active peer on the Lightning Network. This struct is responsible
|
// Brontide is an active peer on the Lightning Network. This struct is responsible
|
||||||
// for managing any channel state related to this peer. To do so, it has
|
// for managing any channel state related to this peer. To do so, it has
|
||||||
// several helper goroutines to handle events such as HTLC timeouts, new
|
// several helper goroutines to handle events such as HTLC timeouts, new
|
||||||
@@ -3390,6 +3396,8 @@ func (p *Brontide) initRbfChanCloser(req *htlcswitch.ChanClose,
|
|||||||
|
|
||||||
chanCloser := protofsm.NewStateMachine(protoCfg)
|
chanCloser := protofsm.NewStateMachine(protoCfg)
|
||||||
|
|
||||||
|
p.activeChanCloses[chanID] = makeRbfCloser(&chanCloser)
|
||||||
|
|
||||||
// Now that we've created the channel state machine, we'll register for
|
// Now that we've created the channel state machine, we'll register for
|
||||||
// a hook to be sent once the channel has been flushed.
|
// a hook to be sent once the channel has been flushed.
|
||||||
link.OnFlushedOnce(func() {
|
link.OnFlushedOnce(func() {
|
||||||
@@ -3455,7 +3463,14 @@ func (p *Brontide) handleLocalCloseReq(req *htlcswitch.ChanClose) {
|
|||||||
// out this channel on-chain, so we execute the cooperative channel
|
// out this channel on-chain, so we execute the cooperative channel
|
||||||
// closure workflow.
|
// closure workflow.
|
||||||
case contractcourt.CloseRegular:
|
case contractcourt.CloseRegular:
|
||||||
err := p.initNegotiateChanCloser(req, channel)
|
var err error
|
||||||
|
switch {
|
||||||
|
case p.rbfCoopCloseAllowed():
|
||||||
|
err = p.initAndStartRbfChanCloser(req, channel)
|
||||||
|
default:
|
||||||
|
err = p.initNegotiateChanCloser(req, channel)
|
||||||
|
}
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
p.log.Errorf(err.Error())
|
p.log.Errorf(err.Error())
|
||||||
req.Err <- err
|
req.Err <- err
|
||||||
|
Reference in New Issue
Block a user