chancloser: mark commitment broadcast before publish

We call MarkCommitmentBroadcasted before publishing the closing tx to
ensure we can attempt to republish at startup if something goes wrong.
This commit is contained in:
Johan T. Halseth 2019-09-06 13:14:40 +02:00
parent 2cb80c4449
commit c90b1dd17d
No known key found for this signature in database
GPG Key ID: 15BAADA29DA20D26

@ -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