Skip to content

Commit e2e590c

Browse files
committed
Clarify CLTV expiry delta for trampolines further
1 parent 12eb3b6 commit e2e590c

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

lightning/src/routing/router.rs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -520,8 +520,12 @@ pub struct RouteHop {
520520
pub fee_msat: u64,
521521
/// The CLTV delta added for this hop.
522522
/// If this is the last hop in [`Path::hops`]:
523-
/// * if we're sending to a [`BlindedPaymentPath`], this is the CLTV delta for the entire blinded
524-
/// path (including any Trampoline hops)
523+
/// * if we're sending to a [`BlindedPaymentPath`] *with* trampoline hops, this is the CLTV
524+
/// delta for the entire blinded path including the trampoline hops, and is thus equal to the
525+
/// sum of [`TrampolineHop::cltv_expiry_delta`] for all the [`BlindedTail::trampoline_hops`].
526+
/// * if we're sending to a [`BlindedPaymentPath`], *without* trampoline hops, this is the CLTV
527+
/// delta for the entire blinded path (including
528+
/// [`BlindedTail::excess_final_cltv_expiry_delta`]).
525529
/// * otherwise, this is the CLTV delta expected at the destination
526530
pub cltv_expiry_delta: u32,
527531
/// Indicates whether this hop is possibly announced in the public network graph.
@@ -753,9 +757,9 @@ impl Route {
753757
let trampoline_cltv_sum: u32 =
754758
tail.trampoline_hops.iter().map(|hop| hop.cltv_expiry_delta).sum();
755759
let last_hop_cltv_delta = path.hops.last().unwrap().cltv_expiry_delta;
756-
if trampoline_cltv_sum > last_hop_cltv_delta {
760+
if !tail.trampoline_hops.is_empty() && trampoline_cltv_sum != last_hop_cltv_delta {
757761
let err = format!(
758-
"Path had a total trampoline CLTV of {trampoline_cltv_sum}, which is less than the total last-hop CLTV delta of {last_hop_cltv_delta}"
762+
"Path had a total trampoline CLTV of {trampoline_cltv_sum}, which is not equal to the total last-hop CLTV delta of {last_hop_cltv_delta}"
759763
);
760764
debug_assert!(false, "{}", err);
761765
log_error!(logger, "{}", err);

0 commit comments

Comments
 (0)