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