htlcswitch+lnwallet: replace updateNeeded by check on channel itself
Instead of tracking local updates in a separate link variable, query this state from the channel itself. This commit also fixes the issue where the commit tx was not updated anymore after a failed first attempt because the revocation window was closed. Also those pending updates will be taken into account when the remote party revokes.
This commit is contained in:
2 files changed
+41
-47
No files matched your search
@@ -4225,6 +4225,17 @@ func (lc *LightningChannel) oweCommitment(local bool) bool {
|
||||
return oweCommitment
|
||||
}
|
||||
|
||||
// PendingLocalUpdateCount returns the number of local updates that still need
|
||||
// to be applied to the remote commitment tx.
|
||||
func (lc *LightningChannel) PendingLocalUpdateCount() uint64 {
|
||||
lc.RLock()
|
||||
defer lc.RUnlock()
|
||||
|
||||
lastRemoteCommit := lc.remoteCommitChain.tip()
|
||||
|
||||
return lc.localUpdateLog.logIndex - lastRemoteCommit.ourMessageIndex
|
||||
}
|
||||
|
||||
// RevokeCurrentCommitment revokes the next lowest unrevoked commitment
|
||||
// transaction in the local commitment chain. As a result the edge of our
|
||||
// revocation window is extended by one, and the tail of our local commitment
|
||||
|
||||
Reference in new issue
Block a user