Skip to content

Commit a6887d7

Browse files
committed
Add trampoline_hops field to Path
1 parent 7a9a464 commit a6887d7

File tree

13 files changed

+48
-37
lines changed

13 files changed

+48
-37
lines changed

fuzz/src/chanmon_consistency.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -559,6 +559,7 @@ fn send_payment(
559559
maybe_announced_channel: true,
560560
}],
561561
blinded_tail: None,
562+
trampoline_hops: vec![],
562563
}],
563564
route_params: None,
564565
},
@@ -639,6 +640,7 @@ fn send_hop_payment(
639640
},
640641
],
641642
blinded_tail: None,
643+
trampoline_hops: vec![],
642644
}],
643645
route_params: None,
644646
},

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
@@ -1928,7 +1928,7 @@ impl MaybeReadable for Event {
19281928
payment_hash,
19291929
payment_failed_permanently,
19301930
failure,
1931-
path: Path { hops: path.unwrap(), blinded_tail },
1931+
path: Path { hops: path.unwrap(), trampoline_hops: vec![], blinded_tail },
19321932
short_channel_id,
19331933
#[cfg(test)]
19341934
error_code,
@@ -2068,7 +2068,7 @@ impl MaybeReadable for Event {
20682068
Ok(Some(Event::PaymentPathSuccessful {
20692069
payment_id: payment_id.0.unwrap(),
20702070
payment_hash,
2071-
path: Path { hops: path, blinded_tail },
2071+
path: Path { hops: path, trampoline_hops: vec![], blinded_tail },
20722072
}))
20732073
};
20742074
f()
@@ -2148,7 +2148,7 @@ impl MaybeReadable for Event {
21482148
Ok(Some(Event::ProbeSuccessful {
21492149
payment_id: payment_id.0.unwrap(),
21502150
payment_hash: payment_hash.0.unwrap(),
2151-
path: Path { hops: path, blinded_tail },
2151+
path: Path { hops: path, trampoline_hops: vec![], blinded_tail },
21522152
}))
21532153
};
21542154
f()
@@ -2165,7 +2165,7 @@ impl MaybeReadable for Event {
21652165
Ok(Some(Event::ProbeFailed {
21662166
payment_id: payment_id.0.unwrap(),
21672167
payment_hash: payment_hash.0.unwrap(),
2168-
path: Path { hops: path, blinded_tail },
2168+
path: Path { hops: path, trampoline_hops: vec![], blinded_tail },
21692169
short_channel_id,
21702170
}))
21712171
};

lightning/src/ln/blinded_payment_tests.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1505,6 +1505,7 @@ fn route_blinding_spec_test_vector() {
15051505
cltv_expiry_delta: 42,
15061506
maybe_announced_channel: false,
15071507
}],
1508+
trampoline_hops: vec![],
15081509
blinded_tail: Some(BlindedTail {
15091510
hops: blinded_hops,
15101511
blinding_point: bob_blinding_point,

lightning/src/ln/channel.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10362,7 +10362,7 @@ mod tests {
1036210362
cltv_expiry: 200000000,
1036310363
state: OutboundHTLCState::Committed,
1036410364
source: HTLCSource::OutboundRoute {
10365-
path: Path { hops: Vec::new(), blinded_tail: None },
10365+
path: Path { hops: Vec::new(), trampoline_hops: vec![], blinded_tail: None },
1036610366
session_priv: SecretKey::from_slice(&<Vec<u8>>::from_hex("0fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff").unwrap()[..]).unwrap(),
1036710367
first_hop_htlc_msat: 548,
1036810368
payment_id: PaymentId([42; 32]),
@@ -10738,6 +10738,7 @@ mod tests {
1073810738
node_features: NodeFeatures::empty(), short_channel_id: 0, fee_msat: 0,
1073910739
cltv_expiry_delta: 0, maybe_announced_channel: false,
1074010740
}],
10741+
trampoline_hops: vec![],
1074110742
blinded_tail: None
1074210743
},
1074310744
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
@@ -650,7 +650,7 @@ impl HTLCSource {
650650
pub fn dummy() -> Self {
651651
assert!(cfg!(not(feature = "grind_signatures")));
652652
HTLCSource::OutboundRoute {
653-
path: Path { hops: Vec::new(), blinded_tail: None },
653+
path: Path { hops: Vec::new(), trampoline_hops: Vec::new(), blinded_tail: None },
654654
session_priv: SecretKey::from_slice(&[1; 32]).unwrap(),
655655
first_hop_htlc_msat: 0,
656656
payment_id: PaymentId([2; 32]),
@@ -12585,7 +12585,7 @@ impl Readable for HTLCSource {
1258512585
// instead.
1258612586
payment_id = Some(PaymentId(*session_priv.0.unwrap().as_ref()));
1258712587
}
12588-
let path = Path { hops: path_hops, blinded_tail };
12588+
let path = Path { hops: path_hops, trampoline_hops: vec![], blinded_tail };
1258912589
if path.hops.len() == 0 {
1259012590
return Err(DecodeError::InvalidValue);
1259112591
}

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
@@ -532,7 +532,7 @@ mod tests {
532532
// Ensure the onion will not fit all the payloads by adding a large custom TLV.
533533
recipient_onion.custom_tlvs.push((13377331, vec![0; 1156]));
534534

535-
let path = Path { hops, blinded_tail: None, };
535+
let path = Path { hops, trampoline_hops: vec![], blinded_tail: None, };
536536
let onion_keys = super::onion_utils::construct_onion_keys(&secp_ctx, &path, &session_priv).unwrap();
537537
let (onion_payloads, ..) = super::onion_utils::build_onion_payloads(
538538
&path, total_amt_msat, &recipient_onion, cur_height + 1, &Some(keysend_preimage), None
@@ -558,6 +558,7 @@ mod tests {
558558

559559
let path = Path {
560560
hops: hops,
561+
trampoline_hops: vec![],
561562
blinded_tail: None,
562563
};
563564

lightning/src/ln/onion_utils.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1342,7 +1342,7 @@ mod tests {
13421342
channel_features: ChannelFeatures::empty(), node_features: NodeFeatures::empty(),
13431343
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.
13441344
},
1345-
], blinded_tail: None }],
1345+
], trampoline_hops: vec![], blinded_tail: None }],
13461346
route_params: None,
13471347
};
13481348

lightning/src/ln/outbound_payment.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2543,7 +2543,7 @@ mod tests {
25432543
fee_msat: 0,
25442544
cltv_expiry_delta: 0,
25452545
maybe_announced_channel: true,
2546-
}], blinded_tail: None }],
2546+
}], trampoline_hops: vec![], blinded_tail: None }],
25472547
route_params: Some(route_params.clone()),
25482548
};
25492549
router.expect_find_route(route_params.clone(), Ok(route.clone()));
@@ -2899,6 +2899,7 @@ mod tests {
28992899
maybe_announced_channel: true,
29002900
}
29012901
],
2902+
trampoline_hops: vec![],
29022903
blinded_tail: None,
29032904
}
29042905
],

lightning/src/ln/payment_tests.rs

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2452,7 +2452,7 @@ fn auto_retry_partial_failure() {
24522452
fee_msat: amt_msat / 2,
24532453
cltv_expiry_delta: 100,
24542454
maybe_announced_channel: true,
2455-
}], blinded_tail: None },
2455+
}], trampoline_hops: vec![], blinded_tail: None },
24562456
Path { hops: vec![RouteHop {
24572457
pubkey: nodes[1].node.get_our_node_id(),
24582458
node_features: nodes[1].node.node_features(),
@@ -2461,7 +2461,7 @@ fn auto_retry_partial_failure() {
24612461
fee_msat: amt_msat / 2,
24622462
cltv_expiry_delta: 100,
24632463
maybe_announced_channel: true,
2464-
}], blinded_tail: None },
2464+
}], trampoline_hops: vec![], blinded_tail: None },
24652465
],
24662466
route_params: Some(route_params.clone()),
24672467
};
@@ -2483,7 +2483,7 @@ fn auto_retry_partial_failure() {
24832483
fee_msat: amt_msat / 4,
24842484
cltv_expiry_delta: 100,
24852485
maybe_announced_channel: true,
2486-
}], blinded_tail: None },
2486+
}], trampoline_hops: vec![], blinded_tail: None },
24872487
Path { hops: vec![RouteHop {
24882488
pubkey: nodes[1].node.get_our_node_id(),
24892489
node_features: nodes[1].node.node_features(),
@@ -2492,7 +2492,7 @@ fn auto_retry_partial_failure() {
24922492
fee_msat: amt_msat / 4,
24932493
cltv_expiry_delta: 100,
24942494
maybe_announced_channel: true,
2495-
}], blinded_tail: None },
2495+
}], trampoline_hops: vec![], blinded_tail: None },
24962496
],
24972497
route_params: Some(retry_1_params.clone()),
24982498
};
@@ -2514,7 +2514,7 @@ fn auto_retry_partial_failure() {
25142514
fee_msat: amt_msat / 4,
25152515
cltv_expiry_delta: 100,
25162516
maybe_announced_channel: true,
2517-
}], blinded_tail: None },
2517+
}], trampoline_hops: vec![], blinded_tail: None },
25182518
],
25192519
route_params: Some(retry_2_params.clone()),
25202520
};
@@ -2659,7 +2659,7 @@ fn auto_retry_zero_attempts_send_error() {
26592659
fee_msat: amt_msat,
26602660
cltv_expiry_delta: 100,
26612661
maybe_announced_channel: true,
2662-
}], blinded_tail: None },
2662+
}], trampoline_hops: vec![], blinded_tail: None },
26632663
],
26642664
route_params: Some(route_params.clone()),
26652665
};
@@ -2757,7 +2757,7 @@ fn retry_multi_path_single_failed_payment() {
27572757
fee_msat: 10_000,
27582758
cltv_expiry_delta: 100,
27592759
maybe_announced_channel: true,
2760-
}], blinded_tail: None },
2760+
}], trampoline_hops: vec![], blinded_tail: None },
27612761
Path { hops: vec![RouteHop {
27622762
pubkey: nodes[1].node.get_our_node_id(),
27632763
node_features: nodes[1].node.node_features(),
@@ -2766,7 +2766,7 @@ fn retry_multi_path_single_failed_payment() {
27662766
fee_msat: 100_000_001, // Our default max-HTLC-value is 10% of the channel value, which this is one more than
27672767
cltv_expiry_delta: 100,
27682768
maybe_announced_channel: true,
2769-
}], blinded_tail: None },
2769+
}], trampoline_hops: vec![], blinded_tail: None },
27702770
],
27712771
route_params: Some(route_params.clone()),
27722772
};
@@ -2848,7 +2848,7 @@ fn immediate_retry_on_failure() {
28482848
fee_msat: 100_000_001, // Our default max-HTLC-value is 10% of the channel value, which this is one more than
28492849
cltv_expiry_delta: 100,
28502850
maybe_announced_channel: true,
2851-
}], blinded_tail: None },
2851+
}], trampoline_hops: vec![], blinded_tail: None },
28522852
],
28532853
route_params: Some(route_params.clone()),
28542854
};
@@ -2942,7 +2942,7 @@ fn no_extra_retries_on_back_to_back_fail() {
29422942
fee_msat: 100_000_000,
29432943
cltv_expiry_delta: 100,
29442944
maybe_announced_channel: true,
2945-
}], blinded_tail: None },
2945+
}], trampoline_hops: vec![], blinded_tail: None },
29462946
Path { hops: vec![RouteHop {
29472947
pubkey: nodes[1].node.get_our_node_id(),
29482948
node_features: nodes[1].node.node_features(),
@@ -2959,7 +2959,7 @@ fn no_extra_retries_on_back_to_back_fail() {
29592959
fee_msat: 100_000_000,
29602960
cltv_expiry_delta: 100,
29612961
maybe_announced_channel: true,
2962-
}], blinded_tail: None }
2962+
}], trampoline_hops: vec![], blinded_tail: None }
29632963
],
29642964
route_params: Some(route_params.clone()),
29652965
};
@@ -3147,7 +3147,7 @@ fn test_simple_partial_retry() {
31473147
fee_msat: 100_000_000,
31483148
cltv_expiry_delta: 100,
31493149
maybe_announced_channel: true,
3150-
}], blinded_tail: None },
3150+
}], trampoline_hops: vec![], blinded_tail: None },
31513151
Path { hops: vec![RouteHop {
31523152
pubkey: nodes[1].node.get_our_node_id(),
31533153
node_features: nodes[1].node.node_features(),
@@ -3164,7 +3164,7 @@ fn test_simple_partial_retry() {
31643164
fee_msat: 100_000_000,
31653165
cltv_expiry_delta: 100,
31663166
maybe_announced_channel: true,
3167-
}], blinded_tail: None }
3167+
}], trampoline_hops: vec![], blinded_tail: None }
31683168
],
31693169
route_params: Some(route_params.clone()),
31703170
};
@@ -3318,7 +3318,7 @@ fn test_threaded_payment_retries() {
33183318
fee_msat: amt_msat / 1000,
33193319
cltv_expiry_delta: 100,
33203320
maybe_announced_channel: true,
3321-
}], blinded_tail: None },
3321+
}], trampoline_hops: vec![], blinded_tail: None },
33223322
Path { hops: vec![RouteHop {
33233323
pubkey: nodes[2].node.get_our_node_id(),
33243324
node_features: nodes[2].node.node_features(),
@@ -3335,7 +3335,7 @@ fn test_threaded_payment_retries() {
33353335
fee_msat: amt_msat - amt_msat / 1000,
33363336
cltv_expiry_delta: 100,
33373337
maybe_announced_channel: true,
3338-
}], blinded_tail: None }
3338+
}], trampoline_hops: vec![], blinded_tail: None }
33393339
],
33403340
route_params: Some(route_params.clone()),
33413341
};

lightning/src/routing/router.rs

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -451,6 +451,8 @@ impl_writeable_tlv_based!(BlindedTail, {
451451
pub struct Path {
452452
/// The list of unblinded hops in this [`Path`]. Must be at least length one.
453453
pub hops: Vec<RouteHop>,
454+
/// The list of unblinded Trampoline hops. When using Trampoline, must contain at least one hop.
455+
pub trampoline_hops: Vec<TrampolineHop>,
454456
/// The blinded path at which this path terminates, if we're sending to one, and its metadata.
455457
pub blinded_tail: Option<BlindedTail>,
456458
}
@@ -583,7 +585,7 @@ impl Readable for Route {
583585
if hops.is_empty() { return Err(DecodeError::InvalidValue); }
584586
min_final_cltv_expiry_delta =
585587
cmp::min(min_final_cltv_expiry_delta, hops.last().unwrap().cltv_expiry_delta);
586-
paths.push(Path { hops, blinded_tail: None });
588+
paths.push(Path { hops, trampoline_hops: vec![], blinded_tail: None });
587589
}
588590
_init_and_read_len_prefixed_tlv_fields!(reader, {
589591
(1, payment_params, (option: ReadableArgs, min_final_cltv_expiry_delta)),
@@ -3385,7 +3387,7 @@ where L::Target: Logger {
33853387
core::mem::replace(&mut hop.cltv_expiry_delta, prev_cltv_expiry_delta)
33863388
});
33873389

3388-
paths.push(Path { hops, blinded_tail });
3390+
paths.push(Path { hops, trampoline_hops: vec![], blinded_tail });
33893391
}
33903392
// Make sure we would never create a route with more paths than we allow.
33913393
debug_assert!(paths.len() <= payment_params.max_path_count.into());
@@ -7109,7 +7111,7 @@ mod tests {
71097111
channel_features: ChannelFeatures::empty(), node_features: NodeFeatures::empty(),
71107112
short_channel_id: 0, fee_msat: 225, cltv_expiry_delta: 0, maybe_announced_channel: true,
71117113
},
7112-
], blinded_tail: None }],
7114+
], trampoline_hops: vec![], blinded_tail: None }],
71137115
route_params: None,
71147116
};
71157117

@@ -7131,7 +7133,7 @@ mod tests {
71317133
channel_features: ChannelFeatures::empty(), node_features: NodeFeatures::empty(),
71327134
short_channel_id: 0, fee_msat: 150, cltv_expiry_delta: 0, maybe_announced_channel: true,
71337135
},
7134-
], blinded_tail: None }, Path { hops: vec![
7136+
], trampoline_hops: vec![], blinded_tail: None }, Path { hops: vec![
71357137
RouteHop {
71367138
pubkey: PublicKey::from_slice(&<Vec<u8>>::from_hex("02eec7245d6b7d2ccb30380bfbe2a3648cd7a942653f5aa340edcea1f283686619").unwrap()[..]).unwrap(),
71377139
channel_features: ChannelFeatures::empty(), node_features: NodeFeatures::empty(),
@@ -7142,7 +7144,7 @@ mod tests {
71427144
channel_features: ChannelFeatures::empty(), node_features: NodeFeatures::empty(),
71437145
short_channel_id: 0, fee_msat: 150, cltv_expiry_delta: 0, maybe_announced_channel: true,
71447146
},
7145-
], blinded_tail: None }],
7147+
], trampoline_hops: vec![], blinded_tail: None }],
71467148
route_params: None,
71477149
};
71487150

@@ -7717,6 +7719,7 @@ mod tests {
77177719
cltv_expiry_delta: 0,
77187720
maybe_announced_channel: true,
77197721
}],
7722+
trampoline_hops: vec![],
77207723
blinded_tail: Some(BlindedTail {
77217724
hops: vec![
77227725
BlindedHop { blinded_node_id: ln_test_utils::pubkey(44), encrypted_payload: Vec::new() },
@@ -7735,7 +7738,7 @@ mod tests {
77357738
fee_msat: 100,
77367739
cltv_expiry_delta: 0,
77377740
maybe_announced_channel: true,
7738-
}], blinded_tail: None }],
7741+
}], trampoline_hops: vec![], blinded_tail: None }],
77397742
route_params: None,
77407743
};
77417744
let encoded_route = route.encode();
@@ -7784,6 +7787,7 @@ mod tests {
77847787
cltv_expiry_delta: 0,
77857788
maybe_announced_channel: false,
77867789
}],
7790+
trampoline_hops: vec![],
77877791
blinded_tail: Some(BlindedTail {
77887792
hops: vec![BlindedHop { blinded_node_id: ln_test_utils::pubkey(49), encrypted_payload: Vec::new() }],
77897793
blinding_point: ln_test_utils::pubkey(48),
@@ -7820,6 +7824,7 @@ mod tests {
78207824
maybe_announced_channel: false,
78217825
}
78227826
],
7827+
trampoline_hops: vec![],
78237828
blinded_tail: Some(BlindedTail {
78247829
hops: vec![
78257830
BlindedHop { blinded_node_id: ln_test_utils::pubkey(45), encrypted_payload: Vec::new() },

0 commit comments

Comments
 (0)