From 30ddd606fca7f04014ef3a2f37697acdc91593b7 Mon Sep 17 00:00:00 2001 From: ziggie Date: Wed, 24 Jun 2026 11:16:59 -0300 Subject: [PATCH] htlcswitch: fix outgoing cltv spelling Rename the ForwardingInfo.OutgoingCTLV field to OutgoingCLTV and update all call sites. This keeps the exported field spelling consistent with the CLTV terminology used elsewhere. Also fix the remaining CTLV typos in nearby comments. (cherry picked from commit 4518bc72763261a640276fb898562b0b3f4257cb) --- contractcourt/channel_arbitrator.go | 2 +- contractcourt/htlc_incoming_contest_resolver.go | 2 +- graph/db/models/channel.go | 2 +- htlcswitch/hop/forwarding_info.go | 6 +++--- htlcswitch/hop/forwarding_info_test.go | 4 ++-- htlcswitch/hop/fuzz_test.go | 2 +- htlcswitch/hop/iterator.go | 2 +- htlcswitch/hop/iterator_test.go | 2 +- htlcswitch/hop/payload.go | 4 ++-- htlcswitch/link.go | 10 +++++----- htlcswitch/link_test.go | 8 ++++---- htlcswitch/mock.go | 8 +++++--- htlcswitch/switch_test.go | 2 +- witness_beacon.go | 2 +- 14 files changed, 29 insertions(+), 27 deletions(-) diff --git a/contractcourt/channel_arbitrator.go b/contractcourt/channel_arbitrator.go index ae2ffc8ab..1c4db6fb8 100644 --- a/contractcourt/channel_arbitrator.go +++ b/contractcourt/channel_arbitrator.go @@ -1437,7 +1437,7 @@ func (c *ChannelArbitrator) sweepAnchors(anchors *lnwallet.AnchorResolutions, // HTLCs, or, // - half of the least CLTV from incoming HTLCs if the preimage is available. // -// We use half of the CTLV value to ensure that we have enough time to sweep +// We use half of the CLTV value to ensure that we have enough time to sweep // the second-level HTLCs. // // It also finds the total value that are time-sensitive, which is the sum of diff --git a/contractcourt/htlc_incoming_contest_resolver.go b/contractcourt/htlc_incoming_contest_resolver.go index 388e3cb97..d075166c1 100644 --- a/contractcourt/htlc_incoming_contest_resolver.go +++ b/contractcourt/htlc_incoming_contest_resolver.go @@ -212,7 +212,7 @@ func (h *htlcIncomingContestResolver) Resolve() (ContractResolver, error) { "expected_expiry=%v, height=%v, max=%v), resolving as "+ "failed", h, h.htlcResolution.ClaimOutpoint, h.htlc.Amt, payload.FwdInfo.AmountToForward, - h.htlcExpiry, payload.FwdInfo.OutgoingCTLV, + h.htlcExpiry, payload.FwdInfo.OutgoingCLTV, currentHeight, invoices.MaxFinalCltvDelta) h.markResolved() diff --git a/graph/db/models/channel.go b/graph/db/models/channel.go index 2069d1629..abe4c3be7 100644 --- a/graph/db/models/channel.go +++ b/graph/db/models/channel.go @@ -123,7 +123,7 @@ type ForwardingPolicy struct { // create the time-lock value for the forwarded outgoing HTLC. The // following constraint MUST hold for an HTLC to be forwarded: // - // * incomingHtlc.timeLock - timeLockDelta = fwdInfo.OutgoingCTLV + // * incomingHtlc.timeLock - timeLockDelta = fwdInfo.OutgoingCLTV // // where fwdInfo is the forwarding information extracted from the // per-hop payload of the incoming HTLC's onion packet. diff --git a/htlcswitch/hop/forwarding_info.go b/htlcswitch/hop/forwarding_info.go index 4f325f84e..539e0db1f 100644 --- a/htlcswitch/hop/forwarding_info.go +++ b/htlcswitch/hop/forwarding_info.go @@ -20,9 +20,9 @@ type ForwardingInfo struct { // node should forward to the next hop. AmountToForward lnwire.MilliSatoshi - // OutgoingCTLV is the specified value of the CTLV timelock to be used + // OutgoingCLTV is the specified value of the CLTV timelock to be used // in the outgoing HTLC. - OutgoingCTLV uint32 + OutgoingCLTV uint32 // NextBlinding is an optional blinding point to be passed to the next // node in UpdateAddHtlc. This field is set if the htlc is part of a @@ -71,7 +71,7 @@ func ValidateFinalHtlc(amt lnwire.MilliSatoshi, expiry, heightNow, // The HTLC expiry is below the final CLTV requested by the onion // payload. - case expiry < fwdInfo.OutgoingCTLV: + case expiry < fwdInfo.OutgoingCLTV: return FinalHtlcInvalidCltv // The HTLC expiry is outside the supported final-hop CLTV range. diff --git a/htlcswitch/hop/forwarding_info_test.go b/htlcswitch/hop/forwarding_info_test.go index 68ac6f2a5..82a5ad0c6 100644 --- a/htlcswitch/hop/forwarding_info_test.go +++ b/htlcswitch/hop/forwarding_info_test.go @@ -20,7 +20,7 @@ func TestValidateFinalHtlc(t *testing.T) { fwdInfo := ForwardingInfo{ AmountToForward: amount, - OutgoingCTLV: expiry, + OutgoingCLTV: expiry, NextHop: Exit, } @@ -114,7 +114,7 @@ func TestValidateFinalHtlc(t *testing.T) { maxCltvDelta: maxCltvDelta, fwdInfo: ForwardingInfo{ AmountToForward: amount, - OutgoingCTLV: expiry + maxCltvDelta + 2, + OutgoingCLTV: expiry + maxCltvDelta + 2, NextHop: Exit, }, validateAmount: true, diff --git a/htlcswitch/hop/fuzz_test.go b/htlcswitch/hop/fuzz_test.go index e5c00b525..525194c38 100644 --- a/htlcswitch/hop/fuzz_test.go +++ b/htlcswitch/hop/fuzz_test.go @@ -84,7 +84,7 @@ func FuzzOnionPacket(f *testing.F) { func hopFromPayload(p *Payload) (*route.Hop, uint64) { return &route.Hop{ AmtToForward: p.FwdInfo.AmountToForward, - OutgoingTimeLock: p.FwdInfo.OutgoingCTLV, + OutgoingTimeLock: p.FwdInfo.OutgoingCLTV, MPP: p.MPP, AMP: p.AMP, Metadata: p.metadata, diff --git a/htlcswitch/hop/iterator.go b/htlcswitch/hop/iterator.go index 553c4921d..cf04b88a1 100644 --- a/htlcswitch/hop/iterator.go +++ b/htlcswitch/hop/iterator.go @@ -327,7 +327,7 @@ func deriveBlindedRouteForwardingInfo(r *sphinxHopIterator, payload.FwdInfo = ForwardingInfo{ NextHop: nextSCID.Val, AmountToForward: fwdAmt, - OutgoingCTLV: r.blindingKit.IncomingCltv - uint32( + OutgoingCLTV: r.blindingKit.IncomingCltv - uint32( relayInfo.Val.CltvExpiryDelta, ), // Remap from blinding override type to blinding point type. diff --git a/htlcswitch/hop/iterator_test.go b/htlcswitch/hop/iterator_test.go index ab435a986..b132a046d 100644 --- a/htlcswitch/hop/iterator_test.go +++ b/htlcswitch/hop/iterator_test.go @@ -35,7 +35,7 @@ func TestSphinxHopIteratorForwardingInstructions(t *testing.T) { expectedFwdInfo := ForwardingInfo{ NextHop: lnwire.NewShortChanIDFromInt(nextAddrInt), AmountToForward: lnwire.MilliSatoshi(hopData.ForwardAmount), - OutgoingCTLV: hopData.OutgoingCltv, + OutgoingCLTV: hopData.OutgoingCltv, } // For our TLV payload, we'll serialize the hop into into a TLV stream diff --git a/htlcswitch/hop/payload.go b/htlcswitch/hop/payload.go index fc456828a..14a0813e8 100644 --- a/htlcswitch/hop/payload.go +++ b/htlcswitch/hop/payload.go @@ -128,7 +128,7 @@ func NewLegacyPayload(f *sphinx.HopData) *Payload { FwdInfo: ForwardingInfo{ NextHop: lnwire.NewShortChanIDFromInt(nextHop), AmountToForward: lnwire.MilliSatoshi(f.ForwardAmount), - OutgoingCTLV: f.OutgoingCltv, + OutgoingCLTV: f.OutgoingCltv, }, customRecords: make(record.CustomSet), } @@ -203,7 +203,7 @@ func ParseTLVPayload(r io.Reader) (*Payload, map[tlv.Type][]byte, error) { FwdInfo: ForwardingInfo{ NextHop: lnwire.NewShortChanIDFromInt(cid), AmountToForward: lnwire.MilliSatoshi(amt), - OutgoingCTLV: cltv, + OutgoingCLTV: cltv, }, MPP: mpp, AMP: amp, diff --git a/htlcswitch/link.go b/htlcswitch/link.go index 3f5685bb7..056403cb3 100644 --- a/htlcswitch/link.go +++ b/htlcswitch/link.go @@ -3200,7 +3200,7 @@ func (l *channelLink) processRemoteAdds(fwdPkg *channeldb.FwdPkg) { // Otherwise, it was already processed, we can // can collect it and continue. outgoingAdd := &lnwire.UpdateAddHTLC{ - Expiry: fwdInfo.OutgoingCTLV, + Expiry: fwdInfo.OutgoingCLTV, Amount: fwdInfo.AmountToForward, PaymentHash: add.PaymentHash, BlindingPoint: fwdInfo.NextBlinding, @@ -3239,7 +3239,7 @@ func (l *channelLink) processRemoteAdds(fwdPkg *channeldb.FwdPkg) { htlc: outgoingAdd, obfuscator: obfuscator, incomingTimeout: add.Expiry, - outgoingTimeout: fwdInfo.OutgoingCTLV, + outgoingTimeout: fwdInfo.OutgoingCLTV, inOnionCustomRecords: pld.CustomRecords(), inboundFee: inboundFee, inWireCustomRecords: add.CustomRecords.Copy(), @@ -3258,7 +3258,7 @@ func (l *channelLink) processRemoteAdds(fwdPkg *channeldb.FwdPkg) { // create the outgoing HTLC using the parameters as // specified in the forwarding info. addMsg := &lnwire.UpdateAddHTLC{ - Expiry: fwdInfo.OutgoingCTLV, + Expiry: fwdInfo.OutgoingCLTV, Amount: fwdInfo.AmountToForward, PaymentHash: add.PaymentHash, BlindingPoint: fwdInfo.NextBlinding, @@ -3316,7 +3316,7 @@ func (l *channelLink) processRemoteAdds(fwdPkg *channeldb.FwdPkg) { htlc: addMsg, obfuscator: obfuscator, incomingTimeout: add.Expiry, - outgoingTimeout: fwdInfo.OutgoingCTLV, + outgoingTimeout: fwdInfo.OutgoingCLTV, inOnionCustomRecords: pld.CustomRecords(), inboundFee: inboundFee, inWireCustomRecords: add.CustomRecords.Copy(), @@ -3447,7 +3447,7 @@ func (l *channelLink) processExitHop(add lnwire.UpdateAddHTLC, case hop.FinalHtlcInvalidCltv: l.log.Errorf("onion payload of incoming htlc(%x) has "+ "incompatible time-lock: expected <=%v, got %v", - add.PaymentHash, add.Expiry, fwdInfo.OutgoingCTLV) + add.PaymentHash, add.Expiry, fwdInfo.OutgoingCLTV) failure := NewLinkError( lnwire.NewFinalIncorrectCltvExpiry(add.Expiry), diff --git a/htlcswitch/link_test.go b/htlcswitch/link_test.go index cb3292b0f..a64942d5c 100644 --- a/htlcswitch/link_test.go +++ b/htlcswitch/link_test.go @@ -779,13 +779,13 @@ func testChannelLinkInboundFee(t *testing.T, //nolint:thelper NextHop: n.carolChannelLink. ShortChanID(), AmountToForward: 1_000_000, - OutgoingCTLV: 106, + OutgoingCLTV: 106, }, }, { FwdInfo: hop.ForwardingInfo{ AmountToForward: 1_000_000, - OutgoingCTLV: 106, + OutgoingCLTV: 106, }, }, } @@ -974,7 +974,7 @@ func TestExitNodeHTLCTimelockExceedsPayload(t *testing.T) { // The proper value of the outgoing CLTV should be the policy set by // the receiving node, instead we set it to be a value less than the // incoming HTLC timelock. - hops[0].FwdInfo.OutgoingCTLV = htlcExpiry - 1 + hops[0].FwdInfo.OutgoingCLTV = htlcExpiry - 1 firstHop := n.firstBobChannelLink.ShortChanID() _, err = makePayment( n.aliceServer, n.bobServer, firstHop, hops, amount, htlcAmt, @@ -1012,7 +1012,7 @@ func TestExitNodeTimelockPayloadExceedsHTLC(t *testing.T) { // The proper value of the outgoing CLTV should be the policy set by // the receiving node, instead we set it to be a value greater than the // incoming HTLC timelock. - hops[0].FwdInfo.OutgoingCTLV = htlcExpiry + 1 + hops[0].FwdInfo.OutgoingCLTV = htlcExpiry + 1 firstHop := n.firstBobChannelLink.ShortChanID() _, err = makePayment( n.aliceServer, n.bobServer, firstHop, hops, amount, htlcAmt, diff --git a/htlcswitch/mock.go b/htlcswitch/mock.go index 70bd73c37..dbab96727 100644 --- a/htlcswitch/mock.go +++ b/htlcswitch/mock.go @@ -375,7 +375,8 @@ func encodeFwdInfo(w io.Writer, f *hop.ForwardingInfo) error { return err } - if err := binary.Write(w, binary.BigEndian, f.OutgoingCTLV); err != nil { + err := binary.Write(w, binary.BigEndian, f.OutgoingCLTV) + if err != nil { return err } @@ -514,7 +515,7 @@ func (p *mockIteratorDecoder) DecodeHopIterator(r io.Reader, rHash []byte, Realm: [1]byte{}, // hop.BitcoinNetwork NextAddress: nextHopBytes, ForwardAmount: uint64(f.AmountToForward), - OutgoingCltv: f.OutgoingCTLV, + OutgoingCltv: f.OutgoingCLTV, }) } @@ -569,7 +570,8 @@ func decodeFwdInfo(r io.Reader, f *hop.ForwardingInfo) error { return err } - if err := binary.Read(r, binary.BigEndian, &f.OutgoingCTLV); err != nil { + err := binary.Read(r, binary.BigEndian, &f.OutgoingCLTV) + if err != nil { return err } diff --git a/htlcswitch/switch_test.go b/htlcswitch/switch_test.go index e8176aaeb..884e9f368 100644 --- a/htlcswitch/switch_test.go +++ b/htlcswitch/switch_test.go @@ -3603,7 +3603,7 @@ func getThreeHopEvents(channels *clusterChannels, htlcID uint64, bobInfo := HtlcInfo{ IncomingTimeLock: htlc.Expiry, IncomingAmt: htlc.Amount, - OutgoingTimeLock: hops[1].FwdInfo.OutgoingCTLV, + OutgoingTimeLock: hops[1].FwdInfo.OutgoingCLTV, OutgoingAmt: hops[1].FwdInfo.AmountToForward, } diff --git a/witness_beacon.go b/witness_beacon.go index 6c315d0c1..eba0bcad6 100644 --- a/witness_beacon.go +++ b/witness_beacon.go @@ -102,7 +102,7 @@ func (p *preimageBeacon) SubscribeUpdates( HtlcID: htlc.HtlcIndex, }, OutgoingChanID: payload.FwdInfo.NextHop, - OutgoingExpiry: payload.FwdInfo.OutgoingCTLV, + OutgoingExpiry: payload.FwdInfo.OutgoingCLTV, OutgoingAmount: payload.FwdInfo.AmountToForward, InOnionCustomRecords: payload.CustomRecords(), InWireCustomRecords: htlc.CustomRecords,