Skip to content

Commit a85aca9

Browse files
committed
Add trampoline_hops field to Path
1 parent a67b6a2 commit a85aca9

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
@@ -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
@@ -1911,7 +1911,7 @@ impl MaybeReadable for Event {
19111911
payment_hash,
19121912
payment_failed_permanently,
19131913
failure,
1914-
path: Path { hops: path.unwrap(), blinded_tail },
1914+
path: Path { hops: path.unwrap(), trampoline_hops: vec![], blinded_tail },
19151915
short_channel_id,
19161916
#[cfg(test)]
19171917
error_code,
@@ -2051,7 +2051,7 @@ impl MaybeReadable for Event {
20512051
Ok(Some(Event::PaymentPathSuccessful {
20522052
payment_id: payment_id.0.unwrap(),
20532053
payment_hash,
2054-
path: Path { hops: path, blinded_tail },
2054+
path: Path { hops: path, trampoline_hops: vec![], blinded_tail },
20552055
}))
20562056
};
20572057
f()
@@ -2131,7 +2131,7 @@ impl MaybeReadable for Event {
21312131
Ok(Some(Event::ProbeSuccessful {
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
}))
21362136
};
21372137
f()
@@ -2148,7 +2148,7 @@ impl MaybeReadable for Event {
21482148
Ok(Some(Event::ProbeFailed {
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
short_channel_id,
21532153
}))
21542154
};

lightning/src/ln/blinded_payment_tests.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1511,6 +1511,7 @@ fn route_blinding_spec_test_vector() {
15111511
cltv_expiry_delta: 42,
15121512
maybe_announced_channel: false,
15131513
}],
1514+
trampoline_hops: vec![],
15141515
blinded_tail: Some(BlindedTail {
15151516
hops: blinded_hops,
15161517
blinding_point: bob_blinding_point,

lightning/src/ln/channel.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9850,7 +9850,7 @@ mod tests {
98509850
cltv_expiry: 200000000,
98519851
state: OutboundHTLCState::Committed,
98529852
source: HTLCSource::OutboundRoute {
9853-
path: Path { hops: Vec::new(), blinded_tail: None },
9853+
path: Path { hops: Vec::new(), trampoline_hops: vec![], blinded_tail: None },
98549854
session_priv: SecretKey::from_slice(&<Vec<u8>>::from_hex("0fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff").unwrap()[..]).unwrap(),
98559855
first_hop_htlc_msat: 548,
98569856
payment_id: PaymentId([42; 32]),
@@ -10226,6 +10226,7 @@ mod tests {
1022610226
node_features: NodeFeatures::empty(), short_channel_id: 0, fee_msat: 0,
1022710227
cltv_expiry_delta: 0, maybe_announced_channel: false,
1022810228
}],
10229+
trampoline_hops: vec![],
1022910230
blinded_tail: None
1023010231
},
1023110232
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
@@ -651,7 +651,7 @@ impl HTLCSource {
651651
pub fn dummy() -> Self {
652652
assert!(cfg!(not(feature = "grind_signatures")));
653653
HTLCSource::OutboundRoute {
654-
path: Path { hops: Vec::new(), blinded_tail: None },
654+
path: Path { hops: Vec::new(), trampoline_hops: Vec::new(), blinded_tail: None },
655655
session_priv: SecretKey::from_slice(&[1; 32]).unwrap(),
656656
first_hop_htlc_msat: 0,
657657
payment_id: PaymentId([2; 32]),
@@ -12167,7 +12167,7 @@ impl Readable for HTLCSource {
1216712167
// instead.
1216812168
payment_id = Some(PaymentId(*session_priv.0.unwrap().as_ref()));
1216912169
}
12170-
let path = Path { hops: path_hops, blinded_tail };
12170+
let path = Path { hops: path_hops, trampoline_hops: vec![], blinded_tail };
1217112171
if path.hops.len() == 0 {
1217212172
return Err(DecodeError::InvalidValue);
1217312173
}

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

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

566566
let path = Path {
567567
hops: hops,
568+
trampoline_hops: vec![],
568569
blinded_tail: None,
569570
};
570571

lightning/src/ln/onion_utils.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1330,7 +1330,7 @@ mod tests {
13301330
channel_features: ChannelFeatures::empty(), node_features: NodeFeatures::empty(),
13311331
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.
13321332
},
1333-
], blinded_tail: None }],
1333+
], trampoline_hops: vec![], blinded_tail: None }],
13341334
route_params: None,
13351335
};
13361336

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
@@ -2459,7 +2459,7 @@ fn auto_retry_partial_failure() {
24592459
fee_msat: amt_msat / 2,
24602460
cltv_expiry_delta: 100,
24612461
maybe_announced_channel: true,
2462-
}], blinded_tail: None },
2462+
}], trampoline_hops: vec![], blinded_tail: None },
24632463
Path { hops: vec![RouteHop {
24642464
pubkey: nodes[1].node.get_our_node_id(),
24652465
node_features: nodes[1].node.node_features(),
@@ -2468,7 +2468,7 @@ fn auto_retry_partial_failure() {
24682468
fee_msat: amt_msat / 2,
24692469
cltv_expiry_delta: 100,
24702470
maybe_announced_channel: true,
2471-
}], blinded_tail: None },
2471+
}], trampoline_hops: vec![], blinded_tail: None },
24722472
],
24732473
route_params: Some(route_params.clone()),
24742474
};
@@ -2490,7 +2490,7 @@ fn auto_retry_partial_failure() {
24902490
fee_msat: amt_msat / 4,
24912491
cltv_expiry_delta: 100,
24922492
maybe_announced_channel: true,
2493-
}], blinded_tail: None },
2493+
}], trampoline_hops: vec![], blinded_tail: None },
24942494
Path { hops: vec![RouteHop {
24952495
pubkey: nodes[1].node.get_our_node_id(),
24962496
node_features: nodes[1].node.node_features(),
@@ -2499,7 +2499,7 @@ fn auto_retry_partial_failure() {
24992499
fee_msat: amt_msat / 4,
25002500
cltv_expiry_delta: 100,
25012501
maybe_announced_channel: true,
2502-
}], blinded_tail: None },
2502+
}], trampoline_hops: vec![], blinded_tail: None },
25032503
],
25042504
route_params: Some(retry_1_params.clone()),
25052505
};
@@ -2521,7 +2521,7 @@ fn auto_retry_partial_failure() {
25212521
fee_msat: amt_msat / 4,
25222522
cltv_expiry_delta: 100,
25232523
maybe_announced_channel: true,
2524-
}], blinded_tail: None },
2524+
}], trampoline_hops: vec![], blinded_tail: None },
25252525
],
25262526
route_params: Some(retry_2_params.clone()),
25272527
};
@@ -2666,7 +2666,7 @@ fn auto_retry_zero_attempts_send_error() {
26662666
fee_msat: amt_msat,
26672667
cltv_expiry_delta: 100,
26682668
maybe_announced_channel: true,
2669-
}], blinded_tail: None },
2669+
}], trampoline_hops: vec![], blinded_tail: None },
26702670
],
26712671
route_params: Some(route_params.clone()),
26722672
};
@@ -2764,7 +2764,7 @@ fn retry_multi_path_single_failed_payment() {
27642764
fee_msat: 10_000,
27652765
cltv_expiry_delta: 100,
27662766
maybe_announced_channel: true,
2767-
}], blinded_tail: None },
2767+
}], trampoline_hops: vec![], blinded_tail: None },
27682768
Path { hops: vec![RouteHop {
27692769
pubkey: nodes[1].node.get_our_node_id(),
27702770
node_features: nodes[1].node.node_features(),
@@ -2773,7 +2773,7 @@ fn retry_multi_path_single_failed_payment() {
27732773
fee_msat: 100_000_001, // Our default max-HTLC-value is 10% of the channel value, which this is one more than
27742774
cltv_expiry_delta: 100,
27752775
maybe_announced_channel: true,
2776-
}], blinded_tail: None },
2776+
}], trampoline_hops: vec![], blinded_tail: None },
27772777
],
27782778
route_params: Some(route_params.clone()),
27792779
};
@@ -2855,7 +2855,7 @@ fn immediate_retry_on_failure() {
28552855
fee_msat: 100_000_001, // Our default max-HTLC-value is 10% of the channel value, which this is one more than
28562856
cltv_expiry_delta: 100,
28572857
maybe_announced_channel: true,
2858-
}], blinded_tail: None },
2858+
}], trampoline_hops: vec![], blinded_tail: None },
28592859
],
28602860
route_params: Some(route_params.clone()),
28612861
};
@@ -2949,7 +2949,7 @@ fn no_extra_retries_on_back_to_back_fail() {
29492949
fee_msat: 100_000_000,
29502950
cltv_expiry_delta: 100,
29512951
maybe_announced_channel: true,
2952-
}], blinded_tail: None },
2952+
}], trampoline_hops: vec![], blinded_tail: None },
29532953
Path { hops: vec![RouteHop {
29542954
pubkey: nodes[1].node.get_our_node_id(),
29552955
node_features: nodes[1].node.node_features(),
@@ -2966,7 +2966,7 @@ fn no_extra_retries_on_back_to_back_fail() {
29662966
fee_msat: 100_000_000,
29672967
cltv_expiry_delta: 100,
29682968
maybe_announced_channel: true,
2969-
}], blinded_tail: None }
2969+
}], trampoline_hops: vec![], blinded_tail: None }
29702970
],
29712971
route_params: Some(route_params.clone()),
29722972
};
@@ -3154,7 +3154,7 @@ fn test_simple_partial_retry() {
31543154
fee_msat: 100_000_000,
31553155
cltv_expiry_delta: 100,
31563156
maybe_announced_channel: true,
3157-
}], blinded_tail: None },
3157+
}], trampoline_hops: vec![], blinded_tail: None },
31583158
Path { hops: vec![RouteHop {
31593159
pubkey: nodes[1].node.get_our_node_id(),
31603160
node_features: nodes[1].node.node_features(),
@@ -3171,7 +3171,7 @@ fn test_simple_partial_retry() {
31713171
fee_msat: 100_000_000,
31723172
cltv_expiry_delta: 100,
31733173
maybe_announced_channel: true,
3174-
}], blinded_tail: None }
3174+
}], trampoline_hops: vec![], blinded_tail: None }
31753175
],
31763176
route_params: Some(route_params.clone()),
31773177
};
@@ -3325,7 +3325,7 @@ fn test_threaded_payment_retries() {
33253325
fee_msat: amt_msat / 1000,
33263326
cltv_expiry_delta: 100,
33273327
maybe_announced_channel: true,
3328-
}], blinded_tail: None },
3328+
}], trampoline_hops: vec![], blinded_tail: None },
33293329
Path { hops: vec![RouteHop {
33303330
pubkey: nodes[2].node.get_our_node_id(),
33313331
node_features: nodes[2].node.node_features(),
@@ -3342,7 +3342,7 @@ fn test_threaded_payment_retries() {
33423342
fee_msat: amt_msat - amt_msat / 1000,
33433343
cltv_expiry_delta: 100,
33443344
maybe_announced_channel: true,
3345-
}], blinded_tail: None }
3345+
}], trampoline_hops: vec![], blinded_tail: None }
33463346
],
33473347
route_params: Some(route_params.clone()),
33483348
};

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)),
@@ -3391,7 +3394,7 @@ where L::Target: Logger {
33913394
core::mem::replace(&mut hop.cltv_expiry_delta, prev_cltv_expiry_delta)
33923395
});
33933396

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

@@ -7137,7 +7140,7 @@ mod tests {
71377140
channel_features: ChannelFeatures::empty(), node_features: NodeFeatures::empty(),
71387141
short_channel_id: 0, fee_msat: 150, cltv_expiry_delta: 0, maybe_announced_channel: true,
71397142
},
7140-
], blinded_tail: None }, Path { hops: vec![
7143+
], trampoline_hops: vec![], blinded_tail: None }, Path { hops: vec![
71417144
RouteHop {
71427145
pubkey: PublicKey::from_slice(&<Vec<u8>>::from_hex("02eec7245d6b7d2ccb30380bfbe2a3648cd7a942653f5aa340edcea1f283686619").unwrap()[..]).unwrap(),
71437146
channel_features: ChannelFeatures::empty(), node_features: NodeFeatures::empty(),
@@ -7148,7 +7151,7 @@ mod tests {
71487151
channel_features: ChannelFeatures::empty(), node_features: NodeFeatures::empty(),
71497152
short_channel_id: 0, fee_msat: 150, cltv_expiry_delta: 0, maybe_announced_channel: true,
71507153
},
7151-
], blinded_tail: None }],
7154+
], trampoline_hops: vec![], blinded_tail: None }],
71527155
route_params: None,
71537156
};
71547157

@@ -7723,6 +7726,7 @@ mod tests {
77237726
cltv_expiry_delta: 0,
77247727
maybe_announced_channel: true,
77257728
}],
7729+
trampoline_hops: vec![],
77267730
blinded_tail: Some(BlindedTail {
77277731
hops: vec![
77287732
BlindedHop { blinded_node_id: ln_test_utils::pubkey(44), encrypted_payload: Vec::new() },
@@ -7741,7 +7745,7 @@ mod tests {
77417745
fee_msat: 100,
77427746
cltv_expiry_delta: 0,
77437747
maybe_announced_channel: true,
7744-
}], blinded_tail: None }],
7748+
}], trampoline_hops: vec![], blinded_tail: None }],
77457749
route_params: None,
77467750
};
77477751
let encoded_route = route.encode();
@@ -7790,6 +7794,7 @@ mod tests {
77907794
cltv_expiry_delta: 0,
77917795
maybe_announced_channel: false,
77927796
}],
7797+
trampoline_hops: vec![],
77937798
blinded_tail: Some(BlindedTail {
77947799
hops: vec![BlindedHop { blinded_node_id: ln_test_utils::pubkey(49), encrypted_payload: Vec::new() }],
77957800
blinding_point: ln_test_utils::pubkey(48),
@@ -7826,6 +7831,7 @@ mod tests {
78267831
maybe_announced_channel: false,
78277832
}
78287833
],
7834+
trampoline_hops: vec![],
78297835
blinded_tail: Some(BlindedTail {
78307836
hops: vec![
78317837
BlindedHop { blinded_node_id: ln_test_utils::pubkey(45), encrypted_payload: Vec::new() },

0 commit comments

Comments
 (0)