htlcswitch: relax final onion packet check

The spec allows the final HTLC value and CLTV expiry to exceed
the value and expiry specified in the payload of the last hop
of the onion packet. We were over-restricting it to require
that it matches exactly.
This commit is contained in:
Keagan McClelland 2023-06-14 14:02:34 -06:00
parent e0c0815c96
commit 1b1eedb434

View File

@ -1929,9 +1929,9 @@ func (l *channelLink) handleUpstreamMsg(msg lnwire.Message) {
// Instead of truncating the slice to conserve memory // Instead of truncating the slice to conserve memory
// allocations, we simply set the uncommitted preimage slice to // allocations, we simply set the uncommitted preimage slice to
// nil so that a new one will be initialized if any more // nil so that a new one will be initialized if any more
// witnesses are discovered. We do this maximum size of the // witnesses are discovered. We do this because the maximum size
// slice can occupy 15KB, and want to ensure we release that // that the slice can occupy is 15KB, and we want to ensure we
// memory back to the runtime. // release that memory back to the runtime.
l.uncommittedPreimages = nil l.uncommittedPreimages = nil
// We just received a new updates to our local commitment // We just received a new updates to our local commitment
@ -3237,11 +3237,10 @@ func (l *channelLink) processExitHop(pd *lnwallet.PaymentDescriptor,
// As we're the exit hop, we'll double check the hop-payload included in // As we're the exit hop, we'll double check the hop-payload included in
// the HTLC to ensure that it was crafted correctly by the sender and // the HTLC to ensure that it was crafted correctly by the sender and
// matches the HTLC we were extended. // is compatible with the HTLC we were extended.
if pd.Amount != fwdInfo.AmountToForward { if pd.Amount < fwdInfo.AmountToForward {
l.log.Errorf("onion payload of incoming htlc(%x) has "+
l.log.Errorf("onion payload of incoming htlc(%x) has incorrect "+ "incompatible value: expected <=%v, got %v", pd.RHash,
"value: expected %v, got %v", pd.RHash,
pd.Amount, fwdInfo.AmountToForward) pd.Amount, fwdInfo.AmountToForward)
failure := NewLinkError( failure := NewLinkError(
@ -3254,9 +3253,9 @@ func (l *channelLink) processExitHop(pd *lnwallet.PaymentDescriptor,
// We'll also ensure that our time-lock value has been computed // We'll also ensure that our time-lock value has been computed
// correctly. // correctly.
if pd.Timeout != fwdInfo.OutgoingCTLV { if pd.Timeout < fwdInfo.OutgoingCTLV {
l.log.Errorf("onion payload of incoming htlc(%x) has incorrect "+ l.log.Errorf("onion payload of incoming htlc(%x) has "+
"time-lock: expected %v, got %v", "incompatible time-lock: expected <=%v, got %v",
pd.RHash[:], pd.Timeout, fwdInfo.OutgoingCTLV) pd.RHash[:], pd.Timeout, fwdInfo.OutgoingCTLV)
failure := NewLinkError( failure := NewLinkError(