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