Skip to content

Commit 907a5e8

Browse files
committed
Add trampoline_hops field to Path.
1 parent ee3cc4f commit 907a5e8

File tree

13 files changed

+50
-39
lines changed

13 files changed

+50
-39
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
@@ -1775,7 +1775,7 @@ mod tests {
17751775
fee_msat: 0,
17761776
cltv_expiry_delta: MIN_CLTV_EXPIRY_DELTA as u32,
17771777
maybe_announced_channel: true,
1778-
}], blinded_tail: None };
1778+
}], trampoline_hops: vec![], blinded_tail: None };
17791779

17801780
$nodes[0].scorer.write_lock().expect(TestResult::PaymentFailure { path: path.clone(), short_channel_id: scored_scid });
17811781
$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
@@ -1378,7 +1378,7 @@ impl MaybeReadable for Event {
13781378
payment_hash,
13791379
payment_failed_permanently,
13801380
failure,
1381-
path: Path { hops: path.unwrap(), blinded_tail },
1381+
path: Path { hops: path.unwrap(), trampoline_hops: vec![], blinded_tail },
13821382
short_channel_id,
13831383
#[cfg(test)]
13841384
error_code,
@@ -1501,7 +1501,7 @@ impl MaybeReadable for Event {
15011501
Ok(Some(Event::PaymentPathSuccessful {
15021502
payment_id: payment_id.0.unwrap(),
15031503
payment_hash,
1504-
path: Path { hops: path, blinded_tail },
1504+
path: Path { hops: path, trampoline_hops: vec![], blinded_tail },
15051505
}))
15061506
};
15071507
f()
@@ -1566,7 +1566,7 @@ impl MaybeReadable for Event {
15661566
Ok(Some(Event::ProbeSuccessful {
15671567
payment_id: payment_id.0.unwrap(),
15681568
payment_hash: payment_hash.0.unwrap(),
1569-
path: Path { hops: path, blinded_tail },
1569+
path: Path { hops: path, trampoline_hops: vec![], blinded_tail },
15701570
}))
15711571
};
15721572
f()
@@ -1583,7 +1583,7 @@ impl MaybeReadable for Event {
15831583
Ok(Some(Event::ProbeFailed {
15841584
payment_id: payment_id.0.unwrap(),
15851585
payment_hash: payment_hash.0.unwrap(),
1586-
path: Path { hops: path, blinded_tail },
1586+
path: Path { hops: path, trampoline_hops: vec![], blinded_tail },
15871587
short_channel_id,
15881588
}))
15891589
};

lightning/src/ln/channel.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9404,7 +9404,7 @@ mod tests {
94049404
cltv_expiry: 200000000,
94059405
state: OutboundHTLCState::Committed,
94069406
source: HTLCSource::OutboundRoute {
9407-
path: Path { hops: Vec::new(), blinded_tail: None },
9407+
path: Path { hops: Vec::new(), trampoline_hops: vec![], blinded_tail: None },
94089408
session_priv: SecretKey::from_slice(&<Vec<u8>>::from_hex("0fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff").unwrap()[..]).unwrap(),
94099409
first_hop_htlc_msat: 548,
94109410
payment_id: PaymentId([42; 32]),
@@ -9778,6 +9778,7 @@ mod tests {
97789778
node_features: NodeFeatures::empty(), short_channel_id: 0, fee_msat: 0,
97799779
cltv_expiry_delta: 0, maybe_announced_channel: false,
97809780
}],
9781+
trampoline_hops: vec![],
97819782
blinded_tail: None
97829783
},
97839784
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
@@ -9977,7 +9977,7 @@ impl Readable for HTLCSource {
99779977
// instead.
99789978
payment_id = Some(PaymentId(*session_priv.0.unwrap().as_ref()));
99799979
}
9980-
let path = Path { hops: path_hops, blinded_tail };
9980+
let path = Path { hops: path_hops, trampoline_hops: vec![], blinded_tail };
99819981
if path.hops.len() == 0 {
99829982
return Err(DecodeError::InvalidValue);
99839983
}

lightning/src/ln/functional_tests.rs

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

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

11011101
// Claim the rebalances...

lightning/src/ln/onion_payment.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -528,7 +528,7 @@ mod tests {
528528
// Ensure the onion will not fit all the payloads by adding a large custom TLV.
529529
recipient_onion.custom_tlvs.push((13377331, vec![0; 1156]));
530530

531-
let path = Path { hops, blinded_tail: None, };
531+
let path = Path { hops, trampoline_hops: vec![], blinded_tail: None, };
532532
let onion_keys = super::onion_utils::construct_onion_keys(&secp_ctx, &path, &session_priv).unwrap();
533533
let (onion_payloads, ..) = super::onion_utils::build_onion_payloads(
534534
&path, total_amt_msat, recipient_onion, cur_height + 1, &Some(keysend_preimage)
@@ -554,6 +554,7 @@ mod tests {
554554

555555
let path = Path {
556556
hops: hops,
557+
trampoline_hops: vec![],
557558
blinded_tail: None,
558559
};
559560

lightning/src/ln/onion_route_tests.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1015,7 +1015,7 @@ fn test_trampoline_onion_payload_construction_vectors() {
10151015
cltv_expiry_delta: 0,
10161016
maybe_announced_channel: false,
10171017
}
1018-
], blinded_tail: None };
1018+
], trampoline_hops: vec![], blinded_tail: None };
10191019

10201020
let slice_to_hex = |slice: &[u8]| {
10211021
slice.iter()
@@ -1083,6 +1083,7 @@ fn test_trampoline_onion_payload_construction_vectors() {
10831083
maybe_announced_channel: false,
10841084
},
10851085
],
1086+
trampoline_hops: vec![],
10861087
blinded_tail: None,
10871088
};
10881089

lightning/src/ln/onion_utils.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1268,7 +1268,7 @@ mod tests {
12681268
channel_features: ChannelFeatures::empty(), node_features: NodeFeatures::empty(),
12691269
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.
12701270
},
1271-
], blinded_tail: None }],
1271+
], trampoline_hops: vec![], blinded_tail: None }],
12721272
route_params: None,
12731273
};
12741274

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)),
@@ -3073,7 +3076,7 @@ where L::Target: Logger {
30733076
core::mem::replace(&mut hop.cltv_expiry_delta, prev_cltv_expiry_delta)
30743077
});
30753078

3076-
paths.push(Path { hops, blinded_tail });
3079+
paths.push(Path { hops, trampoline_hops: vec![], blinded_tail });
30773080
}
30783081
// Make sure we would never create a route with more paths than we allow.
30793082
debug_assert!(paths.len() <= payment_params.max_path_count.into());
@@ -6652,7 +6655,7 @@ mod tests {
66526655
channel_features: ChannelFeatures::empty(), node_features: NodeFeatures::empty(),
66536656
short_channel_id: 0, fee_msat: 225, cltv_expiry_delta: 0, maybe_announced_channel: true,
66546657
},
6655-
], blinded_tail: None }],
6658+
], trampoline_hops: vec![], blinded_tail: None }],
66566659
route_params: None,
66576660
};
66586661

@@ -6674,7 +6677,7 @@ mod tests {
66746677
channel_features: ChannelFeatures::empty(), node_features: NodeFeatures::empty(),
66756678
short_channel_id: 0, fee_msat: 150, cltv_expiry_delta: 0, maybe_announced_channel: true,
66766679
},
6677-
], blinded_tail: None }, Path { hops: vec![
6680+
], trampoline_hops: vec![], blinded_tail: None }, Path { hops: vec![
66786681
RouteHop {
66796682
pubkey: PublicKey::from_slice(&<Vec<u8>>::from_hex("02eec7245d6b7d2ccb30380bfbe2a3648cd7a942653f5aa340edcea1f283686619").unwrap()[..]).unwrap(),
66806683
channel_features: ChannelFeatures::empty(), node_features: NodeFeatures::empty(),
@@ -6685,7 +6688,7 @@ mod tests {
66856688
channel_features: ChannelFeatures::empty(), node_features: NodeFeatures::empty(),
66866689
short_channel_id: 0, fee_msat: 150, cltv_expiry_delta: 0, maybe_announced_channel: true,
66876690
},
6688-
], blinded_tail: None }],
6691+
], trampoline_hops: vec![], blinded_tail: None }],
66896692
route_params: None,
66906693
};
66916694

@@ -7297,6 +7300,7 @@ mod tests {
72977300
cltv_expiry_delta: 0,
72987301
maybe_announced_channel: true,
72997302
}],
7303+
trampoline_hops: vec![],
73007304
blinded_tail: Some(BlindedTail {
73017305
hops: blinded_path_1.blinded_hops,
73027306
blinding_point: blinded_path_1.blinding_point,
@@ -7311,7 +7315,7 @@ mod tests {
73117315
fee_msat: 100,
73127316
cltv_expiry_delta: 0,
73137317
maybe_announced_channel: true,
7314-
}], blinded_tail: None }],
7318+
}], trampoline_hops: vec![], blinded_tail: None }],
73157319
route_params: None,
73167320
};
73177321
let encoded_route = route.encode();
@@ -7361,6 +7365,7 @@ mod tests {
73617365
cltv_expiry_delta: 0,
73627366
maybe_announced_channel: false,
73637367
}],
7368+
trampoline_hops: vec![],
73647369
blinded_tail: Some(BlindedTail {
73657370
hops: blinded_path.blinded_hops,
73667371
blinding_point: blinded_path.blinding_point,
@@ -7404,6 +7409,7 @@ mod tests {
74047409
maybe_announced_channel: false,
74057410
}
74067411
],
7412+
trampoline_hops: vec![],
74077413
blinded_tail: Some(BlindedTail {
74087414
hops: blinded_path.blinded_hops,
74097415
blinding_point: blinded_path.blinding_point,

0 commit comments

Comments
 (0)