Skip to content

Commit b64e5f6

Browse files
committed
Add trampoline_hops field to Path
To specify Trampoline hops in Path instances, we need to introduce a third field to the struct, which is a vec of TrampolineHops defined in the previous commit.
1 parent e626385 commit b64e5f6

File tree

4 files changed

+19
-0
lines changed

4 files changed

+19
-0
lines changed

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
maybe_announced_channel: false,
15061506
}],
15071507
blinded_tail: Some(BlindedTail {
1508+
trampoline_hops: vec![],
15081509
hops: blinded_hops,
15091510
blinding_point: bob_blinding_point,
15101511
excess_final_cltv_expiry_delta: 0,

lightning/src/routing/router.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -400,6 +400,8 @@ pub struct RouteHop {
400400
/// If this is the last hop in [`Path::hops`]:
401401
/// * if we're sending to a [`BlindedPaymentPath`], this is the fee paid for use of the entire
402402
/// blinded path
403+
/// * if we're sending to a Trampoline entrypoint, this is the total incoming amount to the
404+
/// Trampoline entrypoint
403405
/// * otherwise, this is the full value of this [`Path`]'s part of the payment
404406
pub fee_msat: u64,
405407
/// The CLTV delta added for this hop.
@@ -460,6 +462,13 @@ impl_writeable_tlv_based!(TrampolineHop, {
460462
/// [`Bolt12Invoice`]: crate::offers::invoice::Bolt12Invoice
461463
#[derive(Clone, Debug, Hash, PartialEq, Eq)]
462464
pub struct BlindedTail {
465+
/// The list of unblinded Trampoline hops. When using Trampoline, must contain at least one hop.
466+
///
467+
/// Note that the first [`TrampolineHop`] node must also be present as the last [`RouteHop`] node,
468+
/// where the RouteHop's fee_msat is the total amount received by the first [`TrampolineHop`],
469+
/// including any blinded path, whereas the [`TrampolineHop`]'s fee_msat is the fee that node
470+
/// may use to route to the next Trampoline hop and pay itself for the trouble.
471+
pub trampoline_hops: Vec<TrampolineHop>,
463472
/// The hops of the [`BlindedPaymentPath`] provided by the recipient.
464473
pub hops: Vec<BlindedHop>,
465474
/// The blinding point of the [`BlindedPaymentPath`] provided by the recipient.
@@ -476,6 +485,7 @@ impl_writeable_tlv_based!(BlindedTail, {
476485
(2, blinding_point, required),
477486
(4, excess_final_cltv_expiry_delta, required),
478487
(6, final_value_msat, required),
488+
(8, trampoline_hops, optional_vec),
479489
});
480490

481491
/// A path in a [`Route`] to the payment recipient. Must always be at least length one.
@@ -3404,6 +3414,8 @@ where L::Target: Logger {
34043414
if let Some(blinded_path) = h.candidate.blinded_path() {
34053415
final_cltv_delta = h.candidate.cltv_expiry_delta();
34063416
Some(BlindedTail {
3417+
// TODO: fill correctly
3418+
trampoline_hops: vec![],
34073419
hops: blinded_path.blinded_hops().to_vec(),
34083420
blinding_point: blinded_path.blinding_point(),
34093421
excess_final_cltv_expiry_delta: 0,
@@ -7750,6 +7762,7 @@ mod tests {
77507762
maybe_announced_channel: true,
77517763
}],
77527764
blinded_tail: Some(BlindedTail {
7765+
trampoline_hops: vec![],
77537766
hops: vec![
77547767
BlindedHop { blinded_node_id: ln_test_utils::pubkey(44), encrypted_payload: Vec::new() },
77557768
BlindedHop { blinded_node_id: ln_test_utils::pubkey(45), encrypted_payload: Vec::new() }
@@ -7776,6 +7789,7 @@ mod tests {
77767789

77777790
// (De)serialize a Route with two paths, each containing a blinded tail.
77787791
route.paths[1].blinded_tail = Some(BlindedTail {
7792+
trampoline_hops: vec![],
77797793
hops: vec![
77807794
BlindedHop { blinded_node_id: ln_test_utils::pubkey(48), encrypted_payload: Vec::new() },
77817795
BlindedHop { blinded_node_id: ln_test_utils::pubkey(49), encrypted_payload: Vec::new() }
@@ -7815,6 +7829,7 @@ mod tests {
78157829
maybe_announced_channel: false,
78167830
}],
78177831
blinded_tail: Some(BlindedTail {
7832+
trampoline_hops: vec![],
78187833
hops: vec![BlindedHop { blinded_node_id: ln_test_utils::pubkey(49), encrypted_payload: Vec::new() }],
78197834
blinding_point: ln_test_utils::pubkey(48),
78207835
excess_final_cltv_expiry_delta: 0,
@@ -7850,6 +7865,7 @@ mod tests {
78507865
}
78517866
],
78527867
blinded_tail: Some(BlindedTail {
7868+
trampoline_hops: vec![],
78537869
hops: vec![
78547870
BlindedHop { blinded_node_id: ln_test_utils::pubkey(45), encrypted_payload: Vec::new() },
78557871
BlindedHop { blinded_node_id: ln_test_utils::pubkey(46), encrypted_payload: Vec::new() }

lightning/src/routing/scoring.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3571,6 +3571,7 @@ mod tests {
35713571
let mut path = payment_path_for_amount(768);
35723572
let recipient_hop = path.hops.pop().unwrap();
35733573
path.blinded_tail = Some(BlindedTail {
3574+
trampoline_hops: vec![],
35743575
hops: vec![BlindedHop { blinded_node_id: test_utils::pubkey(44), encrypted_payload: Vec::new() }],
35753576
blinding_point: test_utils::pubkey(42),
35763577
excess_final_cltv_expiry_delta: recipient_hop.cltv_expiry_delta,

lightning/src/util/ser.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1044,6 +1044,7 @@ impl_for_vec!(crate::ln::msgs::SocketAddress);
10441044
impl_for_vec!((A, B), A, B);
10451045
impl_writeable_for_vec!(&crate::routing::router::BlindedTail);
10461046
impl_readable_for_vec!(crate::routing::router::BlindedTail);
1047+
impl_for_vec!(crate::routing::router::TrampolineHop);
10471048
impl_for_vec_with_element_length_prefix!(crate::ln::msgs::UpdateAddHTLC);
10481049
impl_writeable_for_vec_with_element_length_prefix!(&crate::ln::msgs::UpdateAddHTLC);
10491050

0 commit comments

Comments
 (0)