diff --git a/chancloser.go b/chancloser.go index d78a3824..3c015a5b 100644 --- a/chancloser.go +++ b/chancloser.go @@ -435,6 +435,14 @@ func (c *channelCloser) ProcessCloseMsg(msg lnwire.Message) ([]lnwire.Message, b "close: %v", c.chanPoint, err) } + // Before publishing the closing tx, we persist it to the + // database, such that it can be republished if something goes + // wrong. + err = c.cfg.channel.MarkCommitmentBroadcasted(closeTx) + if err != nil { + return nil, false, err + } + // With the closing transaction crafted, we'll now broadcast it // to the network. peerLog.Infof("Broadcasting cooperative close tx: %v", @@ -445,11 +453,6 @@ func (c *channelCloser) ProcessCloseMsg(msg lnwire.Message) ([]lnwire.Message, b return nil, false, err } - err = c.cfg.channel.MarkCommitmentBroadcasted(closeTx) - if err != nil { - return nil, false, err - } - // Finally, we'll transition to the closeFinished state, and // also return the final close signed message we sent. // Additionally, we return true for the second argument to