Skip to content

Commit 5695305

Browse files
committed
Add trampoline_hops field to BlindedTail
Given that we do not intend to allow sending to unblinded recipients via Trampoline hops, we're adding a vector of unblinded `TrampolineHop`s directly to the `BlindedTail` struct.
1 parent 75cf8d2 commit 5695305

File tree

4 files changed

+19
-2
lines changed

4 files changed

+19
-2
lines changed

lightning/src/ln/blinded_payment_tests.rs

+1
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

+16-2
Original file line numberDiff line numberDiff line change
@@ -399,13 +399,13 @@ pub struct RouteHop {
399399
/// The fee taken on this hop (for paying for the use of the *next* channel in the path).
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
402-
/// blinded path
402+
/// blinded path (including any Trampoline hops)
403403
/// * otherwise, this is the full value of this [`Path`]'s part of the payment
404404
pub fee_msat: u64,
405405
/// The CLTV delta added for this hop.
406406
/// If this is the last hop in [`Path::hops`]:
407407
/// * if we're sending to a [`BlindedPaymentPath`], this is the CLTV delta for the entire blinded
408-
/// path
408+
/// path (including any Trampoline hops)
409409
/// * otherwise, this is the CLTV delta expected at the destination
410410
pub cltv_expiry_delta: u32,
411411
/// Indicates whether this hop is possibly announced in the public network graph.
@@ -460,6 +460,13 @@ impl_writeable_tlv_based!(TrampolineHop, {
460460
/// [`Bolt12Invoice`]: crate::offers::invoice::Bolt12Invoice
461461
#[derive(Clone, Debug, Hash, PartialEq, Eq)]
462462
pub struct BlindedTail {
463+
/// The list of unblinded Trampoline hops. When using Trampoline, must contain at least one hop.
464+
///
465+
/// Note that the first [`TrampolineHop`] node must also be present as the last [`RouteHop`] node,
466+
/// where the RouteHop's fee_msat is the total amount received by the first [`TrampolineHop`],
467+
/// including any blinded path, whereas the [`TrampolineHop`]'s fee_msat is the fee that node
468+
/// may use to route to the next Trampoline hop and pay itself for the trouble.
469+
pub trampoline_hops: Vec<TrampolineHop>,
463470
/// The hops of the [`BlindedPaymentPath`] provided by the recipient.
464471
pub hops: Vec<BlindedHop>,
465472
/// The blinding point of the [`BlindedPaymentPath`] provided by the recipient.
@@ -476,6 +483,7 @@ impl_writeable_tlv_based!(BlindedTail, {
476483
(2, blinding_point, required),
477484
(4, excess_final_cltv_expiry_delta, required),
478485
(6, final_value_msat, required),
486+
(8, trampoline_hops, optional_vec),
479487
});
480488

481489
/// A path in a [`Route`] to the payment recipient. Must always be at least length one.
@@ -3404,6 +3412,8 @@ where L::Target: Logger {
34043412
if let Some(blinded_path) = h.candidate.blinded_path() {
34053413
final_cltv_delta = h.candidate.cltv_expiry_delta();
34063414
Some(BlindedTail {
3415+
// TODO: fill correctly
3416+
trampoline_hops: vec![],
34073417
hops: blinded_path.blinded_hops().to_vec(),
34083418
blinding_point: blinded_path.blinding_point(),
34093419
excess_final_cltv_expiry_delta: 0,
@@ -7750,6 +7760,7 @@ mod tests {
77507760
maybe_announced_channel: true,
77517761
}],
77527762
blinded_tail: Some(BlindedTail {
7763+
trampoline_hops: vec![],
77537764
hops: vec![
77547765
BlindedHop { blinded_node_id: ln_test_utils::pubkey(44), encrypted_payload: Vec::new() },
77557766
BlindedHop { blinded_node_id: ln_test_utils::pubkey(45), encrypted_payload: Vec::new() }
@@ -7776,6 +7787,7 @@ mod tests {
77767787

77777788
// (De)serialize a Route with two paths, each containing a blinded tail.
77787789
route.paths[1].blinded_tail = Some(BlindedTail {
7790+
trampoline_hops: vec![],
77797791
hops: vec![
77807792
BlindedHop { blinded_node_id: ln_test_utils::pubkey(48), encrypted_payload: Vec::new() },
77817793
BlindedHop { blinded_node_id: ln_test_utils::pubkey(49), encrypted_payload: Vec::new() }
@@ -7815,6 +7827,7 @@ mod tests {
78157827
maybe_announced_channel: false,
78167828
}],
78177829
blinded_tail: Some(BlindedTail {
7830+
trampoline_hops: vec![],
78187831
hops: vec![BlindedHop { blinded_node_id: ln_test_utils::pubkey(49), encrypted_payload: Vec::new() }],
78197832
blinding_point: ln_test_utils::pubkey(48),
78207833
excess_final_cltv_expiry_delta: 0,
@@ -7850,6 +7863,7 @@ mod tests {
78507863
}
78517864
],
78527865
blinded_tail: Some(BlindedTail {
7866+
trampoline_hops: vec![],
78537867
hops: vec![
78547868
BlindedHop { blinded_node_id: ln_test_utils::pubkey(45), encrypted_payload: Vec::new() },
78557869
BlindedHop { blinded_node_id: ln_test_utils::pubkey(46), encrypted_payload: Vec::new() }

lightning/src/routing/scoring.rs

+1
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

+1
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)