pub(crate) fn set_max_path_length(
route_params: &mut RouteParameters, recipient_onion: &RecipientOnionFields,
- keysend_preimage: Option<PaymentPreimage>, best_block_height: u32,
+ keysend_preimage: Option<PaymentPreimage>, invoice_request: Option<&InvoiceRequest>,
+ best_block_height: u32,
) -> Result<(), ()> {
const PAYLOAD_HMAC_LEN: usize = 32;
let unblinded_intermed_payload_len = msgs::OutboundOnionPayload::Forward {
&recipient_onion,
best_block_height,
&keysend_preimage,
- None,
+ invoice_request,
|_, payload| {
num_reserved_bytes = num_reserved_bytes
.saturating_add(payload.serialized_length())
custom_tlvs: vec![],
};
let route = match self.find_initial_route(
- payment_id, payment_hash, &recipient_onion, None, &mut route_params, router,
- &first_hops, &inflight_htlcs, node_signer, best_block_height, logger,
+ payment_id, payment_hash, &recipient_onion, keysend_preimage, invoice_request,
+ &mut route_params, router, &first_hops, &inflight_htlcs, node_signer, best_block_height,
+ logger,
) {
Ok(route) => route,
Err(e) => {
if let Err(()) = onion_utils::set_max_path_length(
&mut route_params, &RecipientOnionFields::spontaneous_empty(), Some(keysend_preimage),
- best_block_height
+ Some(invreq), best_block_height
) {
abandon_with_entry!(entry, PaymentFailureReason::RouteNotFound);
return Err(Bolt12PaymentError::SendingFailed(RetryableSendFailure::OnionPacketSizeExceeded))
}
fn find_initial_route<R: Deref, NS: Deref, IH, L: Deref>(
- &self, payment_id: PaymentId, payment_hash: PaymentHash,
- recipient_onion: &RecipientOnionFields, keysend_preimage: Option<PaymentPreimage>,
+ &self, payment_id: PaymentId, payment_hash: PaymentHash, recipient_onion: &RecipientOnionFields,
+ keysend_preimage: Option<PaymentPreimage>, invoice_request: Option<&InvoiceRequest>,
route_params: &mut RouteParameters, router: &R, first_hops: &Vec<ChannelDetails>,
inflight_htlcs: &IH, node_signer: &NS, best_block_height: u32, logger: &L,
) -> Result<Route, RetryableSendFailure>
}
onion_utils::set_max_path_length(
- route_params, recipient_onion, keysend_preimage, best_block_height
+ route_params, recipient_onion, keysend_preimage, invoice_request, best_block_height
)
.map_err(|()| {
log_error!(logger, "Can't construct an onion packet without exceeding 1300-byte onion \
SP: Fn(SendAlongPathArgs) -> Result<(), APIError>,
{
let route = self.find_initial_route(
- payment_id, payment_hash, &recipient_onion, keysend_preimage, &mut route_params, router,
+ payment_id, payment_hash, &recipient_onion, keysend_preimage, None, &mut route_params, router,
&first_hops, &inflight_htlcs, node_signer, best_block_height, logger,
)?;