Skip to content

Commit

Permalink
separating "internal error case" and "link failed to shutdown" case
Browse files Browse the repository at this point in the history
  • Loading branch information
DerEwige committed Sep 13, 2024
1 parent 84dcdbb commit 4848954
Showing 1 changed file with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -135,12 +135,19 @@ trait ErrorHandlers extends CommonHandlers {
handleMutualClose(bestUnpublishedClosingTx, Left(negotiating))
// NB: we publish the commitment even if we have nothing at stake (in a dataloss situation our peer will send us an error just for that)
case hasCommitments: ChannelDataWithCommitments =>
if ((e.toAscii == "internal error") || (e.toAscii == "link failed to shutdown")) {
if (e.toAscii == "internal error") {
// It seems like lnd sends this error whenever something wrong happens on their side, regardless of whether
// the channel actually needs to be closed. We ignore it to avoid paying the cost of a channel force-close,
// it's up to them to broadcast their commitment if they wish.
log.warning("ignoring remote '"+e.toAscii+"', probably coming from lnd")
stay() sending Warning(d.channelId, "ignoring your '"+e.toAscii+"' to avoid an unnecessary force-close")
} else if (e.toAscii == "link failed to shutdown") {
// When trying to close a channel with LND older than version 0.18.0,
// LND will send an error if there are HTLCs on the channel.
// ignoring this error will prevent a force-close.
// channel closing is retried upon every reconnect of the channel until there is no more HTLC on the channel
log.warning("ignoring remote '"+e.toAscii+"', probably coming from lnd")
stay() sending Warning(d.channelId, "ignoring your '"+e.toAscii+"' to avoid an unnecessary force-close")
} else {
spendLocalCurrent(hasCommitments)
}
Expand Down

0 comments on commit 4848954

Please sign in to comment.