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