htlcswitch/link: don't mark channel borked on force close scanarios

Instead of marking the channel Borked in cases where we want to force
close it, we immediately let the peer fail the link. The channel state
will instead be updated by the channel arbitrator, which will transition
to StateBroadcastCommit, marking the channel borked, then marking the
commitment tx broadcasted right before publishing the force close tx. We
do this to avoid the case where we would mark it Borked, but go down
before being able to publish the closing tx.

Storing the force close tx ensures it will be re-published on startup.
This commit is contained in:
Johan T. Halseth 2019-09-06 13:14:40 +02:00
parent 6e361d04cf
commit 9423fadf56
No known key found for this signature in database
GPG Key ID: 15BAADA29DA20D26

@ -922,12 +922,12 @@ func (l *channelLink) htlcManager() {
// what they sent us before.
// TODO(halseth): ban peer?
case err == lnwallet.ErrInvalidLocalUnrevokedCommitPoint:
err = l.channel.MarkBorked()
if err != nil {
log.Errorf("Unable to mark channel "+
"borked: %v", err)
}
// We'll fail the link and tell the peer to
// force close the channel. Note that the
// database state is not updated here, but will
// be updated when the close transaction is
// ready to avoid that we go down before
// storing the transaction in the db.
l.fail(
LinkFailureError{
code: ErrSyncError,