lnwallet: account for case where remote party has 2 unrevoked commits in DLP

This commit is contained in:
Olaoluwa Osuntokun 2019-03-10 16:43:25 -07:00
parent fc8337b146
commit 4ff4e1b0de
No known key found for this signature in database
GPG Key ID: CE58F7F8E20FD9A2

@ -3501,7 +3501,16 @@ func (lc *LightningChannel) ProcessChanSyncMsg(
// as that's what they should send. // as that's what they should send.
case msg.NextLocalCommitHeight == remoteTailHeight+1: case msg.NextLocalCommitHeight == remoteTailHeight+1:
commitPoint = lc.channelState.RemoteCurrentRevocation 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 && if commitPoint != nil &&
!commitPoint.IsEqual(msg.LocalUnrevokedCommitPoint) { !commitPoint.IsEqual(msg.LocalUnrevokedCommitPoint) {
@ -3513,6 +3522,7 @@ func (lc *LightningChannel) ProcessChanSyncMsg(
if err := lc.channelState.MarkBorked(); err != nil { if err := lc.channelState.MarkBorked(); err != nil {
return nil, nil, nil, err return nil, nil, nil, err
} }
// TODO(halseth): force close? // TODO(halseth): force close?
return nil, nil, nil, ErrInvalidLocalUnrevokedCommitPoint return nil, nil, nil, ErrInvalidLocalUnrevokedCommitPoint
} }