From 4ff4e1b0de856c9a05d5eca9929f5b402eada5a1 Mon Sep 17 00:00:00 2001 From: Olaoluwa Osuntokun Date: Sun, 10 Mar 2019 16:43:25 -0700 Subject: [PATCH] lnwallet: account for case where remote party has 2 unrevoked commits in DLP --- lnwallet/channel.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/lnwallet/channel.go b/lnwallet/channel.go index 2bb049f0..9e620b94 100644 --- a/lnwallet/channel.go +++ b/lnwallet/channel.go @@ -3501,7 +3501,16 @@ func (lc *LightningChannel) ProcessChanSyncMsg( // as that's what they should send. case msg.NextLocalCommitHeight == remoteTailHeight+1: commitPoint = lc.channelState.RemoteCurrentRevocation + + // Alternatively, if their height is two beyond what we know their best + // height to be, then they're holding onto two commitments, and the + // highest unrevoked point it their next revocation. + // + // TODO(roasbeef): verify this in the spec... + case msg.NextLocalCommitHeight == remoteTailHeight+2: + commitPoint = lc.channelState.RemoteNextRevocation } + if commitPoint != nil && !commitPoint.IsEqual(msg.LocalUnrevokedCommitPoint) { @@ -3513,6 +3522,7 @@ func (lc *LightningChannel) ProcessChanSyncMsg( if err := lc.channelState.MarkBorked(); err != nil { return nil, nil, nil, err } + // TODO(halseth): force close? return nil, nil, nil, ErrInvalidLocalUnrevokedCommitPoint }