0891447b5f733a274ab3387e7657ae7c8ba4e0ec
[ldk-c-bindings] / lightning-c-bindings / src / lightning_invoice / mod.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 //! This crate provides data structures to represent
10 //! [lightning BOLT11](https://github.com/lightningnetwork/lightning-rfc/blob/master/11-payment-encoding.md)
11 //! invoices and functions to create, encode and decode these. If you just want to use the standard
12 //! en-/decoding functionality this should get you started:
13 //!
14 //!   * For parsing use `str::parse::<Invoice>(&self)` (see the docs of `impl FromStr for Invoice`)
15 //!   * For constructing invoices use the `InvoiceBuilder`
16 //!   * For serializing invoices use the `Display`/`ToString` traits
17
18 use std::str::FromStr;
19 use std::ffi::c_void;
20 use bitcoin::hashes::Hash;
21 use crate::c_types::*;
22
23 pub mod utils;
24 pub mod constants;
25 mod de {
26
27 use std::str::FromStr;
28 use std::ffi::c_void;
29 use bitcoin::hashes::Hash;
30 use crate::c_types::*;
31
32 mod hrp_sm {
33
34 use std::str::FromStr;
35 use std::ffi::c_void;
36 use bitcoin::hashes::Hash;
37 use crate::c_types::*;
38
39 }
40 #[no_mangle]
41 /// Read a SiPrefix object from a string
42 pub extern "C" fn SiPrefix_from_str(s: crate::c_types::Str) -> crate::c_types::derived::CResult_SiPrefixNoneZ {
43         match lightning_invoice::SiPrefix::from_str(s.into_str()) {
44                 Ok(r) => {
45                         crate::c_types::CResultTempl::ok(
46                                 crate::lightning_invoice::SiPrefix::native_into(r)
47                         )
48                 },
49                 Err(e) => crate::c_types::CResultTempl::err(()),
50         }.into()
51 }
52 #[no_mangle]
53 /// Read a Invoice object from a string
54 pub extern "C" fn Invoice_from_str(s: crate::c_types::Str) -> crate::c_types::derived::CResult_InvoiceNoneZ {
55         match lightning_invoice::Invoice::from_str(s.into_str()) {
56                 Ok(r) => {
57                         crate::c_types::CResultTempl::ok(
58                                 crate::lightning_invoice::Invoice { inner: Box::into_raw(Box::new(r)), is_owned: true }
59                         )
60                 },
61                 Err(e) => crate::c_types::CResultTempl::err(()),
62         }.into()
63 }
64 #[no_mangle]
65 /// Read a SignedRawInvoice object from a string
66 pub extern "C" fn SignedRawInvoice_from_str(s: crate::c_types::Str) -> crate::c_types::derived::CResult_SignedRawInvoiceNoneZ {
67         match lightning_invoice::SignedRawInvoice::from_str(s.into_str()) {
68                 Ok(r) => {
69                         crate::c_types::CResultTempl::ok(
70                                 crate::lightning_invoice::SignedRawInvoice { inner: Box::into_raw(Box::new(r)), is_owned: true }
71                         )
72                 },
73                 Err(e) => crate::c_types::CResultTempl::err(()),
74         }.into()
75 }
76 }
77 mod ser {
78
79 use std::str::FromStr;
80 use std::ffi::c_void;
81 use bitcoin::hashes::Hash;
82 use crate::c_types::*;
83
84 #[no_mangle]
85 /// Get the string representation of a Invoice object
86 pub extern "C" fn Invoice_to_str(o: &crate::lightning_invoice::Invoice) -> Str {
87         format!("{}", unsafe { &*o.inner }).into()
88 }
89 #[no_mangle]
90 /// Get the string representation of a SignedRawInvoice object
91 pub extern "C" fn SignedRawInvoice_to_str(o: &crate::lightning_invoice::SignedRawInvoice) -> Str {
92         format!("{}", unsafe { &*o.inner }).into()
93 }
94 #[no_mangle]
95 /// Get the string representation of a Currency object
96 pub extern "C" fn Currency_to_str(o: &crate::lightning_invoice::Currency) -> Str {
97         format!("{}", &o.to_native()).into()
98 }
99 #[no_mangle]
100 /// Get the string representation of a SiPrefix object
101 pub extern "C" fn SiPrefix_to_str(o: &crate::lightning_invoice::SiPrefix) -> Str {
102         format!("{}", &o.to_native()).into()
103 }
104 }
105 mod tb {
106
107 use std::str::FromStr;
108 use std::ffi::c_void;
109 use bitcoin::hashes::Hash;
110 use crate::c_types::*;
111
112 }
113 /// Default expiry time as defined by [BOLT 11].
114 ///
115 /// [BOLT 11]: https://github.com/lightningnetwork/lightning-rfc/blob/master/11-payment-encoding.md
116
117 #[no_mangle]
118 pub static DEFAULT_EXPIRY_TIME: u64 = lightning_invoice::DEFAULT_EXPIRY_TIME;
119 /// Default minimum final CLTV expiry as defined by [BOLT 11].
120 ///
121 /// Note that this is *not* the same value as rust-lightning's minimum CLTV expiry, which is
122 /// provided in [`MIN_FINAL_CLTV_EXPIRY`].
123 ///
124 /// [BOLT 11]: https://github.com/lightningnetwork/lightning-rfc/blob/master/11-payment-encoding.md
125 /// [`MIN_FINAL_CLTV_EXPIRY`]: lightning::ln::channelmanager::MIN_FINAL_CLTV_EXPIRY
126
127 #[no_mangle]
128 pub static DEFAULT_MIN_FINAL_CLTV_EXPIRY: u64 = lightning_invoice::DEFAULT_MIN_FINAL_CLTV_EXPIRY;
129 /// **Call this function on startup to ensure that all assumptions about the platform are valid.**
130 ///
131 /// Unfortunately we have to make assumptions about the upper bounds of the `SystemTime` type on
132 /// your platform which we can't fully verify at compile time and which isn't part of it's contract.
133 /// To our best knowledge our assumptions hold for all platforms officially supported by rust, but
134 /// since this check is fast we recommend to do it anyway.
135 ///
136 /// If this function fails this is considered a bug. Please open an issue describing your
137 /// platform and stating your current system time.
138 ///
139 /// # Panics
140 /// If the check fails this function panics. By calling this function on startup you ensure that
141 /// this wont happen at an arbitrary later point in time.
142 #[no_mangle]
143 pub extern "C" fn check_platform() {
144         lightning_invoice::check_platform()
145 }
146
147
148 use lightning_invoice::Invoice as nativeInvoiceImport;
149 type nativeInvoice = nativeInvoiceImport;
150
151 /// Represents a syntactically and semantically correct lightning BOLT11 invoice.
152 ///
153 /// There are three ways to construct an `Invoice`:
154 ///  1. using `InvoiceBuilder`
155 ///  2. using `Invoice::from_signed(SignedRawInvoice)`
156 ///  3. using `str::parse::<Invoice>(&str)`
157 #[must_use]
158 #[repr(C)]
159 pub struct Invoice {
160         /// A pointer to the opaque Rust object.
161
162         /// Nearly everywhere, inner must be non-null, however in places where
163         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
164         pub inner: *mut nativeInvoice,
165         /// Indicates that this is the only struct which contains the same pointer.
166
167         /// Rust functions which take ownership of an object provided via an argument require
168         /// this to be true and invalidate the object pointed to by inner.
169         pub is_owned: bool,
170 }
171
172 impl Drop for Invoice {
173         fn drop(&mut self) {
174                 if self.is_owned && !<*mut nativeInvoice>::is_null(self.inner) {
175                         let _ = unsafe { Box::from_raw(self.inner) };
176                 }
177         }
178 }
179 /// Frees any resources used by the Invoice, if is_owned is set and inner is non-NULL.
180 #[no_mangle]
181 pub extern "C" fn Invoice_free(this_obj: Invoice) { }
182 #[allow(unused)]
183 /// Used only if an object of this type is returned as a trait impl by a method
184 extern "C" fn Invoice_free_void(this_ptr: *mut c_void) {
185         unsafe { let _ = Box::from_raw(this_ptr as *mut nativeInvoice); }
186 }
187 #[allow(unused)]
188 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
189 impl Invoice {
190         pub(crate) fn take_inner(mut self) -> *mut nativeInvoice {
191                 assert!(self.is_owned);
192                 let ret = self.inner;
193                 self.inner = std::ptr::null_mut();
194                 ret
195         }
196 }
197 /// Checks if two Invoices contain equal inner contents.
198 /// This ignores pointers and is_owned flags and looks at the values in fields.
199 /// Two objects with NULL inner values will be considered "equal" here.
200 #[no_mangle]
201 pub extern "C" fn Invoice_eq(a: &Invoice, b: &Invoice) -> bool {
202         if a.inner == b.inner { return true; }
203         if a.inner.is_null() || b.inner.is_null() { return false; }
204         if unsafe { &*a.inner } == unsafe { &*b.inner } { true } else { false }
205 }
206 impl Clone for Invoice {
207         fn clone(&self) -> Self {
208                 Self {
209                         inner: if <*mut nativeInvoice>::is_null(self.inner) { std::ptr::null_mut() } else {
210                                 Box::into_raw(Box::new(unsafe { &*self.inner }.clone())) },
211                         is_owned: true,
212                 }
213         }
214 }
215 #[allow(unused)]
216 /// Used only if an object of this type is returned as a trait impl by a method
217 pub(crate) extern "C" fn Invoice_clone_void(this_ptr: *const c_void) -> *mut c_void {
218         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeInvoice)).clone() })) as *mut c_void
219 }
220 #[no_mangle]
221 /// Creates a copy of the Invoice
222 pub extern "C" fn Invoice_clone(orig: &Invoice) -> Invoice {
223         orig.clone()
224 }
225
226 use lightning_invoice::SignedRawInvoice as nativeSignedRawInvoiceImport;
227 type nativeSignedRawInvoice = nativeSignedRawInvoiceImport;
228
229 /// Represents a signed `RawInvoice` with cached hash. The signature is not checked and may be
230 /// invalid.
231 ///
232 /// # Invariants
233 /// The hash has to be either from the deserialized invoice or from the serialized `raw_invoice`.
234 #[must_use]
235 #[repr(C)]
236 pub struct SignedRawInvoice {
237         /// A pointer to the opaque Rust object.
238
239         /// Nearly everywhere, inner must be non-null, however in places where
240         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
241         pub inner: *mut nativeSignedRawInvoice,
242         /// Indicates that this is the only struct which contains the same pointer.
243
244         /// Rust functions which take ownership of an object provided via an argument require
245         /// this to be true and invalidate the object pointed to by inner.
246         pub is_owned: bool,
247 }
248
249 impl Drop for SignedRawInvoice {
250         fn drop(&mut self) {
251                 if self.is_owned && !<*mut nativeSignedRawInvoice>::is_null(self.inner) {
252                         let _ = unsafe { Box::from_raw(self.inner) };
253                 }
254         }
255 }
256 /// Frees any resources used by the SignedRawInvoice, if is_owned is set and inner is non-NULL.
257 #[no_mangle]
258 pub extern "C" fn SignedRawInvoice_free(this_obj: SignedRawInvoice) { }
259 #[allow(unused)]
260 /// Used only if an object of this type is returned as a trait impl by a method
261 extern "C" fn SignedRawInvoice_free_void(this_ptr: *mut c_void) {
262         unsafe { let _ = Box::from_raw(this_ptr as *mut nativeSignedRawInvoice); }
263 }
264 #[allow(unused)]
265 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
266 impl SignedRawInvoice {
267         pub(crate) fn take_inner(mut self) -> *mut nativeSignedRawInvoice {
268                 assert!(self.is_owned);
269                 let ret = self.inner;
270                 self.inner = std::ptr::null_mut();
271                 ret
272         }
273 }
274 /// Checks if two SignedRawInvoices contain equal inner contents.
275 /// This ignores pointers and is_owned flags and looks at the values in fields.
276 /// Two objects with NULL inner values will be considered "equal" here.
277 #[no_mangle]
278 pub extern "C" fn SignedRawInvoice_eq(a: &SignedRawInvoice, b: &SignedRawInvoice) -> bool {
279         if a.inner == b.inner { return true; }
280         if a.inner.is_null() || b.inner.is_null() { return false; }
281         if unsafe { &*a.inner } == unsafe { &*b.inner } { true } else { false }
282 }
283 impl Clone for SignedRawInvoice {
284         fn clone(&self) -> Self {
285                 Self {
286                         inner: if <*mut nativeSignedRawInvoice>::is_null(self.inner) { std::ptr::null_mut() } else {
287                                 Box::into_raw(Box::new(unsafe { &*self.inner }.clone())) },
288                         is_owned: true,
289                 }
290         }
291 }
292 #[allow(unused)]
293 /// Used only if an object of this type is returned as a trait impl by a method
294 pub(crate) extern "C" fn SignedRawInvoice_clone_void(this_ptr: *const c_void) -> *mut c_void {
295         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeSignedRawInvoice)).clone() })) as *mut c_void
296 }
297 #[no_mangle]
298 /// Creates a copy of the SignedRawInvoice
299 pub extern "C" fn SignedRawInvoice_clone(orig: &SignedRawInvoice) -> SignedRawInvoice {
300         orig.clone()
301 }
302
303 use lightning_invoice::RawInvoice as nativeRawInvoiceImport;
304 type nativeRawInvoice = nativeRawInvoiceImport;
305
306 /// Represents an syntactically correct Invoice for a payment on the lightning network,
307 /// but without the signature information.
308 /// De- and encoding should not lead to information loss but may lead to different hashes.
309 ///
310 /// For methods without docs see the corresponding methods in `Invoice`.
311 #[must_use]
312 #[repr(C)]
313 pub struct RawInvoice {
314         /// A pointer to the opaque Rust object.
315
316         /// Nearly everywhere, inner must be non-null, however in places where
317         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
318         pub inner: *mut nativeRawInvoice,
319         /// Indicates that this is the only struct which contains the same pointer.
320
321         /// Rust functions which take ownership of an object provided via an argument require
322         /// this to be true and invalidate the object pointed to by inner.
323         pub is_owned: bool,
324 }
325
326 impl Drop for RawInvoice {
327         fn drop(&mut self) {
328                 if self.is_owned && !<*mut nativeRawInvoice>::is_null(self.inner) {
329                         let _ = unsafe { Box::from_raw(self.inner) };
330                 }
331         }
332 }
333 /// Frees any resources used by the RawInvoice, if is_owned is set and inner is non-NULL.
334 #[no_mangle]
335 pub extern "C" fn RawInvoice_free(this_obj: RawInvoice) { }
336 #[allow(unused)]
337 /// Used only if an object of this type is returned as a trait impl by a method
338 extern "C" fn RawInvoice_free_void(this_ptr: *mut c_void) {
339         unsafe { let _ = Box::from_raw(this_ptr as *mut nativeRawInvoice); }
340 }
341 #[allow(unused)]
342 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
343 impl RawInvoice {
344         pub(crate) fn take_inner(mut self) -> *mut nativeRawInvoice {
345                 assert!(self.is_owned);
346                 let ret = self.inner;
347                 self.inner = std::ptr::null_mut();
348                 ret
349         }
350 }
351 /// data part
352 #[no_mangle]
353 pub extern "C" fn RawInvoice_get_data(this_ptr: &RawInvoice) -> crate::lightning_invoice::RawDataPart {
354         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.data;
355         crate::lightning_invoice::RawDataPart { inner: unsafe { ( (&(*inner_val) as *const _) as *mut _) }, is_owned: false }
356 }
357 /// data part
358 #[no_mangle]
359 pub extern "C" fn RawInvoice_set_data(this_ptr: &mut RawInvoice, mut val: crate::lightning_invoice::RawDataPart) {
360         unsafe { &mut *this_ptr.inner }.data = *unsafe { Box::from_raw(val.take_inner()) };
361 }
362 /// Checks if two RawInvoices contain equal inner contents.
363 /// This ignores pointers and is_owned flags and looks at the values in fields.
364 /// Two objects with NULL inner values will be considered "equal" here.
365 #[no_mangle]
366 pub extern "C" fn RawInvoice_eq(a: &RawInvoice, b: &RawInvoice) -> bool {
367         if a.inner == b.inner { return true; }
368         if a.inner.is_null() || b.inner.is_null() { return false; }
369         if unsafe { &*a.inner } == unsafe { &*b.inner } { true } else { false }
370 }
371 impl Clone for RawInvoice {
372         fn clone(&self) -> Self {
373                 Self {
374                         inner: if <*mut nativeRawInvoice>::is_null(self.inner) { std::ptr::null_mut() } else {
375                                 Box::into_raw(Box::new(unsafe { &*self.inner }.clone())) },
376                         is_owned: true,
377                 }
378         }
379 }
380 #[allow(unused)]
381 /// Used only if an object of this type is returned as a trait impl by a method
382 pub(crate) extern "C" fn RawInvoice_clone_void(this_ptr: *const c_void) -> *mut c_void {
383         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeRawInvoice)).clone() })) as *mut c_void
384 }
385 #[no_mangle]
386 /// Creates a copy of the RawInvoice
387 pub extern "C" fn RawInvoice_clone(orig: &RawInvoice) -> RawInvoice {
388         orig.clone()
389 }
390
391 use lightning_invoice::RawDataPart as nativeRawDataPartImport;
392 type nativeRawDataPart = nativeRawDataPartImport;
393
394 /// Data of the `RawInvoice` that is encoded in the data part
395 #[must_use]
396 #[repr(C)]
397 pub struct RawDataPart {
398         /// A pointer to the opaque Rust object.
399
400         /// Nearly everywhere, inner must be non-null, however in places where
401         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
402         pub inner: *mut nativeRawDataPart,
403         /// Indicates that this is the only struct which contains the same pointer.
404
405         /// Rust functions which take ownership of an object provided via an argument require
406         /// this to be true and invalidate the object pointed to by inner.
407         pub is_owned: bool,
408 }
409
410 impl Drop for RawDataPart {
411         fn drop(&mut self) {
412                 if self.is_owned && !<*mut nativeRawDataPart>::is_null(self.inner) {
413                         let _ = unsafe { Box::from_raw(self.inner) };
414                 }
415         }
416 }
417 /// Frees any resources used by the RawDataPart, if is_owned is set and inner is non-NULL.
418 #[no_mangle]
419 pub extern "C" fn RawDataPart_free(this_obj: RawDataPart) { }
420 #[allow(unused)]
421 /// Used only if an object of this type is returned as a trait impl by a method
422 extern "C" fn RawDataPart_free_void(this_ptr: *mut c_void) {
423         unsafe { let _ = Box::from_raw(this_ptr as *mut nativeRawDataPart); }
424 }
425 #[allow(unused)]
426 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
427 impl RawDataPart {
428         pub(crate) fn take_inner(mut self) -> *mut nativeRawDataPart {
429                 assert!(self.is_owned);
430                 let ret = self.inner;
431                 self.inner = std::ptr::null_mut();
432                 ret
433         }
434 }
435 /// generation time of the invoice
436 #[no_mangle]
437 pub extern "C" fn RawDataPart_get_timestamp(this_ptr: &RawDataPart) -> crate::lightning_invoice::PositiveTimestamp {
438         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.timestamp;
439         crate::lightning_invoice::PositiveTimestamp { inner: unsafe { ( (&(*inner_val) as *const _) as *mut _) }, is_owned: false }
440 }
441 /// generation time of the invoice
442 #[no_mangle]
443 pub extern "C" fn RawDataPart_set_timestamp(this_ptr: &mut RawDataPart, mut val: crate::lightning_invoice::PositiveTimestamp) {
444         unsafe { &mut *this_ptr.inner }.timestamp = *unsafe { Box::from_raw(val.take_inner()) };
445 }
446 /// Checks if two RawDataParts contain equal inner contents.
447 /// This ignores pointers and is_owned flags and looks at the values in fields.
448 /// Two objects with NULL inner values will be considered "equal" here.
449 #[no_mangle]
450 pub extern "C" fn RawDataPart_eq(a: &RawDataPart, b: &RawDataPart) -> bool {
451         if a.inner == b.inner { return true; }
452         if a.inner.is_null() || b.inner.is_null() { return false; }
453         if unsafe { &*a.inner } == unsafe { &*b.inner } { true } else { false }
454 }
455 impl Clone for RawDataPart {
456         fn clone(&self) -> Self {
457                 Self {
458                         inner: if <*mut nativeRawDataPart>::is_null(self.inner) { std::ptr::null_mut() } else {
459                                 Box::into_raw(Box::new(unsafe { &*self.inner }.clone())) },
460                         is_owned: true,
461                 }
462         }
463 }
464 #[allow(unused)]
465 /// Used only if an object of this type is returned as a trait impl by a method
466 pub(crate) extern "C" fn RawDataPart_clone_void(this_ptr: *const c_void) -> *mut c_void {
467         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeRawDataPart)).clone() })) as *mut c_void
468 }
469 #[no_mangle]
470 /// Creates a copy of the RawDataPart
471 pub extern "C" fn RawDataPart_clone(orig: &RawDataPart) -> RawDataPart {
472         orig.clone()
473 }
474
475 use lightning_invoice::PositiveTimestamp as nativePositiveTimestampImport;
476 type nativePositiveTimestamp = nativePositiveTimestampImport;
477
478 /// A timestamp that refers to a date after 1 January 1970 which means its representation as UNIX
479 /// timestamp is positive.
480 ///
481 /// # Invariants
482 /// The UNIX timestamp representing the stored time has to be positive and small enough so that
483 /// a `EpiryTime` can be added to it without an overflow.
484 #[must_use]
485 #[repr(C)]
486 pub struct PositiveTimestamp {
487         /// A pointer to the opaque Rust object.
488
489         /// Nearly everywhere, inner must be non-null, however in places where
490         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
491         pub inner: *mut nativePositiveTimestamp,
492         /// Indicates that this is the only struct which contains the same pointer.
493
494         /// Rust functions which take ownership of an object provided via an argument require
495         /// this to be true and invalidate the object pointed to by inner.
496         pub is_owned: bool,
497 }
498
499 impl Drop for PositiveTimestamp {
500         fn drop(&mut self) {
501                 if self.is_owned && !<*mut nativePositiveTimestamp>::is_null(self.inner) {
502                         let _ = unsafe { Box::from_raw(self.inner) };
503                 }
504         }
505 }
506 /// Frees any resources used by the PositiveTimestamp, if is_owned is set and inner is non-NULL.
507 #[no_mangle]
508 pub extern "C" fn PositiveTimestamp_free(this_obj: PositiveTimestamp) { }
509 #[allow(unused)]
510 /// Used only if an object of this type is returned as a trait impl by a method
511 extern "C" fn PositiveTimestamp_free_void(this_ptr: *mut c_void) {
512         unsafe { let _ = Box::from_raw(this_ptr as *mut nativePositiveTimestamp); }
513 }
514 #[allow(unused)]
515 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
516 impl PositiveTimestamp {
517         pub(crate) fn take_inner(mut self) -> *mut nativePositiveTimestamp {
518                 assert!(self.is_owned);
519                 let ret = self.inner;
520                 self.inner = std::ptr::null_mut();
521                 ret
522         }
523 }
524 /// Checks if two PositiveTimestamps contain equal inner contents.
525 /// This ignores pointers and is_owned flags and looks at the values in fields.
526 /// Two objects with NULL inner values will be considered "equal" here.
527 #[no_mangle]
528 pub extern "C" fn PositiveTimestamp_eq(a: &PositiveTimestamp, b: &PositiveTimestamp) -> bool {
529         if a.inner == b.inner { return true; }
530         if a.inner.is_null() || b.inner.is_null() { return false; }
531         if unsafe { &*a.inner } == unsafe { &*b.inner } { true } else { false }
532 }
533 impl Clone for PositiveTimestamp {
534         fn clone(&self) -> Self {
535                 Self {
536                         inner: if <*mut nativePositiveTimestamp>::is_null(self.inner) { std::ptr::null_mut() } else {
537                                 Box::into_raw(Box::new(unsafe { &*self.inner }.clone())) },
538                         is_owned: true,
539                 }
540         }
541 }
542 #[allow(unused)]
543 /// Used only if an object of this type is returned as a trait impl by a method
544 pub(crate) extern "C" fn PositiveTimestamp_clone_void(this_ptr: *const c_void) -> *mut c_void {
545         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativePositiveTimestamp)).clone() })) as *mut c_void
546 }
547 #[no_mangle]
548 /// Creates a copy of the PositiveTimestamp
549 pub extern "C" fn PositiveTimestamp_clone(orig: &PositiveTimestamp) -> PositiveTimestamp {
550         orig.clone()
551 }
552 /// SI prefixes for the human readable part
553 #[must_use]
554 #[derive(Clone)]
555 #[repr(C)]
556 pub enum SiPrefix {
557         /// 10^-3
558         Milli,
559         /// 10^-6
560         Micro,
561         /// 10^-9
562         Nano,
563         /// 10^-12
564         Pico,
565 }
566 use lightning_invoice::SiPrefix as nativeSiPrefix;
567 impl SiPrefix {
568         #[allow(unused)]
569         pub(crate) fn to_native(&self) -> nativeSiPrefix {
570                 match self {
571                         SiPrefix::Milli => nativeSiPrefix::Milli,
572                         SiPrefix::Micro => nativeSiPrefix::Micro,
573                         SiPrefix::Nano => nativeSiPrefix::Nano,
574                         SiPrefix::Pico => nativeSiPrefix::Pico,
575                 }
576         }
577         #[allow(unused)]
578         pub(crate) fn into_native(self) -> nativeSiPrefix {
579                 match self {
580                         SiPrefix::Milli => nativeSiPrefix::Milli,
581                         SiPrefix::Micro => nativeSiPrefix::Micro,
582                         SiPrefix::Nano => nativeSiPrefix::Nano,
583                         SiPrefix::Pico => nativeSiPrefix::Pico,
584                 }
585         }
586         #[allow(unused)]
587         pub(crate) fn from_native(native: &nativeSiPrefix) -> Self {
588                 match native {
589                         nativeSiPrefix::Milli => SiPrefix::Milli,
590                         nativeSiPrefix::Micro => SiPrefix::Micro,
591                         nativeSiPrefix::Nano => SiPrefix::Nano,
592                         nativeSiPrefix::Pico => SiPrefix::Pico,
593                 }
594         }
595         #[allow(unused)]
596         pub(crate) fn native_into(native: nativeSiPrefix) -> Self {
597                 match native {
598                         nativeSiPrefix::Milli => SiPrefix::Milli,
599                         nativeSiPrefix::Micro => SiPrefix::Micro,
600                         nativeSiPrefix::Nano => SiPrefix::Nano,
601                         nativeSiPrefix::Pico => SiPrefix::Pico,
602                 }
603         }
604 }
605 /// Creates a copy of the SiPrefix
606 #[no_mangle]
607 pub extern "C" fn SiPrefix_clone(orig: &SiPrefix) -> SiPrefix {
608         orig.clone()
609 }
610 /// Checks if two SiPrefixs contain equal inner contents.
611 /// This ignores pointers and is_owned flags and looks at the values in fields.
612 #[no_mangle]
613 pub extern "C" fn SiPrefix_eq(a: &SiPrefix, b: &SiPrefix) -> bool {
614         if &a.to_native() == &b.to_native() { true } else { false }
615 }
616 /// Returns the multiplier to go from a BTC value to picoBTC implied by this SiPrefix.
617 /// This is effectively 10^12 * the prefix multiplier
618 #[must_use]
619 #[no_mangle]
620 pub extern "C" fn SiPrefix_multiplier(this_arg: &SiPrefix) -> u64 {
621         let mut ret = this_arg.to_native().multiplier();
622         ret
623 }
624
625 /// Enum representing the crypto currencies (or networks) supported by this library
626 #[must_use]
627 #[derive(Clone)]
628 #[repr(C)]
629 pub enum Currency {
630         /// Bitcoin mainnet
631         Bitcoin,
632         /// Bitcoin testnet
633         BitcoinTestnet,
634         /// Bitcoin regtest
635         Regtest,
636         /// Bitcoin simnet
637         Simnet,
638         /// Bitcoin signet
639         Signet,
640 }
641 use lightning_invoice::Currency as nativeCurrency;
642 impl Currency {
643         #[allow(unused)]
644         pub(crate) fn to_native(&self) -> nativeCurrency {
645                 match self {
646                         Currency::Bitcoin => nativeCurrency::Bitcoin,
647                         Currency::BitcoinTestnet => nativeCurrency::BitcoinTestnet,
648                         Currency::Regtest => nativeCurrency::Regtest,
649                         Currency::Simnet => nativeCurrency::Simnet,
650                         Currency::Signet => nativeCurrency::Signet,
651                 }
652         }
653         #[allow(unused)]
654         pub(crate) fn into_native(self) -> nativeCurrency {
655                 match self {
656                         Currency::Bitcoin => nativeCurrency::Bitcoin,
657                         Currency::BitcoinTestnet => nativeCurrency::BitcoinTestnet,
658                         Currency::Regtest => nativeCurrency::Regtest,
659                         Currency::Simnet => nativeCurrency::Simnet,
660                         Currency::Signet => nativeCurrency::Signet,
661                 }
662         }
663         #[allow(unused)]
664         pub(crate) fn from_native(native: &nativeCurrency) -> Self {
665                 match native {
666                         nativeCurrency::Bitcoin => Currency::Bitcoin,
667                         nativeCurrency::BitcoinTestnet => Currency::BitcoinTestnet,
668                         nativeCurrency::Regtest => Currency::Regtest,
669                         nativeCurrency::Simnet => Currency::Simnet,
670                         nativeCurrency::Signet => Currency::Signet,
671                 }
672         }
673         #[allow(unused)]
674         pub(crate) fn native_into(native: nativeCurrency) -> Self {
675                 match native {
676                         nativeCurrency::Bitcoin => Currency::Bitcoin,
677                         nativeCurrency::BitcoinTestnet => Currency::BitcoinTestnet,
678                         nativeCurrency::Regtest => Currency::Regtest,
679                         nativeCurrency::Simnet => Currency::Simnet,
680                         nativeCurrency::Signet => Currency::Signet,
681                 }
682         }
683 }
684 /// Creates a copy of the Currency
685 #[no_mangle]
686 pub extern "C" fn Currency_clone(orig: &Currency) -> Currency {
687         orig.clone()
688 }
689 /// Checks if two Currencys contain equal inner contents.
690 /// This ignores pointers and is_owned flags and looks at the values in fields.
691 #[no_mangle]
692 pub extern "C" fn Currency_eq(a: &Currency, b: &Currency) -> bool {
693         if &a.to_native() == &b.to_native() { true } else { false }
694 }
695
696 use lightning_invoice::Sha256 as nativeSha256Import;
697 type nativeSha256 = nativeSha256Import;
698
699 /// SHA-256 hash
700 #[must_use]
701 #[repr(C)]
702 pub struct Sha256 {
703         /// A pointer to the opaque Rust object.
704
705         /// Nearly everywhere, inner must be non-null, however in places where
706         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
707         pub inner: *mut nativeSha256,
708         /// Indicates that this is the only struct which contains the same pointer.
709
710         /// Rust functions which take ownership of an object provided via an argument require
711         /// this to be true and invalidate the object pointed to by inner.
712         pub is_owned: bool,
713 }
714
715 impl Drop for Sha256 {
716         fn drop(&mut self) {
717                 if self.is_owned && !<*mut nativeSha256>::is_null(self.inner) {
718                         let _ = unsafe { Box::from_raw(self.inner) };
719                 }
720         }
721 }
722 /// Frees any resources used by the Sha256, if is_owned is set and inner is non-NULL.
723 #[no_mangle]
724 pub extern "C" fn Sha256_free(this_obj: Sha256) { }
725 #[allow(unused)]
726 /// Used only if an object of this type is returned as a trait impl by a method
727 extern "C" fn Sha256_free_void(this_ptr: *mut c_void) {
728         unsafe { let _ = Box::from_raw(this_ptr as *mut nativeSha256); }
729 }
730 #[allow(unused)]
731 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
732 impl Sha256 {
733         pub(crate) fn take_inner(mut self) -> *mut nativeSha256 {
734                 assert!(self.is_owned);
735                 let ret = self.inner;
736                 self.inner = std::ptr::null_mut();
737                 ret
738         }
739 }
740 /// Checks if two Sha256s contain equal inner contents.
741 /// This ignores pointers and is_owned flags and looks at the values in fields.
742 /// Two objects with NULL inner values will be considered "equal" here.
743 #[no_mangle]
744 pub extern "C" fn Sha256_eq(a: &Sha256, b: &Sha256) -> bool {
745         if a.inner == b.inner { return true; }
746         if a.inner.is_null() || b.inner.is_null() { return false; }
747         if unsafe { &*a.inner } == unsafe { &*b.inner } { true } else { false }
748 }
749 impl Clone for Sha256 {
750         fn clone(&self) -> Self {
751                 Self {
752                         inner: if <*mut nativeSha256>::is_null(self.inner) { std::ptr::null_mut() } else {
753                                 Box::into_raw(Box::new(unsafe { &*self.inner }.clone())) },
754                         is_owned: true,
755                 }
756         }
757 }
758 #[allow(unused)]
759 /// Used only if an object of this type is returned as a trait impl by a method
760 pub(crate) extern "C" fn Sha256_clone_void(this_ptr: *const c_void) -> *mut c_void {
761         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeSha256)).clone() })) as *mut c_void
762 }
763 #[no_mangle]
764 /// Creates a copy of the Sha256
765 pub extern "C" fn Sha256_clone(orig: &Sha256) -> Sha256 {
766         orig.clone()
767 }
768
769 use lightning_invoice::Description as nativeDescriptionImport;
770 type nativeDescription = nativeDescriptionImport;
771
772 /// Description string
773 ///
774 /// # Invariants
775 /// The description can be at most 639 __bytes__ long
776 #[must_use]
777 #[repr(C)]
778 pub struct Description {
779         /// A pointer to the opaque Rust object.
780
781         /// Nearly everywhere, inner must be non-null, however in places where
782         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
783         pub inner: *mut nativeDescription,
784         /// Indicates that this is the only struct which contains the same pointer.
785
786         /// Rust functions which take ownership of an object provided via an argument require
787         /// this to be true and invalidate the object pointed to by inner.
788         pub is_owned: bool,
789 }
790
791 impl Drop for Description {
792         fn drop(&mut self) {
793                 if self.is_owned && !<*mut nativeDescription>::is_null(self.inner) {
794                         let _ = unsafe { Box::from_raw(self.inner) };
795                 }
796         }
797 }
798 /// Frees any resources used by the Description, if is_owned is set and inner is non-NULL.
799 #[no_mangle]
800 pub extern "C" fn Description_free(this_obj: Description) { }
801 #[allow(unused)]
802 /// Used only if an object of this type is returned as a trait impl by a method
803 extern "C" fn Description_free_void(this_ptr: *mut c_void) {
804         unsafe { let _ = Box::from_raw(this_ptr as *mut nativeDescription); }
805 }
806 #[allow(unused)]
807 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
808 impl Description {
809         pub(crate) fn take_inner(mut self) -> *mut nativeDescription {
810                 assert!(self.is_owned);
811                 let ret = self.inner;
812                 self.inner = std::ptr::null_mut();
813                 ret
814         }
815 }
816 /// Checks if two Descriptions contain equal inner contents.
817 /// This ignores pointers and is_owned flags and looks at the values in fields.
818 /// Two objects with NULL inner values will be considered "equal" here.
819 #[no_mangle]
820 pub extern "C" fn Description_eq(a: &Description, b: &Description) -> bool {
821         if a.inner == b.inner { return true; }
822         if a.inner.is_null() || b.inner.is_null() { return false; }
823         if unsafe { &*a.inner } == unsafe { &*b.inner } { true } else { false }
824 }
825 impl Clone for Description {
826         fn clone(&self) -> Self {
827                 Self {
828                         inner: if <*mut nativeDescription>::is_null(self.inner) { std::ptr::null_mut() } else {
829                                 Box::into_raw(Box::new(unsafe { &*self.inner }.clone())) },
830                         is_owned: true,
831                 }
832         }
833 }
834 #[allow(unused)]
835 /// Used only if an object of this type is returned as a trait impl by a method
836 pub(crate) extern "C" fn Description_clone_void(this_ptr: *const c_void) -> *mut c_void {
837         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeDescription)).clone() })) as *mut c_void
838 }
839 #[no_mangle]
840 /// Creates a copy of the Description
841 pub extern "C" fn Description_clone(orig: &Description) -> Description {
842         orig.clone()
843 }
844
845 use lightning_invoice::PayeePubKey as nativePayeePubKeyImport;
846 type nativePayeePubKey = nativePayeePubKeyImport;
847
848 /// Payee public key
849 #[must_use]
850 #[repr(C)]
851 pub struct PayeePubKey {
852         /// A pointer to the opaque Rust object.
853
854         /// Nearly everywhere, inner must be non-null, however in places where
855         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
856         pub inner: *mut nativePayeePubKey,
857         /// Indicates that this is the only struct which contains the same pointer.
858
859         /// Rust functions which take ownership of an object provided via an argument require
860         /// this to be true and invalidate the object pointed to by inner.
861         pub is_owned: bool,
862 }
863
864 impl Drop for PayeePubKey {
865         fn drop(&mut self) {
866                 if self.is_owned && !<*mut nativePayeePubKey>::is_null(self.inner) {
867                         let _ = unsafe { Box::from_raw(self.inner) };
868                 }
869         }
870 }
871 /// Frees any resources used by the PayeePubKey, if is_owned is set and inner is non-NULL.
872 #[no_mangle]
873 pub extern "C" fn PayeePubKey_free(this_obj: PayeePubKey) { }
874 #[allow(unused)]
875 /// Used only if an object of this type is returned as a trait impl by a method
876 extern "C" fn PayeePubKey_free_void(this_ptr: *mut c_void) {
877         unsafe { let _ = Box::from_raw(this_ptr as *mut nativePayeePubKey); }
878 }
879 #[allow(unused)]
880 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
881 impl PayeePubKey {
882         pub(crate) fn take_inner(mut self) -> *mut nativePayeePubKey {
883                 assert!(self.is_owned);
884                 let ret = self.inner;
885                 self.inner = std::ptr::null_mut();
886                 ret
887         }
888 }
889 /// Checks if two PayeePubKeys contain equal inner contents.
890 /// This ignores pointers and is_owned flags and looks at the values in fields.
891 /// Two objects with NULL inner values will be considered "equal" here.
892 #[no_mangle]
893 pub extern "C" fn PayeePubKey_eq(a: &PayeePubKey, b: &PayeePubKey) -> bool {
894         if a.inner == b.inner { return true; }
895         if a.inner.is_null() || b.inner.is_null() { return false; }
896         if unsafe { &*a.inner } == unsafe { &*b.inner } { true } else { false }
897 }
898 impl Clone for PayeePubKey {
899         fn clone(&self) -> Self {
900                 Self {
901                         inner: if <*mut nativePayeePubKey>::is_null(self.inner) { std::ptr::null_mut() } else {
902                                 Box::into_raw(Box::new(unsafe { &*self.inner }.clone())) },
903                         is_owned: true,
904                 }
905         }
906 }
907 #[allow(unused)]
908 /// Used only if an object of this type is returned as a trait impl by a method
909 pub(crate) extern "C" fn PayeePubKey_clone_void(this_ptr: *const c_void) -> *mut c_void {
910         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativePayeePubKey)).clone() })) as *mut c_void
911 }
912 #[no_mangle]
913 /// Creates a copy of the PayeePubKey
914 pub extern "C" fn PayeePubKey_clone(orig: &PayeePubKey) -> PayeePubKey {
915         orig.clone()
916 }
917
918 use lightning_invoice::ExpiryTime as nativeExpiryTimeImport;
919 type nativeExpiryTime = nativeExpiryTimeImport;
920
921 /// Positive duration that defines when (relatively to the timestamp) in the future the invoice
922 /// expires
923 ///
924 /// # Invariants
925 /// The number of seconds this expiry time represents has to be in the range
926 /// `0...(SYSTEM_TIME_MAX_UNIX_TIMESTAMP - MAX_EXPIRY_TIME)` to avoid overflows when adding it to a
927 /// timestamp
928 #[must_use]
929 #[repr(C)]
930 pub struct ExpiryTime {
931         /// A pointer to the opaque Rust object.
932
933         /// Nearly everywhere, inner must be non-null, however in places where
934         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
935         pub inner: *mut nativeExpiryTime,
936         /// Indicates that this is the only struct which contains the same pointer.
937
938         /// Rust functions which take ownership of an object provided via an argument require
939         /// this to be true and invalidate the object pointed to by inner.
940         pub is_owned: bool,
941 }
942
943 impl Drop for ExpiryTime {
944         fn drop(&mut self) {
945                 if self.is_owned && !<*mut nativeExpiryTime>::is_null(self.inner) {
946                         let _ = unsafe { Box::from_raw(self.inner) };
947                 }
948         }
949 }
950 /// Frees any resources used by the ExpiryTime, if is_owned is set and inner is non-NULL.
951 #[no_mangle]
952 pub extern "C" fn ExpiryTime_free(this_obj: ExpiryTime) { }
953 #[allow(unused)]
954 /// Used only if an object of this type is returned as a trait impl by a method
955 extern "C" fn ExpiryTime_free_void(this_ptr: *mut c_void) {
956         unsafe { let _ = Box::from_raw(this_ptr as *mut nativeExpiryTime); }
957 }
958 #[allow(unused)]
959 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
960 impl ExpiryTime {
961         pub(crate) fn take_inner(mut self) -> *mut nativeExpiryTime {
962                 assert!(self.is_owned);
963                 let ret = self.inner;
964                 self.inner = std::ptr::null_mut();
965                 ret
966         }
967 }
968 /// Checks if two ExpiryTimes contain equal inner contents.
969 /// This ignores pointers and is_owned flags and looks at the values in fields.
970 /// Two objects with NULL inner values will be considered "equal" here.
971 #[no_mangle]
972 pub extern "C" fn ExpiryTime_eq(a: &ExpiryTime, b: &ExpiryTime) -> bool {
973         if a.inner == b.inner { return true; }
974         if a.inner.is_null() || b.inner.is_null() { return false; }
975         if unsafe { &*a.inner } == unsafe { &*b.inner } { true } else { false }
976 }
977 impl Clone for ExpiryTime {
978         fn clone(&self) -> Self {
979                 Self {
980                         inner: if <*mut nativeExpiryTime>::is_null(self.inner) { std::ptr::null_mut() } else {
981                                 Box::into_raw(Box::new(unsafe { &*self.inner }.clone())) },
982                         is_owned: true,
983                 }
984         }
985 }
986 #[allow(unused)]
987 /// Used only if an object of this type is returned as a trait impl by a method
988 pub(crate) extern "C" fn ExpiryTime_clone_void(this_ptr: *const c_void) -> *mut c_void {
989         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeExpiryTime)).clone() })) as *mut c_void
990 }
991 #[no_mangle]
992 /// Creates a copy of the ExpiryTime
993 pub extern "C" fn ExpiryTime_clone(orig: &ExpiryTime) -> ExpiryTime {
994         orig.clone()
995 }
996
997 use lightning_invoice::MinFinalCltvExpiry as nativeMinFinalCltvExpiryImport;
998 type nativeMinFinalCltvExpiry = nativeMinFinalCltvExpiryImport;
999
1000 /// `min_final_cltv_expiry` to use for the last HTLC in the route
1001 #[must_use]
1002 #[repr(C)]
1003 pub struct MinFinalCltvExpiry {
1004         /// A pointer to the opaque Rust object.
1005
1006         /// Nearly everywhere, inner must be non-null, however in places where
1007         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
1008         pub inner: *mut nativeMinFinalCltvExpiry,
1009         /// Indicates that this is the only struct which contains the same pointer.
1010
1011         /// Rust functions which take ownership of an object provided via an argument require
1012         /// this to be true and invalidate the object pointed to by inner.
1013         pub is_owned: bool,
1014 }
1015
1016 impl Drop for MinFinalCltvExpiry {
1017         fn drop(&mut self) {
1018                 if self.is_owned && !<*mut nativeMinFinalCltvExpiry>::is_null(self.inner) {
1019                         let _ = unsafe { Box::from_raw(self.inner) };
1020                 }
1021         }
1022 }
1023 /// Frees any resources used by the MinFinalCltvExpiry, if is_owned is set and inner is non-NULL.
1024 #[no_mangle]
1025 pub extern "C" fn MinFinalCltvExpiry_free(this_obj: MinFinalCltvExpiry) { }
1026 #[allow(unused)]
1027 /// Used only if an object of this type is returned as a trait impl by a method
1028 extern "C" fn MinFinalCltvExpiry_free_void(this_ptr: *mut c_void) {
1029         unsafe { let _ = Box::from_raw(this_ptr as *mut nativeMinFinalCltvExpiry); }
1030 }
1031 #[allow(unused)]
1032 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
1033 impl MinFinalCltvExpiry {
1034         pub(crate) fn take_inner(mut self) -> *mut nativeMinFinalCltvExpiry {
1035                 assert!(self.is_owned);
1036                 let ret = self.inner;
1037                 self.inner = std::ptr::null_mut();
1038                 ret
1039         }
1040 }
1041 /// Checks if two MinFinalCltvExpirys contain equal inner contents.
1042 /// This ignores pointers and is_owned flags and looks at the values in fields.
1043 /// Two objects with NULL inner values will be considered "equal" here.
1044 #[no_mangle]
1045 pub extern "C" fn MinFinalCltvExpiry_eq(a: &MinFinalCltvExpiry, b: &MinFinalCltvExpiry) -> bool {
1046         if a.inner == b.inner { return true; }
1047         if a.inner.is_null() || b.inner.is_null() { return false; }
1048         if unsafe { &*a.inner } == unsafe { &*b.inner } { true } else { false }
1049 }
1050 impl Clone for MinFinalCltvExpiry {
1051         fn clone(&self) -> Self {
1052                 Self {
1053                         inner: if <*mut nativeMinFinalCltvExpiry>::is_null(self.inner) { std::ptr::null_mut() } else {
1054                                 Box::into_raw(Box::new(unsafe { &*self.inner }.clone())) },
1055                         is_owned: true,
1056                 }
1057         }
1058 }
1059 #[allow(unused)]
1060 /// Used only if an object of this type is returned as a trait impl by a method
1061 pub(crate) extern "C" fn MinFinalCltvExpiry_clone_void(this_ptr: *const c_void) -> *mut c_void {
1062         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeMinFinalCltvExpiry)).clone() })) as *mut c_void
1063 }
1064 #[no_mangle]
1065 /// Creates a copy of the MinFinalCltvExpiry
1066 pub extern "C" fn MinFinalCltvExpiry_clone(orig: &MinFinalCltvExpiry) -> MinFinalCltvExpiry {
1067         orig.clone()
1068 }
1069 /// Fallback address in case no LN payment is possible
1070 #[must_use]
1071 #[derive(Clone)]
1072 #[repr(C)]
1073 pub enum Fallback {
1074         SegWitProgram {
1075                 version: crate::c_types::u5,
1076                 program: crate::c_types::derived::CVec_u8Z,
1077         },
1078         PubKeyHash(crate::c_types::TwentyBytes),
1079         ScriptHash(crate::c_types::TwentyBytes),
1080 }
1081 use lightning_invoice::Fallback as nativeFallback;
1082 impl Fallback {
1083         #[allow(unused)]
1084         pub(crate) fn to_native(&self) -> nativeFallback {
1085                 match self {
1086                         Fallback::SegWitProgram {ref version, ref program, } => {
1087                                 let mut version_nonref = (*version).clone();
1088                                 let mut program_nonref = (*program).clone();
1089                                 let mut local_program_nonref = Vec::new(); for mut item in program_nonref.into_rust().drain(..) { local_program_nonref.push( { item }); };
1090                                 nativeFallback::SegWitProgram {
1091                                         version: version_nonref.into(),
1092                                         program: local_program_nonref,
1093                                 }
1094                         },
1095                         Fallback::PubKeyHash (ref a, ) => {
1096                                 let mut a_nonref = (*a).clone();
1097                                 nativeFallback::PubKeyHash (
1098                                         a_nonref.data,
1099                                 )
1100                         },
1101                         Fallback::ScriptHash (ref a, ) => {
1102                                 let mut a_nonref = (*a).clone();
1103                                 nativeFallback::ScriptHash (
1104                                         a_nonref.data,
1105                                 )
1106                         },
1107                 }
1108         }
1109         #[allow(unused)]
1110         pub(crate) fn into_native(self) -> nativeFallback {
1111                 match self {
1112                         Fallback::SegWitProgram {mut version, mut program, } => {
1113                                 let mut local_program = Vec::new(); for mut item in program.into_rust().drain(..) { local_program.push( { item }); };
1114                                 nativeFallback::SegWitProgram {
1115                                         version: version.into(),
1116                                         program: local_program,
1117                                 }
1118                         },
1119                         Fallback::PubKeyHash (mut a, ) => {
1120                                 nativeFallback::PubKeyHash (
1121                                         a.data,
1122                                 )
1123                         },
1124                         Fallback::ScriptHash (mut a, ) => {
1125                                 nativeFallback::ScriptHash (
1126                                         a.data,
1127                                 )
1128                         },
1129                 }
1130         }
1131         #[allow(unused)]
1132         pub(crate) fn from_native(native: &nativeFallback) -> Self {
1133                 match native {
1134                         nativeFallback::SegWitProgram {ref version, ref program, } => {
1135                                 let mut version_nonref = (*version).clone();
1136                                 let mut program_nonref = (*program).clone();
1137                                 let mut local_program_nonref = Vec::new(); for mut item in program_nonref.drain(..) { local_program_nonref.push( { item }); };
1138                                 Fallback::SegWitProgram {
1139                                         version: version_nonref.into(),
1140                                         program: local_program_nonref.into(),
1141                                 }
1142                         },
1143                         nativeFallback::PubKeyHash (ref a, ) => {
1144                                 let mut a_nonref = (*a).clone();
1145                                 Fallback::PubKeyHash (
1146                                         crate::c_types::TwentyBytes { data: a_nonref },
1147                                 )
1148                         },
1149                         nativeFallback::ScriptHash (ref a, ) => {
1150                                 let mut a_nonref = (*a).clone();
1151                                 Fallback::ScriptHash (
1152                                         crate::c_types::TwentyBytes { data: a_nonref },
1153                                 )
1154                         },
1155                 }
1156         }
1157         #[allow(unused)]
1158         pub(crate) fn native_into(native: nativeFallback) -> Self {
1159                 match native {
1160                         nativeFallback::SegWitProgram {mut version, mut program, } => {
1161                                 let mut local_program = Vec::new(); for mut item in program.drain(..) { local_program.push( { item }); };
1162                                 Fallback::SegWitProgram {
1163                                         version: version.into(),
1164                                         program: local_program.into(),
1165                                 }
1166                         },
1167                         nativeFallback::PubKeyHash (mut a, ) => {
1168                                 Fallback::PubKeyHash (
1169                                         crate::c_types::TwentyBytes { data: a },
1170                                 )
1171                         },
1172                         nativeFallback::ScriptHash (mut a, ) => {
1173                                 Fallback::ScriptHash (
1174                                         crate::c_types::TwentyBytes { data: a },
1175                                 )
1176                         },
1177                 }
1178         }
1179 }
1180 /// Frees any resources used by the Fallback
1181 #[no_mangle]
1182 pub extern "C" fn Fallback_free(this_ptr: Fallback) { }
1183 /// Creates a copy of the Fallback
1184 #[no_mangle]
1185 pub extern "C" fn Fallback_clone(orig: &Fallback) -> Fallback {
1186         orig.clone()
1187 }
1188 /// Checks if two Fallbacks contain equal inner contents.
1189 /// This ignores pointers and is_owned flags and looks at the values in fields.
1190 #[no_mangle]
1191 pub extern "C" fn Fallback_eq(a: &Fallback, b: &Fallback) -> bool {
1192         if &a.to_native() == &b.to_native() { true } else { false }
1193 }
1194
1195 use lightning_invoice::InvoiceSignature as nativeInvoiceSignatureImport;
1196 type nativeInvoiceSignature = nativeInvoiceSignatureImport;
1197
1198 /// Recoverable signature
1199 #[must_use]
1200 #[repr(C)]
1201 pub struct InvoiceSignature {
1202         /// A pointer to the opaque Rust object.
1203
1204         /// Nearly everywhere, inner must be non-null, however in places where
1205         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
1206         pub inner: *mut nativeInvoiceSignature,
1207         /// Indicates that this is the only struct which contains the same pointer.
1208
1209         /// Rust functions which take ownership of an object provided via an argument require
1210         /// this to be true and invalidate the object pointed to by inner.
1211         pub is_owned: bool,
1212 }
1213
1214 impl Drop for InvoiceSignature {
1215         fn drop(&mut self) {
1216                 if self.is_owned && !<*mut nativeInvoiceSignature>::is_null(self.inner) {
1217                         let _ = unsafe { Box::from_raw(self.inner) };
1218                 }
1219         }
1220 }
1221 /// Frees any resources used by the InvoiceSignature, if is_owned is set and inner is non-NULL.
1222 #[no_mangle]
1223 pub extern "C" fn InvoiceSignature_free(this_obj: InvoiceSignature) { }
1224 #[allow(unused)]
1225 /// Used only if an object of this type is returned as a trait impl by a method
1226 extern "C" fn InvoiceSignature_free_void(this_ptr: *mut c_void) {
1227         unsafe { let _ = Box::from_raw(this_ptr as *mut nativeInvoiceSignature); }
1228 }
1229 #[allow(unused)]
1230 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
1231 impl InvoiceSignature {
1232         pub(crate) fn take_inner(mut self) -> *mut nativeInvoiceSignature {
1233                 assert!(self.is_owned);
1234                 let ret = self.inner;
1235                 self.inner = std::ptr::null_mut();
1236                 ret
1237         }
1238 }
1239 /// Checks if two InvoiceSignatures contain equal inner contents.
1240 /// This ignores pointers and is_owned flags and looks at the values in fields.
1241 /// Two objects with NULL inner values will be considered "equal" here.
1242 #[no_mangle]
1243 pub extern "C" fn InvoiceSignature_eq(a: &InvoiceSignature, b: &InvoiceSignature) -> bool {
1244         if a.inner == b.inner { return true; }
1245         if a.inner.is_null() || b.inner.is_null() { return false; }
1246         if unsafe { &*a.inner } == unsafe { &*b.inner } { true } else { false }
1247 }
1248 impl Clone for InvoiceSignature {
1249         fn clone(&self) -> Self {
1250                 Self {
1251                         inner: if <*mut nativeInvoiceSignature>::is_null(self.inner) { std::ptr::null_mut() } else {
1252                                 Box::into_raw(Box::new(unsafe { &*self.inner }.clone())) },
1253                         is_owned: true,
1254                 }
1255         }
1256 }
1257 #[allow(unused)]
1258 /// Used only if an object of this type is returned as a trait impl by a method
1259 pub(crate) extern "C" fn InvoiceSignature_clone_void(this_ptr: *const c_void) -> *mut c_void {
1260         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeInvoiceSignature)).clone() })) as *mut c_void
1261 }
1262 #[no_mangle]
1263 /// Creates a copy of the InvoiceSignature
1264 pub extern "C" fn InvoiceSignature_clone(orig: &InvoiceSignature) -> InvoiceSignature {
1265         orig.clone()
1266 }
1267
1268 use lightning_invoice::PrivateRoute as nativePrivateRouteImport;
1269 type nativePrivateRoute = nativePrivateRouteImport;
1270
1271 /// Private routing information
1272 ///
1273 /// # Invariants
1274 /// The encoded route has to be <1024 5bit characters long (<=639 bytes or <=12 hops)
1275 ///
1276 #[must_use]
1277 #[repr(C)]
1278 pub struct PrivateRoute {
1279         /// A pointer to the opaque Rust object.
1280
1281         /// Nearly everywhere, inner must be non-null, however in places where
1282         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
1283         pub inner: *mut nativePrivateRoute,
1284         /// Indicates that this is the only struct which contains the same pointer.
1285
1286         /// Rust functions which take ownership of an object provided via an argument require
1287         /// this to be true and invalidate the object pointed to by inner.
1288         pub is_owned: bool,
1289 }
1290
1291 impl Drop for PrivateRoute {
1292         fn drop(&mut self) {
1293                 if self.is_owned && !<*mut nativePrivateRoute>::is_null(self.inner) {
1294                         let _ = unsafe { Box::from_raw(self.inner) };
1295                 }
1296         }
1297 }
1298 /// Frees any resources used by the PrivateRoute, if is_owned is set and inner is non-NULL.
1299 #[no_mangle]
1300 pub extern "C" fn PrivateRoute_free(this_obj: PrivateRoute) { }
1301 #[allow(unused)]
1302 /// Used only if an object of this type is returned as a trait impl by a method
1303 extern "C" fn PrivateRoute_free_void(this_ptr: *mut c_void) {
1304         unsafe { let _ = Box::from_raw(this_ptr as *mut nativePrivateRoute); }
1305 }
1306 #[allow(unused)]
1307 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
1308 impl PrivateRoute {
1309         pub(crate) fn take_inner(mut self) -> *mut nativePrivateRoute {
1310                 assert!(self.is_owned);
1311                 let ret = self.inner;
1312                 self.inner = std::ptr::null_mut();
1313                 ret
1314         }
1315 }
1316 /// Checks if two PrivateRoutes contain equal inner contents.
1317 /// This ignores pointers and is_owned flags and looks at the values in fields.
1318 /// Two objects with NULL inner values will be considered "equal" here.
1319 #[no_mangle]
1320 pub extern "C" fn PrivateRoute_eq(a: &PrivateRoute, b: &PrivateRoute) -> bool {
1321         if a.inner == b.inner { return true; }
1322         if a.inner.is_null() || b.inner.is_null() { return false; }
1323         if unsafe { &*a.inner } == unsafe { &*b.inner } { true } else { false }
1324 }
1325 impl Clone for PrivateRoute {
1326         fn clone(&self) -> Self {
1327                 Self {
1328                         inner: if <*mut nativePrivateRoute>::is_null(self.inner) { std::ptr::null_mut() } else {
1329                                 Box::into_raw(Box::new(unsafe { &*self.inner }.clone())) },
1330                         is_owned: true,
1331                 }
1332         }
1333 }
1334 #[allow(unused)]
1335 /// Used only if an object of this type is returned as a trait impl by a method
1336 pub(crate) extern "C" fn PrivateRoute_clone_void(this_ptr: *const c_void) -> *mut c_void {
1337         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativePrivateRoute)).clone() })) as *mut c_void
1338 }
1339 #[no_mangle]
1340 /// Creates a copy of the PrivateRoute
1341 pub extern "C" fn PrivateRoute_clone(orig: &PrivateRoute) -> PrivateRoute {
1342         orig.clone()
1343 }
1344 /// Disassembles the `SignedRawInvoice` into its three parts:
1345 ///  1. raw invoice
1346 ///  2. hash of the raw invoice
1347 ///  3. signature
1348 #[must_use]
1349 #[no_mangle]
1350 pub extern "C" fn SignedRawInvoice_into_parts(mut this_arg: SignedRawInvoice) -> crate::c_types::derived::C3Tuple_RawInvoice_u832InvoiceSignatureZ {
1351         let mut ret = (*unsafe { Box::from_raw(this_arg.take_inner()) }).into_parts();
1352         let (mut orig_ret_0, mut orig_ret_1, mut orig_ret_2) = ret; let mut local_ret = (crate::lightning_invoice::RawInvoice { inner: Box::into_raw(Box::new(orig_ret_0)), is_owned: true }, crate::c_types::ThirtyTwoBytes { data: orig_ret_1 }, crate::lightning_invoice::InvoiceSignature { inner: Box::into_raw(Box::new(orig_ret_2)), is_owned: true }).into();
1353         local_ret
1354 }
1355
1356 /// The `RawInvoice` which was signed.
1357 #[must_use]
1358 #[no_mangle]
1359 pub extern "C" fn SignedRawInvoice_raw_invoice(this_arg: &SignedRawInvoice) -> crate::lightning_invoice::RawInvoice {
1360         let mut ret = unsafe { &*this_arg.inner }.raw_invoice();
1361         crate::lightning_invoice::RawInvoice { inner: unsafe { ( (&(*ret) as *const _) as *mut _) }, is_owned: false }
1362 }
1363
1364 /// The hash of the `RawInvoice` that was signed.
1365 #[must_use]
1366 #[no_mangle]
1367 pub extern "C" fn SignedRawInvoice_hash(this_arg: &SignedRawInvoice) -> *const [u8; 32] {
1368         let mut ret = unsafe { &*this_arg.inner }.hash();
1369         ret
1370 }
1371
1372 /// InvoiceSignature for the invoice.
1373 #[must_use]
1374 #[no_mangle]
1375 pub extern "C" fn SignedRawInvoice_signature(this_arg: &SignedRawInvoice) -> crate::lightning_invoice::InvoiceSignature {
1376         let mut ret = unsafe { &*this_arg.inner }.signature();
1377         crate::lightning_invoice::InvoiceSignature { inner: unsafe { ( (&(*ret) as *const _) as *mut _) }, is_owned: false }
1378 }
1379
1380 /// Recovers the public key used for signing the invoice from the recoverable signature.
1381 #[must_use]
1382 #[no_mangle]
1383 pub extern "C" fn SignedRawInvoice_recover_payee_pub_key(this_arg: &SignedRawInvoice) -> crate::c_types::derived::CResult_PayeePubKeyErrorZ {
1384         let mut ret = unsafe { &*this_arg.inner }.recover_payee_pub_key();
1385         let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning_invoice::PayeePubKey { inner: Box::into_raw(Box::new(o)), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::c_types::Secp256k1Error::from_rust(e) }).into() };
1386         local_ret
1387 }
1388
1389 /// Checks if the signature is valid for the included payee public key or if none exists if it's
1390 /// valid for the recovered signature (which should always be true?).
1391 #[must_use]
1392 #[no_mangle]
1393 pub extern "C" fn SignedRawInvoice_check_signature(this_arg: &SignedRawInvoice) -> bool {
1394         let mut ret = unsafe { &*this_arg.inner }.check_signature();
1395         ret
1396 }
1397
1398 /// Calculate the hash of the encoded `RawInvoice`
1399 #[must_use]
1400 #[no_mangle]
1401 pub extern "C" fn RawInvoice_hash(this_arg: &RawInvoice) -> crate::c_types::ThirtyTwoBytes {
1402         let mut ret = unsafe { &*this_arg.inner }.hash();
1403         crate::c_types::ThirtyTwoBytes { data: ret }
1404 }
1405
1406 #[must_use]
1407 #[no_mangle]
1408 pub extern "C" fn RawInvoice_payment_hash(this_arg: &RawInvoice) -> crate::lightning_invoice::Sha256 {
1409         let mut ret = unsafe { &*this_arg.inner }.payment_hash();
1410         let mut local_ret = crate::lightning_invoice::Sha256 { inner: unsafe { (if ret.is_none() { std::ptr::null() } else {  { (ret.unwrap()) } } as *const _) as *mut _ }, is_owned: false };
1411         local_ret
1412 }
1413
1414 #[must_use]
1415 #[no_mangle]
1416 pub extern "C" fn RawInvoice_description(this_arg: &RawInvoice) -> crate::lightning_invoice::Description {
1417         let mut ret = unsafe { &*this_arg.inner }.description();
1418         let mut local_ret = crate::lightning_invoice::Description { inner: unsafe { (if ret.is_none() { std::ptr::null() } else {  { (ret.unwrap()) } } as *const _) as *mut _ }, is_owned: false };
1419         local_ret
1420 }
1421
1422 #[must_use]
1423 #[no_mangle]
1424 pub extern "C" fn RawInvoice_payee_pub_key(this_arg: &RawInvoice) -> crate::lightning_invoice::PayeePubKey {
1425         let mut ret = unsafe { &*this_arg.inner }.payee_pub_key();
1426         let mut local_ret = crate::lightning_invoice::PayeePubKey { inner: unsafe { (if ret.is_none() { std::ptr::null() } else {  { (ret.unwrap()) } } as *const _) as *mut _ }, is_owned: false };
1427         local_ret
1428 }
1429
1430 #[must_use]
1431 #[no_mangle]
1432 pub extern "C" fn RawInvoice_description_hash(this_arg: &RawInvoice) -> crate::lightning_invoice::Sha256 {
1433         let mut ret = unsafe { &*this_arg.inner }.description_hash();
1434         let mut local_ret = crate::lightning_invoice::Sha256 { inner: unsafe { (if ret.is_none() { std::ptr::null() } else {  { (ret.unwrap()) } } as *const _) as *mut _ }, is_owned: false };
1435         local_ret
1436 }
1437
1438 #[must_use]
1439 #[no_mangle]
1440 pub extern "C" fn RawInvoice_expiry_time(this_arg: &RawInvoice) -> crate::lightning_invoice::ExpiryTime {
1441         let mut ret = unsafe { &*this_arg.inner }.expiry_time();
1442         let mut local_ret = crate::lightning_invoice::ExpiryTime { inner: unsafe { (if ret.is_none() { std::ptr::null() } else {  { (ret.unwrap()) } } as *const _) as *mut _ }, is_owned: false };
1443         local_ret
1444 }
1445
1446 #[must_use]
1447 #[no_mangle]
1448 pub extern "C" fn RawInvoice_min_final_cltv_expiry(this_arg: &RawInvoice) -> crate::lightning_invoice::MinFinalCltvExpiry {
1449         let mut ret = unsafe { &*this_arg.inner }.min_final_cltv_expiry();
1450         let mut local_ret = crate::lightning_invoice::MinFinalCltvExpiry { inner: unsafe { (if ret.is_none() { std::ptr::null() } else {  { (ret.unwrap()) } } as *const _) as *mut _ }, is_owned: false };
1451         local_ret
1452 }
1453
1454 #[must_use]
1455 #[no_mangle]
1456 pub extern "C" fn RawInvoice_payment_secret(this_arg: &RawInvoice) -> crate::c_types::ThirtyTwoBytes {
1457         let mut ret = unsafe { &*this_arg.inner }.payment_secret();
1458         let mut local_ret = if ret.is_none() { crate::c_types::ThirtyTwoBytes::null() } else {  { crate::c_types::ThirtyTwoBytes { data: (ret.unwrap()).0 } } };
1459         local_ret
1460 }
1461
1462 #[must_use]
1463 #[no_mangle]
1464 pub extern "C" fn RawInvoice_features(this_arg: &RawInvoice) -> crate::lightning::ln::features::InvoiceFeatures {
1465         let mut ret = unsafe { &*this_arg.inner }.features();
1466         let mut local_ret = crate::lightning::ln::features::InvoiceFeatures { inner: unsafe { (if ret.is_none() { std::ptr::null() } else {  { (ret.unwrap()) } } as *const _) as *mut _ }, is_owned: false };
1467         local_ret
1468 }
1469
1470 #[must_use]
1471 #[no_mangle]
1472 pub extern "C" fn RawInvoice_private_routes(this_arg: &RawInvoice) -> crate::c_types::derived::CVec_PrivateRouteZ {
1473         let mut ret = unsafe { &*this_arg.inner }.private_routes();
1474         let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { crate::lightning_invoice::PrivateRoute { inner: unsafe { ( (&(*item) as *const _) as *mut _) }, is_owned: false } }); };
1475         local_ret.into()
1476 }
1477
1478 #[must_use]
1479 #[no_mangle]
1480 pub extern "C" fn RawInvoice_amount_pico_btc(this_arg: &RawInvoice) -> crate::c_types::derived::COption_u64Z {
1481         let mut ret = unsafe { &*this_arg.inner }.amount_pico_btc();
1482         let mut local_ret = if ret.is_none() { crate::c_types::derived::COption_u64Z::None } else {  { crate::c_types::derived::COption_u64Z::Some(ret.unwrap()) } };
1483         local_ret
1484 }
1485
1486 #[must_use]
1487 #[no_mangle]
1488 pub extern "C" fn RawInvoice_currency(this_arg: &RawInvoice) -> crate::lightning_invoice::Currency {
1489         let mut ret = unsafe { &*this_arg.inner }.currency();
1490         crate::lightning_invoice::Currency::native_into(ret)
1491 }
1492
1493 /// Create a new `PositiveTimestamp` from a unix timestamp in the Range
1494 /// `0...SYSTEM_TIME_MAX_UNIX_TIMESTAMP - MAX_EXPIRY_TIME`, otherwise return a
1495 /// `CreationError::TimestampOutOfBounds`.
1496 #[must_use]
1497 #[no_mangle]
1498 pub extern "C" fn PositiveTimestamp_from_unix_timestamp(mut unix_seconds: u64) -> crate::c_types::derived::CResult_PositiveTimestampCreationErrorZ {
1499         let mut ret = lightning_invoice::PositiveTimestamp::from_unix_timestamp(unix_seconds);
1500         let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning_invoice::PositiveTimestamp { inner: Box::into_raw(Box::new(o)), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning_invoice::CreationError::native_into(e) }).into() };
1501         local_ret
1502 }
1503
1504 /// Create a new `PositiveTimestamp` from a `SystemTime` with a corresponding unix timestamp in
1505 /// the Range `0...SYSTEM_TIME_MAX_UNIX_TIMESTAMP - MAX_EXPIRY_TIME`, otherwise return a
1506 /// `CreationError::TimestampOutOfBounds`.
1507 #[must_use]
1508 #[no_mangle]
1509 pub extern "C" fn PositiveTimestamp_from_system_time(mut time: u64) -> crate::c_types::derived::CResult_PositiveTimestampCreationErrorZ {
1510         let mut ret = lightning_invoice::PositiveTimestamp::from_system_time((::std::time::SystemTime::UNIX_EPOCH + std::time::Duration::from_secs(time)));
1511         let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning_invoice::PositiveTimestamp { inner: Box::into_raw(Box::new(o)), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning_invoice::CreationError::native_into(e) }).into() };
1512         local_ret
1513 }
1514
1515 /// Returns the UNIX timestamp representing the stored time
1516 #[must_use]
1517 #[no_mangle]
1518 pub extern "C" fn PositiveTimestamp_as_unix_timestamp(this_arg: &PositiveTimestamp) -> u64 {
1519         let mut ret = unsafe { &*this_arg.inner }.as_unix_timestamp();
1520         ret
1521 }
1522
1523 /// Returns a reference to the internal `SystemTime` time representation
1524 #[must_use]
1525 #[no_mangle]
1526 pub extern "C" fn PositiveTimestamp_as_time(this_arg: &PositiveTimestamp) -> u64 {
1527         let mut ret = unsafe { &*this_arg.inner }.as_time();
1528         ret.duration_since(::std::time::SystemTime::UNIX_EPOCH).expect("Times must be post-1970").as_secs()
1529 }
1530
1531 /// Transform the `Invoice` into it's unchecked version
1532 #[must_use]
1533 #[no_mangle]
1534 pub extern "C" fn Invoice_into_signed_raw(mut this_arg: Invoice) -> crate::lightning_invoice::SignedRawInvoice {
1535         let mut ret = (*unsafe { Box::from_raw(this_arg.take_inner()) }).into_signed_raw();
1536         crate::lightning_invoice::SignedRawInvoice { inner: Box::into_raw(Box::new(ret)), is_owned: true }
1537 }
1538
1539 /// Check that the invoice is signed correctly and that key recovery works
1540 #[must_use]
1541 #[no_mangle]
1542 pub extern "C" fn Invoice_check_signature(this_arg: &Invoice) -> crate::c_types::derived::CResult_NoneSemanticErrorZ {
1543         let mut ret = unsafe { &*this_arg.inner }.check_signature();
1544         let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { () /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning_invoice::SemanticError::native_into(e) }).into() };
1545         local_ret
1546 }
1547
1548 /// Constructs an `Invoice` from a `SignedRawInvoice` by checking all its invariants.
1549 /// ```
1550 /// use lightning_invoice::*;
1551 ///
1552 /// let invoice = \"lnbc1pvjluezpp5qqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqypqdp\\
1553 /// \tl2pkx2ctnv5sxxmmwwd5kgetjypeh2ursdae8g6twvus8g6rfwvs8qun0dfjkxaq8rkx3yf5tcsyz3d7\\
1554 /// \t3gafnh3cax9rn449d9p5uxz9ezhhypd0elx87sjle52x86fux2ypatgddc6k63n7erqz25le42c4u4ec\\
1555 /// \tky03ylcqca784w\";
1556 ///
1557 /// let signed = invoice.parse::<SignedRawInvoice>().unwrap();
1558 ///
1559 /// assert!(Invoice::from_signed(signed).is_ok());
1560 /// ```
1561 #[must_use]
1562 #[no_mangle]
1563 pub extern "C" fn Invoice_from_signed(mut signed_invoice: crate::lightning_invoice::SignedRawInvoice) -> crate::c_types::derived::CResult_InvoiceSemanticErrorZ {
1564         let mut ret = lightning_invoice::Invoice::from_signed(*unsafe { Box::from_raw(signed_invoice.take_inner()) });
1565         let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning_invoice::Invoice { inner: Box::into_raw(Box::new(o)), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning_invoice::SemanticError::native_into(e) }).into() };
1566         local_ret
1567 }
1568
1569 /// Returns the `Invoice`'s timestamp (should equal it's creation time)
1570 #[must_use]
1571 #[no_mangle]
1572 pub extern "C" fn Invoice_timestamp(this_arg: &Invoice) -> u64 {
1573         let mut ret = unsafe { &*this_arg.inner }.timestamp();
1574         ret.duration_since(::std::time::SystemTime::UNIX_EPOCH).expect("Times must be post-1970").as_secs()
1575 }
1576
1577 /// Returns the hash to which we will receive the preimage on completion of the payment
1578 #[must_use]
1579 #[no_mangle]
1580 pub extern "C" fn Invoice_payment_hash(this_arg: &Invoice) -> *const [u8; 32] {
1581         let mut ret = unsafe { &*this_arg.inner }.payment_hash();
1582         ret.as_inner()
1583 }
1584
1585 /// Get the payee's public key if one was included in the invoice
1586 #[must_use]
1587 #[no_mangle]
1588 pub extern "C" fn Invoice_payee_pub_key(this_arg: &Invoice) -> crate::c_types::PublicKey {
1589         let mut ret = unsafe { &*this_arg.inner }.payee_pub_key();
1590         let mut local_ret = if ret.is_none() { crate::c_types::PublicKey::null() } else {  { crate::c_types::PublicKey::from_rust(&(ret.unwrap())) } };
1591         local_ret
1592 }
1593
1594 /// Get the payment secret if one was included in the invoice
1595 #[must_use]
1596 #[no_mangle]
1597 pub extern "C" fn Invoice_payment_secret(this_arg: &Invoice) -> crate::c_types::ThirtyTwoBytes {
1598         let mut ret = unsafe { &*this_arg.inner }.payment_secret();
1599         let mut local_ret = if ret.is_none() { crate::c_types::ThirtyTwoBytes::null() } else {  { crate::c_types::ThirtyTwoBytes { data: (ret.unwrap()).0 } } };
1600         local_ret
1601 }
1602
1603 /// Get the invoice features if they were included in the invoice
1604 #[must_use]
1605 #[no_mangle]
1606 pub extern "C" fn Invoice_features(this_arg: &Invoice) -> crate::lightning::ln::features::InvoiceFeatures {
1607         let mut ret = unsafe { &*this_arg.inner }.features();
1608         let mut local_ret = crate::lightning::ln::features::InvoiceFeatures { inner: unsafe { (if ret.is_none() { std::ptr::null() } else {  { (ret.unwrap()) } } as *const _) as *mut _ }, is_owned: false };
1609         local_ret
1610 }
1611
1612 /// Recover the payee's public key (only to be used if none was included in the invoice)
1613 #[must_use]
1614 #[no_mangle]
1615 pub extern "C" fn Invoice_recover_payee_pub_key(this_arg: &Invoice) -> crate::c_types::PublicKey {
1616         let mut ret = unsafe { &*this_arg.inner }.recover_payee_pub_key();
1617         crate::c_types::PublicKey::from_rust(&ret)
1618 }
1619
1620 /// Returns the invoice's expiry time, if present, otherwise [`DEFAULT_EXPIRY_TIME`].
1621 #[must_use]
1622 #[no_mangle]
1623 pub extern "C" fn Invoice_expiry_time(this_arg: &Invoice) -> u64 {
1624         let mut ret = unsafe { &*this_arg.inner }.expiry_time();
1625         ret.as_secs()
1626 }
1627
1628 /// Returns the invoice's `min_final_cltv_expiry` time, if present, otherwise
1629 /// [`DEFAULT_MIN_FINAL_CLTV_EXPIRY`].
1630 #[must_use]
1631 #[no_mangle]
1632 pub extern "C" fn Invoice_min_final_cltv_expiry(this_arg: &Invoice) -> u64 {
1633         let mut ret = unsafe { &*this_arg.inner }.min_final_cltv_expiry();
1634         ret
1635 }
1636
1637 /// Returns a list of all routes included in the invoice
1638 #[must_use]
1639 #[no_mangle]
1640 pub extern "C" fn Invoice_private_routes(this_arg: &Invoice) -> crate::c_types::derived::CVec_PrivateRouteZ {
1641         let mut ret = unsafe { &*this_arg.inner }.private_routes();
1642         let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { crate::lightning_invoice::PrivateRoute { inner: unsafe { ( (&(*item) as *const _) as *mut _) }, is_owned: false } }); };
1643         local_ret.into()
1644 }
1645
1646 /// Returns a list of all routes included in the invoice as the underlying hints
1647 #[must_use]
1648 #[no_mangle]
1649 pub extern "C" fn Invoice_route_hints(this_arg: &Invoice) -> crate::c_types::derived::CVec_RouteHintZ {
1650         let mut ret = unsafe { &*this_arg.inner }.route_hints();
1651         let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { crate::lightning::routing::router::RouteHint { inner: unsafe { ( (&(*item) as *const _) as *mut _) }, is_owned: false } }); };
1652         local_ret.into()
1653 }
1654
1655 /// Returns the currency for which the invoice was issued
1656 #[must_use]
1657 #[no_mangle]
1658 pub extern "C" fn Invoice_currency(this_arg: &Invoice) -> crate::lightning_invoice::Currency {
1659         let mut ret = unsafe { &*this_arg.inner }.currency();
1660         crate::lightning_invoice::Currency::native_into(ret)
1661 }
1662
1663 /// Returns the amount if specified in the invoice as pico <currency>.
1664 #[must_use]
1665 #[no_mangle]
1666 pub extern "C" fn Invoice_amount_pico_btc(this_arg: &Invoice) -> crate::c_types::derived::COption_u64Z {
1667         let mut ret = unsafe { &*this_arg.inner }.amount_pico_btc();
1668         let mut local_ret = if ret.is_none() { crate::c_types::derived::COption_u64Z::None } else {  { crate::c_types::derived::COption_u64Z::Some(ret.unwrap()) } };
1669         local_ret
1670 }
1671
1672 /// Creates a new `Description` if `description` is at most 1023 __bytes__ long,
1673 /// returns `CreationError::DescriptionTooLong` otherwise
1674 ///
1675 /// Please note that single characters may use more than one byte due to UTF8 encoding.
1676 #[must_use]
1677 #[no_mangle]
1678 pub extern "C" fn Description_new(mut description: crate::c_types::Str) -> crate::c_types::derived::CResult_DescriptionCreationErrorZ {
1679         let mut ret = lightning_invoice::Description::new(description.into_string());
1680         let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning_invoice::Description { inner: Box::into_raw(Box::new(o)), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning_invoice::CreationError::native_into(e) }).into() };
1681         local_ret
1682 }
1683
1684 /// Returns the underlying description `String`
1685 #[must_use]
1686 #[no_mangle]
1687 pub extern "C" fn Description_into_inner(mut this_arg: Description) -> crate::c_types::Str {
1688         let mut ret = (*unsafe { Box::from_raw(this_arg.take_inner()) }).into_inner();
1689         ret.into()
1690 }
1691
1692 /// Construct an `ExpiryTime` from seconds. If there exists a `PositiveTimestamp` which would
1693 /// overflow on adding the `EpiryTime` to it then this function will return a
1694 /// `CreationError::ExpiryTimeOutOfBounds`.
1695 #[must_use]
1696 #[no_mangle]
1697 pub extern "C" fn ExpiryTime_from_seconds(mut seconds: u64) -> crate::c_types::derived::CResult_ExpiryTimeCreationErrorZ {
1698         let mut ret = lightning_invoice::ExpiryTime::from_seconds(seconds);
1699         let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning_invoice::ExpiryTime { inner: Box::into_raw(Box::new(o)), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning_invoice::CreationError::native_into(e) }).into() };
1700         local_ret
1701 }
1702
1703 /// Construct an `ExpiryTime` from a `Duration`. If there exists a `PositiveTimestamp` which
1704 /// would overflow on adding the `EpiryTime` to it then this function will return a
1705 /// `CreationError::ExpiryTimeOutOfBounds`.
1706 #[must_use]
1707 #[no_mangle]
1708 pub extern "C" fn ExpiryTime_from_duration(mut duration: u64) -> crate::c_types::derived::CResult_ExpiryTimeCreationErrorZ {
1709         let mut ret = lightning_invoice::ExpiryTime::from_duration(std::time::Duration::from_secs(duration));
1710         let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning_invoice::ExpiryTime { inner: Box::into_raw(Box::new(o)), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning_invoice::CreationError::native_into(e) }).into() };
1711         local_ret
1712 }
1713
1714 /// Returns the expiry time in seconds
1715 #[must_use]
1716 #[no_mangle]
1717 pub extern "C" fn ExpiryTime_as_seconds(this_arg: &ExpiryTime) -> u64 {
1718         let mut ret = unsafe { &*this_arg.inner }.as_seconds();
1719         ret
1720 }
1721
1722 /// Returns a reference to the underlying `Duration` (=expiry time)
1723 #[must_use]
1724 #[no_mangle]
1725 pub extern "C" fn ExpiryTime_as_duration(this_arg: &ExpiryTime) -> u64 {
1726         let mut ret = unsafe { &*this_arg.inner }.as_duration();
1727         ret.as_secs()
1728 }
1729
1730 /// Creates a new (partial) route from a list of hops
1731 #[must_use]
1732 #[no_mangle]
1733 pub extern "C" fn PrivateRoute_new(mut hops: crate::lightning::routing::router::RouteHint) -> crate::c_types::derived::CResult_PrivateRouteCreationErrorZ {
1734         let mut ret = lightning_invoice::PrivateRoute::new(*unsafe { Box::from_raw(hops.take_inner()) });
1735         let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning_invoice::PrivateRoute { inner: Box::into_raw(Box::new(o)), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning_invoice::CreationError::native_into(e) }).into() };
1736         local_ret
1737 }
1738
1739 /// Returns the underlying list of hops
1740 #[must_use]
1741 #[no_mangle]
1742 pub extern "C" fn PrivateRoute_into_inner(mut this_arg: PrivateRoute) -> crate::lightning::routing::router::RouteHint {
1743         let mut ret = (*unsafe { Box::from_raw(this_arg.take_inner()) }).into_inner();
1744         crate::lightning::routing::router::RouteHint { inner: Box::into_raw(Box::new(ret)), is_owned: true }
1745 }
1746
1747 /// Errors that may occur when constructing a new `RawInvoice` or `Invoice`
1748 #[must_use]
1749 #[derive(Clone)]
1750 #[repr(C)]
1751 pub enum CreationError {
1752         /// The supplied description string was longer than 639 __bytes__ (see [`Description::new(…)`](./struct.Description.html#method.new))
1753         DescriptionTooLong,
1754         /// The specified route has too many hops and can't be encoded
1755         RouteTooLong,
1756         /// The unix timestamp of the supplied date is <0 or can't be represented as `SystemTime`
1757         TimestampOutOfBounds,
1758         /// The supplied expiry time could cause an overflow if added to a `PositiveTimestamp`
1759         ExpiryTimeOutOfBounds,
1760 }
1761 use lightning_invoice::CreationError as nativeCreationError;
1762 impl CreationError {
1763         #[allow(unused)]
1764         pub(crate) fn to_native(&self) -> nativeCreationError {
1765                 match self {
1766                         CreationError::DescriptionTooLong => nativeCreationError::DescriptionTooLong,
1767                         CreationError::RouteTooLong => nativeCreationError::RouteTooLong,
1768                         CreationError::TimestampOutOfBounds => nativeCreationError::TimestampOutOfBounds,
1769                         CreationError::ExpiryTimeOutOfBounds => nativeCreationError::ExpiryTimeOutOfBounds,
1770                 }
1771         }
1772         #[allow(unused)]
1773         pub(crate) fn into_native(self) -> nativeCreationError {
1774                 match self {
1775                         CreationError::DescriptionTooLong => nativeCreationError::DescriptionTooLong,
1776                         CreationError::RouteTooLong => nativeCreationError::RouteTooLong,
1777                         CreationError::TimestampOutOfBounds => nativeCreationError::TimestampOutOfBounds,
1778                         CreationError::ExpiryTimeOutOfBounds => nativeCreationError::ExpiryTimeOutOfBounds,
1779                 }
1780         }
1781         #[allow(unused)]
1782         pub(crate) fn from_native(native: &nativeCreationError) -> Self {
1783                 match native {
1784                         nativeCreationError::DescriptionTooLong => CreationError::DescriptionTooLong,
1785                         nativeCreationError::RouteTooLong => CreationError::RouteTooLong,
1786                         nativeCreationError::TimestampOutOfBounds => CreationError::TimestampOutOfBounds,
1787                         nativeCreationError::ExpiryTimeOutOfBounds => CreationError::ExpiryTimeOutOfBounds,
1788                 }
1789         }
1790         #[allow(unused)]
1791         pub(crate) fn native_into(native: nativeCreationError) -> Self {
1792                 match native {
1793                         nativeCreationError::DescriptionTooLong => CreationError::DescriptionTooLong,
1794                         nativeCreationError::RouteTooLong => CreationError::RouteTooLong,
1795                         nativeCreationError::TimestampOutOfBounds => CreationError::TimestampOutOfBounds,
1796                         nativeCreationError::ExpiryTimeOutOfBounds => CreationError::ExpiryTimeOutOfBounds,
1797                 }
1798         }
1799 }
1800 /// Creates a copy of the CreationError
1801 #[no_mangle]
1802 pub extern "C" fn CreationError_clone(orig: &CreationError) -> CreationError {
1803         orig.clone()
1804 }
1805 /// Checks if two CreationErrors contain equal inner contents.
1806 /// This ignores pointers and is_owned flags and looks at the values in fields.
1807 #[no_mangle]
1808 pub extern "C" fn CreationError_eq(a: &CreationError, b: &CreationError) -> bool {
1809         if &a.to_native() == &b.to_native() { true } else { false }
1810 }
1811 #[no_mangle]
1812 /// Get the string representation of a CreationError object
1813 pub extern "C" fn CreationError_to_str(o: &crate::lightning_invoice::CreationError) -> Str {
1814         format!("{}", &o.to_native()).into()
1815 }
1816 /// Errors that may occur when converting a `RawInvoice` to an `Invoice`. They relate to the
1817 /// requirements sections in BOLT #11
1818 #[must_use]
1819 #[derive(Clone)]
1820 #[repr(C)]
1821 pub enum SemanticError {
1822         /// The invoice is missing the mandatory payment hash
1823         NoPaymentHash,
1824         /// The invoice has multiple payment hashes which isn't allowed
1825         MultiplePaymentHashes,
1826         /// No description or description hash are part of the invoice
1827         NoDescription,
1828         /// The invoice contains multiple descriptions and/or description hashes which isn't allowed
1829         MultipleDescriptions,
1830         /// The invoice contains multiple payment secrets
1831         MultiplePaymentSecrets,
1832         /// The invoice's features are invalid
1833         InvalidFeatures,
1834         /// The recovery id doesn't fit the signature/pub key
1835         InvalidRecoveryId,
1836         /// The invoice's signature is invalid
1837         InvalidSignature,
1838 }
1839 use lightning_invoice::SemanticError as nativeSemanticError;
1840 impl SemanticError {
1841         #[allow(unused)]
1842         pub(crate) fn to_native(&self) -> nativeSemanticError {
1843                 match self {
1844                         SemanticError::NoPaymentHash => nativeSemanticError::NoPaymentHash,
1845                         SemanticError::MultiplePaymentHashes => nativeSemanticError::MultiplePaymentHashes,
1846                         SemanticError::NoDescription => nativeSemanticError::NoDescription,
1847                         SemanticError::MultipleDescriptions => nativeSemanticError::MultipleDescriptions,
1848                         SemanticError::MultiplePaymentSecrets => nativeSemanticError::MultiplePaymentSecrets,
1849                         SemanticError::InvalidFeatures => nativeSemanticError::InvalidFeatures,
1850                         SemanticError::InvalidRecoveryId => nativeSemanticError::InvalidRecoveryId,
1851                         SemanticError::InvalidSignature => nativeSemanticError::InvalidSignature,
1852                 }
1853         }
1854         #[allow(unused)]
1855         pub(crate) fn into_native(self) -> nativeSemanticError {
1856                 match self {
1857                         SemanticError::NoPaymentHash => nativeSemanticError::NoPaymentHash,
1858                         SemanticError::MultiplePaymentHashes => nativeSemanticError::MultiplePaymentHashes,
1859                         SemanticError::NoDescription => nativeSemanticError::NoDescription,
1860                         SemanticError::MultipleDescriptions => nativeSemanticError::MultipleDescriptions,
1861                         SemanticError::MultiplePaymentSecrets => nativeSemanticError::MultiplePaymentSecrets,
1862                         SemanticError::InvalidFeatures => nativeSemanticError::InvalidFeatures,
1863                         SemanticError::InvalidRecoveryId => nativeSemanticError::InvalidRecoveryId,
1864                         SemanticError::InvalidSignature => nativeSemanticError::InvalidSignature,
1865                 }
1866         }
1867         #[allow(unused)]
1868         pub(crate) fn from_native(native: &nativeSemanticError) -> Self {
1869                 match native {
1870                         nativeSemanticError::NoPaymentHash => SemanticError::NoPaymentHash,
1871                         nativeSemanticError::MultiplePaymentHashes => SemanticError::MultiplePaymentHashes,
1872                         nativeSemanticError::NoDescription => SemanticError::NoDescription,
1873                         nativeSemanticError::MultipleDescriptions => SemanticError::MultipleDescriptions,
1874                         nativeSemanticError::MultiplePaymentSecrets => SemanticError::MultiplePaymentSecrets,
1875                         nativeSemanticError::InvalidFeatures => SemanticError::InvalidFeatures,
1876                         nativeSemanticError::InvalidRecoveryId => SemanticError::InvalidRecoveryId,
1877                         nativeSemanticError::InvalidSignature => SemanticError::InvalidSignature,
1878                 }
1879         }
1880         #[allow(unused)]
1881         pub(crate) fn native_into(native: nativeSemanticError) -> Self {
1882                 match native {
1883                         nativeSemanticError::NoPaymentHash => SemanticError::NoPaymentHash,
1884                         nativeSemanticError::MultiplePaymentHashes => SemanticError::MultiplePaymentHashes,
1885                         nativeSemanticError::NoDescription => SemanticError::NoDescription,
1886                         nativeSemanticError::MultipleDescriptions => SemanticError::MultipleDescriptions,
1887                         nativeSemanticError::MultiplePaymentSecrets => SemanticError::MultiplePaymentSecrets,
1888                         nativeSemanticError::InvalidFeatures => SemanticError::InvalidFeatures,
1889                         nativeSemanticError::InvalidRecoveryId => SemanticError::InvalidRecoveryId,
1890                         nativeSemanticError::InvalidSignature => SemanticError::InvalidSignature,
1891                 }
1892         }
1893 }
1894 /// Creates a copy of the SemanticError
1895 #[no_mangle]
1896 pub extern "C" fn SemanticError_clone(orig: &SemanticError) -> SemanticError {
1897         orig.clone()
1898 }
1899 /// Checks if two SemanticErrors contain equal inner contents.
1900 /// This ignores pointers and is_owned flags and looks at the values in fields.
1901 #[no_mangle]
1902 pub extern "C" fn SemanticError_eq(a: &SemanticError, b: &SemanticError) -> bool {
1903         if &a.to_native() == &b.to_native() { true } else { false }
1904 }
1905 #[no_mangle]
1906 /// Get the string representation of a SemanticError object
1907 pub extern "C" fn SemanticError_to_str(o: &crate::lightning_invoice::SemanticError) -> Str {
1908         format!("{}", &o.to_native()).into()
1909 }
1910 /// When signing using a fallible method either an user-supplied `SignError` or a `CreationError`
1911 /// may occur.
1912 #[must_use]
1913 #[derive(Clone)]
1914 #[repr(C)]
1915 pub enum SignOrCreationError {
1916         /// An error occurred during signing
1917         SignError,
1918         /// An error occurred while building the transaction
1919         CreationError(crate::lightning_invoice::CreationError),
1920 }
1921 use lightning_invoice::SignOrCreationError as nativeSignOrCreationError;
1922 impl SignOrCreationError {
1923         #[allow(unused)]
1924         pub(crate) fn to_native(&self) -> nativeSignOrCreationError {
1925                 match self {
1926                         SignOrCreationError::SignError => {
1927                                 nativeSignOrCreationError::SignError (
1928                                         () /*a_nonref*/,
1929                                 )
1930                         },
1931                         SignOrCreationError::CreationError (ref a, ) => {
1932                                 let mut a_nonref = (*a).clone();
1933                                 nativeSignOrCreationError::CreationError (
1934                                         a_nonref.into_native(),
1935                                 )
1936                         },
1937                 }
1938         }
1939         #[allow(unused)]
1940         pub(crate) fn into_native(self) -> nativeSignOrCreationError {
1941                 match self {
1942                         SignOrCreationError::SignError => {
1943                                 nativeSignOrCreationError::SignError (
1944                                         () /*a*/,
1945                                 )
1946                         },
1947                         SignOrCreationError::CreationError (mut a, ) => {
1948                                 nativeSignOrCreationError::CreationError (
1949                                         a.into_native(),
1950                                 )
1951                         },
1952                 }
1953         }
1954         #[allow(unused)]
1955         pub(crate) fn from_native(native: &nativeSignOrCreationError) -> Self {
1956                 match native {
1957                         nativeSignOrCreationError::SignError (ref a, ) => {
1958                                 SignOrCreationError::SignError                  },
1959                         nativeSignOrCreationError::CreationError (ref a, ) => {
1960                                 let mut a_nonref = (*a).clone();
1961                                 SignOrCreationError::CreationError (
1962                                         crate::lightning_invoice::CreationError::native_into(a_nonref),
1963                                 )
1964                         },
1965                 }
1966         }
1967         #[allow(unused)]
1968         pub(crate) fn native_into(native: nativeSignOrCreationError) -> Self {
1969                 match native {
1970                         nativeSignOrCreationError::SignError (mut a, ) => {
1971                                 SignOrCreationError::SignError                  },
1972                         nativeSignOrCreationError::CreationError (mut a, ) => {
1973                                 SignOrCreationError::CreationError (
1974                                         crate::lightning_invoice::CreationError::native_into(a),
1975                                 )
1976                         },
1977                 }
1978         }
1979 }
1980 /// Frees any resources used by the SignOrCreationError
1981 #[no_mangle]
1982 pub extern "C" fn SignOrCreationError_free(this_ptr: SignOrCreationError) { }
1983 /// Creates a copy of the SignOrCreationError
1984 #[no_mangle]
1985 pub extern "C" fn SignOrCreationError_clone(orig: &SignOrCreationError) -> SignOrCreationError {
1986         orig.clone()
1987 }
1988 /// Checks if two SignOrCreationErrors contain equal inner contents.
1989 /// This ignores pointers and is_owned flags and looks at the values in fields.
1990 #[no_mangle]
1991 pub extern "C" fn SignOrCreationError_eq(a: &SignOrCreationError, b: &SignOrCreationError) -> bool {
1992         if &a.to_native() == &b.to_native() { true } else { false }
1993 }
1994 #[no_mangle]
1995 /// Get the string representation of a SignOrCreationError object
1996 pub extern "C" fn SignOrCreationError_to_str(o: &crate::lightning_invoice::SignOrCreationError) -> Str {
1997         format!("{}", &o.to_native()).into()
1998 }