@@ -45,6 +45,8 @@ pub enum PendingHTLCRouting {
4545 ///
4646 /// Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None
4747 blinded : crate :: lightning:: ln:: channelmanager:: BlindedForward ,
48+ /// The absolute CLTV of the inbound HTLC
49+ incoming_cltv_expiry : crate :: c_types:: derived:: COption_u32Z ,
4850 } ,
4951 /// The onion indicates that this is a payment for an invoice (supposedly) generated by us.
5052 ///
@@ -129,15 +131,18 @@ impl PendingHTLCRouting {
129131 #[ allow( unused) ]
130132 pub ( crate ) fn to_native ( & self ) -> nativePendingHTLCRouting {
131133 match self {
132- PendingHTLCRouting :: Forward { ref onion_packet, ref short_channel_id, ref blinded, } => {
134+ PendingHTLCRouting :: Forward { ref onion_packet, ref short_channel_id, ref blinded, ref incoming_cltv_expiry , } => {
133135 let mut onion_packet_nonref = Clone :: clone ( onion_packet) ;
134136 let mut short_channel_id_nonref = Clone :: clone ( short_channel_id) ;
135137 let mut blinded_nonref = Clone :: clone ( blinded) ;
136138 let mut local_blinded_nonref = if blinded_nonref. inner . is_null ( ) { None } else { Some ( { * unsafe { Box :: from_raw ( blinded_nonref. take_inner ( ) ) } } ) } ;
139+ let mut incoming_cltv_expiry_nonref = Clone :: clone ( incoming_cltv_expiry) ;
140+ let mut local_incoming_cltv_expiry_nonref = if incoming_cltv_expiry_nonref. is_some ( ) { Some ( { incoming_cltv_expiry_nonref. take ( ) } ) } else { None } ;
137141 nativePendingHTLCRouting:: Forward {
138142 onion_packet : * unsafe { Box :: from_raw ( onion_packet_nonref. take_inner ( ) ) } ,
139143 short_channel_id : short_channel_id_nonref,
140144 blinded : local_blinded_nonref,
145+ incoming_cltv_expiry : local_incoming_cltv_expiry_nonref,
141146 }
142147 } ,
143148 PendingHTLCRouting :: Receive { ref payment_data, ref payment_metadata, ref payment_context, ref incoming_cltv_expiry, ref phantom_shared_secret, ref custom_tlvs, ref requires_blinded_error, } => {
@@ -188,12 +193,14 @@ impl PendingHTLCRouting {
188193 #[ allow( unused) ]
189194 pub ( crate ) fn into_native ( self ) -> nativePendingHTLCRouting {
190195 match self {
191- PendingHTLCRouting :: Forward { mut onion_packet, mut short_channel_id, mut blinded, } => {
196+ PendingHTLCRouting :: Forward { mut onion_packet, mut short_channel_id, mut blinded, mut incoming_cltv_expiry , } => {
192197 let mut local_blinded = if blinded. inner . is_null ( ) { None } else { Some ( { * unsafe { Box :: from_raw ( blinded. take_inner ( ) ) } } ) } ;
198+ let mut local_incoming_cltv_expiry = if incoming_cltv_expiry. is_some ( ) { Some ( { incoming_cltv_expiry. take ( ) } ) } else { None } ;
193199 nativePendingHTLCRouting:: Forward {
194200 onion_packet : * unsafe { Box :: from_raw ( onion_packet. take_inner ( ) ) } ,
195201 short_channel_id : short_channel_id,
196202 blinded : local_blinded,
203+ incoming_cltv_expiry : local_incoming_cltv_expiry,
197204 }
198205 } ,
199206 PendingHTLCRouting :: Receive { mut payment_data, mut payment_metadata, mut payment_context, mut incoming_cltv_expiry, mut phantom_shared_secret, mut custom_tlvs, mut requires_blinded_error, } => {
@@ -231,15 +238,18 @@ impl PendingHTLCRouting {
231238 pub ( crate ) fn from_native ( native : & PendingHTLCRoutingImport ) -> Self {
232239 let native = unsafe { & * ( native as * const _ as * const c_void as * const nativePendingHTLCRouting ) } ;
233240 match native {
234- nativePendingHTLCRouting:: Forward { ref onion_packet, ref short_channel_id, ref blinded, } => {
241+ nativePendingHTLCRouting:: Forward { ref onion_packet, ref short_channel_id, ref blinded, ref incoming_cltv_expiry , } => {
235242 let mut onion_packet_nonref = Clone :: clone ( onion_packet) ;
236243 let mut short_channel_id_nonref = Clone :: clone ( short_channel_id) ;
237244 let mut blinded_nonref = Clone :: clone ( blinded) ;
238245 let mut local_blinded_nonref = crate :: lightning:: ln:: channelmanager:: BlindedForward { inner : if blinded_nonref. is_none ( ) { core:: ptr:: null_mut ( ) } else { { ObjOps :: heap_alloc ( ( blinded_nonref. unwrap ( ) ) ) } } , is_owned : true } ;
246+ let mut incoming_cltv_expiry_nonref = Clone :: clone ( incoming_cltv_expiry) ;
247+ let mut local_incoming_cltv_expiry_nonref = if incoming_cltv_expiry_nonref. is_none ( ) { crate :: c_types:: derived:: COption_u32Z :: None } else { crate :: c_types:: derived:: COption_u32Z :: Some ( { incoming_cltv_expiry_nonref. unwrap ( ) } ) } ;
239248 PendingHTLCRouting :: Forward {
240249 onion_packet : crate :: lightning:: ln:: msgs:: OnionPacket { inner : ObjOps :: heap_alloc ( onion_packet_nonref) , is_owned : true } ,
241250 short_channel_id : short_channel_id_nonref,
242251 blinded : local_blinded_nonref,
252+ incoming_cltv_expiry : local_incoming_cltv_expiry_nonref,
243253 }
244254 } ,
245255 nativePendingHTLCRouting:: Receive { ref payment_data, ref payment_metadata, ref payment_context, ref incoming_cltv_expiry, ref phantom_shared_secret, ref custom_tlvs, ref requires_blinded_error, } => {
@@ -290,12 +300,14 @@ impl PendingHTLCRouting {
290300 #[ allow( unused) ]
291301 pub ( crate ) fn native_into ( native : nativePendingHTLCRouting ) -> Self {
292302 match native {
293- nativePendingHTLCRouting:: Forward { mut onion_packet, mut short_channel_id, mut blinded, } => {
303+ nativePendingHTLCRouting:: Forward { mut onion_packet, mut short_channel_id, mut blinded, mut incoming_cltv_expiry , } => {
294304 let mut local_blinded = crate :: lightning:: ln:: channelmanager:: BlindedForward { inner : if blinded. is_none ( ) { core:: ptr:: null_mut ( ) } else { { ObjOps :: heap_alloc ( ( blinded. unwrap ( ) ) ) } } , is_owned : true } ;
305+ let mut local_incoming_cltv_expiry = if incoming_cltv_expiry. is_none ( ) { crate :: c_types:: derived:: COption_u32Z :: None } else { crate :: c_types:: derived:: COption_u32Z :: Some ( { incoming_cltv_expiry. unwrap ( ) } ) } ;
295306 PendingHTLCRouting :: Forward {
296307 onion_packet : crate :: lightning:: ln:: msgs:: OnionPacket { inner : ObjOps :: heap_alloc ( onion_packet) , is_owned : true } ,
297308 short_channel_id : short_channel_id,
298309 blinded : local_blinded,
310+ incoming_cltv_expiry : local_incoming_cltv_expiry,
299311 }
300312 } ,
301313 nativePendingHTLCRouting:: Receive { mut payment_data, mut payment_metadata, mut payment_context, mut incoming_cltv_expiry, mut phantom_shared_secret, mut custom_tlvs, mut requires_blinded_error, } => {
@@ -350,11 +362,12 @@ pub(crate) extern "C" fn PendingHTLCRouting_free_void(this_ptr: *mut c_void) {
350362}
351363#[ no_mangle]
352364/// Utility method to constructs a new Forward-variant PendingHTLCRouting
353- pub extern "C" fn PendingHTLCRouting_forward ( onion_packet : crate :: lightning:: ln:: msgs:: OnionPacket , short_channel_id : u64 , blinded : crate :: lightning:: ln:: channelmanager:: BlindedForward ) -> PendingHTLCRouting {
365+ pub extern "C" fn PendingHTLCRouting_forward ( onion_packet : crate :: lightning:: ln:: msgs:: OnionPacket , short_channel_id : u64 , blinded : crate :: lightning:: ln:: channelmanager:: BlindedForward , incoming_cltv_expiry : crate :: c_types :: derived :: COption_u32Z ) -> PendingHTLCRouting {
354366 PendingHTLCRouting :: Forward {
355367 onion_packet,
356368 short_channel_id,
357369 blinded,
370+ incoming_cltv_expiry,
358371 }
359372}
360373#[ no_mangle]
@@ -2673,6 +2686,18 @@ pub extern "C" fn ChannelManager_force_close_all_channels_without_broadcasting_t
26732686 unsafe { & * ObjOps :: untweak_ptr ( this_arg. inner ) } . force_close_all_channels_without_broadcasting_txn ( error_message. into_string ( ) )
26742687}
26752688
2689+ /// Sends a payment along a given route. See [`Self::send_payment`] for more info.
2690+ ///
2691+ /// LDK will not automatically retry this payment, though it may be manually re-sent after an
2692+ /// [`Event::PaymentFailed`] is generated.
2693+ #[ must_use]
2694+ #[ no_mangle]
2695+ pub extern "C" fn ChannelManager_send_payment_with_route ( this_arg : & crate :: lightning:: ln:: channelmanager:: ChannelManager , mut route : crate :: lightning:: routing:: router:: Route , mut payment_hash : crate :: c_types:: ThirtyTwoBytes , mut recipient_onion : crate :: lightning:: ln:: outbound_payment:: RecipientOnionFields , mut payment_id : crate :: c_types:: ThirtyTwoBytes ) -> crate :: c_types:: derived:: CResult_NoneRetryableSendFailureZ {
2696+ let mut ret = unsafe { & * ObjOps :: untweak_ptr ( this_arg. inner ) } . send_payment_with_route ( * unsafe { Box :: from_raw ( route. take_inner ( ) ) } , :: lightning:: types:: payment:: PaymentHash ( payment_hash. data ) , * unsafe { Box :: from_raw ( recipient_onion. take_inner ( ) ) } , :: lightning:: ln:: channelmanager:: PaymentId ( payment_id. data ) ) ;
2697+ let mut local_ret = match ret { Ok ( mut o) => crate :: c_types:: CResultTempl :: ok ( { ( ) /*o*/ } ) . into ( ) , Err ( mut e) => crate :: c_types:: CResultTempl :: err ( { crate :: lightning:: ln:: outbound_payment:: RetryableSendFailure :: native_into ( e) } ) . into ( ) } ;
2698+ local_ret
2699+ }
2700+
26762701/// Sends a payment to the route found using the provided [`RouteParameters`], retrying failed
26772702/// payment paths based on the provided `Retry`.
26782703///
@@ -2699,7 +2724,8 @@ pub extern "C" fn ChannelManager_force_close_all_channels_without_broadcasting_t
26992724/// [`ChannelManager::list_recent_payments`] for more information.
27002725///
27012726/// Routes are automatically found using the [`Router] provided on startup. To fix a route for a
2702- /// particular payment, match the [`PaymentId`] passed to [`Router::find_route_with_id`].
2727+ /// particular payment, use [`Self::send_payment_with_route`] or match the [`PaymentId`] passed to
2728+ /// [`Router::find_route_with_id`].
27032729///
27042730/// [`Event::PaymentSent`]: events::Event::PaymentSent
27052731/// [`Event::PaymentFailed`]: events::Event::PaymentFailed
0 commit comments