Skip to content

Commit 4d5b4a5

Browse files
f don't count blinded hops towards max path len
1 parent d59ca51 commit 4d5b4a5

File tree

2 files changed

+10
-13
lines changed

2 files changed

+10
-13
lines changed

lightning/src/ln/blinded_payment_tests.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,9 +282,10 @@ fn do_forward_checks_failure(check: ForwardCheckFail, intro_fails: bool) {
282282

283283
let amt_msat = 5000;
284284
let (_, payment_hash, payment_secret) = get_payment_preimage_hash(&nodes[3], Some(amt_msat), None);
285-
let route_params = get_blinded_route_parameters(amt_msat, payment_secret, 1, 1_0000_0000,
285+
let mut route_params = get_blinded_route_parameters(amt_msat, payment_secret, 1, 1_0000_0000,
286286
nodes.iter().skip(1).map(|n| n.node.get_our_node_id()).collect(),
287287
&[&chan_upd_1_2, &chan_upd_2_3], &chanmon_cfgs[3].keys_manager);
288+
route_params.payment_params.max_path_length = 18;
288289

289290
let route = get_route(&nodes[0], &route_params).unwrap();
290291
node_cfgs[0].router.expect_find_route(route_params.clone(), Ok(route.clone()));

lightning/src/ln/onion_utils.rs

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -333,23 +333,19 @@ pub(crate) fn set_max_path_length(
333333
MIN_FINAL_VALUE_ESTIMATE_WITH_OVERPAY,
334334
);
335335

336-
let (num_reserved_hops, blinded_tail_opt) = route_params
336+
let blinded_tail_opt = route_params
337337
.payment_params
338338
.payee
339339
.blinded_route_hints()
340340
.iter()
341341
.map(|(_, path)| path)
342342
.max_by_key(|path| path.serialized_length())
343-
.map(|largest_path| {
344-
let blinded_tail = BlindedTailHopIter {
345-
hops: largest_path.blinded_hops.iter(),
346-
blinding_point: largest_path.blinding_point,
347-
final_value_msat: final_value_msat_with_overpay_buffer,
348-
excess_final_cltv_expiry_delta: 0,
349-
};
350-
(largest_path.blinded_hops.len(), Some(blinded_tail))
351-
})
352-
.unwrap_or((1, None));
343+
.map(|largest_path| BlindedTailHopIter {
344+
hops: largest_path.blinded_hops.iter(),
345+
blinding_point: largest_path.blinding_point,
346+
final_value_msat: final_value_msat_with_overpay_buffer,
347+
excess_final_cltv_expiry_delta: 0,
348+
});
353349

354350
let unblinded_route_hop = RouteHop {
355351
pubkey: PublicKey::from_slice(&[2; 33]).unwrap(),
@@ -379,7 +375,7 @@ pub(crate) fn set_max_path_length(
379375
let max_path_length = 1300usize
380376
.checked_sub(num_reserved_bytes)
381377
.map(|p| p / unblinded_intermed_payload_len)
382-
.and_then(|l| u8::try_from(l.saturating_add(num_reserved_hops)).ok())
378+
.and_then(|l| u8::try_from(l.saturating_add(1)).ok())
383379
.ok_or(())?;
384380

385381
route_params.payment_params.max_path_length =

0 commit comments

Comments
 (0)