@@ -919,7 +919,7 @@ impl OutboundPayments {
919919 #[ cfg( async_payments) ]
920920 pub ( super ) fn static_invoice_received < ES : Deref > (
921921 & self , invoice : & StaticInvoice , payment_id : PaymentId , features : Bolt12InvoiceFeatures ,
922- entropy_source : ES ,
922+ best_block_height : u32 , entropy_source : ES ,
923923 pending_events : & Mutex < VecDeque < ( events:: Event , Option < EventCompletionAction > ) > >
924924 ) -> Result < [ u8 ; 32 ] , Bolt12PaymentError > where ES :: Target : EntropySource {
925925 macro_rules! abandon_with_entry {
@@ -961,7 +961,16 @@ impl OutboundPayments {
961961 let payment_hash = PaymentHash ( Sha256 :: hash ( & keysend_preimage. 0 ) . to_byte_array ( ) ) ;
962962 let payment_release_secret = entropy_source. get_secure_random_bytes ( ) ;
963963 let pay_params = PaymentParameters :: from_static_invoice ( invoice) ;
964- let route_params = RouteParameters :: from_payment_params_and_value ( pay_params, amount_msat) ;
964+ let mut route_params = RouteParameters :: from_payment_params_and_value ( pay_params, amount_msat) ;
965+
966+ if let Err ( ( ) ) = onion_utils:: set_max_path_length (
967+ & mut route_params, & RecipientOnionFields :: spontaneous_empty ( ) , Some ( keysend_preimage) ,
968+ best_block_height
969+ ) {
970+ abandon_with_entry ! ( entry, PaymentFailureReason :: UnexpectedError ) ;
971+ return Err ( Bolt12PaymentError :: SendingFailed ( RetryableSendFailure :: OnionPacketSizeExceeded ) )
972+ }
973+
965974 * entry. into_mut ( ) = PendingOutboundPayment :: StaticInvoiceReceived {
966975 payment_hash,
967976 keysend_preimage,
0 commit comments