From c1e96e01e620340ee80d57d6c3cb3ed575ed01fe Mon Sep 17 00:00:00 2001 From: "Johan T. Halseth" Date: Wed, 16 May 2018 13:34:35 +0200 Subject: [PATCH] lnwallet/channel: remove restoreHtlc from pendingRemoteCommit This commit removes the stage during updateLog restoration where we would attempt to restore incoming HLTCs from the pendingRemoteCommit, in addition to update our log and htlc counter to reflect this state. The reason we can safely remove this is to observe that a pending remote commit is always created from a commitDiff which only contains updates made by _us_, and thus only taken from the localUpdateLog. The same can be said for the counters, when creating a commitDiff we'll always use the remoteACKedIndex as the index into the remoteUpdateLog, meaning that all potential updates will already be included in the remote commit that has been ACKed. --- lnwallet/channel.go | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/lnwallet/channel.go b/lnwallet/channel.go index 16c90af4b..f041d472d 100644 --- a/lnwallet/channel.go +++ b/lnwallet/channel.go @@ -1724,22 +1724,6 @@ func (lc *LightningChannel) restoreStateLogs( return nil } - // If we do have a dangling commitment for the remote party, then we'll - // also restore into the log any incoming HTLC's offered by them. Any - // outgoing HTLC's that were initially committed in this new state will - // be restored below. - for i := range pendingRemoteCommit.incomingHTLCs { - htlc := pendingRemoteCommit.incomingHTLCs[i] - lc.remoteUpdateLog.restoreHtlc(&htlc) - } - - // We'll also update the log counters to match the latest known - // counters in this dangling commitment. Otherwise, our updateLog would - // have dated counters as it was initially created using their lowest - // unrevoked commitment. - lc.remoteUpdateLog.logIndex = pendingRemoteCommit.theirMessageIndex - lc.remoteUpdateLog.htlcCounter = pendingRemoteCommit.theirHtlcIndex - pendingCommit := pendingRemoteCommitDiff.Commitment pendingHeight := pendingCommit.CommitHeight