Update auto-generated bindings to LDK 0.0.118
[ldk-c-bindings] / lightning-c-bindings / src / lightning / ln / outbound_payment.rs
1 // This file is Copyright its original authors, visible in version control
2 // history and in the source files from which this was generated.
3 //
4 // This file is licensed under the license available in the LICENSE or LICENSE.md
5 // file in the root of this repository or, if no such file exists, the same
6 // license as that which applies to the original source files from which this
7 // source was automatically generated.
8
9 //! Utilities to send payments and manage outbound payment information.
10
11 use alloc::str::FromStr;
12 use alloc::string::String;
13 use core::ffi::c_void;
14 use core::convert::Infallible;
15 use bitcoin::hashes::Hash;
16 use crate::c_types::*;
17 #[cfg(feature="no-std")]
18 use alloc::{vec::Vec, boxed::Box};
19
20 /// Strategies available to retry payment path failures.
21 #[derive(Clone)]
22 #[must_use]
23 #[repr(C)]
24 pub enum Retry {
25         /// Max number of attempts to retry payment.
26         ///
27         /// Each attempt may be multiple HTLCs along multiple paths if the router decides to split up a
28         /// retry, and may retry multiple failed HTLCs at once if they failed around the same time and
29         /// were retried along a route from a single call to [`Router::find_route_with_id`].
30         Attempts(
31                 u32),
32         /// Time elapsed before abandoning retries for a payment. At least one attempt at payment is made;
33         /// see [`PaymentParameters::expiry_time`] to avoid any attempt at payment after a specific time.
34         ///
35         /// [`PaymentParameters::expiry_time`]: crate::routing::router::PaymentParameters::expiry_time
36         Timeout(
37                 u64),
38 }
39 use lightning::ln::outbound_payment::Retry as RetryImport;
40 pub(crate) type nativeRetry = RetryImport;
41
42 impl Retry {
43         #[allow(unused)]
44         pub(crate) fn to_native(&self) -> nativeRetry {
45                 match self {
46                         Retry::Attempts (ref a, ) => {
47                                 let mut a_nonref = Clone::clone(a);
48                                 nativeRetry::Attempts (
49                                         a_nonref,
50                                 )
51                         },
52                         Retry::Timeout (ref a, ) => {
53                                 let mut a_nonref = Clone::clone(a);
54                                 nativeRetry::Timeout (
55                                         core::time::Duration::from_secs(a_nonref),
56                                 )
57                         },
58                 }
59         }
60         #[allow(unused)]
61         pub(crate) fn into_native(self) -> nativeRetry {
62                 match self {
63                         Retry::Attempts (mut a, ) => {
64                                 nativeRetry::Attempts (
65                                         a,
66                                 )
67                         },
68                         Retry::Timeout (mut a, ) => {
69                                 nativeRetry::Timeout (
70                                         core::time::Duration::from_secs(a),
71                                 )
72                         },
73                 }
74         }
75         #[allow(unused)]
76         pub(crate) fn from_native(native: &nativeRetry) -> Self {
77                 match native {
78                         nativeRetry::Attempts (ref a, ) => {
79                                 let mut a_nonref = Clone::clone(a);
80                                 Retry::Attempts (
81                                         a_nonref,
82                                 )
83                         },
84                         nativeRetry::Timeout (ref a, ) => {
85                                 let mut a_nonref = Clone::clone(a);
86                                 Retry::Timeout (
87                                         a_nonref.as_secs(),
88                                 )
89                         },
90                 }
91         }
92         #[allow(unused)]
93         pub(crate) fn native_into(native: nativeRetry) -> Self {
94                 match native {
95                         nativeRetry::Attempts (mut a, ) => {
96                                 Retry::Attempts (
97                                         a,
98                                 )
99                         },
100                         nativeRetry::Timeout (mut a, ) => {
101                                 Retry::Timeout (
102                                         a.as_secs(),
103                                 )
104                         },
105                 }
106         }
107 }
108 /// Frees any resources used by the Retry
109 #[no_mangle]
110 pub extern "C" fn Retry_free(this_ptr: Retry) { }
111 /// Creates a copy of the Retry
112 #[no_mangle]
113 pub extern "C" fn Retry_clone(orig: &Retry) -> Retry {
114         orig.clone()
115 }
116 #[allow(unused)]
117 /// Used only if an object of this type is returned as a trait impl by a method
118 pub(crate) extern "C" fn Retry_clone_void(this_ptr: *const c_void) -> *mut c_void {
119         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const Retry)).clone() })) as *mut c_void
120 }
121 #[allow(unused)]
122 /// Used only if an object of this type is returned as a trait impl by a method
123 pub(crate) extern "C" fn Retry_free_void(this_ptr: *mut c_void) {
124         let _ = unsafe { Box::from_raw(this_ptr as *mut Retry) };
125 }
126 #[no_mangle]
127 /// Utility method to constructs a new Attempts-variant Retry
128 pub extern "C" fn Retry_attempts(a: u32) -> Retry {
129         Retry::Attempts(a, )
130 }
131 #[no_mangle]
132 /// Utility method to constructs a new Timeout-variant Retry
133 pub extern "C" fn Retry_timeout(a: u64) -> Retry {
134         Retry::Timeout(a, )
135 }
136 /// Checks if two Retrys contain equal inner contents.
137 /// This ignores pointers and is_owned flags and looks at the values in fields.
138 #[no_mangle]
139 pub extern "C" fn Retry_eq(a: &Retry, b: &Retry) -> bool {
140         if &a.to_native() == &b.to_native() { true } else { false }
141 }
142 /// Generates a non-cryptographic 64-bit hash of the Retry.
143 #[no_mangle]
144 pub extern "C" fn Retry_hash(o: &Retry) -> u64 {
145         // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
146         #[allow(deprecated)]
147         let mut hasher = core::hash::SipHasher::new();
148         core::hash::Hash::hash(&o.to_native(), &mut hasher);
149         core::hash::Hasher::finish(&hasher)
150 }
151 #[no_mangle]
152 /// Serialize the Retry object into a byte array which can be read by Retry_read
153 pub extern "C" fn Retry_write(obj: &crate::lightning::ln::outbound_payment::Retry) -> crate::c_types::derived::CVec_u8Z {
154         crate::c_types::serialize_obj(&unsafe { &*obj }.to_native())
155 }
156 #[allow(unused)]
157 pub(crate) extern "C" fn Retry_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
158         Retry_write(unsafe { &*(obj as *const Retry) })
159 }
160 #[no_mangle]
161 /// Read a Retry from a byte array, created by Retry_write
162 pub extern "C" fn Retry_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_RetryDecodeErrorZ {
163         let res: Result<lightning::ln::outbound_payment::Retry, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
164         let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::outbound_payment::Retry::native_into(o) }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() };
165         local_res
166 }
167 /// Indicates an immediate error on [`ChannelManager::send_payment`]. Further errors may be
168 /// surfaced later via [`Event::PaymentPathFailed`] and [`Event::PaymentFailed`].
169 ///
170 /// [`ChannelManager::send_payment`]: crate::ln::channelmanager::ChannelManager::send_payment
171 /// [`Event::PaymentPathFailed`]: crate::events::Event::PaymentPathFailed
172 /// [`Event::PaymentFailed`]: crate::events::Event::PaymentFailed
173 #[derive(Clone)]
174 #[must_use]
175 #[repr(C)]
176 pub enum RetryableSendFailure {
177         /// The provided [`PaymentParameters::expiry_time`] indicated that the payment has expired. Note
178         /// that this error is *not* caused by [`Retry::Timeout`].
179         ///
180         /// [`PaymentParameters::expiry_time`]: crate::routing::router::PaymentParameters::expiry_time
181         PaymentExpired,
182         /// We were unable to find a route to the destination.
183         RouteNotFound,
184         /// Indicates that a payment for the provided [`PaymentId`] is already in-flight and has not
185         /// yet completed (i.e. generated an [`Event::PaymentSent`] or [`Event::PaymentFailed`]).
186         ///
187         /// [`PaymentId`]: crate::ln::channelmanager::PaymentId
188         /// [`Event::PaymentSent`]: crate::events::Event::PaymentSent
189         /// [`Event::PaymentFailed`]: crate::events::Event::PaymentFailed
190         DuplicatePayment,
191 }
192 use lightning::ln::outbound_payment::RetryableSendFailure as RetryableSendFailureImport;
193 pub(crate) type nativeRetryableSendFailure = RetryableSendFailureImport;
194
195 impl RetryableSendFailure {
196         #[allow(unused)]
197         pub(crate) fn to_native(&self) -> nativeRetryableSendFailure {
198                 match self {
199                         RetryableSendFailure::PaymentExpired => nativeRetryableSendFailure::PaymentExpired,
200                         RetryableSendFailure::RouteNotFound => nativeRetryableSendFailure::RouteNotFound,
201                         RetryableSendFailure::DuplicatePayment => nativeRetryableSendFailure::DuplicatePayment,
202                 }
203         }
204         #[allow(unused)]
205         pub(crate) fn into_native(self) -> nativeRetryableSendFailure {
206                 match self {
207                         RetryableSendFailure::PaymentExpired => nativeRetryableSendFailure::PaymentExpired,
208                         RetryableSendFailure::RouteNotFound => nativeRetryableSendFailure::RouteNotFound,
209                         RetryableSendFailure::DuplicatePayment => nativeRetryableSendFailure::DuplicatePayment,
210                 }
211         }
212         #[allow(unused)]
213         pub(crate) fn from_native(native: &nativeRetryableSendFailure) -> Self {
214                 match native {
215                         nativeRetryableSendFailure::PaymentExpired => RetryableSendFailure::PaymentExpired,
216                         nativeRetryableSendFailure::RouteNotFound => RetryableSendFailure::RouteNotFound,
217                         nativeRetryableSendFailure::DuplicatePayment => RetryableSendFailure::DuplicatePayment,
218                 }
219         }
220         #[allow(unused)]
221         pub(crate) fn native_into(native: nativeRetryableSendFailure) -> Self {
222                 match native {
223                         nativeRetryableSendFailure::PaymentExpired => RetryableSendFailure::PaymentExpired,
224                         nativeRetryableSendFailure::RouteNotFound => RetryableSendFailure::RouteNotFound,
225                         nativeRetryableSendFailure::DuplicatePayment => RetryableSendFailure::DuplicatePayment,
226                 }
227         }
228 }
229 /// Creates a copy of the RetryableSendFailure
230 #[no_mangle]
231 pub extern "C" fn RetryableSendFailure_clone(orig: &RetryableSendFailure) -> RetryableSendFailure {
232         orig.clone()
233 }
234 #[allow(unused)]
235 /// Used only if an object of this type is returned as a trait impl by a method
236 pub(crate) extern "C" fn RetryableSendFailure_clone_void(this_ptr: *const c_void) -> *mut c_void {
237         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const RetryableSendFailure)).clone() })) as *mut c_void
238 }
239 #[allow(unused)]
240 /// Used only if an object of this type is returned as a trait impl by a method
241 pub(crate) extern "C" fn RetryableSendFailure_free_void(this_ptr: *mut c_void) {
242         let _ = unsafe { Box::from_raw(this_ptr as *mut RetryableSendFailure) };
243 }
244 #[no_mangle]
245 /// Utility method to constructs a new PaymentExpired-variant RetryableSendFailure
246 pub extern "C" fn RetryableSendFailure_payment_expired() -> RetryableSendFailure {
247         RetryableSendFailure::PaymentExpired}
248 #[no_mangle]
249 /// Utility method to constructs a new RouteNotFound-variant RetryableSendFailure
250 pub extern "C" fn RetryableSendFailure_route_not_found() -> RetryableSendFailure {
251         RetryableSendFailure::RouteNotFound}
252 #[no_mangle]
253 /// Utility method to constructs a new DuplicatePayment-variant RetryableSendFailure
254 pub extern "C" fn RetryableSendFailure_duplicate_payment() -> RetryableSendFailure {
255         RetryableSendFailure::DuplicatePayment}
256 /// Checks if two RetryableSendFailures contain equal inner contents.
257 /// This ignores pointers and is_owned flags and looks at the values in fields.
258 #[no_mangle]
259 pub extern "C" fn RetryableSendFailure_eq(a: &RetryableSendFailure, b: &RetryableSendFailure) -> bool {
260         if &a.to_native() == &b.to_native() { true } else { false }
261 }
262 /// If a payment fails to send with [`ChannelManager::send_payment_with_route`], it can be in one
263 /// of several states. This enum is returned as the Err() type describing which state the payment
264 /// is in, see the description of individual enum states for more.
265 ///
266 /// [`ChannelManager::send_payment_with_route`]: crate::ln::channelmanager::ChannelManager::send_payment_with_route
267 #[derive(Clone)]
268 #[must_use]
269 #[repr(C)]
270 pub enum PaymentSendFailure {
271         /// A parameter which was passed to send_payment was invalid, preventing us from attempting to
272         /// send the payment at all.
273         ///
274         /// You can freely resend the payment in full (with the parameter error fixed).
275         ///
276         /// Because the payment failed outright, no payment tracking is done and no
277         /// [`Event::PaymentPathFailed`] or [`Event::PaymentFailed`] events will be generated.
278         ///
279         /// [`Event::PaymentPathFailed`]: crate::events::Event::PaymentPathFailed
280         /// [`Event::PaymentFailed`]: crate::events::Event::PaymentFailed
281         ParameterError(
282                 crate::lightning::util::errors::APIError),
283         /// A parameter in a single path which was passed to send_payment was invalid, preventing us
284         /// from attempting to send the payment at all.
285         ///
286         /// You can freely resend the payment in full (with the parameter error fixed).
287         ///
288         /// Because the payment failed outright, no payment tracking is done and no
289         /// [`Event::PaymentPathFailed`] or [`Event::PaymentFailed`] events will be generated.
290         ///
291         /// The results here are ordered the same as the paths in the route object which was passed to
292         /// send_payment.
293         ///
294         /// [`Event::PaymentPathFailed`]: crate::events::Event::PaymentPathFailed
295         /// [`Event::PaymentFailed`]: crate::events::Event::PaymentFailed
296         PathParameterError(
297                 crate::c_types::derived::CVec_CResult_NoneAPIErrorZZ),
298         /// All paths which were attempted failed to send, with no channel state change taking place.
299         /// You can freely resend the payment in full (though you probably want to do so over different
300         /// paths than the ones selected).
301         ///
302         /// Because the payment failed outright, no payment tracking is done and no
303         /// [`Event::PaymentPathFailed`] or [`Event::PaymentFailed`] events will be generated.
304         ///
305         /// [`Event::PaymentPathFailed`]: crate::events::Event::PaymentPathFailed
306         /// [`Event::PaymentFailed`]: crate::events::Event::PaymentFailed
307         AllFailedResendSafe(
308                 crate::c_types::derived::CVec_APIErrorZ),
309         /// Indicates that a payment for the provided [`PaymentId`] is already in-flight and has not
310         /// yet completed (i.e. generated an [`Event::PaymentSent`] or [`Event::PaymentFailed`]).
311         ///
312         /// [`PaymentId`]: crate::ln::channelmanager::PaymentId
313         /// [`Event::PaymentSent`]: crate::events::Event::PaymentSent
314         /// [`Event::PaymentFailed`]: crate::events::Event::PaymentFailed
315         DuplicatePayment,
316         /// Some paths that were attempted failed to send, though some paths may have succeeded. At least
317         /// some paths have irrevocably committed to the HTLC.
318         ///
319         /// The results here are ordered the same as the paths in the route object that was passed to
320         /// send_payment.
321         ///
322         /// Any entries that contain `Err(APIError::MonitorUpdateInprogress)` will send once a
323         /// [`MonitorEvent::Completed`] is provided for the next-hop channel with the latest update_id.
324         ///
325         /// [`MonitorEvent::Completed`]: crate::chain::channelmonitor::MonitorEvent::Completed
326         PartialFailure {
327                 /// The errors themselves, in the same order as the paths from the route.
328                 results: crate::c_types::derived::CVec_CResult_NoneAPIErrorZZ,
329                 /// If some paths failed without irrevocably committing to the new HTLC(s), this will
330                 /// contain a [`RouteParameters`] object for the failing paths.
331                 ///
332                 /// Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None
333                 failed_paths_retry: crate::lightning::routing::router::RouteParameters,
334                 /// The payment id for the payment, which is now at least partially pending.
335                 payment_id: crate::c_types::ThirtyTwoBytes,
336         },
337 }
338 use lightning::ln::outbound_payment::PaymentSendFailure as PaymentSendFailureImport;
339 pub(crate) type nativePaymentSendFailure = PaymentSendFailureImport;
340
341 impl PaymentSendFailure {
342         #[allow(unused)]
343         pub(crate) fn to_native(&self) -> nativePaymentSendFailure {
344                 match self {
345                         PaymentSendFailure::ParameterError (ref a, ) => {
346                                 let mut a_nonref = Clone::clone(a);
347                                 nativePaymentSendFailure::ParameterError (
348                                         a_nonref.into_native(),
349                                 )
350                         },
351                         PaymentSendFailure::PathParameterError (ref a, ) => {
352                                 let mut a_nonref = Clone::clone(a);
353                                 let mut local_a_nonref = Vec::new(); for mut item in a_nonref.into_rust().drain(..) { local_a_nonref.push( { let mut local_a_nonref_0 = match item.result_ok { true => Ok( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut item.contents.result)) })*/ }), false => Err( { (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut item.contents.err)) }).into_native() })}; local_a_nonref_0 }); };
354                                 nativePaymentSendFailure::PathParameterError (
355                                         local_a_nonref,
356                                 )
357                         },
358                         PaymentSendFailure::AllFailedResendSafe (ref a, ) => {
359                                 let mut a_nonref = Clone::clone(a);
360                                 let mut local_a_nonref = Vec::new(); for mut item in a_nonref.into_rust().drain(..) { local_a_nonref.push( { item.into_native() }); };
361                                 nativePaymentSendFailure::AllFailedResendSafe (
362                                         local_a_nonref,
363                                 )
364                         },
365                         PaymentSendFailure::DuplicatePayment => nativePaymentSendFailure::DuplicatePayment,
366                         PaymentSendFailure::PartialFailure {ref results, ref failed_paths_retry, ref payment_id, } => {
367                                 let mut results_nonref = Clone::clone(results);
368                                 let mut local_results_nonref = Vec::new(); for mut item in results_nonref.into_rust().drain(..) { local_results_nonref.push( { let mut local_results_nonref_0 = match item.result_ok { true => Ok( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut item.contents.result)) })*/ }), false => Err( { (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut item.contents.err)) }).into_native() })}; local_results_nonref_0 }); };
369                                 let mut failed_paths_retry_nonref = Clone::clone(failed_paths_retry);
370                                 let mut local_failed_paths_retry_nonref = if failed_paths_retry_nonref.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(failed_paths_retry_nonref.take_inner()) } }) };
371                                 let mut payment_id_nonref = Clone::clone(payment_id);
372                                 nativePaymentSendFailure::PartialFailure {
373                                         results: local_results_nonref,
374                                         failed_paths_retry: local_failed_paths_retry_nonref,
375                                         payment_id: ::lightning::ln::channelmanager::PaymentId(payment_id_nonref.data),
376                                 }
377                         },
378                 }
379         }
380         #[allow(unused)]
381         pub(crate) fn into_native(self) -> nativePaymentSendFailure {
382                 match self {
383                         PaymentSendFailure::ParameterError (mut a, ) => {
384                                 nativePaymentSendFailure::ParameterError (
385                                         a.into_native(),
386                                 )
387                         },
388                         PaymentSendFailure::PathParameterError (mut a, ) => {
389                                 let mut local_a = Vec::new(); for mut item in a.into_rust().drain(..) { local_a.push( { let mut local_a_0 = match item.result_ok { true => Ok( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut item.contents.result)) })*/ }), false => Err( { (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut item.contents.err)) }).into_native() })}; local_a_0 }); };
390                                 nativePaymentSendFailure::PathParameterError (
391                                         local_a,
392                                 )
393                         },
394                         PaymentSendFailure::AllFailedResendSafe (mut a, ) => {
395                                 let mut local_a = Vec::new(); for mut item in a.into_rust().drain(..) { local_a.push( { item.into_native() }); };
396                                 nativePaymentSendFailure::AllFailedResendSafe (
397                                         local_a,
398                                 )
399                         },
400                         PaymentSendFailure::DuplicatePayment => nativePaymentSendFailure::DuplicatePayment,
401                         PaymentSendFailure::PartialFailure {mut results, mut failed_paths_retry, mut payment_id, } => {
402                                 let mut local_results = Vec::new(); for mut item in results.into_rust().drain(..) { local_results.push( { let mut local_results_0 = match item.result_ok { true => Ok( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut item.contents.result)) })*/ }), false => Err( { (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut item.contents.err)) }).into_native() })}; local_results_0 }); };
403                                 let mut local_failed_paths_retry = if failed_paths_retry.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(failed_paths_retry.take_inner()) } }) };
404                                 nativePaymentSendFailure::PartialFailure {
405                                         results: local_results,
406                                         failed_paths_retry: local_failed_paths_retry,
407                                         payment_id: ::lightning::ln::channelmanager::PaymentId(payment_id.data),
408                                 }
409                         },
410                 }
411         }
412         #[allow(unused)]
413         pub(crate) fn from_native(native: &nativePaymentSendFailure) -> Self {
414                 match native {
415                         nativePaymentSendFailure::ParameterError (ref a, ) => {
416                                 let mut a_nonref = Clone::clone(a);
417                                 PaymentSendFailure::ParameterError (
418                                         crate::lightning::util::errors::APIError::native_into(a_nonref),
419                                 )
420                         },
421                         nativePaymentSendFailure::PathParameterError (ref a, ) => {
422                                 let mut a_nonref = Clone::clone(a);
423                                 let mut local_a_nonref = Vec::new(); for mut item in a_nonref.drain(..) { local_a_nonref.push( { let mut local_a_nonref_0 = match item { Ok(mut o) => crate::c_types::CResultTempl::ok( { () /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::util::errors::APIError::native_into(e) }).into() }; local_a_nonref_0 }); };
424                                 PaymentSendFailure::PathParameterError (
425                                         local_a_nonref.into(),
426                                 )
427                         },
428                         nativePaymentSendFailure::AllFailedResendSafe (ref a, ) => {
429                                 let mut a_nonref = Clone::clone(a);
430                                 let mut local_a_nonref = Vec::new(); for mut item in a_nonref.drain(..) { local_a_nonref.push( { crate::lightning::util::errors::APIError::native_into(item) }); };
431                                 PaymentSendFailure::AllFailedResendSafe (
432                                         local_a_nonref.into(),
433                                 )
434                         },
435                         nativePaymentSendFailure::DuplicatePayment => PaymentSendFailure::DuplicatePayment,
436                         nativePaymentSendFailure::PartialFailure {ref results, ref failed_paths_retry, ref payment_id, } => {
437                                 let mut results_nonref = Clone::clone(results);
438                                 let mut local_results_nonref = Vec::new(); for mut item in results_nonref.drain(..) { local_results_nonref.push( { let mut local_results_nonref_0 = match item { Ok(mut o) => crate::c_types::CResultTempl::ok( { () /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::util::errors::APIError::native_into(e) }).into() }; local_results_nonref_0 }); };
439                                 let mut failed_paths_retry_nonref = Clone::clone(failed_paths_retry);
440                                 let mut local_failed_paths_retry_nonref = crate::lightning::routing::router::RouteParameters { inner: if failed_paths_retry_nonref.is_none() { core::ptr::null_mut() } else {  { ObjOps::heap_alloc((failed_paths_retry_nonref.unwrap())) } }, is_owned: true };
441                                 let mut payment_id_nonref = Clone::clone(payment_id);
442                                 PaymentSendFailure::PartialFailure {
443                                         results: local_results_nonref.into(),
444                                         failed_paths_retry: local_failed_paths_retry_nonref,
445                                         payment_id: crate::c_types::ThirtyTwoBytes { data: payment_id_nonref.0 },
446                                 }
447                         },
448                 }
449         }
450         #[allow(unused)]
451         pub(crate) fn native_into(native: nativePaymentSendFailure) -> Self {
452                 match native {
453                         nativePaymentSendFailure::ParameterError (mut a, ) => {
454                                 PaymentSendFailure::ParameterError (
455                                         crate::lightning::util::errors::APIError::native_into(a),
456                                 )
457                         },
458                         nativePaymentSendFailure::PathParameterError (mut a, ) => {
459                                 let mut local_a = Vec::new(); for mut item in a.drain(..) { local_a.push( { let mut local_a_0 = match item { Ok(mut o) => crate::c_types::CResultTempl::ok( { () /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::util::errors::APIError::native_into(e) }).into() }; local_a_0 }); };
460                                 PaymentSendFailure::PathParameterError (
461                                         local_a.into(),
462                                 )
463                         },
464                         nativePaymentSendFailure::AllFailedResendSafe (mut a, ) => {
465                                 let mut local_a = Vec::new(); for mut item in a.drain(..) { local_a.push( { crate::lightning::util::errors::APIError::native_into(item) }); };
466                                 PaymentSendFailure::AllFailedResendSafe (
467                                         local_a.into(),
468                                 )
469                         },
470                         nativePaymentSendFailure::DuplicatePayment => PaymentSendFailure::DuplicatePayment,
471                         nativePaymentSendFailure::PartialFailure {mut results, mut failed_paths_retry, mut payment_id, } => {
472                                 let mut local_results = Vec::new(); for mut item in results.drain(..) { local_results.push( { let mut local_results_0 = match item { Ok(mut o) => crate::c_types::CResultTempl::ok( { () /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::util::errors::APIError::native_into(e) }).into() }; local_results_0 }); };
473                                 let mut local_failed_paths_retry = crate::lightning::routing::router::RouteParameters { inner: if failed_paths_retry.is_none() { core::ptr::null_mut() } else {  { ObjOps::heap_alloc((failed_paths_retry.unwrap())) } }, is_owned: true };
474                                 PaymentSendFailure::PartialFailure {
475                                         results: local_results.into(),
476                                         failed_paths_retry: local_failed_paths_retry,
477                                         payment_id: crate::c_types::ThirtyTwoBytes { data: payment_id.0 },
478                                 }
479                         },
480                 }
481         }
482 }
483 /// Frees any resources used by the PaymentSendFailure
484 #[no_mangle]
485 pub extern "C" fn PaymentSendFailure_free(this_ptr: PaymentSendFailure) { }
486 /// Creates a copy of the PaymentSendFailure
487 #[no_mangle]
488 pub extern "C" fn PaymentSendFailure_clone(orig: &PaymentSendFailure) -> PaymentSendFailure {
489         orig.clone()
490 }
491 #[allow(unused)]
492 /// Used only if an object of this type is returned as a trait impl by a method
493 pub(crate) extern "C" fn PaymentSendFailure_clone_void(this_ptr: *const c_void) -> *mut c_void {
494         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const PaymentSendFailure)).clone() })) as *mut c_void
495 }
496 #[allow(unused)]
497 /// Used only if an object of this type is returned as a trait impl by a method
498 pub(crate) extern "C" fn PaymentSendFailure_free_void(this_ptr: *mut c_void) {
499         let _ = unsafe { Box::from_raw(this_ptr as *mut PaymentSendFailure) };
500 }
501 #[no_mangle]
502 /// Utility method to constructs a new ParameterError-variant PaymentSendFailure
503 pub extern "C" fn PaymentSendFailure_parameter_error(a: crate::lightning::util::errors::APIError) -> PaymentSendFailure {
504         PaymentSendFailure::ParameterError(a, )
505 }
506 #[no_mangle]
507 /// Utility method to constructs a new PathParameterError-variant PaymentSendFailure
508 pub extern "C" fn PaymentSendFailure_path_parameter_error(a: crate::c_types::derived::CVec_CResult_NoneAPIErrorZZ) -> PaymentSendFailure {
509         PaymentSendFailure::PathParameterError(a, )
510 }
511 #[no_mangle]
512 /// Utility method to constructs a new AllFailedResendSafe-variant PaymentSendFailure
513 pub extern "C" fn PaymentSendFailure_all_failed_resend_safe(a: crate::c_types::derived::CVec_APIErrorZ) -> PaymentSendFailure {
514         PaymentSendFailure::AllFailedResendSafe(a, )
515 }
516 #[no_mangle]
517 /// Utility method to constructs a new DuplicatePayment-variant PaymentSendFailure
518 pub extern "C" fn PaymentSendFailure_duplicate_payment() -> PaymentSendFailure {
519         PaymentSendFailure::DuplicatePayment}
520 #[no_mangle]
521 /// Utility method to constructs a new PartialFailure-variant PaymentSendFailure
522 pub extern "C" fn PaymentSendFailure_partial_failure(results: crate::c_types::derived::CVec_CResult_NoneAPIErrorZZ, failed_paths_retry: crate::lightning::routing::router::RouteParameters, payment_id: crate::c_types::ThirtyTwoBytes) -> PaymentSendFailure {
523         PaymentSendFailure::PartialFailure {
524                 results,
525                 failed_paths_retry,
526                 payment_id,
527         }
528 }
529 /// Checks if two PaymentSendFailures contain equal inner contents.
530 /// This ignores pointers and is_owned flags and looks at the values in fields.
531 #[no_mangle]
532 pub extern "C" fn PaymentSendFailure_eq(a: &PaymentSendFailure, b: &PaymentSendFailure) -> bool {
533         if &a.to_native() == &b.to_native() { true } else { false }
534 }
535 /// Indicates that we failed to send a payment probe. Further errors may be surfaced later via
536 /// [`Event::ProbeFailed`].
537 ///
538 /// [`Event::ProbeFailed`]: crate::events::Event::ProbeFailed
539 #[derive(Clone)]
540 #[must_use]
541 #[repr(C)]
542 pub enum ProbeSendFailure {
543         /// We were unable to find a route to the destination.
544         RouteNotFound,
545         /// We failed to send the payment probes.
546         SendingFailed(
547                 crate::lightning::ln::outbound_payment::PaymentSendFailure),
548 }
549 use lightning::ln::outbound_payment::ProbeSendFailure as ProbeSendFailureImport;
550 pub(crate) type nativeProbeSendFailure = ProbeSendFailureImport;
551
552 impl ProbeSendFailure {
553         #[allow(unused)]
554         pub(crate) fn to_native(&self) -> nativeProbeSendFailure {
555                 match self {
556                         ProbeSendFailure::RouteNotFound => nativeProbeSendFailure::RouteNotFound,
557                         ProbeSendFailure::SendingFailed (ref a, ) => {
558                                 let mut a_nonref = Clone::clone(a);
559                                 nativeProbeSendFailure::SendingFailed (
560                                         a_nonref.into_native(),
561                                 )
562                         },
563                 }
564         }
565         #[allow(unused)]
566         pub(crate) fn into_native(self) -> nativeProbeSendFailure {
567                 match self {
568                         ProbeSendFailure::RouteNotFound => nativeProbeSendFailure::RouteNotFound,
569                         ProbeSendFailure::SendingFailed (mut a, ) => {
570                                 nativeProbeSendFailure::SendingFailed (
571                                         a.into_native(),
572                                 )
573                         },
574                 }
575         }
576         #[allow(unused)]
577         pub(crate) fn from_native(native: &nativeProbeSendFailure) -> Self {
578                 match native {
579                         nativeProbeSendFailure::RouteNotFound => ProbeSendFailure::RouteNotFound,
580                         nativeProbeSendFailure::SendingFailed (ref a, ) => {
581                                 let mut a_nonref = Clone::clone(a);
582                                 ProbeSendFailure::SendingFailed (
583                                         crate::lightning::ln::outbound_payment::PaymentSendFailure::native_into(a_nonref),
584                                 )
585                         },
586                 }
587         }
588         #[allow(unused)]
589         pub(crate) fn native_into(native: nativeProbeSendFailure) -> Self {
590                 match native {
591                         nativeProbeSendFailure::RouteNotFound => ProbeSendFailure::RouteNotFound,
592                         nativeProbeSendFailure::SendingFailed (mut a, ) => {
593                                 ProbeSendFailure::SendingFailed (
594                                         crate::lightning::ln::outbound_payment::PaymentSendFailure::native_into(a),
595                                 )
596                         },
597                 }
598         }
599 }
600 /// Frees any resources used by the ProbeSendFailure
601 #[no_mangle]
602 pub extern "C" fn ProbeSendFailure_free(this_ptr: ProbeSendFailure) { }
603 /// Creates a copy of the ProbeSendFailure
604 #[no_mangle]
605 pub extern "C" fn ProbeSendFailure_clone(orig: &ProbeSendFailure) -> ProbeSendFailure {
606         orig.clone()
607 }
608 #[allow(unused)]
609 /// Used only if an object of this type is returned as a trait impl by a method
610 pub(crate) extern "C" fn ProbeSendFailure_clone_void(this_ptr: *const c_void) -> *mut c_void {
611         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const ProbeSendFailure)).clone() })) as *mut c_void
612 }
613 #[allow(unused)]
614 /// Used only if an object of this type is returned as a trait impl by a method
615 pub(crate) extern "C" fn ProbeSendFailure_free_void(this_ptr: *mut c_void) {
616         let _ = unsafe { Box::from_raw(this_ptr as *mut ProbeSendFailure) };
617 }
618 #[no_mangle]
619 /// Utility method to constructs a new RouteNotFound-variant ProbeSendFailure
620 pub extern "C" fn ProbeSendFailure_route_not_found() -> ProbeSendFailure {
621         ProbeSendFailure::RouteNotFound}
622 #[no_mangle]
623 /// Utility method to constructs a new SendingFailed-variant ProbeSendFailure
624 pub extern "C" fn ProbeSendFailure_sending_failed(a: crate::lightning::ln::outbound_payment::PaymentSendFailure) -> ProbeSendFailure {
625         ProbeSendFailure::SendingFailed(a, )
626 }
627 /// Checks if two ProbeSendFailures contain equal inner contents.
628 /// This ignores pointers and is_owned flags and looks at the values in fields.
629 #[no_mangle]
630 pub extern "C" fn ProbeSendFailure_eq(a: &ProbeSendFailure, b: &ProbeSendFailure) -> bool {
631         if &a.to_native() == &b.to_native() { true } else { false }
632 }
633
634 use lightning::ln::outbound_payment::RecipientOnionFields as nativeRecipientOnionFieldsImport;
635 pub(crate) type nativeRecipientOnionFields = nativeRecipientOnionFieldsImport;
636
637 /// Information which is provided, encrypted, to the payment recipient when sending HTLCs.
638 ///
639 /// This should generally be constructed with data communicated to us from the recipient (via a
640 /// BOLT11 or BOLT12 invoice).
641 #[must_use]
642 #[repr(C)]
643 pub struct RecipientOnionFields {
644         /// A pointer to the opaque Rust object.
645
646         /// Nearly everywhere, inner must be non-null, however in places where
647         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
648         pub inner: *mut nativeRecipientOnionFields,
649         /// Indicates that this is the only struct which contains the same pointer.
650
651         /// Rust functions which take ownership of an object provided via an argument require
652         /// this to be true and invalidate the object pointed to by inner.
653         pub is_owned: bool,
654 }
655
656 impl Drop for RecipientOnionFields {
657         fn drop(&mut self) {
658                 if self.is_owned && !<*mut nativeRecipientOnionFields>::is_null(self.inner) {
659                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
660                 }
661         }
662 }
663 /// Frees any resources used by the RecipientOnionFields, if is_owned is set and inner is non-NULL.
664 #[no_mangle]
665 pub extern "C" fn RecipientOnionFields_free(this_obj: RecipientOnionFields) { }
666 #[allow(unused)]
667 /// Used only if an object of this type is returned as a trait impl by a method
668 pub(crate) extern "C" fn RecipientOnionFields_free_void(this_ptr: *mut c_void) {
669         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeRecipientOnionFields) };
670 }
671 #[allow(unused)]
672 impl RecipientOnionFields {
673         pub(crate) fn get_native_ref(&self) -> &'static nativeRecipientOnionFields {
674                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
675         }
676         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeRecipientOnionFields {
677                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
678         }
679         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
680         pub(crate) fn take_inner(mut self) -> *mut nativeRecipientOnionFields {
681                 assert!(self.is_owned);
682                 let ret = ObjOps::untweak_ptr(self.inner);
683                 self.inner = core::ptr::null_mut();
684                 ret
685         }
686 }
687 /// The [`PaymentSecret`] is an arbitrary 32 bytes provided by the recipient for us to repeat
688 /// in the onion. It is unrelated to `payment_hash` (or [`PaymentPreimage`]) and exists to
689 /// authenticate the sender to the recipient and prevent payment-probing (deanonymization)
690 /// attacks.
691 ///
692 /// If you do not have one, the [`Route`] you pay over must not contain multiple paths as
693 /// multi-path payments require a recipient-provided secret.
694 ///
695 /// Some implementations may reject spontaneous payments with payment secrets, so you may only
696 /// want to provide a secret for a spontaneous payment if MPP is needed and you know your
697 /// recipient will not reject it.
698 #[no_mangle]
699 pub extern "C" fn RecipientOnionFields_get_payment_secret(this_ptr: &RecipientOnionFields) -> crate::c_types::derived::COption_ThirtyTwoBytesZ {
700         let mut inner_val = &mut this_ptr.get_native_mut_ref().payment_secret;
701         let mut local_inner_val = if inner_val.is_none() { crate::c_types::derived::COption_ThirtyTwoBytesZ::None } else { crate::c_types::derived::COption_ThirtyTwoBytesZ::Some(/* WARNING: CLONING CONVERSION HERE! &Option<Enum> is otherwise un-expressable. */ { crate::c_types::ThirtyTwoBytes { data: (*inner_val.as_ref().unwrap()).clone().0 } }) };
702         local_inner_val
703 }
704 /// The [`PaymentSecret`] is an arbitrary 32 bytes provided by the recipient for us to repeat
705 /// in the onion. It is unrelated to `payment_hash` (or [`PaymentPreimage`]) and exists to
706 /// authenticate the sender to the recipient and prevent payment-probing (deanonymization)
707 /// attacks.
708 ///
709 /// If you do not have one, the [`Route`] you pay over must not contain multiple paths as
710 /// multi-path payments require a recipient-provided secret.
711 ///
712 /// Some implementations may reject spontaneous payments with payment secrets, so you may only
713 /// want to provide a secret for a spontaneous payment if MPP is needed and you know your
714 /// recipient will not reject it.
715 #[no_mangle]
716 pub extern "C" fn RecipientOnionFields_set_payment_secret(this_ptr: &mut RecipientOnionFields, mut val: crate::c_types::derived::COption_ThirtyTwoBytesZ) {
717         let mut local_val = { /*val*/ let val_opt = val; if val_opt.is_none() { None } else { Some({ { ::lightning::ln::PaymentSecret({ val_opt.take() }.data) }})} };
718         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.payment_secret = local_val;
719 }
720 /// The payment metadata serves a similar purpose as [`Self::payment_secret`] but is of
721 /// arbitrary length. This gives recipients substantially more flexibility to receive
722 /// additional data.
723 ///
724 /// In LDK, while the [`Self::payment_secret`] is fixed based on an internal authentication
725 /// scheme to authenticate received payments against expected payments and invoices, this field
726 /// is not used in LDK for received payments, and can be used to store arbitrary data in
727 /// invoices which will be received with the payment.
728 ///
729 /// Note that this field was added to the lightning specification more recently than
730 /// [`Self::payment_secret`] and while nearly all lightning senders support secrets, metadata
731 /// may not be supported as universally.
732 ///
733 /// Returns a copy of the field.
734 #[no_mangle]
735 pub extern "C" fn RecipientOnionFields_get_payment_metadata(this_ptr: &RecipientOnionFields) -> crate::c_types::derived::COption_CVec_u8ZZ {
736         let mut inner_val = this_ptr.get_native_mut_ref().payment_metadata.clone();
737         let mut local_inner_val = if inner_val.is_none() { crate::c_types::derived::COption_CVec_u8ZZ::None } else { crate::c_types::derived::COption_CVec_u8ZZ::Some( { let mut local_inner_val_0 = Vec::new(); for mut item in inner_val.unwrap().drain(..) { local_inner_val_0.push( { item }); }; local_inner_val_0.into() }) };
738         local_inner_val
739 }
740 /// The payment metadata serves a similar purpose as [`Self::payment_secret`] but is of
741 /// arbitrary length. This gives recipients substantially more flexibility to receive
742 /// additional data.
743 ///
744 /// In LDK, while the [`Self::payment_secret`] is fixed based on an internal authentication
745 /// scheme to authenticate received payments against expected payments and invoices, this field
746 /// is not used in LDK for received payments, and can be used to store arbitrary data in
747 /// invoices which will be received with the payment.
748 ///
749 /// Note that this field was added to the lightning specification more recently than
750 /// [`Self::payment_secret`] and while nearly all lightning senders support secrets, metadata
751 /// may not be supported as universally.
752 #[no_mangle]
753 pub extern "C" fn RecipientOnionFields_set_payment_metadata(this_ptr: &mut RecipientOnionFields, mut val: crate::c_types::derived::COption_CVec_u8ZZ) {
754         let mut local_val = { /*val*/ let val_opt = val; if val_opt.is_none() { None } else { Some({ { let mut local_val_0 = Vec::new(); for mut item in { val_opt.take() }.into_rust().drain(..) { local_val_0.push( { item }); }; local_val_0 }})} };
755         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.payment_metadata = local_val;
756 }
757 impl Clone for RecipientOnionFields {
758         fn clone(&self) -> Self {
759                 Self {
760                         inner: if <*mut nativeRecipientOnionFields>::is_null(self.inner) { core::ptr::null_mut() } else {
761                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
762                         is_owned: true,
763                 }
764         }
765 }
766 #[allow(unused)]
767 /// Used only if an object of this type is returned as a trait impl by a method
768 pub(crate) extern "C" fn RecipientOnionFields_clone_void(this_ptr: *const c_void) -> *mut c_void {
769         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeRecipientOnionFields)).clone() })) as *mut c_void
770 }
771 #[no_mangle]
772 /// Creates a copy of the RecipientOnionFields
773 pub extern "C" fn RecipientOnionFields_clone(orig: &RecipientOnionFields) -> RecipientOnionFields {
774         orig.clone()
775 }
776 /// Checks if two RecipientOnionFieldss contain equal inner contents.
777 /// This ignores pointers and is_owned flags and looks at the values in fields.
778 /// Two objects with NULL inner values will be considered "equal" here.
779 #[no_mangle]
780 pub extern "C" fn RecipientOnionFields_eq(a: &RecipientOnionFields, b: &RecipientOnionFields) -> bool {
781         if a.inner == b.inner { return true; }
782         if a.inner.is_null() || b.inner.is_null() { return false; }
783         if a.get_native_ref() == b.get_native_ref() { true } else { false }
784 }
785 #[no_mangle]
786 /// Serialize the RecipientOnionFields object into a byte array which can be read by RecipientOnionFields_read
787 pub extern "C" fn RecipientOnionFields_write(obj: &crate::lightning::ln::outbound_payment::RecipientOnionFields) -> crate::c_types::derived::CVec_u8Z {
788         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
789 }
790 #[allow(unused)]
791 pub(crate) extern "C" fn RecipientOnionFields_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
792         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeRecipientOnionFields) })
793 }
794 #[no_mangle]
795 /// Read a RecipientOnionFields from a byte array, created by RecipientOnionFields_write
796 pub extern "C" fn RecipientOnionFields_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_RecipientOnionFieldsDecodeErrorZ {
797         let res: Result<lightning::ln::outbound_payment::RecipientOnionFields, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
798         let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::outbound_payment::RecipientOnionFields { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() };
799         local_res
800 }
801 /// Creates a [`RecipientOnionFields`] from only a [`PaymentSecret`]. This is the most common
802 /// set of onion fields for today's BOLT11 invoices - most nodes require a [`PaymentSecret`]
803 /// but do not require or provide any further data.
804 #[must_use]
805 #[no_mangle]
806 pub extern "C" fn RecipientOnionFields_secret_only(mut payment_secret: crate::c_types::ThirtyTwoBytes) -> crate::lightning::ln::outbound_payment::RecipientOnionFields {
807         let mut ret = lightning::ln::outbound_payment::RecipientOnionFields::secret_only(::lightning::ln::PaymentSecret(payment_secret.data));
808         crate::lightning::ln::outbound_payment::RecipientOnionFields { inner: ObjOps::heap_alloc(ret), is_owned: true }
809 }
810
811 /// Creates a new [`RecipientOnionFields`] with no fields. This generally does not create
812 /// payable HTLCs except for single-path spontaneous payments, i.e. this should generally
813 /// only be used for calls to [`ChannelManager::send_spontaneous_payment`]. If you are sending
814 /// a spontaneous MPP this will not work as all MPP require payment secrets; you may
815 /// instead want to use [`RecipientOnionFields::secret_only`].
816 ///
817 /// [`ChannelManager::send_spontaneous_payment`]: super::channelmanager::ChannelManager::send_spontaneous_payment
818 /// [`RecipientOnionFields::secret_only`]: RecipientOnionFields::secret_only
819 #[must_use]
820 #[no_mangle]
821 pub extern "C" fn RecipientOnionFields_spontaneous_empty() -> crate::lightning::ln::outbound_payment::RecipientOnionFields {
822         let mut ret = lightning::ln::outbound_payment::RecipientOnionFields::spontaneous_empty();
823         crate::lightning::ln::outbound_payment::RecipientOnionFields { inner: ObjOps::heap_alloc(ret), is_owned: true }
824 }
825
826 /// Creates a new [`RecipientOnionFields`] from an existing one, adding custom TLVs. Each
827 /// TLV is provided as a `(u64, Vec<u8>)` for the type number and serialized value
828 /// respectively. TLV type numbers must be unique and within the range
829 /// reserved for custom types, i.e. >= 2^16, otherwise this method will return `Err(())`.
830 ///
831 /// This method will also error for types in the experimental range which have been
832 /// standardized within the protocol, which only includes 5482373484 (keysend) for now.
833 ///
834 /// See [`Self::custom_tlvs`] for more info.
835 #[must_use]
836 #[no_mangle]
837 pub extern "C" fn RecipientOnionFields_with_custom_tlvs(mut this_arg: crate::lightning::ln::outbound_payment::RecipientOnionFields, mut custom_tlvs: crate::c_types::derived::CVec_C2Tuple_u64CVec_u8ZZZ) -> crate::c_types::derived::CResult_RecipientOnionFieldsNoneZ {
838         let mut local_custom_tlvs = Vec::new(); for mut item in custom_tlvs.into_rust().drain(..) { local_custom_tlvs.push( { let (mut orig_custom_tlvs_0_0, mut orig_custom_tlvs_0_1) = item.to_rust(); let mut local_orig_custom_tlvs_0_1 = Vec::new(); for mut item in orig_custom_tlvs_0_1.into_rust().drain(..) { local_orig_custom_tlvs_0_1.push( { item }); }; let mut local_custom_tlvs_0 = (orig_custom_tlvs_0_0, local_orig_custom_tlvs_0_1); local_custom_tlvs_0 }); };
839         let mut ret = (*unsafe { Box::from_raw(this_arg.take_inner()) }).with_custom_tlvs(local_custom_tlvs);
840         let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::outbound_payment::RecipientOnionFields { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() };
841         local_ret
842 }
843
844 /// Gets the custom TLVs that will be sent or have been received.
845 ///
846 /// Custom TLVs allow sending extra application-specific data with a payment. They provide
847 /// additional flexibility on top of payment metadata, as while other implementations may
848 /// require `payment_metadata` to reflect metadata provided in an invoice, custom TLVs
849 /// do not have this restriction.
850 ///
851 /// Note that if this field is non-empty, it will contain strictly increasing TLVs, each
852 /// represented by a `(u64, Vec<u8>)` for its type number and serialized value respectively.
853 /// This is validated when setting this field using [`Self::with_custom_tlvs`].
854 #[must_use]
855 #[no_mangle]
856 pub extern "C" fn RecipientOnionFields_custom_tlvs(this_arg: &crate::lightning::ln::outbound_payment::RecipientOnionFields) -> crate::c_types::derived::CVec_C2Tuple_u64CVec_u8ZZZ {
857         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.custom_tlvs();
858         let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { let (mut orig_ret_0_0, mut orig_ret_0_1) = item; let mut local_orig_ret_0_1 = Vec::new(); for mut item in orig_ret_0_1.drain(..) { local_orig_ret_0_1.push( { item }); }; let mut local_ret_0 = (orig_ret_0_0, local_orig_ret_0_1.into()).into(); local_ret_0 }); };
859         local_ret.into()
860 }
861