lnwallet/channel: don't use commit height to determine FullySynced
This commit removes a faulty check we did to determine if the channel commitments were fully synced. We assumed that if out local commitment chain had a height higher than the remote, then we would have state updates present in our chain but not in theirs, and owed a commitment. However, there were cases where this wasn't true, and we would send a new commitment even though we had no new updates to sign. This is a protocol violation. Now we don't longer check the heights to determine if we are fully synced. A consequence of this is that we also need to check if we have any pending fee updates that are nopt yet signed, as those are considered non-empty updates.
This commit is contained in:
parent
ddcbb40898
commit
71228a6b06
@ -3924,15 +3924,27 @@ func (lc *LightningChannel) FullySynced() bool {
|
||||
lastLocalCommit := lc.localCommitChain.tip()
|
||||
lastRemoteCommit := lc.remoteCommitChain.tip()
|
||||
|
||||
oweCommitment := lastLocalCommit.height > lastRemoteCommit.height
|
||||
|
||||
localUpdatesSynced := (lastLocalCommit.ourMessageIndex ==
|
||||
lastRemoteCommit.ourMessageIndex)
|
||||
|
||||
remoteUpdatesSynced := (lastLocalCommit.theirMessageIndex ==
|
||||
lastRemoteCommit.theirMessageIndex)
|
||||
|
||||
return !oweCommitment && localUpdatesSynced && remoteUpdatesSynced
|
||||
pendingFeeAck := false
|
||||
|
||||
// If we have received a fee update which we haven't yet ACKed, then
|
||||
// we owe a commitment.
|
||||
if !lc.channelState.IsInitiator {
|
||||
pendingFeeAck = lc.pendingAckFeeUpdate != nil
|
||||
}
|
||||
|
||||
// If we have sent a fee update which we haven't yet signed, then
|
||||
// we owe a commitment.
|
||||
if lc.channelState.IsInitiator {
|
||||
pendingFeeAck = lc.pendingFeeUpdate != nil
|
||||
}
|
||||
|
||||
return localUpdatesSynced && remoteUpdatesSynced && !pendingFeeAck
|
||||
}
|
||||
|
||||
// RevokeCurrentCommitment revokes the next lowest unrevoked commitment
|
||||
|
Loading…
Reference in New Issue
Block a user