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