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