lnwallet/channel: locked in settle/fail
This commit is contained in:
parent
9f358db7c7
commit
e693f89cb0
@ -4071,6 +4071,7 @@ func (lc *LightningChannel) ReceiveRevocation(revMsg *lnwire.RevokeAndAck) (
|
|||||||
remoteChainTail := lc.remoteCommitChain.tail().height + 1
|
remoteChainTail := lc.remoteCommitChain.tail().height + 1
|
||||||
localChainTail := lc.localCommitChain.tail().height
|
localChainTail := lc.localCommitChain.tail().height
|
||||||
|
|
||||||
|
source := lc.ShortChanID()
|
||||||
chanID := lnwire.NewChanIDFromOutPoint(&lc.channelState.FundingOutpoint)
|
chanID := lnwire.NewChanIDFromOutPoint(&lc.channelState.FundingOutpoint)
|
||||||
|
|
||||||
// Determine the set of htlcs that can be forwarded as a result of
|
// Determine the set of htlcs that can be forwarded as a result of
|
||||||
@ -4093,11 +4094,14 @@ func (lc *LightningChannel) ReceiveRevocation(revMsg *lnwire.RevokeAndAck) (
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
uncommitted := (pd.addCommitHeightRemote == 0 ||
|
// For each type of HTLC, we will only consider forwarding it if
|
||||||
pd.addCommitHeightLocal == 0)
|
// both of the remote and local heights are non-zero. If either
|
||||||
if pd.EntryType == Add && uncommitted {
|
// of these values is zero, it has yet to be committed in both
|
||||||
continue
|
// the local and remote chains.
|
||||||
}
|
committedAdd := pd.addCommitHeightRemote > 0 &&
|
||||||
|
pd.addCommitHeightLocal > 0
|
||||||
|
committedRmv := pd.removeCommitHeightRemote > 0 &&
|
||||||
|
pd.removeCommitHeightLocal > 0
|
||||||
|
|
||||||
// Using the height of the remote and local commitments,
|
// Using the height of the remote and local commitments,
|
||||||
// preemptively compute whether or not to forward this HTLC for
|
// preemptively compute whether or not to forward this HTLC for
|
||||||
@ -4105,7 +4109,7 @@ func (lc *LightningChannel) ReceiveRevocation(revMsg *lnwire.RevokeAndAck) (
|
|||||||
// Settle, Fail, or MalformedFail.
|
// Settle, Fail, or MalformedFail.
|
||||||
shouldFwdAdd := remoteChainTail == pd.addCommitHeightRemote &&
|
shouldFwdAdd := remoteChainTail == pd.addCommitHeightRemote &&
|
||||||
localChainTail >= pd.addCommitHeightLocal
|
localChainTail >= pd.addCommitHeightLocal
|
||||||
shouldFwdRmv := remoteChainTail >= pd.removeCommitHeightRemote &&
|
shouldFwdRmv := remoteChainTail == pd.removeCommitHeightRemote &&
|
||||||
localChainTail >= pd.removeCommitHeightLocal
|
localChainTail >= pd.removeCommitHeightLocal
|
||||||
|
|
||||||
// We'll only forward any new HTLC additions iff, it's "freshly
|
// We'll only forward any new HTLC additions iff, it's "freshly
|
||||||
@ -4114,8 +4118,7 @@ func (lc *LightningChannel) ReceiveRevocation(revMsg *lnwire.RevokeAndAck) (
|
|||||||
// don't re-forward any already processed HTLC's after a
|
// don't re-forward any already processed HTLC's after a
|
||||||
// restart.
|
// restart.
|
||||||
switch {
|
switch {
|
||||||
case pd.EntryType == Add && shouldFwdAdd:
|
case pd.EntryType == Add && committedAdd && shouldFwdAdd:
|
||||||
|
|
||||||
// Construct a reference specifying the location that
|
// Construct a reference specifying the location that
|
||||||
// this forwarded Add will be written in the forwarding
|
// this forwarded Add will be written in the forwarding
|
||||||
// package constructed at this remote height.
|
// package constructed at this remote height.
|
||||||
@ -4128,13 +4131,12 @@ func (lc *LightningChannel) ReceiveRevocation(revMsg *lnwire.RevokeAndAck) (
|
|||||||
pd.isForwarded = true
|
pd.isForwarded = true
|
||||||
addsToForward = append(addsToForward, pd)
|
addsToForward = append(addsToForward, pd)
|
||||||
|
|
||||||
case pd.EntryType != Add && shouldFwdRmv:
|
case pd.EntryType != Add && committedRmv && shouldFwdRmv:
|
||||||
|
|
||||||
// Construct a reference specifying the location that
|
// Construct a reference specifying the location that
|
||||||
// this forwarded Settle/Fail will be written in the
|
// this forwarded Settle/Fail will be written in the
|
||||||
// forwarding package constructed at this remote height.
|
// forwarding package constructed at this remote height.
|
||||||
pd.DestRef = &channeldb.SettleFailRef{
|
pd.DestRef = &channeldb.SettleFailRef{
|
||||||
Source: lc.ShortChanID(),
|
Source: source,
|
||||||
Height: remoteChainTail,
|
Height: remoteChainTail,
|
||||||
Index: settleFailIndex,
|
Index: settleFailIndex,
|
||||||
}
|
}
|
||||||
@ -4199,8 +4201,6 @@ func (lc *LightningChannel) ReceiveRevocation(revMsg *lnwire.RevokeAndAck) (
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
source := lc.ShortChanID()
|
|
||||||
|
|
||||||
// Now that we have gathered the set of HTLCs to forward, separated by
|
// Now that we have gathered the set of HTLCs to forward, separated by
|
||||||
// type, construct a forwarding package using the height that the remote
|
// type, construct a forwarding package using the height that the remote
|
||||||
// commitment chain will be extended after persisting the revocation.
|
// commitment chain will be extended after persisting the revocation.
|
||||||
|
Loading…
Reference in New Issue
Block a user