Skip to content

Commit 20f8e46

Browse files
committed
Add trampoline_hops field to Path.
1 parent 5093ee6 commit 20f8e46

File tree

12 files changed

+48
-38
lines changed

12 files changed

+48
-38
lines changed

fuzz/src/chanmon_consistency.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -396,7 +396,7 @@ fn send_payment(source: &ChanMan, dest: &ChanMan, dest_chan_id: u64, amt: u64, p
396396
fee_msat: amt,
397397
cltv_expiry_delta: 200,
398398
maybe_announced_channel: true,
399-
}], blinded_tail: None }],
399+
}], trampoline_hops: vec![], blinded_tail: None }],
400400
route_params: None,
401401
}, payment_hash, RecipientOnionFields::secret_only(payment_secret), PaymentId(payment_id)) {
402402
check_payment_err(err, amt > max_value_sendable || amt < min_value_sendable);
@@ -439,7 +439,7 @@ fn send_hop_payment(source: &ChanMan, middle: &ChanMan, middle_chan_id: u64, des
439439
fee_msat: amt,
440440
cltv_expiry_delta: 200,
441441
maybe_announced_channel: true,
442-
}], blinded_tail: None }],
442+
}], trampoline_hops: vec![], blinded_tail: None }],
443443
route_params: None,
444444
}, payment_hash, RecipientOnionFields::secret_only(payment_secret), PaymentId(payment_id)) {
445445
let sent_amt = amt + first_hop_fee;

lightning-background-processor/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1776,7 +1776,7 @@ mod tests {
17761776
fee_msat: 0,
17771777
cltv_expiry_delta: MIN_CLTV_EXPIRY_DELTA as u32,
17781778
maybe_announced_channel: true,
1779-
}], blinded_tail: None };
1779+
}], trampoline_hops: vec![], blinded_tail: None };
17801780

17811781
$nodes[0].scorer.write_lock().expect(TestResult::PaymentFailure { path: path.clone(), short_channel_id: scored_scid });
17821782
$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
@@ -1402,7 +1402,7 @@ impl MaybeReadable for Event {
14021402
payment_hash,
14031403
payment_failed_permanently,
14041404
failure,
1405-
path: Path { hops: path.unwrap(), blinded_tail },
1405+
path: Path { hops: path.unwrap(), trampoline_hops: vec![], blinded_tail },
14061406
short_channel_id,
14071407
#[cfg(test)]
14081408
error_code,
@@ -1530,7 +1530,7 @@ impl MaybeReadable for Event {
15301530
Ok(Some(Event::PaymentPathSuccessful {
15311531
payment_id: payment_id.0.unwrap(),
15321532
payment_hash,
1533-
path: Path { hops: path, blinded_tail },
1533+
path: Path { hops: path, trampoline_hops: vec![], blinded_tail },
15341534
}))
15351535
};
15361536
f()
@@ -1595,7 +1595,7 @@ impl MaybeReadable for Event {
15951595
Ok(Some(Event::ProbeSuccessful {
15961596
payment_id: payment_id.0.unwrap(),
15971597
payment_hash: payment_hash.0.unwrap(),
1598-
path: Path { hops: path, blinded_tail },
1598+
path: Path { hops: path, trampoline_hops: vec![], blinded_tail },
15991599
}))
16001600
};
16011601
f()
@@ -1612,7 +1612,7 @@ impl MaybeReadable for Event {
16121612
Ok(Some(Event::ProbeFailed {
16131613
payment_id: payment_id.0.unwrap(),
16141614
payment_hash: payment_hash.0.unwrap(),
1615-
path: Path { hops: path, blinded_tail },
1615+
path: Path { hops: path, trampoline_hops: vec![], blinded_tail },
16161616
short_channel_id,
16171617
}))
16181618
};

lightning/src/ln/channel.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9531,7 +9531,7 @@ mod tests {
95319531
cltv_expiry: 200000000,
95329532
state: OutboundHTLCState::Committed,
95339533
source: HTLCSource::OutboundRoute {
9534-
path: Path { hops: Vec::new(), blinded_tail: None },
9534+
path: Path { hops: Vec::new(), trampoline_hops: vec![], blinded_tail: None },
95359535
session_priv: SecretKey::from_slice(&<Vec<u8>>::from_hex("0fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff").unwrap()[..]).unwrap(),
95369536
first_hop_htlc_msat: 548,
95379537
payment_id: PaymentId([42; 32]),
@@ -9905,6 +9905,7 @@ mod tests {
99059905
node_features: NodeFeatures::empty(), short_channel_id: 0, fee_msat: 0,
99069906
cltv_expiry_delta: 0, maybe_announced_channel: false,
99079907
}],
9908+
trampoline_hops: vec![],
99089909
blinded_tail: None
99099910
},
99109911
session_priv: test_utils::privkey(42),

lightning/src/ln/channelmanager.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10881,7 +10881,7 @@ impl Readable for HTLCSource {
1088110881
// instead.
1088210882
payment_id = Some(PaymentId(*session_priv.0.unwrap().as_ref()));
1088310883
}
10884-
let path = Path { hops: path_hops, blinded_tail };
10884+
let path = Path { hops: path_hops, trampoline_hops: vec![], blinded_tail };
1088510885
if path.hops.len() == 0 {
1088610886
return Err(DecodeError::InvalidValue);
1088710887
}

lightning/src/ln/functional_tests.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1058,7 +1058,7 @@ fn fake_network_test() {
10581058
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;
10591059
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;
10601060
let payment_preimage_1 = send_along_route(&nodes[1],
1061-
Route { paths: vec![Path { hops, blinded_tail: None }], route_params: None },
1061+
Route { paths: vec![Path { hops, trampoline_hops: vec![], blinded_tail: None }], route_params: None },
10621062
&vec!(&nodes[2], &nodes[3], &nodes[1])[..], 1000000).0;
10631063

10641064
let mut hops = Vec::with_capacity(3);
@@ -1092,7 +1092,7 @@ fn fake_network_test() {
10921092
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;
10931093
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;
10941094
let payment_hash_2 = send_along_route(&nodes[1],
1095-
Route { paths: vec![Path { hops, blinded_tail: None }], route_params: None },
1095+
Route { paths: vec![Path { hops, trampoline_hops: vec![], blinded_tail: None }], route_params: None },
10961096
&vec!(&nodes[3], &nodes[2], &nodes[1])[..], 1000000).1;
10971097

10981098
// 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)
@@ -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
@@ -1289,7 +1289,7 @@ mod tests {
12891289
channel_features: ChannelFeatures::empty(), node_features: NodeFeatures::empty(),
12901290
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.
12911291
},
1292-
], blinded_tail: None }],
1292+
], trampoline_hops: vec![], blinded_tail: None }],
12931293
route_params: None,
12941294
};
12951295

lightning/src/ln/outbound_payment.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1989,7 +1989,7 @@ mod tests {
19891989
fee_msat: 0,
19901990
cltv_expiry_delta: 0,
19911991
maybe_announced_channel: true,
1992-
}], blinded_tail: None }],
1992+
}], trampoline_hops: vec![], blinded_tail: None }],
19931993
route_params: Some(route_params.clone()),
19941994
};
19951995
router.expect_find_route(route_params.clone(), Ok(route.clone()));
@@ -2327,6 +2327,7 @@ mod tests {
23272327
maybe_announced_channel: true,
23282328
}
23292329
],
2330+
trampoline_hops: vec![],
23302331
blinded_tail: None,
23312332
}
23322333
],

lightning/src/ln/payment_tests.rs

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2446,7 +2446,7 @@ fn auto_retry_partial_failure() {
24462446
fee_msat: amt_msat / 2,
24472447
cltv_expiry_delta: 100,
24482448
maybe_announced_channel: true,
2449-
}], blinded_tail: None },
2449+
}], trampoline_hops: vec![], blinded_tail: None },
24502450
Path { hops: vec![RouteHop {
24512451
pubkey: nodes[1].node.get_our_node_id(),
24522452
node_features: nodes[1].node.node_features(),
@@ -2455,7 +2455,7 @@ fn auto_retry_partial_failure() {
24552455
fee_msat: amt_msat / 2,
24562456
cltv_expiry_delta: 100,
24572457
maybe_announced_channel: true,
2458-
}], blinded_tail: None },
2458+
}], trampoline_hops: vec![], blinded_tail: None },
24592459
],
24602460
route_params: Some(route_params.clone()),
24612461
};
@@ -2477,7 +2477,7 @@ fn auto_retry_partial_failure() {
24772477
fee_msat: amt_msat / 4,
24782478
cltv_expiry_delta: 100,
24792479
maybe_announced_channel: true,
2480-
}], blinded_tail: None },
2480+
}], trampoline_hops: vec![], blinded_tail: None },
24812481
Path { hops: vec![RouteHop {
24822482
pubkey: nodes[1].node.get_our_node_id(),
24832483
node_features: nodes[1].node.node_features(),
@@ -2486,7 +2486,7 @@ fn auto_retry_partial_failure() {
24862486
fee_msat: amt_msat / 4,
24872487
cltv_expiry_delta: 100,
24882488
maybe_announced_channel: true,
2489-
}], blinded_tail: None },
2489+
}], trampoline_hops: vec![], blinded_tail: None },
24902490
],
24912491
route_params: Some(retry_1_params.clone()),
24922492
};
@@ -2508,7 +2508,7 @@ fn auto_retry_partial_failure() {
25082508
fee_msat: amt_msat / 4,
25092509
cltv_expiry_delta: 100,
25102510
maybe_announced_channel: true,
2511-
}], blinded_tail: None },
2511+
}], trampoline_hops: vec![], blinded_tail: None },
25122512
],
25132513
route_params: Some(retry_2_params.clone()),
25142514
};
@@ -2653,7 +2653,7 @@ fn auto_retry_zero_attempts_send_error() {
26532653
fee_msat: amt_msat,
26542654
cltv_expiry_delta: 100,
26552655
maybe_announced_channel: true,
2656-
}], blinded_tail: None },
2656+
}], trampoline_hops: vec![], blinded_tail: None },
26572657
],
26582658
route_params: Some(route_params.clone()),
26592659
};
@@ -2751,7 +2751,7 @@ fn retry_multi_path_single_failed_payment() {
27512751
fee_msat: 10_000,
27522752
cltv_expiry_delta: 100,
27532753
maybe_announced_channel: true,
2754-
}], blinded_tail: None },
2754+
}], trampoline_hops: vec![], blinded_tail: None },
27552755
Path { hops: vec![RouteHop {
27562756
pubkey: nodes[1].node.get_our_node_id(),
27572757
node_features: nodes[1].node.node_features(),
@@ -2760,7 +2760,7 @@ fn retry_multi_path_single_failed_payment() {
27602760
fee_msat: 100_000_001, // Our default max-HTLC-value is 10% of the channel value, which this is one more than
27612761
cltv_expiry_delta: 100,
27622762
maybe_announced_channel: true,
2763-
}], blinded_tail: None },
2763+
}], trampoline_hops: vec![], blinded_tail: None },
27642764
],
27652765
route_params: Some(route_params.clone()),
27662766
};
@@ -2842,7 +2842,7 @@ fn immediate_retry_on_failure() {
28422842
fee_msat: 100_000_001, // Our default max-HTLC-value is 10% of the channel value, which this is one more than
28432843
cltv_expiry_delta: 100,
28442844
maybe_announced_channel: true,
2845-
}], blinded_tail: None },
2845+
}], trampoline_hops: vec![], blinded_tail: None },
28462846
],
28472847
route_params: Some(route_params.clone()),
28482848
};
@@ -2936,7 +2936,7 @@ fn no_extra_retries_on_back_to_back_fail() {
29362936
fee_msat: 100_000_000,
29372937
cltv_expiry_delta: 100,
29382938
maybe_announced_channel: true,
2939-
}], blinded_tail: None },
2939+
}], trampoline_hops: vec![], blinded_tail: None },
29402940
Path { hops: vec![RouteHop {
29412941
pubkey: nodes[1].node.get_our_node_id(),
29422942
node_features: nodes[1].node.node_features(),
@@ -2953,7 +2953,7 @@ fn no_extra_retries_on_back_to_back_fail() {
29532953
fee_msat: 100_000_000,
29542954
cltv_expiry_delta: 100,
29552955
maybe_announced_channel: true,
2956-
}], blinded_tail: None }
2956+
}], trampoline_hops: vec![], blinded_tail: None }
29572957
],
29582958
route_params: Some(route_params.clone()),
29592959
};
@@ -3141,7 +3141,7 @@ fn test_simple_partial_retry() {
31413141
fee_msat: 100_000_000,
31423142
cltv_expiry_delta: 100,
31433143
maybe_announced_channel: true,
3144-
}], blinded_tail: None },
3144+
}], trampoline_hops: vec![], blinded_tail: None },
31453145
Path { hops: vec![RouteHop {
31463146
pubkey: nodes[1].node.get_our_node_id(),
31473147
node_features: nodes[1].node.node_features(),
@@ -3158,7 +3158,7 @@ fn test_simple_partial_retry() {
31583158
fee_msat: 100_000_000,
31593159
cltv_expiry_delta: 100,
31603160
maybe_announced_channel: true,
3161-
}], blinded_tail: None }
3161+
}], trampoline_hops: vec![], blinded_tail: None }
31623162
],
31633163
route_params: Some(route_params.clone()),
31643164
};
@@ -3312,7 +3312,7 @@ fn test_threaded_payment_retries() {
33123312
fee_msat: amt_msat / 1000,
33133313
cltv_expiry_delta: 100,
33143314
maybe_announced_channel: true,
3315-
}], blinded_tail: None },
3315+
}], trampoline_hops: vec![], blinded_tail: None },
33163316
Path { hops: vec![RouteHop {
33173317
pubkey: nodes[2].node.get_our_node_id(),
33183318
node_features: nodes[2].node.node_features(),
@@ -3329,7 +3329,7 @@ fn test_threaded_payment_retries() {
33293329
fee_msat: amt_msat - amt_msat / 1000,
33303330
cltv_expiry_delta: 100,
33313331
maybe_announced_channel: true,
3332-
}], blinded_tail: None }
3332+
}], trampoline_hops: vec![], blinded_tail: None }
33333333
],
33343334
route_params: Some(route_params.clone()),
33353335
};

lightning/src/routing/router.rs

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -451,6 +451,9 @@ 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. If present, must be at least one.
455+
/// The public key of the first Trampoline hop must match the public key of the last regular hop.
456+
pub trampoline_hops: Vec<TrampolineHop>,
454457
/// The blinded path at which this path terminates, if we're sending to one, and its metadata.
455458
pub blinded_tail: Option<BlindedTail>,
456459
}
@@ -583,7 +586,7 @@ impl Readable for Route {
583586
if hops.is_empty() { return Err(DecodeError::InvalidValue); }
584587
min_final_cltv_expiry_delta =
585588
cmp::min(min_final_cltv_expiry_delta, hops.last().unwrap().cltv_expiry_delta);
586-
paths.push(Path { hops, blinded_tail: None });
589+
paths.push(Path { hops, trampoline_hops: vec![], blinded_tail: None });
587590
}
588591
_init_and_read_len_prefixed_tlv_fields!(reader, {
589592
(1, payment_params, (option: ReadableArgs, min_final_cltv_expiry_delta)),
@@ -3131,7 +3134,7 @@ where L::Target: Logger {
31313134
core::mem::replace(&mut hop.cltv_expiry_delta, prev_cltv_expiry_delta)
31323135
});
31333136

3134-
paths.push(Path { hops, blinded_tail });
3137+
paths.push(Path { hops, trampoline_hops: vec![], blinded_tail });
31353138
}
31363139
// Make sure we would never create a route with more paths than we allow.
31373140
debug_assert!(paths.len() <= payment_params.max_path_count.into());
@@ -6713,7 +6716,7 @@ mod tests {
67136716
channel_features: ChannelFeatures::empty(), node_features: NodeFeatures::empty(),
67146717
short_channel_id: 0, fee_msat: 225, cltv_expiry_delta: 0, maybe_announced_channel: true,
67156718
},
6716-
], blinded_tail: None }],
6719+
], trampoline_hops: vec![], blinded_tail: None }],
67176720
route_params: None,
67186721
};
67196722

@@ -6735,7 +6738,7 @@ mod tests {
67356738
channel_features: ChannelFeatures::empty(), node_features: NodeFeatures::empty(),
67366739
short_channel_id: 0, fee_msat: 150, cltv_expiry_delta: 0, maybe_announced_channel: true,
67376740
},
6738-
], blinded_tail: None }, Path { hops: vec![
6741+
], trampoline_hops: vec![], blinded_tail: None }, Path { hops: vec![
67396742
RouteHop {
67406743
pubkey: PublicKey::from_slice(&<Vec<u8>>::from_hex("02eec7245d6b7d2ccb30380bfbe2a3648cd7a942653f5aa340edcea1f283686619").unwrap()[..]).unwrap(),
67416744
channel_features: ChannelFeatures::empty(), node_features: NodeFeatures::empty(),
@@ -6746,7 +6749,7 @@ mod tests {
67466749
channel_features: ChannelFeatures::empty(), node_features: NodeFeatures::empty(),
67476750
short_channel_id: 0, fee_msat: 150, cltv_expiry_delta: 0, maybe_announced_channel: true,
67486751
},
6749-
], blinded_tail: None }],
6752+
], trampoline_hops: vec![], blinded_tail: None }],
67506753
route_params: None,
67516754
};
67526755

@@ -7358,6 +7361,7 @@ mod tests {
73587361
cltv_expiry_delta: 0,
73597362
maybe_announced_channel: true,
73607363
}],
7364+
trampoline_hops: vec![],
73617365
blinded_tail: Some(BlindedTail {
73627366
hops: blinded_path_1.blinded_hops,
73637367
blinding_point: blinded_path_1.blinding_point,
@@ -7372,7 +7376,7 @@ mod tests {
73727376
fee_msat: 100,
73737377
cltv_expiry_delta: 0,
73747378
maybe_announced_channel: true,
7375-
}], blinded_tail: None }],
7379+
}], trampoline_hops: vec![], blinded_tail: None }],
73767380
route_params: None,
73777381
};
73787382
let encoded_route = route.encode();
@@ -7422,6 +7426,7 @@ mod tests {
74227426
cltv_expiry_delta: 0,
74237427
maybe_announced_channel: false,
74247428
}],
7429+
trampoline_hops: vec![],
74257430
blinded_tail: Some(BlindedTail {
74267431
hops: blinded_path.blinded_hops,
74277432
blinding_point: blinded_path.blinding_point,
@@ -7465,6 +7470,7 @@ mod tests {
74657470
maybe_announced_channel: false,
74667471
}
74677472
],
7473+
trampoline_hops: vec![],
74687474
blinded_tail: Some(BlindedTail {
74697475
hops: blinded_path.blinded_hops,
74707476
blinding_point: blinded_path.blinding_point,

0 commit comments

Comments
 (0)