Skip to content

Commit 3c83538

Browse files
committed
Add trampoline_hops field to Path
1 parent 6fb690e commit 3c83538

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
@@ -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
});
@@ -648,6 +649,7 @@ fn send_hop_payment(
648649
},
649650
],
650651
blinded_tail: None,
652+
trampoline_hops: vec![],
651653
}],
652654
route_params: None,
653655
});

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
@@ -1940,7 +1940,7 @@ impl MaybeReadable for Event {
19401940
payment_hash,
19411941
payment_failed_permanently,
19421942
failure,
1943-
path: Path { hops: path.unwrap(), blinded_tail },
1943+
path: Path { hops: path.unwrap(), trampoline_hops: vec![], blinded_tail },
19441944
short_channel_id,
19451945
#[cfg(test)]
19461946
error_code,
@@ -2085,7 +2085,7 @@ impl MaybeReadable for Event {
20852085
Ok(Some(Event::PaymentPathSuccessful {
20862086
payment_id: payment_id.0.unwrap(),
20872087
payment_hash,
2088-
path: Path { hops: path, blinded_tail },
2088+
path: Path { hops: path, trampoline_hops: vec![], blinded_tail },
20892089
}))
20902090
};
20912091
f()
@@ -2165,7 +2165,7 @@ impl MaybeReadable for Event {
21652165
Ok(Some(Event::ProbeSuccessful {
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
}))
21702170
};
21712171
f()
@@ -2182,7 +2182,7 @@ impl MaybeReadable for Event {
21822182
Ok(Some(Event::ProbeFailed {
21832183
payment_id: payment_id.0.unwrap(),
21842184
payment_hash: payment_hash.0.unwrap(),
2185-
path: Path { hops: path, blinded_tail },
2185+
path: Path { hops: path, trampoline_hops: vec![], blinded_tail },
21862186
short_channel_id,
21872187
}))
21882188
};

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
@@ -10378,7 +10378,7 @@ mod tests {
1037810378
cltv_expiry: 200000000,
1037910379
state: OutboundHTLCState::Committed,
1038010380
source: HTLCSource::OutboundRoute {
10381-
path: Path { hops: Vec::new(), blinded_tail: None },
10381+
path: Path { hops: Vec::new(), trampoline_hops: vec![], blinded_tail: None },
1038210382
session_priv: SecretKey::from_slice(&<Vec<u8>>::from_hex("0fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff").unwrap()[..]).unwrap(),
1038310383
first_hop_htlc_msat: 548,
1038410384
payment_id: PaymentId([42; 32]),
@@ -10754,6 +10754,7 @@ mod tests {
1075410754
node_features: NodeFeatures::empty(), short_channel_id: 0, fee_msat: 0,
1075510755
cltv_expiry_delta: 0, maybe_announced_channel: false,
1075610756
}],
10757+
trampoline_hops: vec![],
1075710758
blinded_tail: None
1075810759
},
1075910760
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
@@ -654,7 +654,7 @@ impl HTLCSource {
654654
pub fn dummy() -> Self {
655655
assert!(cfg!(not(feature = "grind_signatures")));
656656
HTLCSource::OutboundRoute {
657-
path: Path { hops: Vec::new(), blinded_tail: None },
657+
path: Path { hops: Vec::new(), trampoline_hops: Vec::new(), blinded_tail: None },
658658
session_priv: SecretKey::from_slice(&[1; 32]).unwrap(),
659659
first_hop_htlc_msat: 0,
660660
payment_id: PaymentId([2; 32]),
@@ -12575,7 +12575,7 @@ impl Readable for HTLCSource {
1257512575
// instead.
1257612576
payment_id = Some(PaymentId(*session_priv.0.unwrap().as_ref()));
1257712577
}
12578-
let path = Path { hops: path_hops, blinded_tail };
12578+
let path = Path { hops: path_hops, trampoline_hops: vec![], blinded_tail };
1257912579
if path.hops.len() == 0 {
1258012580
return Err(DecodeError::InvalidValue);
1258112581
}

lightning/src/ln/functional_tests.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1097,7 +1097,7 @@ fn fake_network_test() {
10971097
).with_bolt11_features(nodes[1].node.bolt11_invoice_features()).unwrap();
10981098
let route_params = RouteParameters::from_payment_params_and_value(payment_params, 1000000);
10991099
let payment_preimage_1 = send_along_route(&nodes[1],
1100-
Route { paths: vec![Path { hops, blinded_tail: None }], route_params: Some(route_params.clone()) },
1100+
Route { paths: vec![Path { hops, trampoline_hops: vec![], blinded_tail: None }], route_params: Some(route_params.clone()) },
11011101
&vec!(&nodes[2], &nodes[3], &nodes[1])[..], 1000000).0;
11021102

11031103
let mut hops = Vec::with_capacity(3);
@@ -1131,7 +1131,7 @@ fn fake_network_test() {
11311131
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;
11321132
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;
11331133
let payment_hash_2 = send_along_route(&nodes[1],
1134-
Route { paths: vec![Path { hops, blinded_tail: None }], route_params: Some(route_params) },
1134+
Route { paths: vec![Path { hops, trampoline_hops: vec![], blinded_tail: None }], route_params: Some(route_params) },
11351135
&vec!(&nodes[3], &nodes[2], &nodes[1])[..], 1000000).1;
11361136

11371137
// 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
@@ -2554,7 +2554,7 @@ mod tests {
25542554
fee_msat: 0,
25552555
cltv_expiry_delta: 0,
25562556
maybe_announced_channel: true,
2557-
}], blinded_tail: None }],
2557+
}], trampoline_hops: vec![], blinded_tail: None }],
25582558
route_params: Some(route_params.clone()),
25592559
};
25602560
router.expect_find_route(route_params.clone(), Ok(route.clone()));
@@ -2910,6 +2910,7 @@ mod tests {
29102910
maybe_announced_channel: true,
29112911
}
29122912
],
2913+
trampoline_hops: vec![],
29132914
blinded_tail: None,
29142915
}
29152916
],

lightning/src/ln/payment_tests.rs

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2441,7 +2441,7 @@ fn auto_retry_partial_failure() {
24412441
fee_msat: amt_msat / 2,
24422442
cltv_expiry_delta: 100,
24432443
maybe_announced_channel: true,
2444-
}], blinded_tail: None },
2444+
}], trampoline_hops: vec![], blinded_tail: None },
24452445
Path { hops: vec![RouteHop {
24462446
pubkey: nodes[1].node.get_our_node_id(),
24472447
node_features: nodes[1].node.node_features(),
@@ -2450,7 +2450,7 @@ fn auto_retry_partial_failure() {
24502450
fee_msat: amt_msat / 2,
24512451
cltv_expiry_delta: 100,
24522452
maybe_announced_channel: true,
2453-
}], blinded_tail: None },
2453+
}], trampoline_hops: vec![], blinded_tail: None },
24542454
],
24552455
route_params: Some(route_params.clone()),
24562456
};
@@ -2472,7 +2472,7 @@ fn auto_retry_partial_failure() {
24722472
fee_msat: amt_msat / 4,
24732473
cltv_expiry_delta: 100,
24742474
maybe_announced_channel: true,
2475-
}], blinded_tail: None },
2475+
}], trampoline_hops: vec![], blinded_tail: None },
24762476
Path { hops: vec![RouteHop {
24772477
pubkey: nodes[1].node.get_our_node_id(),
24782478
node_features: nodes[1].node.node_features(),
@@ -2481,7 +2481,7 @@ fn auto_retry_partial_failure() {
24812481
fee_msat: amt_msat / 4,
24822482
cltv_expiry_delta: 100,
24832483
maybe_announced_channel: true,
2484-
}], blinded_tail: None },
2484+
}], trampoline_hops: vec![], blinded_tail: None },
24852485
],
24862486
route_params: Some(retry_1_params.clone()),
24872487
};
@@ -2503,7 +2503,7 @@ fn auto_retry_partial_failure() {
25032503
fee_msat: amt_msat / 4,
25042504
cltv_expiry_delta: 100,
25052505
maybe_announced_channel: true,
2506-
}], blinded_tail: None },
2506+
}], trampoline_hops: vec![], blinded_tail: None },
25072507
],
25082508
route_params: Some(retry_2_params.clone()),
25092509
};
@@ -2648,7 +2648,7 @@ fn auto_retry_zero_attempts_send_error() {
26482648
fee_msat: amt_msat,
26492649
cltv_expiry_delta: 100,
26502650
maybe_announced_channel: true,
2651-
}], blinded_tail: None },
2651+
}], trampoline_hops: vec![], blinded_tail: None },
26522652
],
26532653
route_params: Some(route_params.clone()),
26542654
};
@@ -2746,7 +2746,7 @@ fn retry_multi_path_single_failed_payment() {
27462746
fee_msat: 10_000,
27472747
cltv_expiry_delta: 100,
27482748
maybe_announced_channel: true,
2749-
}], blinded_tail: None },
2749+
}], trampoline_hops: vec![], blinded_tail: None },
27502750
Path { hops: vec![RouteHop {
27512751
pubkey: nodes[1].node.get_our_node_id(),
27522752
node_features: nodes[1].node.node_features(),
@@ -2755,7 +2755,7 @@ fn retry_multi_path_single_failed_payment() {
27552755
fee_msat: 100_000_001, // Our default max-HTLC-value is 10% of the channel value, which this is one more than
27562756
cltv_expiry_delta: 100,
27572757
maybe_announced_channel: true,
2758-
}], blinded_tail: None },
2758+
}], trampoline_hops: vec![], blinded_tail: None },
27592759
],
27602760
route_params: Some(route_params.clone()),
27612761
};
@@ -2837,7 +2837,7 @@ fn immediate_retry_on_failure() {
28372837
fee_msat: 100_000_001, // Our default max-HTLC-value is 10% of the channel value, which this is one more than
28382838
cltv_expiry_delta: 100,
28392839
maybe_announced_channel: true,
2840-
}], blinded_tail: None },
2840+
}], trampoline_hops: vec![], blinded_tail: None },
28412841
],
28422842
route_params: Some(route_params.clone()),
28432843
};
@@ -2931,7 +2931,7 @@ fn no_extra_retries_on_back_to_back_fail() {
29312931
fee_msat: 100_000_000,
29322932
cltv_expiry_delta: 100,
29332933
maybe_announced_channel: true,
2934-
}], blinded_tail: None },
2934+
}], trampoline_hops: vec![], blinded_tail: None },
29352935
Path { hops: vec![RouteHop {
29362936
pubkey: nodes[1].node.get_our_node_id(),
29372937
node_features: nodes[1].node.node_features(),
@@ -2948,7 +2948,7 @@ fn no_extra_retries_on_back_to_back_fail() {
29482948
fee_msat: 100_000_000,
29492949
cltv_expiry_delta: 100,
29502950
maybe_announced_channel: true,
2951-
}], blinded_tail: None }
2951+
}], trampoline_hops: vec![], blinded_tail: None }
29522952
],
29532953
route_params: Some(route_params.clone()),
29542954
};
@@ -3136,7 +3136,7 @@ fn test_simple_partial_retry() {
31363136
fee_msat: 100_000_000,
31373137
cltv_expiry_delta: 100,
31383138
maybe_announced_channel: true,
3139-
}], blinded_tail: None },
3139+
}], trampoline_hops: vec![], blinded_tail: None },
31403140
Path { hops: vec![RouteHop {
31413141
pubkey: nodes[1].node.get_our_node_id(),
31423142
node_features: nodes[1].node.node_features(),
@@ -3153,7 +3153,7 @@ fn test_simple_partial_retry() {
31533153
fee_msat: 100_000_000,
31543154
cltv_expiry_delta: 100,
31553155
maybe_announced_channel: true,
3156-
}], blinded_tail: None }
3156+
}], trampoline_hops: vec![], blinded_tail: None }
31573157
],
31583158
route_params: Some(route_params.clone()),
31593159
};
@@ -3307,7 +3307,7 @@ fn test_threaded_payment_retries() {
33073307
fee_msat: amt_msat / 1000,
33083308
cltv_expiry_delta: 100,
33093309
maybe_announced_channel: true,
3310-
}], blinded_tail: None },
3310+
}], trampoline_hops: vec![], blinded_tail: None },
33113311
Path { hops: vec![RouteHop {
33123312
pubkey: nodes[2].node.get_our_node_id(),
33133313
node_features: nodes[2].node.node_features(),
@@ -3324,7 +3324,7 @@ fn test_threaded_payment_retries() {
33243324
fee_msat: amt_msat - amt_msat / 1000,
33253325
cltv_expiry_delta: 100,
33263326
maybe_announced_channel: true,
3327-
}], blinded_tail: None }
3327+
}], trampoline_hops: vec![], blinded_tail: None }
33283328
],
33293329
route_params: Some(route_params.clone()),
33303330
};

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)