@@ -4071,6 +4071,7 @@ func (lc *LightningChannel) ReceiveRevocation(revMsg *lnwire.RevokeAndAck) (
4071
4071
remoteChainTail := lc .remoteCommitChain .tail ().height + 1
4072
4072
localChainTail := lc .localCommitChain .tail ().height
4073
4073
4074
+ source := lc .ShortChanID ()
4074
4075
chanID := lnwire .NewChanIDFromOutPoint (& lc .channelState .FundingOutpoint )
4075
4076
4076
4077
// Determine the set of htlcs that can be forwarded as a result of
@@ -4093,19 +4094,22 @@ func (lc *LightningChannel) ReceiveRevocation(revMsg *lnwire.RevokeAndAck) (
4093
4094
continue
4094
4095
}
4095
4096
4096
- uncommitted := (pd .addCommitHeightRemote == 0 ||
4097
- pd .addCommitHeightLocal == 0 )
4098
- if pd .EntryType == Add && uncommitted {
4099
- continue
4100
- }
4097
+ // For each type of HTLC, we will only consider forwarding it if
4098
+ // both of the remote and local heights are non-zero. If either
4099
+ // of these values is zero, it has yet to be committed in both
4100
+ // the local and remote chains.
4101
+ committedAdd := pd .addCommitHeightRemote > 0 &&
4102
+ pd .addCommitHeightLocal > 0
4103
+ committedRmv := pd .removeCommitHeightRemote > 0 &&
4104
+ pd .removeCommitHeightLocal > 0
4101
4105
4102
4106
// Using the height of the remote and local commitments,
4103
4107
// preemptively compute whether or not to forward this HTLC for
4104
4108
// the case in which this in an Add HTLC, or if this is a
4105
4109
// Settle, Fail, or MalformedFail.
4106
4110
shouldFwdAdd := remoteChainTail == pd .addCommitHeightRemote &&
4107
4111
localChainTail >= pd .addCommitHeightLocal
4108
- shouldFwdRmv := remoteChainTail > = pd .removeCommitHeightRemote &&
4112
+ shouldFwdRmv := remoteChainTail = = pd .removeCommitHeightRemote &&
4109
4113
localChainTail >= pd .removeCommitHeightLocal
4110
4114
4111
4115
// We'll only forward any new HTLC additions iff, it's "freshly
@@ -4114,8 +4118,7 @@ func (lc *LightningChannel) ReceiveRevocation(revMsg *lnwire.RevokeAndAck) (
4114
4118
// don't re-forward any already processed HTLC's after a
4115
4119
// restart.
4116
4120
switch {
4117
- case pd .EntryType == Add && shouldFwdAdd :
4118
-
4121
+ case pd .EntryType == Add && committedAdd && shouldFwdAdd :
4119
4122
// Construct a reference specifying the location that
4120
4123
// this forwarded Add will be written in the forwarding
4121
4124
// package constructed at this remote height.
@@ -4128,13 +4131,12 @@ func (lc *LightningChannel) ReceiveRevocation(revMsg *lnwire.RevokeAndAck) (
4128
4131
pd .isForwarded = true
4129
4132
addsToForward = append (addsToForward , pd )
4130
4133
4131
- case pd .EntryType != Add && shouldFwdRmv :
4132
-
4134
+ case pd .EntryType != Add && committedRmv && shouldFwdRmv :
4133
4135
// Construct a reference specifying the location that
4134
4136
// this forwarded Settle/Fail will be written in the
4135
4137
// forwarding package constructed at this remote height.
4136
4138
pd .DestRef = & channeldb.SettleFailRef {
4137
- Source : lc . ShortChanID () ,
4139
+ Source : source ,
4138
4140
Height : remoteChainTail ,
4139
4141
Index : settleFailIndex ,
4140
4142
}
@@ -4199,8 +4201,6 @@ func (lc *LightningChannel) ReceiveRevocation(revMsg *lnwire.RevokeAndAck) (
4199
4201
}
4200
4202
}
4201
4203
4202
- source := lc .ShortChanID ()
4203
-
4204
4204
// Now that we have gathered the set of HTLCs to forward, separated by
4205
4205
// type, construct a forwarding package using the height that the remote
4206
4206
// commitment chain will be extended after persisting the revocation.
0 commit comments