mirror of
https://github.com/lightningnetwork/lnd.git
synced 2024-11-19 01:43:16 +01:00
htlcswitch: update forwarding policy verification to use new time lock info
This commit is contained in:
parent
7b4c150983
commit
bdecc5bea9
@ -1807,7 +1807,7 @@ func (l *channelLink) HtlcSatifiesPolicy(payHash [32]byte,
|
||||
// to the current height.
|
||||
timeDelta := policy.TimeLockDelta
|
||||
if incomingTimeout-timeDelta <= heightNow {
|
||||
log.Errorf("htlc(%x) has an expiry that's too soon: "+
|
||||
l.errorf("htlc(%x) has an expiry that's too soon: "+
|
||||
"outgoing_expiry=%v, best_height=%v", payHash[:],
|
||||
incomingTimeout-timeDelta, heightNow)
|
||||
|
||||
@ -1829,7 +1829,7 @@ func (l *channelLink) HtlcSatifiesPolicy(payHash [32]byte,
|
||||
// delta should equal the outgoing time lock. Otherwise, whether the
|
||||
// sender messed up, or an intermediate node tampered with the HTLC.
|
||||
if incomingTimeout-timeDelta < outgoingTimeout {
|
||||
log.Errorf("Incoming htlc(%x) has incorrect time-lock value: "+
|
||||
l.errorf("Incoming htlc(%x) has incorrect time-lock value: "+
|
||||
"expected at least %v block delta, got %v block delta",
|
||||
payHash[:], timeDelta, incomingTimeout-outgoingTimeout)
|
||||
|
||||
|
@ -964,9 +964,11 @@ func (s *Switch) handlePacketForward(packet *htlcPacket) error {
|
||||
// Before we check the link's bandwidth, we'll ensure
|
||||
// that the HTLC satisfies the current forwarding
|
||||
// policy of this target link.
|
||||
currentHeight := atomic.LoadUint32(&s.bestHeight)
|
||||
err := link.HtlcSatifiesPolicy(
|
||||
htlc.PaymentHash, packet.incomingAmount,
|
||||
packet.amount,
|
||||
packet.amount, packet.incomingTimeout,
|
||||
packet.outgoingTimeout, currentHeight,
|
||||
)
|
||||
if err != nil {
|
||||
linkErrs[link.ShortChanID()] = err
|
||||
@ -1404,6 +1406,7 @@ out:
|
||||
}
|
||||
|
||||
atomic.StoreUint32(&s.bestHeight, uint32(blockEpoch.Height))
|
||||
|
||||
// A local close request has arrived, we'll forward this to the
|
||||
// relevant link (if it exists) so the channel can be
|
||||
// cooperatively closed (if possible).
|
||||
|
Loading…
Reference in New Issue
Block a user