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 4518bc7276)
This commit is contained in:
ziggie 2026-06-24 11:16:59 -03:00
parent 1c82b7a27d
commit 30ddd606fc
No known key found for this signature in database
GPG key ID: 1AFF9C4DCED6D666
14 changed files with 29 additions and 27 deletions

View file

@ -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

View file

@ -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()

View file

@ -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.

View file

@ -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.

View file

@ -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,

View file

@ -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,

View file

@ -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.

View file

@ -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

View file

@ -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,

View file

@ -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),

View file

@ -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,

View file

@ -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
}

View file

@ -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,
}

View file

@ -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,