Skip to content

Commit de9f85a

Browse files
committed
Add trampoline_hops field to Path
1 parent f1a1a0c commit de9f85a

File tree

13 files changed

+49
-37
lines changed

13 files changed

+49
-37
lines changed

fuzz/src/chanmon_consistency.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -566,6 +566,7 @@ fn send_payment(
566566
maybe_announced_channel: true,
567567
}],
568568
blinded_tail: None,
569+
trampoline_hops: vec![],
569570
}],
570571
route_params: None,
571572
},
@@ -646,6 +647,7 @@ fn send_hop_payment(
646647
},
647648
],
648649
blinded_tail: None,
650+
trampoline_hops: vec![],
649651
}],
650652
route_params: None,
651653
},

lightning-background-processor/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2540,7 +2540,7 @@ mod tests {
25402540
fee_msat: 0,
25412541
cltv_expiry_delta: MIN_CLTV_EXPIRY_DELTA as u32,
25422542
maybe_announced_channel: true,
2543-
}], blinded_tail: None };
2543+
}], trampoline_hops: vec![], blinded_tail: None };
25442544

25452545
$nodes[0].scorer.write_lock().expect(TestResult::PaymentFailure { path: path.clone(), short_channel_id: scored_scid });
25462546
$nodes[0].node.push_pending_event(Event::PaymentPathFailed {

lightning/src/events/mod.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1894,7 +1894,7 @@ impl MaybeReadable for Event {
18941894
payment_hash,
18951895
payment_failed_permanently,
18961896
failure,
1897-
path: Path { hops: path.unwrap(), blinded_tail },
1897+
path: Path { hops: path.unwrap(), trampoline_hops: vec![], blinded_tail },
18981898
short_channel_id,
18991899
#[cfg(test)]
19001900
error_code,
@@ -2034,7 +2034,7 @@ impl MaybeReadable for Event {
20342034
Ok(Some(Event::PaymentPathSuccessful {
20352035
payment_id: payment_id.0.unwrap(),
20362036
payment_hash,
2037-
path: Path { hops: path, blinded_tail },
2037+
path: Path { hops: path, trampoline_hops: vec![], blinded_tail },
20382038
}))
20392039
};
20402040
f()
@@ -2114,7 +2114,7 @@ impl MaybeReadable for Event {
21142114
Ok(Some(Event::ProbeSuccessful {
21152115
payment_id: payment_id.0.unwrap(),
21162116
payment_hash: payment_hash.0.unwrap(),
2117-
path: Path { hops: path, blinded_tail },
2117+
path: Path { hops: path, trampoline_hops: vec![], blinded_tail },
21182118
}))
21192119
};
21202120
f()
@@ -2131,7 +2131,7 @@ impl MaybeReadable for Event {
21312131
Ok(Some(Event::ProbeFailed {
21322132
payment_id: payment_id.0.unwrap(),
21332133
payment_hash: payment_hash.0.unwrap(),
2134-
path: Path { hops: path, blinded_tail },
2134+
path: Path { hops: path, trampoline_hops: vec![], blinded_tail },
21352135
short_channel_id,
21362136
}))
21372137
};

lightning/src/ln/blinded_payment_tests.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1439,6 +1439,7 @@ fn route_blinding_spec_test_vector() {
14391439
cltv_expiry_delta: 42,
14401440
maybe_announced_channel: false,
14411441
}],
1442+
trampoline_hops: vec![],
14421443
blinded_tail: Some(BlindedTail {
14431444
hops: blinded_hops,
14441445
blinding_point: bob_blinding_point,

lightning/src/ln/channel.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9835,7 +9835,7 @@ mod tests {
98359835
cltv_expiry: 200000000,
98369836
state: OutboundHTLCState::Committed,
98379837
source: HTLCSource::OutboundRoute {
9838-
path: Path { hops: Vec::new(), blinded_tail: None },
9838+
path: Path { hops: Vec::new(), trampoline_hops: vec![], blinded_tail: None },
98399839
session_priv: SecretKey::from_slice(&<Vec<u8>>::from_hex("0fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff").unwrap()[..]).unwrap(),
98409840
first_hop_htlc_msat: 548,
98419841
payment_id: PaymentId([42; 32]),
@@ -10211,6 +10211,7 @@ mod tests {
1021110211
node_features: NodeFeatures::empty(), short_channel_id: 0, fee_msat: 0,
1021210212
cltv_expiry_delta: 0, maybe_announced_channel: false,
1021310213
}],
10214+
trampoline_hops: vec![],
1021410215
blinded_tail: None
1021510216
},
1021610217
session_priv: test_utils::privkey(42),

lightning/src/ln/channelmanager.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -639,7 +639,7 @@ impl HTLCSource {
639639
pub fn dummy() -> Self {
640640
assert!(cfg!(not(feature = "grind_signatures")));
641641
HTLCSource::OutboundRoute {
642-
path: Path { hops: Vec::new(), blinded_tail: None },
642+
path: Path { hops: Vec::new(), trampoline_hops: Vec::new(), blinded_tail: None },
643643
session_priv: SecretKey::from_slice(&[1; 32]).unwrap(),
644644
first_hop_htlc_msat: 0,
645645
payment_id: PaymentId([2; 32]),
@@ -11667,7 +11667,7 @@ impl Readable for HTLCSource {
1166711667
// instead.
1166811668
payment_id = Some(PaymentId(*session_priv.0.unwrap().as_ref()));
1166911669
}
11670-
let path = Path { hops: path_hops, blinded_tail };
11670+
let path = Path { hops: path_hops, trampoline_hops: vec![], blinded_tail };
1167111671
if path.hops.len() == 0 {
1167211672
return Err(DecodeError::InvalidValue);
1167311673
}

lightning/src/ln/functional_tests.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1093,7 +1093,7 @@ fn fake_network_test() {
10931093
hops[1].fee_msat = chan_4.1.contents.fee_base_msat as u64 + chan_4.1.contents.fee_proportional_millionths as u64 * hops[2].fee_msat as u64 / 1000000;
10941094
hops[0].fee_msat = chan_3.0.contents.fee_base_msat as u64 + chan_3.0.contents.fee_proportional_millionths as u64 * hops[1].fee_msat as u64 / 1000000;
10951095
let payment_preimage_1 = send_along_route(&nodes[1],
1096-
Route { paths: vec![Path { hops, blinded_tail: None }], route_params: None },
1096+
Route { paths: vec![Path { hops, trampoline_hops: vec![], blinded_tail: None }], route_params: None },
10971097
&vec!(&nodes[2], &nodes[3], &nodes[1])[..], 1000000).0;
10981098

10991099
let mut hops = Vec::with_capacity(3);
@@ -1127,7 +1127,7 @@ fn fake_network_test() {
11271127
hops[1].fee_msat = chan_2.1.contents.fee_base_msat as u64 + chan_2.1.contents.fee_proportional_millionths as u64 * hops[2].fee_msat as u64 / 1000000;
11281128
hops[0].fee_msat = chan_3.1.contents.fee_base_msat as u64 + chan_3.1.contents.fee_proportional_millionths as u64 * hops[1].fee_msat as u64 / 1000000;
11291129
let payment_hash_2 = send_along_route(&nodes[1],
1130-
Route { paths: vec![Path { hops, blinded_tail: None }], route_params: None },
1130+
Route { paths: vec![Path { hops, trampoline_hops: vec![], blinded_tail: None }], route_params: None },
11311131
&vec!(&nodes[3], &nodes[2], &nodes[1])[..], 1000000).1;
11321132

11331133
// Claim the rebalances...

lightning/src/ln/onion_payment.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -538,7 +538,7 @@ mod tests {
538538
// Ensure the onion will not fit all the payloads by adding a large custom TLV.
539539
recipient_onion.custom_tlvs.push((13377331, vec![0; 1156]));
540540

541-
let path = Path { hops, blinded_tail: None, };
541+
let path = Path { hops, trampoline_hops: vec![], blinded_tail: None, };
542542
let onion_keys = super::onion_utils::construct_onion_keys(&secp_ctx, &path, &session_priv).unwrap();
543543
let (onion_payloads, ..) = super::onion_utils::build_onion_payloads(
544544
&path, total_amt_msat, &recipient_onion, cur_height + 1, &Some(keysend_preimage)
@@ -564,6 +564,7 @@ mod tests {
564564

565565
let path = Path {
566566
hops: hops,
567+
trampoline_hops: vec![],
567568
blinded_tail: None,
568569
};
569570

lightning/src/ln/onion_utils.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1321,7 +1321,7 @@ mod tests {
13211321
channel_features: ChannelFeatures::empty(), node_features: NodeFeatures::empty(),
13221322
short_channel_id: 0, fee_msat: 0, cltv_expiry_delta: 0, maybe_announced_channel: true, // We fill in the payloads manually instead of generating them from RouteHops.
13231323
},
1324-
], blinded_tail: None }],
1324+
], trampoline_hops: vec![], blinded_tail: None }],
13251325
route_params: None,
13261326
};
13271327

lightning/src/ln/outbound_payment.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2418,7 +2418,7 @@ mod tests {
24182418
fee_msat: 0,
24192419
cltv_expiry_delta: 0,
24202420
maybe_announced_channel: true,
2421-
}], blinded_tail: None }],
2421+
}], trampoline_hops: vec![], blinded_tail: None }],
24222422
route_params: Some(route_params.clone()),
24232423
};
24242424
router.expect_find_route(route_params.clone(), Ok(route.clone()));
@@ -2771,6 +2771,7 @@ mod tests {
27712771
maybe_announced_channel: true,
27722772
}
27732773
],
2774+
trampoline_hops: vec![],
27742775
blinded_tail: None,
27752776
}
27762777
],

lightning/src/ln/payment_tests.rs

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2462,7 +2462,7 @@ fn auto_retry_partial_failure() {
24622462
fee_msat: amt_msat / 2,
24632463
cltv_expiry_delta: 100,
24642464
maybe_announced_channel: true,
2465-
}], blinded_tail: None },
2465+
}], trampoline_hops: vec![], blinded_tail: None },
24662466
Path { hops: vec![RouteHop {
24672467
pubkey: nodes[1].node.get_our_node_id(),
24682468
node_features: nodes[1].node.node_features(),
@@ -2471,7 +2471,7 @@ fn auto_retry_partial_failure() {
24712471
fee_msat: amt_msat / 2,
24722472
cltv_expiry_delta: 100,
24732473
maybe_announced_channel: true,
2474-
}], blinded_tail: None },
2474+
}], trampoline_hops: vec![], blinded_tail: None },
24752475
],
24762476
route_params: Some(route_params.clone()),
24772477
};
@@ -2493,7 +2493,7 @@ fn auto_retry_partial_failure() {
24932493
fee_msat: amt_msat / 4,
24942494
cltv_expiry_delta: 100,
24952495
maybe_announced_channel: true,
2496-
}], blinded_tail: None },
2496+
}], trampoline_hops: vec![], blinded_tail: None },
24972497
Path { hops: vec![RouteHop {
24982498
pubkey: nodes[1].node.get_our_node_id(),
24992499
node_features: nodes[1].node.node_features(),
@@ -2502,7 +2502,7 @@ fn auto_retry_partial_failure() {
25022502
fee_msat: amt_msat / 4,
25032503
cltv_expiry_delta: 100,
25042504
maybe_announced_channel: true,
2505-
}], blinded_tail: None },
2505+
}], trampoline_hops: vec![], blinded_tail: None },
25062506
],
25072507
route_params: Some(retry_1_params.clone()),
25082508
};
@@ -2524,7 +2524,7 @@ fn auto_retry_partial_failure() {
25242524
fee_msat: amt_msat / 4,
25252525
cltv_expiry_delta: 100,
25262526
maybe_announced_channel: true,
2527-
}], blinded_tail: None },
2527+
}], trampoline_hops: vec![], blinded_tail: None },
25282528
],
25292529
route_params: Some(retry_2_params.clone()),
25302530
};
@@ -2669,7 +2669,7 @@ fn auto_retry_zero_attempts_send_error() {
26692669
fee_msat: amt_msat,
26702670
cltv_expiry_delta: 100,
26712671
maybe_announced_channel: true,
2672-
}], blinded_tail: None },
2672+
}], trampoline_hops: vec![], blinded_tail: None },
26732673
],
26742674
route_params: Some(route_params.clone()),
26752675
};
@@ -2767,7 +2767,7 @@ fn retry_multi_path_single_failed_payment() {
27672767
fee_msat: 10_000,
27682768
cltv_expiry_delta: 100,
27692769
maybe_announced_channel: true,
2770-
}], blinded_tail: None },
2770+
}], trampoline_hops: vec![], blinded_tail: None },
27712771
Path { hops: vec![RouteHop {
27722772
pubkey: nodes[1].node.get_our_node_id(),
27732773
node_features: nodes[1].node.node_features(),
@@ -2776,7 +2776,7 @@ fn retry_multi_path_single_failed_payment() {
27762776
fee_msat: 100_000_001, // Our default max-HTLC-value is 10% of the channel value, which this is one more than
27772777
cltv_expiry_delta: 100,
27782778
maybe_announced_channel: true,
2779-
}], blinded_tail: None },
2779+
}], trampoline_hops: vec![], blinded_tail: None },
27802780
],
27812781
route_params: Some(route_params.clone()),
27822782
};
@@ -2858,7 +2858,7 @@ fn immediate_retry_on_failure() {
28582858
fee_msat: 100_000_001, // Our default max-HTLC-value is 10% of the channel value, which this is one more than
28592859
cltv_expiry_delta: 100,
28602860
maybe_announced_channel: true,
2861-
}], blinded_tail: None },
2861+
}], trampoline_hops: vec![], blinded_tail: None },
28622862
],
28632863
route_params: Some(route_params.clone()),
28642864
};
@@ -2952,7 +2952,7 @@ fn no_extra_retries_on_back_to_back_fail() {
29522952
fee_msat: 100_000_000,
29532953
cltv_expiry_delta: 100,
29542954
maybe_announced_channel: true,
2955-
}], blinded_tail: None },
2955+
}], trampoline_hops: vec![], blinded_tail: None },
29562956
Path { hops: vec![RouteHop {
29572957
pubkey: nodes[1].node.get_our_node_id(),
29582958
node_features: nodes[1].node.node_features(),
@@ -2969,7 +2969,7 @@ fn no_extra_retries_on_back_to_back_fail() {
29692969
fee_msat: 100_000_000,
29702970
cltv_expiry_delta: 100,
29712971
maybe_announced_channel: true,
2972-
}], blinded_tail: None }
2972+
}], trampoline_hops: vec![], blinded_tail: None }
29732973
],
29742974
route_params: Some(route_params.clone()),
29752975
};
@@ -3157,7 +3157,7 @@ fn test_simple_partial_retry() {
31573157
fee_msat: 100_000_000,
31583158
cltv_expiry_delta: 100,
31593159
maybe_announced_channel: true,
3160-
}], blinded_tail: None },
3160+
}], trampoline_hops: vec![], blinded_tail: None },
31613161
Path { hops: vec![RouteHop {
31623162
pubkey: nodes[1].node.get_our_node_id(),
31633163
node_features: nodes[1].node.node_features(),
@@ -3174,7 +3174,7 @@ fn test_simple_partial_retry() {
31743174
fee_msat: 100_000_000,
31753175
cltv_expiry_delta: 100,
31763176
maybe_announced_channel: true,
3177-
}], blinded_tail: None }
3177+
}], trampoline_hops: vec![], blinded_tail: None }
31783178
],
31793179
route_params: Some(route_params.clone()),
31803180
};
@@ -3328,7 +3328,7 @@ fn test_threaded_payment_retries() {
33283328
fee_msat: amt_msat / 1000,
33293329
cltv_expiry_delta: 100,
33303330
maybe_announced_channel: true,
3331-
}], blinded_tail: None },
3331+
}], trampoline_hops: vec![], blinded_tail: None },
33323332
Path { hops: vec![RouteHop {
33333333
pubkey: nodes[2].node.get_our_node_id(),
33343334
node_features: nodes[2].node.node_features(),
@@ -3345,7 +3345,7 @@ fn test_threaded_payment_retries() {
33453345
fee_msat: amt_msat - amt_msat / 1000,
33463346
cltv_expiry_delta: 100,
33473347
maybe_announced_channel: true,
3348-
}], blinded_tail: None }
3348+
}], trampoline_hops: vec![], blinded_tail: None }
33493349
],
33503350
route_params: Some(route_params.clone()),
33513351
};

lightning/src/routing/router.rs

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -457,6 +457,9 @@ impl_writeable_tlv_based!(BlindedTail, {
457457
pub struct Path {
458458
/// The list of unblinded hops in this [`Path`]. Must be at least length one.
459459
pub hops: Vec<RouteHop>,
460+
/// The list of unblinded Trampoline hops. If present, must be at least one.
461+
/// The public key of the first Trampoline hop must match the public key of the last regular hop.
462+
pub trampoline_hops: Vec<TrampolineHop>,
460463
/// The blinded path at which this path terminates, if we're sending to one, and its metadata.
461464
pub blinded_tail: Option<BlindedTail>,
462465
}
@@ -589,7 +592,7 @@ impl Readable for Route {
589592
if hops.is_empty() { return Err(DecodeError::InvalidValue); }
590593
min_final_cltv_expiry_delta =
591594
cmp::min(min_final_cltv_expiry_delta, hops.last().unwrap().cltv_expiry_delta);
592-
paths.push(Path { hops, blinded_tail: None });
595+
paths.push(Path { hops, trampoline_hops: vec![], blinded_tail: None });
593596
}
594597
_init_and_read_len_prefixed_tlv_fields!(reader, {
595598
(1, payment_params, (option: ReadableArgs, min_final_cltv_expiry_delta)),
@@ -3390,7 +3393,7 @@ where L::Target: Logger {
33903393
core::mem::replace(&mut hop.cltv_expiry_delta, prev_cltv_expiry_delta)
33913394
});
33923395

3393-
paths.push(Path { hops, blinded_tail });
3396+
paths.push(Path { hops, trampoline_hops: vec![], blinded_tail });
33943397
}
33953398
// Make sure we would never create a route with more paths than we allow.
33963399
debug_assert!(paths.len() <= payment_params.max_path_count.into());
@@ -7114,7 +7117,7 @@ mod tests {
71147117
channel_features: ChannelFeatures::empty(), node_features: NodeFeatures::empty(),
71157118
short_channel_id: 0, fee_msat: 225, cltv_expiry_delta: 0, maybe_announced_channel: true,
71167119
},
7117-
], blinded_tail: None }],
7120+
], trampoline_hops: vec![], blinded_tail: None }],
71187121
route_params: None,
71197122
};
71207123

@@ -7136,7 +7139,7 @@ mod tests {
71367139
channel_features: ChannelFeatures::empty(), node_features: NodeFeatures::empty(),
71377140
short_channel_id: 0, fee_msat: 150, cltv_expiry_delta: 0, maybe_announced_channel: true,
71387141
},
7139-
], blinded_tail: None }, Path { hops: vec![
7142+
], trampoline_hops: vec![], blinded_tail: None }, Path { hops: vec![
71407143
RouteHop {
71417144
pubkey: PublicKey::from_slice(&<Vec<u8>>::from_hex("02eec7245d6b7d2ccb30380bfbe2a3648cd7a942653f5aa340edcea1f283686619").unwrap()[..]).unwrap(),
71427145
channel_features: ChannelFeatures::empty(), node_features: NodeFeatures::empty(),
@@ -7147,7 +7150,7 @@ mod tests {
71477150
channel_features: ChannelFeatures::empty(), node_features: NodeFeatures::empty(),
71487151
short_channel_id: 0, fee_msat: 150, cltv_expiry_delta: 0, maybe_announced_channel: true,
71497152
},
7150-
], blinded_tail: None }],
7153+
], trampoline_hops: vec![], blinded_tail: None }],
71517154
route_params: None,
71527155
};
71537156

@@ -7722,6 +7725,7 @@ mod tests {
77227725
cltv_expiry_delta: 0,
77237726
maybe_announced_channel: true,
77247727
}],
7728+
trampoline_hops: vec![],
77257729
blinded_tail: Some(BlindedTail {
77267730
hops: vec![
77277731
BlindedHop { blinded_node_id: ln_test_utils::pubkey(44), encrypted_payload: Vec::new() },
@@ -7740,7 +7744,7 @@ mod tests {
77407744
fee_msat: 100,
77417745
cltv_expiry_delta: 0,
77427746
maybe_announced_channel: true,
7743-
}], blinded_tail: None }],
7747+
}], trampoline_hops: vec![], blinded_tail: None }],
77447748
route_params: None,
77457749
};
77467750
let encoded_route = route.encode();
@@ -7789,6 +7793,7 @@ mod tests {
77897793
cltv_expiry_delta: 0,
77907794
maybe_announced_channel: false,
77917795
}],
7796+
trampoline_hops: vec![],
77927797
blinded_tail: Some(BlindedTail {
77937798
hops: vec![BlindedHop { blinded_node_id: ln_test_utils::pubkey(49), encrypted_payload: Vec::new() }],
77947799
blinding_point: ln_test_utils::pubkey(48),
@@ -7825,6 +7830,7 @@ mod tests {
78257830
maybe_announced_channel: false,
78267831
}
78277832
],
7833+
trampoline_hops: vec![],
78287834
blinded_tail: Some(BlindedTail {
78297835
hops: vec![
78307836
BlindedHop { blinded_node_id: ln_test_utils::pubkey(45), encrypted_payload: Vec::new() },

0 commit comments

Comments
 (0)