Skip to content

Commit ce3554f

Browse files
f set max path length for async payments
1 parent df8bd68 commit ce3554f

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

lightning/src/ln/outbound_payment.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -932,22 +932,26 @@ impl OutboundPayments {
932932
IH: Fn() -> InFlightHtlcs,
933933
SP: Fn(SendAlongPathArgs) -> Result<(), APIError>,
934934
{
935-
let (payment_hash, route_params) =
935+
let (payment_hash, keysend_preimage, mut route_params) =
936936
match self.pending_outbound_payments.lock().unwrap().entry(payment_id) {
937937
hash_map::Entry::Occupied(entry) => match entry.get() {
938938
PendingOutboundPayment::StaticInvoiceReceived {
939-
payment_hash, payment_release_secret: release_secret, route_params, ..
939+
payment_hash, payment_release_secret: release_secret, keysend_preimage, route_params, ..
940940
} => {
941941
if payment_release_secret != *release_secret {
942942
return Err(Bolt12PaymentError::UnexpectedInvoice)
943943
}
944-
(*payment_hash, route_params.clone())
944+
(*payment_hash, *keysend_preimage, route_params.clone())
945945
},
946946
_ => return Err(Bolt12PaymentError::DuplicateInvoice),
947947
},
948948
hash_map::Entry::Vacant(_) => return Err(Bolt12PaymentError::UnexpectedInvoice),
949949
};
950950

951+
onion_utils::set_max_path_length(
952+
&mut route_params, &RecipientOnionFields::spontaneous_empty(), Some(keysend_preimage), best_block_height
953+
).map_err(|()| Bolt12PaymentError::OnionPacketSizeExceeded)?;
954+
951955
self.find_route_and_send_payment(
952956
payment_hash, payment_id, route_params, router, first_hops, &inflight_htlcs,
953957
entropy_source, node_signer, best_block_height, logger, pending_events,

0 commit comments

Comments
 (0)