diff --git a/lnwallet/channel.go b/lnwallet/channel.go index f041d472..c98a5356 100644 --- a/lnwallet/channel.go +++ b/lnwallet/channel.go @@ -1692,27 +1692,17 @@ func (lc *LightningChannel) restoreStateLogs( pendingRemoteCommitDiff *channeldb.CommitDiff, pendingRemoteKeys *CommitmentKeyRing) error { - // For each HTLC within the local commitment, we add it to the relevant - // update logc based on if it's incoming vs outgoing. For any incoming - // HTLC's, we also re-add it to the rHashMap so we can quickly look it - // up. + // For each incoming HTLC within the local commitment, we add it to the + // remote update log. Since HTLCs are added first to the receiver's + // commitment, we don't have to restore outgoing HTLCs, as they will be + // restored from the remote commitment below. for i := range localCommitment.incomingHTLCs { htlc := localCommitment.incomingHTLCs[i] lc.remoteUpdateLog.restoreHtlc(&htlc) } - for i := range localCommitment.outgoingHTLCs { - htlc := localCommitment.outgoingHTLCs[i] - lc.localUpdateLog.restoreHtlc(&htlc) - } - // We'll also do the same for the HTLC"s within the remote commitment - // party. We also insert these HTLC's as it's possible our state has - // diverged slightly in the case of a congruent update from both sides. - // The restoreHtlc method will de-dup the HTLC's to handle this case. - for i := range remoteCommitment.incomingHTLCs { - htlc := remoteCommitment.incomingHTLCs[i] - lc.remoteUpdateLog.restoreHtlc(&htlc) - } + // Similarly, we'll do the same for the outgoing HTLCs within the + // remote commitment, adding them to the local update log. for i := range remoteCommitment.outgoingHTLCs { htlc := remoteCommitment.outgoingHTLCs[i] lc.localUpdateLog.restoreHtlc(&htlc)