Skip to content

Commit 936e7d5

Browse files
Factor invreq into payment path len limiting.
1 parent 741cf01 commit 936e7d5

File tree

3 files changed

+7
-5
lines changed

3 files changed

+7
-5
lines changed

lightning/src/ln/onion_utils.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,8 @@ pub(crate) const MIN_FINAL_VALUE_ESTIMATE_WITH_OVERPAY: u64 = 100_000_000;
320320

321321
pub(crate) fn set_max_path_length(
322322
route_params: &mut RouteParameters, recipient_onion: &RecipientOnionFields,
323-
keysend_preimage: Option<PaymentPreimage>, best_block_height: u32,
323+
keysend_preimage: Option<PaymentPreimage>, invoice_request: Option<&InvoiceRequest>,
324+
best_block_height: u32,
324325
) -> Result<(), ()> {
325326
const PAYLOAD_HMAC_LEN: usize = 32;
326327
let unblinded_intermed_payload_len = msgs::OutboundOnionPayload::Forward {
@@ -367,7 +368,7 @@ pub(crate) fn set_max_path_length(
367368
&recipient_onion,
368369
best_block_height,
369370
&keysend_preimage,
370-
None,
371+
invoice_request,
371372
|_, payload| {
372373
num_reserved_bytes = num_reserved_bytes
373374
.saturating_add(payload.serialized_length())

lightning/src/ln/outbound_payment.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -974,7 +974,7 @@ impl OutboundPayments {
974974

975975
if let Err(()) = onion_utils::set_max_path_length(
976976
&mut route_params, &RecipientOnionFields::spontaneous_empty(), Some(keysend_preimage),
977-
best_block_height
977+
invoice_request.as_ref(), best_block_height
978978
) {
979979
abandon_with_entry!(entry, PaymentFailureReason::UnexpectedError);
980980
return Err(Bolt12PaymentError::SendingFailed(RetryableSendFailure::OnionPacketSizeExceeded))
@@ -1122,7 +1122,7 @@ impl OutboundPayments {
11221122
}
11231123

11241124
onion_utils::set_max_path_length(
1125-
route_params, recipient_onion, keysend_preimage, best_block_height
1125+
route_params, recipient_onion, keysend_preimage, None, best_block_height
11261126
).map_err(|()| RetryableSendFailure::OnionPacketSizeExceeded)?;
11271127

11281128
let mut route = router.find_route_with_id(

lightning/src/routing/router.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -641,8 +641,9 @@ impl RouteParameters {
641641
&mut self, recipient_onion: &RecipientOnionFields, is_keysend: bool, best_block_height: u32
642642
) -> Result<(), ()> {
643643
let keysend_preimage_opt = is_keysend.then(|| PaymentPreimage([42; 32]));
644+
// TODO: no way to account for the invoice request here yet
644645
onion_utils::set_max_path_length(
645-
self, recipient_onion, keysend_preimage_opt, best_block_height
646+
self, recipient_onion, keysend_preimage_opt, None, best_block_height
646647
)
647648
}
648649
}

0 commit comments

Comments
 (0)