Merge pull request #27 from TheBlueMatt/main
[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
621         Simnet,
622         /// Bitcoin signet
623         Signet,
624 }
625 use lightning_invoice::Currency as nativeCurrency;
626 impl Currency {
627         #[allow(unused)]
628         pub(crate) fn to_native(&self) -> nativeCurrency {
629                 match self {
630                         Currency::Bitcoin => nativeCurrency::Bitcoin,
631                         Currency::BitcoinTestnet => nativeCurrency::BitcoinTestnet,
632                         Currency::Regtest => nativeCurrency::Regtest,
633                         Currency::Simnet => nativeCurrency::Simnet,
634                         Currency::Signet => nativeCurrency::Signet,
635                 }
636         }
637         #[allow(unused)]
638         pub(crate) fn into_native(self) -> nativeCurrency {
639                 match self {
640                         Currency::Bitcoin => nativeCurrency::Bitcoin,
641                         Currency::BitcoinTestnet => nativeCurrency::BitcoinTestnet,
642                         Currency::Regtest => nativeCurrency::Regtest,
643                         Currency::Simnet => nativeCurrency::Simnet,
644                         Currency::Signet => nativeCurrency::Signet,
645                 }
646         }
647         #[allow(unused)]
648         pub(crate) fn from_native(native: &nativeCurrency) -> Self {
649                 match native {
650                         nativeCurrency::Bitcoin => Currency::Bitcoin,
651                         nativeCurrency::BitcoinTestnet => Currency::BitcoinTestnet,
652                         nativeCurrency::Regtest => Currency::Regtest,
653                         nativeCurrency::Simnet => Currency::Simnet,
654                         nativeCurrency::Signet => Currency::Signet,
655                 }
656         }
657         #[allow(unused)]
658         pub(crate) fn native_into(native: nativeCurrency) -> Self {
659                 match native {
660                         nativeCurrency::Bitcoin => Currency::Bitcoin,
661                         nativeCurrency::BitcoinTestnet => Currency::BitcoinTestnet,
662                         nativeCurrency::Regtest => Currency::Regtest,
663                         nativeCurrency::Simnet => Currency::Simnet,
664                         nativeCurrency::Signet => Currency::Signet,
665                 }
666         }
667 }
668 /// Creates a copy of the Currency
669 #[no_mangle]
670 pub extern "C" fn Currency_clone(orig: &Currency) -> Currency {
671         orig.clone()
672 }
673 /// Checks if two Currencys contain equal inner contents.
674 /// This ignores pointers and is_owned flags and looks at the values in fields.
675 #[no_mangle]
676 pub extern "C" fn Currency_eq(a: &Currency, b: &Currency) -> bool {
677         if &a.to_native() == &b.to_native() { true } else { false }
678 }
679
680 use lightning_invoice::Sha256 as nativeSha256Import;
681 type nativeSha256 = nativeSha256Import;
682
683 /// SHA-256 hash
684 #[must_use]
685 #[repr(C)]
686 pub struct Sha256 {
687         /// A pointer to the opaque Rust object.
688
689         /// Nearly everywhere, inner must be non-null, however in places where
690         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
691         pub inner: *mut nativeSha256,
692         /// Indicates that this is the only struct which contains the same pointer.
693
694         /// Rust functions which take ownership of an object provided via an argument require
695         /// this to be true and invalidate the object pointed to by inner.
696         pub is_owned: bool,
697 }
698
699 impl Drop for Sha256 {
700         fn drop(&mut self) {
701                 if self.is_owned && !<*mut nativeSha256>::is_null(self.inner) {
702                         let _ = unsafe { Box::from_raw(self.inner) };
703                 }
704         }
705 }
706 /// Frees any resources used by the Sha256, if is_owned is set and inner is non-NULL.
707 #[no_mangle]
708 pub extern "C" fn Sha256_free(this_obj: Sha256) { }
709 #[allow(unused)]
710 /// Used only if an object of this type is returned as a trait impl by a method
711 extern "C" fn Sha256_free_void(this_ptr: *mut c_void) {
712         unsafe { let _ = Box::from_raw(this_ptr as *mut nativeSha256); }
713 }
714 #[allow(unused)]
715 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
716 impl Sha256 {
717         pub(crate) fn take_inner(mut self) -> *mut nativeSha256 {
718                 assert!(self.is_owned);
719                 let ret = self.inner;
720                 self.inner = std::ptr::null_mut();
721                 ret
722         }
723 }
724 /// Checks if two Sha256s contain equal inner contents.
725 /// This ignores pointers and is_owned flags and looks at the values in fields.
726 /// Two objects with NULL inner values will be considered "equal" here.
727 #[no_mangle]
728 pub extern "C" fn Sha256_eq(a: &Sha256, b: &Sha256) -> bool {
729         if a.inner == b.inner { return true; }
730         if a.inner.is_null() || b.inner.is_null() { return false; }
731         if unsafe { &*a.inner } == unsafe { &*b.inner } { true } else { false }
732 }
733 impl Clone for Sha256 {
734         fn clone(&self) -> Self {
735                 Self {
736                         inner: if <*mut nativeSha256>::is_null(self.inner) { std::ptr::null_mut() } else {
737                                 Box::into_raw(Box::new(unsafe { &*self.inner }.clone())) },
738                         is_owned: true,
739                 }
740         }
741 }
742 #[allow(unused)]
743 /// Used only if an object of this type is returned as a trait impl by a method
744 pub(crate) extern "C" fn Sha256_clone_void(this_ptr: *const c_void) -> *mut c_void {
745         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeSha256)).clone() })) as *mut c_void
746 }
747 #[no_mangle]
748 /// Creates a copy of the Sha256
749 pub extern "C" fn Sha256_clone(orig: &Sha256) -> Sha256 {
750         orig.clone()
751 }
752
753 use lightning_invoice::Description as nativeDescriptionImport;
754 type nativeDescription = nativeDescriptionImport;
755
756 /// Description string
757 ///
758 /// # Invariants
759 /// The description can be at most 639 __bytes__ long
760 #[must_use]
761 #[repr(C)]
762 pub struct Description {
763         /// A pointer to the opaque Rust object.
764
765         /// Nearly everywhere, inner must be non-null, however in places where
766         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
767         pub inner: *mut nativeDescription,
768         /// Indicates that this is the only struct which contains the same pointer.
769
770         /// Rust functions which take ownership of an object provided via an argument require
771         /// this to be true and invalidate the object pointed to by inner.
772         pub is_owned: bool,
773 }
774
775 impl Drop for Description {
776         fn drop(&mut self) {
777                 if self.is_owned && !<*mut nativeDescription>::is_null(self.inner) {
778                         let _ = unsafe { Box::from_raw(self.inner) };
779                 }
780         }
781 }
782 /// Frees any resources used by the Description, if is_owned is set and inner is non-NULL.
783 #[no_mangle]
784 pub extern "C" fn Description_free(this_obj: Description) { }
785 #[allow(unused)]
786 /// Used only if an object of this type is returned as a trait impl by a method
787 extern "C" fn Description_free_void(this_ptr: *mut c_void) {
788         unsafe { let _ = Box::from_raw(this_ptr as *mut nativeDescription); }
789 }
790 #[allow(unused)]
791 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
792 impl Description {
793         pub(crate) fn take_inner(mut self) -> *mut nativeDescription {
794                 assert!(self.is_owned);
795                 let ret = self.inner;
796                 self.inner = std::ptr::null_mut();
797                 ret
798         }
799 }
800 /// Checks if two Descriptions contain equal inner contents.
801 /// This ignores pointers and is_owned flags and looks at the values in fields.
802 /// Two objects with NULL inner values will be considered "equal" here.
803 #[no_mangle]
804 pub extern "C" fn Description_eq(a: &Description, b: &Description) -> bool {
805         if a.inner == b.inner { return true; }
806         if a.inner.is_null() || b.inner.is_null() { return false; }
807         if unsafe { &*a.inner } == unsafe { &*b.inner } { true } else { false }
808 }
809 impl Clone for Description {
810         fn clone(&self) -> Self {
811                 Self {
812                         inner: if <*mut nativeDescription>::is_null(self.inner) { std::ptr::null_mut() } else {
813                                 Box::into_raw(Box::new(unsafe { &*self.inner }.clone())) },
814                         is_owned: true,
815                 }
816         }
817 }
818 #[allow(unused)]
819 /// Used only if an object of this type is returned as a trait impl by a method
820 pub(crate) extern "C" fn Description_clone_void(this_ptr: *const c_void) -> *mut c_void {
821         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeDescription)).clone() })) as *mut c_void
822 }
823 #[no_mangle]
824 /// Creates a copy of the Description
825 pub extern "C" fn Description_clone(orig: &Description) -> Description {
826         orig.clone()
827 }
828
829 use lightning_invoice::PayeePubKey as nativePayeePubKeyImport;
830 type nativePayeePubKey = nativePayeePubKeyImport;
831
832 /// Payee public key
833 #[must_use]
834 #[repr(C)]
835 pub struct PayeePubKey {
836         /// A pointer to the opaque Rust object.
837
838         /// Nearly everywhere, inner must be non-null, however in places where
839         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
840         pub inner: *mut nativePayeePubKey,
841         /// Indicates that this is the only struct which contains the same pointer.
842
843         /// Rust functions which take ownership of an object provided via an argument require
844         /// this to be true and invalidate the object pointed to by inner.
845         pub is_owned: bool,
846 }
847
848 impl Drop for PayeePubKey {
849         fn drop(&mut self) {
850                 if self.is_owned && !<*mut nativePayeePubKey>::is_null(self.inner) {
851                         let _ = unsafe { Box::from_raw(self.inner) };
852                 }
853         }
854 }
855 /// Frees any resources used by the PayeePubKey, if is_owned is set and inner is non-NULL.
856 #[no_mangle]
857 pub extern "C" fn PayeePubKey_free(this_obj: PayeePubKey) { }
858 #[allow(unused)]
859 /// Used only if an object of this type is returned as a trait impl by a method
860 extern "C" fn PayeePubKey_free_void(this_ptr: *mut c_void) {
861         unsafe { let _ = Box::from_raw(this_ptr as *mut nativePayeePubKey); }
862 }
863 #[allow(unused)]
864 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
865 impl PayeePubKey {
866         pub(crate) fn take_inner(mut self) -> *mut nativePayeePubKey {
867                 assert!(self.is_owned);
868                 let ret = self.inner;
869                 self.inner = std::ptr::null_mut();
870                 ret
871         }
872 }
873 /// Checks if two PayeePubKeys contain equal inner contents.
874 /// This ignores pointers and is_owned flags and looks at the values in fields.
875 /// Two objects with NULL inner values will be considered "equal" here.
876 #[no_mangle]
877 pub extern "C" fn PayeePubKey_eq(a: &PayeePubKey, b: &PayeePubKey) -> bool {
878         if a.inner == b.inner { return true; }
879         if a.inner.is_null() || b.inner.is_null() { return false; }
880         if unsafe { &*a.inner } == unsafe { &*b.inner } { true } else { false }
881 }
882 impl Clone for PayeePubKey {
883         fn clone(&self) -> Self {
884                 Self {
885                         inner: if <*mut nativePayeePubKey>::is_null(self.inner) { std::ptr::null_mut() } else {
886                                 Box::into_raw(Box::new(unsafe { &*self.inner }.clone())) },
887                         is_owned: true,
888                 }
889         }
890 }
891 #[allow(unused)]
892 /// Used only if an object of this type is returned as a trait impl by a method
893 pub(crate) extern "C" fn PayeePubKey_clone_void(this_ptr: *const c_void) -> *mut c_void {
894         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativePayeePubKey)).clone() })) as *mut c_void
895 }
896 #[no_mangle]
897 /// Creates a copy of the PayeePubKey
898 pub extern "C" fn PayeePubKey_clone(orig: &PayeePubKey) -> PayeePubKey {
899         orig.clone()
900 }
901
902 use lightning_invoice::ExpiryTime as nativeExpiryTimeImport;
903 type nativeExpiryTime = nativeExpiryTimeImport;
904
905 /// Positive duration that defines when (relatively to the timestamp) in the future the invoice
906 /// expires
907 ///
908 /// # Invariants
909 /// The number of seconds this expiry time represents has to be in the range
910 /// `0...(SYSTEM_TIME_MAX_UNIX_TIMESTAMP - MAX_EXPIRY_TIME)` to avoid overflows when adding it to a
911 /// timestamp
912 #[must_use]
913 #[repr(C)]
914 pub struct ExpiryTime {
915         /// A pointer to the opaque Rust object.
916
917         /// Nearly everywhere, inner must be non-null, however in places where
918         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
919         pub inner: *mut nativeExpiryTime,
920         /// Indicates that this is the only struct which contains the same pointer.
921
922         /// Rust functions which take ownership of an object provided via an argument require
923         /// this to be true and invalidate the object pointed to by inner.
924         pub is_owned: bool,
925 }
926
927 impl Drop for ExpiryTime {
928         fn drop(&mut self) {
929                 if self.is_owned && !<*mut nativeExpiryTime>::is_null(self.inner) {
930                         let _ = unsafe { Box::from_raw(self.inner) };
931                 }
932         }
933 }
934 /// Frees any resources used by the ExpiryTime, if is_owned is set and inner is non-NULL.
935 #[no_mangle]
936 pub extern "C" fn ExpiryTime_free(this_obj: ExpiryTime) { }
937 #[allow(unused)]
938 /// Used only if an object of this type is returned as a trait impl by a method
939 extern "C" fn ExpiryTime_free_void(this_ptr: *mut c_void) {
940         unsafe { let _ = Box::from_raw(this_ptr as *mut nativeExpiryTime); }
941 }
942 #[allow(unused)]
943 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
944 impl ExpiryTime {
945         pub(crate) fn take_inner(mut self) -> *mut nativeExpiryTime {
946                 assert!(self.is_owned);
947                 let ret = self.inner;
948                 self.inner = std::ptr::null_mut();
949                 ret
950         }
951 }
952 /// Checks if two ExpiryTimes contain equal inner contents.
953 /// This ignores pointers and is_owned flags and looks at the values in fields.
954 /// Two objects with NULL inner values will be considered "equal" here.
955 #[no_mangle]
956 pub extern "C" fn ExpiryTime_eq(a: &ExpiryTime, b: &ExpiryTime) -> bool {
957         if a.inner == b.inner { return true; }
958         if a.inner.is_null() || b.inner.is_null() { return false; }
959         if unsafe { &*a.inner } == unsafe { &*b.inner } { true } else { false }
960 }
961 impl Clone for ExpiryTime {
962         fn clone(&self) -> Self {
963                 Self {
964                         inner: if <*mut nativeExpiryTime>::is_null(self.inner) { std::ptr::null_mut() } else {
965                                 Box::into_raw(Box::new(unsafe { &*self.inner }.clone())) },
966                         is_owned: true,
967                 }
968         }
969 }
970 #[allow(unused)]
971 /// Used only if an object of this type is returned as a trait impl by a method
972 pub(crate) extern "C" fn ExpiryTime_clone_void(this_ptr: *const c_void) -> *mut c_void {
973         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeExpiryTime)).clone() })) as *mut c_void
974 }
975 #[no_mangle]
976 /// Creates a copy of the ExpiryTime
977 pub extern "C" fn ExpiryTime_clone(orig: &ExpiryTime) -> ExpiryTime {
978         orig.clone()
979 }
980
981 use lightning_invoice::MinFinalCltvExpiry as nativeMinFinalCltvExpiryImport;
982 type nativeMinFinalCltvExpiry = nativeMinFinalCltvExpiryImport;
983
984 /// `min_final_cltv_expiry` to use for the last HTLC in the route
985 #[must_use]
986 #[repr(C)]
987 pub struct MinFinalCltvExpiry {
988         /// A pointer to the opaque Rust object.
989
990         /// Nearly everywhere, inner must be non-null, however in places where
991         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
992         pub inner: *mut nativeMinFinalCltvExpiry,
993         /// Indicates that this is the only struct which contains the same pointer.
994
995         /// Rust functions which take ownership of an object provided via an argument require
996         /// this to be true and invalidate the object pointed to by inner.
997         pub is_owned: bool,
998 }
999
1000 impl Drop for MinFinalCltvExpiry {
1001         fn drop(&mut self) {
1002                 if self.is_owned && !<*mut nativeMinFinalCltvExpiry>::is_null(self.inner) {
1003                         let _ = unsafe { Box::from_raw(self.inner) };
1004                 }
1005         }
1006 }
1007 /// Frees any resources used by the MinFinalCltvExpiry, if is_owned is set and inner is non-NULL.
1008 #[no_mangle]
1009 pub extern "C" fn MinFinalCltvExpiry_free(this_obj: MinFinalCltvExpiry) { }
1010 #[allow(unused)]
1011 /// Used only if an object of this type is returned as a trait impl by a method
1012 extern "C" fn MinFinalCltvExpiry_free_void(this_ptr: *mut c_void) {
1013         unsafe { let _ = Box::from_raw(this_ptr as *mut nativeMinFinalCltvExpiry); }
1014 }
1015 #[allow(unused)]
1016 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
1017 impl MinFinalCltvExpiry {
1018         pub(crate) fn take_inner(mut self) -> *mut nativeMinFinalCltvExpiry {
1019                 assert!(self.is_owned);
1020                 let ret = self.inner;
1021                 self.inner = std::ptr::null_mut();
1022                 ret
1023         }
1024 }
1025 /// Checks if two MinFinalCltvExpirys contain equal inner contents.
1026 /// This ignores pointers and is_owned flags and looks at the values in fields.
1027 /// Two objects with NULL inner values will be considered "equal" here.
1028 #[no_mangle]
1029 pub extern "C" fn MinFinalCltvExpiry_eq(a: &MinFinalCltvExpiry, b: &MinFinalCltvExpiry) -> bool {
1030         if a.inner == b.inner { return true; }
1031         if a.inner.is_null() || b.inner.is_null() { return false; }
1032         if unsafe { &*a.inner } == unsafe { &*b.inner } { true } else { false }
1033 }
1034 impl Clone for MinFinalCltvExpiry {
1035         fn clone(&self) -> Self {
1036                 Self {
1037                         inner: if <*mut nativeMinFinalCltvExpiry>::is_null(self.inner) { std::ptr::null_mut() } else {
1038                                 Box::into_raw(Box::new(unsafe { &*self.inner }.clone())) },
1039                         is_owned: true,
1040                 }
1041         }
1042 }
1043 #[allow(unused)]
1044 /// Used only if an object of this type is returned as a trait impl by a method
1045 pub(crate) extern "C" fn MinFinalCltvExpiry_clone_void(this_ptr: *const c_void) -> *mut c_void {
1046         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeMinFinalCltvExpiry)).clone() })) as *mut c_void
1047 }
1048 #[no_mangle]
1049 /// Creates a copy of the MinFinalCltvExpiry
1050 pub extern "C" fn MinFinalCltvExpiry_clone(orig: &MinFinalCltvExpiry) -> MinFinalCltvExpiry {
1051         orig.clone()
1052 }
1053 /// Fallback address in case no LN payment is possible
1054 #[must_use]
1055 #[derive(Clone)]
1056 #[repr(C)]
1057 pub enum Fallback {
1058         SegWitProgram {
1059                 version: crate::c_types::u5,
1060                 program: crate::c_types::derived::CVec_u8Z,
1061         },
1062         PubKeyHash(crate::c_types::TwentyBytes),
1063         ScriptHash(crate::c_types::TwentyBytes),
1064 }
1065 use lightning_invoice::Fallback as nativeFallback;
1066 impl Fallback {
1067         #[allow(unused)]
1068         pub(crate) fn to_native(&self) -> nativeFallback {
1069                 match self {
1070                         Fallback::SegWitProgram {ref version, ref program, } => {
1071                                 let mut version_nonref = (*version).clone();
1072                                 let mut program_nonref = (*program).clone();
1073                                 let mut local_program_nonref = Vec::new(); for mut item in program_nonref.into_rust().drain(..) { local_program_nonref.push( { item }); };
1074                                 nativeFallback::SegWitProgram {
1075                                         version: version_nonref.into(),
1076                                         program: local_program_nonref,
1077                                 }
1078                         },
1079                         Fallback::PubKeyHash (ref a, ) => {
1080                                 let mut a_nonref = (*a).clone();
1081                                 nativeFallback::PubKeyHash (
1082                                         a_nonref.data,
1083                                 )
1084                         },
1085                         Fallback::ScriptHash (ref a, ) => {
1086                                 let mut a_nonref = (*a).clone();
1087                                 nativeFallback::ScriptHash (
1088                                         a_nonref.data,
1089                                 )
1090                         },
1091                 }
1092         }
1093         #[allow(unused)]
1094         pub(crate) fn into_native(self) -> nativeFallback {
1095                 match self {
1096                         Fallback::SegWitProgram {mut version, mut program, } => {
1097                                 let mut local_program = Vec::new(); for mut item in program.into_rust().drain(..) { local_program.push( { item }); };
1098                                 nativeFallback::SegWitProgram {
1099                                         version: version.into(),
1100                                         program: local_program,
1101                                 }
1102                         },
1103                         Fallback::PubKeyHash (mut a, ) => {
1104                                 nativeFallback::PubKeyHash (
1105                                         a.data,
1106                                 )
1107                         },
1108                         Fallback::ScriptHash (mut a, ) => {
1109                                 nativeFallback::ScriptHash (
1110                                         a.data,
1111                                 )
1112                         },
1113                 }
1114         }
1115         #[allow(unused)]
1116         pub(crate) fn from_native(native: &nativeFallback) -> Self {
1117                 match native {
1118                         nativeFallback::SegWitProgram {ref version, ref program, } => {
1119                                 let mut version_nonref = (*version).clone();
1120                                 let mut program_nonref = (*program).clone();
1121                                 let mut local_program_nonref = Vec::new(); for mut item in program_nonref.drain(..) { local_program_nonref.push( { item }); };
1122                                 Fallback::SegWitProgram {
1123                                         version: version_nonref.into(),
1124                                         program: local_program_nonref.into(),
1125                                 }
1126                         },
1127                         nativeFallback::PubKeyHash (ref a, ) => {
1128                                 let mut a_nonref = (*a).clone();
1129                                 Fallback::PubKeyHash (
1130                                         crate::c_types::TwentyBytes { data: a_nonref },
1131                                 )
1132                         },
1133                         nativeFallback::ScriptHash (ref a, ) => {
1134                                 let mut a_nonref = (*a).clone();
1135                                 Fallback::ScriptHash (
1136                                         crate::c_types::TwentyBytes { data: a_nonref },
1137                                 )
1138                         },
1139                 }
1140         }
1141         #[allow(unused)]
1142         pub(crate) fn native_into(native: nativeFallback) -> Self {
1143                 match native {
1144                         nativeFallback::SegWitProgram {mut version, mut program, } => {
1145                                 let mut local_program = Vec::new(); for mut item in program.drain(..) { local_program.push( { item }); };
1146                                 Fallback::SegWitProgram {
1147                                         version: version.into(),
1148                                         program: local_program.into(),
1149                                 }
1150                         },
1151                         nativeFallback::PubKeyHash (mut a, ) => {
1152                                 Fallback::PubKeyHash (
1153                                         crate::c_types::TwentyBytes { data: a },
1154                                 )
1155                         },
1156                         nativeFallback::ScriptHash (mut a, ) => {
1157                                 Fallback::ScriptHash (
1158                                         crate::c_types::TwentyBytes { data: a },
1159                                 )
1160                         },
1161                 }
1162         }
1163 }
1164 /// Frees any resources used by the Fallback
1165 #[no_mangle]
1166 pub extern "C" fn Fallback_free(this_ptr: Fallback) { }
1167 /// Creates a copy of the Fallback
1168 #[no_mangle]
1169 pub extern "C" fn Fallback_clone(orig: &Fallback) -> Fallback {
1170         orig.clone()
1171 }
1172 /// Checks if two Fallbacks contain equal inner contents.
1173 /// This ignores pointers and is_owned flags and looks at the values in fields.
1174 #[no_mangle]
1175 pub extern "C" fn Fallback_eq(a: &Fallback, b: &Fallback) -> bool {
1176         if &a.to_native() == &b.to_native() { true } else { false }
1177 }
1178
1179 use lightning_invoice::InvoiceSignature as nativeInvoiceSignatureImport;
1180 type nativeInvoiceSignature = nativeInvoiceSignatureImport;
1181
1182 /// Recoverable signature
1183 #[must_use]
1184 #[repr(C)]
1185 pub struct InvoiceSignature {
1186         /// A pointer to the opaque Rust object.
1187
1188         /// Nearly everywhere, inner must be non-null, however in places where
1189         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
1190         pub inner: *mut nativeInvoiceSignature,
1191         /// Indicates that this is the only struct which contains the same pointer.
1192
1193         /// Rust functions which take ownership of an object provided via an argument require
1194         /// this to be true and invalidate the object pointed to by inner.
1195         pub is_owned: bool,
1196 }
1197
1198 impl Drop for InvoiceSignature {
1199         fn drop(&mut self) {
1200                 if self.is_owned && !<*mut nativeInvoiceSignature>::is_null(self.inner) {
1201                         let _ = unsafe { Box::from_raw(self.inner) };
1202                 }
1203         }
1204 }
1205 /// Frees any resources used by the InvoiceSignature, if is_owned is set and inner is non-NULL.
1206 #[no_mangle]
1207 pub extern "C" fn InvoiceSignature_free(this_obj: InvoiceSignature) { }
1208 #[allow(unused)]
1209 /// Used only if an object of this type is returned as a trait impl by a method
1210 extern "C" fn InvoiceSignature_free_void(this_ptr: *mut c_void) {
1211         unsafe { let _ = Box::from_raw(this_ptr as *mut nativeInvoiceSignature); }
1212 }
1213 #[allow(unused)]
1214 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
1215 impl InvoiceSignature {
1216         pub(crate) fn take_inner(mut self) -> *mut nativeInvoiceSignature {
1217                 assert!(self.is_owned);
1218                 let ret = self.inner;
1219                 self.inner = std::ptr::null_mut();
1220                 ret
1221         }
1222 }
1223 /// Checks if two InvoiceSignatures contain equal inner contents.
1224 /// This ignores pointers and is_owned flags and looks at the values in fields.
1225 /// Two objects with NULL inner values will be considered "equal" here.
1226 #[no_mangle]
1227 pub extern "C" fn InvoiceSignature_eq(a: &InvoiceSignature, b: &InvoiceSignature) -> bool {
1228         if a.inner == b.inner { return true; }
1229         if a.inner.is_null() || b.inner.is_null() { return false; }
1230         if unsafe { &*a.inner } == unsafe { &*b.inner } { true } else { false }
1231 }
1232 impl Clone for InvoiceSignature {
1233         fn clone(&self) -> Self {
1234                 Self {
1235                         inner: if <*mut nativeInvoiceSignature>::is_null(self.inner) { std::ptr::null_mut() } else {
1236                                 Box::into_raw(Box::new(unsafe { &*self.inner }.clone())) },
1237                         is_owned: true,
1238                 }
1239         }
1240 }
1241 #[allow(unused)]
1242 /// Used only if an object of this type is returned as a trait impl by a method
1243 pub(crate) extern "C" fn InvoiceSignature_clone_void(this_ptr: *const c_void) -> *mut c_void {
1244         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeInvoiceSignature)).clone() })) as *mut c_void
1245 }
1246 #[no_mangle]
1247 /// Creates a copy of the InvoiceSignature
1248 pub extern "C" fn InvoiceSignature_clone(orig: &InvoiceSignature) -> InvoiceSignature {
1249         orig.clone()
1250 }
1251
1252 use lightning_invoice::RouteHint as nativeRouteHintImport;
1253 type nativeRouteHint = nativeRouteHintImport;
1254
1255 /// Private routing information
1256 ///
1257 /// # Invariants
1258 /// The encoded route has to be <1024 5bit characters long (<=639 bytes or <=12 hops)
1259 ///
1260 #[must_use]
1261 #[repr(C)]
1262 pub struct RouteHint {
1263         /// A pointer to the opaque Rust object.
1264
1265         /// Nearly everywhere, inner must be non-null, however in places where
1266         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
1267         pub inner: *mut nativeRouteHint,
1268         /// Indicates that this is the only struct which contains the same pointer.
1269
1270         /// Rust functions which take ownership of an object provided via an argument require
1271         /// this to be true and invalidate the object pointed to by inner.
1272         pub is_owned: bool,
1273 }
1274
1275 impl Drop for RouteHint {
1276         fn drop(&mut self) {
1277                 if self.is_owned && !<*mut nativeRouteHint>::is_null(self.inner) {
1278                         let _ = unsafe { Box::from_raw(self.inner) };
1279                 }
1280         }
1281 }
1282 /// Frees any resources used by the RouteHint, if is_owned is set and inner is non-NULL.
1283 #[no_mangle]
1284 pub extern "C" fn RouteHint_free(this_obj: RouteHint) { }
1285 #[allow(unused)]
1286 /// Used only if an object of this type is returned as a trait impl by a method
1287 extern "C" fn RouteHint_free_void(this_ptr: *mut c_void) {
1288         unsafe { let _ = Box::from_raw(this_ptr as *mut nativeRouteHint); }
1289 }
1290 #[allow(unused)]
1291 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
1292 impl RouteHint {
1293         pub(crate) fn take_inner(mut self) -> *mut nativeRouteHint {
1294                 assert!(self.is_owned);
1295                 let ret = self.inner;
1296                 self.inner = std::ptr::null_mut();
1297                 ret
1298         }
1299 }
1300 /// Checks if two RouteHints contain equal inner contents.
1301 /// This ignores pointers and is_owned flags and looks at the values in fields.
1302 /// Two objects with NULL inner values will be considered "equal" here.
1303 #[no_mangle]
1304 pub extern "C" fn RouteHint_eq(a: &RouteHint, b: &RouteHint) -> bool {
1305         if a.inner == b.inner { return true; }
1306         if a.inner.is_null() || b.inner.is_null() { return false; }
1307         if unsafe { &*a.inner } == unsafe { &*b.inner } { true } else { false }
1308 }
1309 impl Clone for RouteHint {
1310         fn clone(&self) -> Self {
1311                 Self {
1312                         inner: if <*mut nativeRouteHint>::is_null(self.inner) { std::ptr::null_mut() } else {
1313                                 Box::into_raw(Box::new(unsafe { &*self.inner }.clone())) },
1314                         is_owned: true,
1315                 }
1316         }
1317 }
1318 #[allow(unused)]
1319 /// Used only if an object of this type is returned as a trait impl by a method
1320 pub(crate) extern "C" fn RouteHint_clone_void(this_ptr: *const c_void) -> *mut c_void {
1321         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeRouteHint)).clone() })) as *mut c_void
1322 }
1323 #[no_mangle]
1324 /// Creates a copy of the RouteHint
1325 pub extern "C" fn RouteHint_clone(orig: &RouteHint) -> RouteHint {
1326         orig.clone()
1327 }
1328 /// Disassembles the `SignedRawInvoice` into its three parts:
1329 ///  1. raw invoice
1330 ///  2. hash of the raw invoice
1331 ///  3. signature
1332 #[must_use]
1333 #[no_mangle]
1334 pub extern "C" fn SignedRawInvoice_into_parts(mut this_arg: SignedRawInvoice) -> crate::c_types::derived::C3Tuple_RawInvoice_u832InvoiceSignatureZ {
1335         let mut ret = (*unsafe { Box::from_raw(this_arg.take_inner()) }).into_parts();
1336         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();
1337         local_ret
1338 }
1339
1340 /// The `RawInvoice` which was signed.
1341 #[must_use]
1342 #[no_mangle]
1343 pub extern "C" fn SignedRawInvoice_raw_invoice(this_arg: &SignedRawInvoice) -> crate::lightning_invoice::RawInvoice {
1344         let mut ret = unsafe { &*this_arg.inner }.raw_invoice();
1345         crate::lightning_invoice::RawInvoice { inner: unsafe { ( (&(*ret) as *const _) as *mut _) }, is_owned: false }
1346 }
1347
1348 /// The hash of the `RawInvoice` that was signed.
1349 #[must_use]
1350 #[no_mangle]
1351 pub extern "C" fn SignedRawInvoice_hash(this_arg: &SignedRawInvoice) -> *const [u8; 32] {
1352         let mut ret = unsafe { &*this_arg.inner }.hash();
1353         ret
1354 }
1355
1356 /// InvoiceSignature for the invoice.
1357 #[must_use]
1358 #[no_mangle]
1359 pub extern "C" fn SignedRawInvoice_signature(this_arg: &SignedRawInvoice) -> crate::lightning_invoice::InvoiceSignature {
1360         let mut ret = unsafe { &*this_arg.inner }.signature();
1361         crate::lightning_invoice::InvoiceSignature { inner: unsafe { ( (&(*ret) as *const _) as *mut _) }, is_owned: false }
1362 }
1363
1364 /// Recovers the public key used for signing the invoice from the recoverable signature.
1365 #[must_use]
1366 #[no_mangle]
1367 pub extern "C" fn SignedRawInvoice_recover_payee_pub_key(this_arg: &SignedRawInvoice) -> crate::c_types::derived::CResult_PayeePubKeyErrorZ {
1368         let mut ret = unsafe { &*this_arg.inner }.recover_payee_pub_key();
1369         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() };
1370         local_ret
1371 }
1372
1373 /// Checks if the signature is valid for the included payee public key or if none exists if it's
1374 /// valid for the recovered signature (which should always be true?).
1375 #[must_use]
1376 #[no_mangle]
1377 pub extern "C" fn SignedRawInvoice_check_signature(this_arg: &SignedRawInvoice) -> bool {
1378         let mut ret = unsafe { &*this_arg.inner }.check_signature();
1379         ret
1380 }
1381
1382 /// Calculate the hash of the encoded `RawInvoice`
1383 #[must_use]
1384 #[no_mangle]
1385 pub extern "C" fn RawInvoice_hash(this_arg: &RawInvoice) -> crate::c_types::ThirtyTwoBytes {
1386         let mut ret = unsafe { &*this_arg.inner }.hash();
1387         crate::c_types::ThirtyTwoBytes { data: ret }
1388 }
1389
1390 #[must_use]
1391 #[no_mangle]
1392 pub extern "C" fn RawInvoice_payment_hash(this_arg: &RawInvoice) -> crate::lightning_invoice::Sha256 {
1393         let mut ret = unsafe { &*this_arg.inner }.payment_hash();
1394         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 };
1395         local_ret
1396 }
1397
1398 #[must_use]
1399 #[no_mangle]
1400 pub extern "C" fn RawInvoice_description(this_arg: &RawInvoice) -> crate::lightning_invoice::Description {
1401         let mut ret = unsafe { &*this_arg.inner }.description();
1402         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 };
1403         local_ret
1404 }
1405
1406 #[must_use]
1407 #[no_mangle]
1408 pub extern "C" fn RawInvoice_payee_pub_key(this_arg: &RawInvoice) -> crate::lightning_invoice::PayeePubKey {
1409         let mut ret = unsafe { &*this_arg.inner }.payee_pub_key();
1410         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 };
1411         local_ret
1412 }
1413
1414 #[must_use]
1415 #[no_mangle]
1416 pub extern "C" fn RawInvoice_description_hash(this_arg: &RawInvoice) -> crate::lightning_invoice::Sha256 {
1417         let mut ret = unsafe { &*this_arg.inner }.description_hash();
1418         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 };
1419         local_ret
1420 }
1421
1422 #[must_use]
1423 #[no_mangle]
1424 pub extern "C" fn RawInvoice_expiry_time(this_arg: &RawInvoice) -> crate::lightning_invoice::ExpiryTime {
1425         let mut ret = unsafe { &*this_arg.inner }.expiry_time();
1426         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 };
1427         local_ret
1428 }
1429
1430 #[must_use]
1431 #[no_mangle]
1432 pub extern "C" fn RawInvoice_min_final_cltv_expiry(this_arg: &RawInvoice) -> crate::lightning_invoice::MinFinalCltvExpiry {
1433         let mut ret = unsafe { &*this_arg.inner }.min_final_cltv_expiry();
1434         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 };
1435         local_ret
1436 }
1437
1438 #[must_use]
1439 #[no_mangle]
1440 pub extern "C" fn RawInvoice_payment_secret(this_arg: &RawInvoice) -> crate::c_types::ThirtyTwoBytes {
1441         let mut ret = unsafe { &*this_arg.inner }.payment_secret();
1442         let mut local_ret = if ret.is_none() { crate::c_types::ThirtyTwoBytes::null() } else {  { crate::c_types::ThirtyTwoBytes { data: (ret.unwrap()).0 } } };
1443         local_ret
1444 }
1445
1446 #[must_use]
1447 #[no_mangle]
1448 pub extern "C" fn RawInvoice_features(this_arg: &RawInvoice) -> crate::lightning::ln::features::InvoiceFeatures {
1449         let mut ret = unsafe { &*this_arg.inner }.features();
1450         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 };
1451         local_ret
1452 }
1453
1454 #[must_use]
1455 #[no_mangle]
1456 pub extern "C" fn RawInvoice_routes(this_arg: &RawInvoice) -> crate::c_types::derived::CVec_RouteHintZ {
1457         let mut ret = unsafe { &*this_arg.inner }.routes();
1458         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 } }); };
1459         local_ret.into()
1460 }
1461
1462 #[must_use]
1463 #[no_mangle]
1464 pub extern "C" fn RawInvoice_amount_pico_btc(this_arg: &RawInvoice) -> crate::c_types::derived::COption_u64Z {
1465         let mut ret = unsafe { &*this_arg.inner }.amount_pico_btc();
1466         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()) } };
1467         local_ret
1468 }
1469
1470 #[must_use]
1471 #[no_mangle]
1472 pub extern "C" fn RawInvoice_currency(this_arg: &RawInvoice) -> crate::lightning_invoice::Currency {
1473         let mut ret = unsafe { &*this_arg.inner }.currency();
1474         crate::lightning_invoice::Currency::native_into(ret)
1475 }
1476
1477 /// Create a new `PositiveTimestamp` from a unix timestamp in the Range
1478 /// `0...SYSTEM_TIME_MAX_UNIX_TIMESTAMP - MAX_EXPIRY_TIME`, otherwise return a
1479 /// `CreationError::TimestampOutOfBounds`.
1480 #[must_use]
1481 #[no_mangle]
1482 pub extern "C" fn PositiveTimestamp_from_unix_timestamp(mut unix_seconds: u64) -> crate::c_types::derived::CResult_PositiveTimestampCreationErrorZ {
1483         let mut ret = lightning_invoice::PositiveTimestamp::from_unix_timestamp(unix_seconds);
1484         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() };
1485         local_ret
1486 }
1487
1488 /// Create a new `PositiveTimestamp` from a `SystemTime` with a corresponding unix timestamp in
1489 /// the Range `0...SYSTEM_TIME_MAX_UNIX_TIMESTAMP - MAX_EXPIRY_TIME`, otherwise return a
1490 /// `CreationError::TimestampOutOfBounds`.
1491 #[must_use]
1492 #[no_mangle]
1493 pub extern "C" fn PositiveTimestamp_from_system_time(mut time: u64) -> crate::c_types::derived::CResult_PositiveTimestampCreationErrorZ {
1494         let mut ret = lightning_invoice::PositiveTimestamp::from_system_time((::std::time::SystemTime::UNIX_EPOCH + std::time::Duration::from_secs(time)));
1495         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() };
1496         local_ret
1497 }
1498
1499 /// Returns the UNIX timestamp representing the stored time
1500 #[must_use]
1501 #[no_mangle]
1502 pub extern "C" fn PositiveTimestamp_as_unix_timestamp(this_arg: &PositiveTimestamp) -> u64 {
1503         let mut ret = unsafe { &*this_arg.inner }.as_unix_timestamp();
1504         ret
1505 }
1506
1507 /// Returns a reference to the internal `SystemTime` time representation
1508 #[must_use]
1509 #[no_mangle]
1510 pub extern "C" fn PositiveTimestamp_as_time(this_arg: &PositiveTimestamp) -> u64 {
1511         let mut ret = unsafe { &*this_arg.inner }.as_time();
1512         ret.duration_since(::std::time::SystemTime::UNIX_EPOCH).expect("Times must be post-1970").as_secs()
1513 }
1514
1515 /// Transform the `Invoice` into it's unchecked version
1516 #[must_use]
1517 #[no_mangle]
1518 pub extern "C" fn Invoice_into_signed_raw(mut this_arg: Invoice) -> crate::lightning_invoice::SignedRawInvoice {
1519         let mut ret = (*unsafe { Box::from_raw(this_arg.take_inner()) }).into_signed_raw();
1520         crate::lightning_invoice::SignedRawInvoice { inner: Box::into_raw(Box::new(ret)), is_owned: true }
1521 }
1522
1523 /// Check that the invoice is signed correctly and that key recovery works
1524 #[must_use]
1525 #[no_mangle]
1526 pub extern "C" fn Invoice_check_signature(this_arg: &Invoice) -> crate::c_types::derived::CResult_NoneSemanticErrorZ {
1527         let mut ret = unsafe { &*this_arg.inner }.check_signature();
1528         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() };
1529         local_ret
1530 }
1531
1532 /// Constructs an `Invoice` from a `SignedInvoice` by checking all its invariants.
1533 /// ```
1534 /// use lightning_invoice::*;
1535 ///
1536 /// let invoice = \"lnbc1pvjluezpp5qqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqypqdp\\
1537 /// \tl2pkx2ctnv5sxxmmwwd5kgetjypeh2ursdae8g6twvus8g6rfwvs8qun0dfjkxaq8rkx3yf5tcsyz3d7\\
1538 /// \t3gafnh3cax9rn449d9p5uxz9ezhhypd0elx87sjle52x86fux2ypatgddc6k63n7erqz25le42c4u4ec\\
1539 /// \tky03ylcqca784w\";
1540 ///
1541 /// let signed = invoice.parse::<SignedRawInvoice>().unwrap();
1542 ///
1543 /// assert!(Invoice::from_signed(signed).is_ok());
1544 /// ```
1545 #[must_use]
1546 #[no_mangle]
1547 pub extern "C" fn Invoice_from_signed(mut signed_invoice: crate::lightning_invoice::SignedRawInvoice) -> crate::c_types::derived::CResult_InvoiceSemanticErrorZ {
1548         let mut ret = lightning_invoice::Invoice::from_signed(*unsafe { Box::from_raw(signed_invoice.take_inner()) });
1549         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() };
1550         local_ret
1551 }
1552
1553 /// Returns the `Invoice`'s timestamp (should equal it's creation time)
1554 #[must_use]
1555 #[no_mangle]
1556 pub extern "C" fn Invoice_timestamp(this_arg: &Invoice) -> u64 {
1557         let mut ret = unsafe { &*this_arg.inner }.timestamp();
1558         ret.duration_since(::std::time::SystemTime::UNIX_EPOCH).expect("Times must be post-1970").as_secs()
1559 }
1560
1561 /// Returns the hash to which we will receive the preimage on completion of the payment
1562 #[must_use]
1563 #[no_mangle]
1564 pub extern "C" fn Invoice_payment_hash(this_arg: &Invoice) -> *const [u8; 32] {
1565         let mut ret = unsafe { &*this_arg.inner }.payment_hash();
1566         ret.as_inner()
1567 }
1568
1569 /// Get the payee's public key if one was included in the invoice
1570 #[must_use]
1571 #[no_mangle]
1572 pub extern "C" fn Invoice_payee_pub_key(this_arg: &Invoice) -> crate::c_types::PublicKey {
1573         let mut ret = unsafe { &*this_arg.inner }.payee_pub_key();
1574         let mut local_ret = if ret.is_none() { crate::c_types::PublicKey::null() } else {  { crate::c_types::PublicKey::from_rust(&(ret.unwrap())) } };
1575         local_ret
1576 }
1577
1578 /// Get the payment secret if one was included in the invoice
1579 #[must_use]
1580 #[no_mangle]
1581 pub extern "C" fn Invoice_payment_secret(this_arg: &Invoice) -> crate::c_types::ThirtyTwoBytes {
1582         let mut ret = unsafe { &*this_arg.inner }.payment_secret();
1583         let mut local_ret = if ret.is_none() { crate::c_types::ThirtyTwoBytes::null() } else {  { crate::c_types::ThirtyTwoBytes { data: (ret.unwrap()).0 } } };
1584         local_ret
1585 }
1586
1587 /// Get the invoice features if they were included in the invoice
1588 #[must_use]
1589 #[no_mangle]
1590 pub extern "C" fn Invoice_features(this_arg: &Invoice) -> crate::lightning::ln::features::InvoiceFeatures {
1591         let mut ret = unsafe { &*this_arg.inner }.features();
1592         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 };
1593         local_ret
1594 }
1595
1596 /// Recover the payee's public key (only to be used if none was included in the invoice)
1597 #[must_use]
1598 #[no_mangle]
1599 pub extern "C" fn Invoice_recover_payee_pub_key(this_arg: &Invoice) -> crate::c_types::PublicKey {
1600         let mut ret = unsafe { &*this_arg.inner }.recover_payee_pub_key();
1601         crate::c_types::PublicKey::from_rust(&ret)
1602 }
1603
1604 /// Returns the invoice's expiry time, if present, otherwise [`DEFAULT_EXPIRY_TIME`].
1605 #[must_use]
1606 #[no_mangle]
1607 pub extern "C" fn Invoice_expiry_time(this_arg: &Invoice) -> u64 {
1608         let mut ret = unsafe { &*this_arg.inner }.expiry_time();
1609         ret.as_secs()
1610 }
1611
1612 /// Returns the invoice's `min_final_cltv_expiry` time, if present, otherwise
1613 /// [`DEFAULT_MIN_FINAL_CLTV_EXPIRY`].
1614 #[must_use]
1615 #[no_mangle]
1616 pub extern "C" fn Invoice_min_final_cltv_expiry(this_arg: &Invoice) -> u64 {
1617         let mut ret = unsafe { &*this_arg.inner }.min_final_cltv_expiry();
1618         ret
1619 }
1620
1621 /// Returns a list of all routes included in the invoice
1622 #[must_use]
1623 #[no_mangle]
1624 pub extern "C" fn Invoice_routes(this_arg: &Invoice) -> crate::c_types::derived::CVec_RouteHintZ {
1625         let mut ret = unsafe { &*this_arg.inner }.routes();
1626         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 } }); };
1627         local_ret.into()
1628 }
1629
1630 /// Returns the currency for which the invoice was issued
1631 #[must_use]
1632 #[no_mangle]
1633 pub extern "C" fn Invoice_currency(this_arg: &Invoice) -> crate::lightning_invoice::Currency {
1634         let mut ret = unsafe { &*this_arg.inner }.currency();
1635         crate::lightning_invoice::Currency::native_into(ret)
1636 }
1637
1638 /// Returns the amount if specified in the invoice as pico <currency>.
1639 #[must_use]
1640 #[no_mangle]
1641 pub extern "C" fn Invoice_amount_pico_btc(this_arg: &Invoice) -> crate::c_types::derived::COption_u64Z {
1642         let mut ret = unsafe { &*this_arg.inner }.amount_pico_btc();
1643         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()) } };
1644         local_ret
1645 }
1646
1647 /// Creates a new `Description` if `description` is at most 1023 __bytes__ long,
1648 /// returns `CreationError::DescriptionTooLong` otherwise
1649 ///
1650 /// Please note that single characters may use more than one byte due to UTF8 encoding.
1651 #[must_use]
1652 #[no_mangle]
1653 pub extern "C" fn Description_new(mut description: crate::c_types::Str) -> crate::c_types::derived::CResult_DescriptionCreationErrorZ {
1654         let mut ret = lightning_invoice::Description::new(description.into_string());
1655         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() };
1656         local_ret
1657 }
1658
1659 /// Returns the underlying description `String`
1660 #[must_use]
1661 #[no_mangle]
1662 pub extern "C" fn Description_into_inner(mut this_arg: Description) -> crate::c_types::Str {
1663         let mut ret = (*unsafe { Box::from_raw(this_arg.take_inner()) }).into_inner();
1664         ret.into()
1665 }
1666
1667 /// Construct an `ExpiryTime` from seconds. If there exists a `PositiveTimestamp` which would
1668 /// overflow on adding the `EpiryTime` to it then this function will return a
1669 /// `CreationError::ExpiryTimeOutOfBounds`.
1670 #[must_use]
1671 #[no_mangle]
1672 pub extern "C" fn ExpiryTime_from_seconds(mut seconds: u64) -> crate::c_types::derived::CResult_ExpiryTimeCreationErrorZ {
1673         let mut ret = lightning_invoice::ExpiryTime::from_seconds(seconds);
1674         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() };
1675         local_ret
1676 }
1677
1678 /// Construct an `ExpiryTime` from a `Duration`. If there exists a `PositiveTimestamp` which
1679 /// would overflow on adding the `EpiryTime` to it then this function will return a
1680 /// `CreationError::ExpiryTimeOutOfBounds`.
1681 #[must_use]
1682 #[no_mangle]
1683 pub extern "C" fn ExpiryTime_from_duration(mut duration: u64) -> crate::c_types::derived::CResult_ExpiryTimeCreationErrorZ {
1684         let mut ret = lightning_invoice::ExpiryTime::from_duration(std::time::Duration::from_secs(duration));
1685         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() };
1686         local_ret
1687 }
1688
1689 /// Returns the expiry time in seconds
1690 #[must_use]
1691 #[no_mangle]
1692 pub extern "C" fn ExpiryTime_as_seconds(this_arg: &ExpiryTime) -> u64 {
1693         let mut ret = unsafe { &*this_arg.inner }.as_seconds();
1694         ret
1695 }
1696
1697 /// Returns a reference to the underlying `Duration` (=expiry time)
1698 #[must_use]
1699 #[no_mangle]
1700 pub extern "C" fn ExpiryTime_as_duration(this_arg: &ExpiryTime) -> u64 {
1701         let mut ret = unsafe { &*this_arg.inner }.as_duration();
1702         ret.as_secs()
1703 }
1704
1705 /// Create a new (partial) route from a list of hops
1706 #[must_use]
1707 #[no_mangle]
1708 pub extern "C" fn RouteHint_new(mut hops: crate::c_types::derived::CVec_RouteHintHopZ) -> crate::c_types::derived::CResult_RouteHintCreationErrorZ {
1709         let mut local_hops = Vec::new(); for mut item in hops.into_rust().drain(..) { local_hops.push( { *unsafe { Box::from_raw(item.take_inner()) } }); };
1710         let mut ret = lightning_invoice::RouteHint::new(local_hops);
1711         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() };
1712         local_ret
1713 }
1714
1715 /// Returrn the underlying vector of hops
1716 #[must_use]
1717 #[no_mangle]
1718 pub extern "C" fn RouteHint_into_inner(mut this_arg: RouteHint) -> crate::c_types::derived::CVec_RouteHintHopZ {
1719         let mut ret = (*unsafe { Box::from_raw(this_arg.take_inner()) }).into_inner();
1720         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 } }); };
1721         local_ret.into()
1722 }
1723
1724 /// Errors that may occur when constructing a new `RawInvoice` or `Invoice`
1725 #[must_use]
1726 #[derive(Clone)]
1727 #[repr(C)]
1728 pub enum CreationError {
1729         /// The supplied description string was longer than 639 __bytes__ (see [`Description::new(…)`](./struct.Description.html#method.new))
1730         DescriptionTooLong,
1731         /// The specified route has too many hops and can't be encoded
1732         RouteTooLong,
1733         /// The unix timestamp of the supplied date is <0 or can't be represented as `SystemTime`
1734         TimestampOutOfBounds,
1735         /// The supplied expiry time could cause an overflow if added to a `PositiveTimestamp`
1736         ExpiryTimeOutOfBounds,
1737 }
1738 use lightning_invoice::CreationError as nativeCreationError;
1739 impl CreationError {
1740         #[allow(unused)]
1741         pub(crate) fn to_native(&self) -> nativeCreationError {
1742                 match self {
1743                         CreationError::DescriptionTooLong => nativeCreationError::DescriptionTooLong,
1744                         CreationError::RouteTooLong => nativeCreationError::RouteTooLong,
1745                         CreationError::TimestampOutOfBounds => nativeCreationError::TimestampOutOfBounds,
1746                         CreationError::ExpiryTimeOutOfBounds => nativeCreationError::ExpiryTimeOutOfBounds,
1747                 }
1748         }
1749         #[allow(unused)]
1750         pub(crate) fn into_native(self) -> nativeCreationError {
1751                 match self {
1752                         CreationError::DescriptionTooLong => nativeCreationError::DescriptionTooLong,
1753                         CreationError::RouteTooLong => nativeCreationError::RouteTooLong,
1754                         CreationError::TimestampOutOfBounds => nativeCreationError::TimestampOutOfBounds,
1755                         CreationError::ExpiryTimeOutOfBounds => nativeCreationError::ExpiryTimeOutOfBounds,
1756                 }
1757         }
1758         #[allow(unused)]
1759         pub(crate) fn from_native(native: &nativeCreationError) -> Self {
1760                 match native {
1761                         nativeCreationError::DescriptionTooLong => CreationError::DescriptionTooLong,
1762                         nativeCreationError::RouteTooLong => CreationError::RouteTooLong,
1763                         nativeCreationError::TimestampOutOfBounds => CreationError::TimestampOutOfBounds,
1764                         nativeCreationError::ExpiryTimeOutOfBounds => CreationError::ExpiryTimeOutOfBounds,
1765                 }
1766         }
1767         #[allow(unused)]
1768         pub(crate) fn native_into(native: nativeCreationError) -> Self {
1769                 match native {
1770                         nativeCreationError::DescriptionTooLong => CreationError::DescriptionTooLong,
1771                         nativeCreationError::RouteTooLong => CreationError::RouteTooLong,
1772                         nativeCreationError::TimestampOutOfBounds => CreationError::TimestampOutOfBounds,
1773                         nativeCreationError::ExpiryTimeOutOfBounds => CreationError::ExpiryTimeOutOfBounds,
1774                 }
1775         }
1776 }
1777 /// Creates a copy of the CreationError
1778 #[no_mangle]
1779 pub extern "C" fn CreationError_clone(orig: &CreationError) -> CreationError {
1780         orig.clone()
1781 }
1782 /// Checks if two CreationErrors contain equal inner contents.
1783 /// This ignores pointers and is_owned flags and looks at the values in fields.
1784 #[no_mangle]
1785 pub extern "C" fn CreationError_eq(a: &CreationError, b: &CreationError) -> bool {
1786         if &a.to_native() == &b.to_native() { true } else { false }
1787 }
1788 #[no_mangle]
1789 /// Get the string representation of a CreationError object
1790 pub extern "C" fn CreationError_to_str(o: &crate::lightning_invoice::CreationError) -> Str {
1791         format!("{}", &o.to_native()).into()
1792 }
1793 /// Errors that may occur when converting a `RawInvoice` to an `Invoice`. They relate to the
1794 /// requirements sections in BOLT #11
1795 #[must_use]
1796 #[derive(Clone)]
1797 #[repr(C)]
1798 pub enum SemanticError {
1799         /// The invoice is missing the mandatory payment hash
1800         NoPaymentHash,
1801         /// The invoice has multiple payment hashes which isn't allowed
1802         MultiplePaymentHashes,
1803         /// No description or description hash are part of the invoice
1804         NoDescription,
1805         /// The invoice contains multiple descriptions and/or description hashes which isn't allowed
1806         MultipleDescriptions,
1807         /// The invoice contains multiple payment secrets
1808         MultiplePaymentSecrets,
1809         /// The invoice's features are invalid
1810         InvalidFeatures,
1811         /// The recovery id doesn't fit the signature/pub key
1812         InvalidRecoveryId,
1813         /// The invoice's signature is invalid
1814         InvalidSignature,
1815 }
1816 use lightning_invoice::SemanticError as nativeSemanticError;
1817 impl SemanticError {
1818         #[allow(unused)]
1819         pub(crate) fn to_native(&self) -> nativeSemanticError {
1820                 match self {
1821                         SemanticError::NoPaymentHash => nativeSemanticError::NoPaymentHash,
1822                         SemanticError::MultiplePaymentHashes => nativeSemanticError::MultiplePaymentHashes,
1823                         SemanticError::NoDescription => nativeSemanticError::NoDescription,
1824                         SemanticError::MultipleDescriptions => nativeSemanticError::MultipleDescriptions,
1825                         SemanticError::MultiplePaymentSecrets => nativeSemanticError::MultiplePaymentSecrets,
1826                         SemanticError::InvalidFeatures => nativeSemanticError::InvalidFeatures,
1827                         SemanticError::InvalidRecoveryId => nativeSemanticError::InvalidRecoveryId,
1828                         SemanticError::InvalidSignature => nativeSemanticError::InvalidSignature,
1829                 }
1830         }
1831         #[allow(unused)]
1832         pub(crate) fn into_native(self) -> nativeSemanticError {
1833                 match self {
1834                         SemanticError::NoPaymentHash => nativeSemanticError::NoPaymentHash,
1835                         SemanticError::MultiplePaymentHashes => nativeSemanticError::MultiplePaymentHashes,
1836                         SemanticError::NoDescription => nativeSemanticError::NoDescription,
1837                         SemanticError::MultipleDescriptions => nativeSemanticError::MultipleDescriptions,
1838                         SemanticError::MultiplePaymentSecrets => nativeSemanticError::MultiplePaymentSecrets,
1839                         SemanticError::InvalidFeatures => nativeSemanticError::InvalidFeatures,
1840                         SemanticError::InvalidRecoveryId => nativeSemanticError::InvalidRecoveryId,
1841                         SemanticError::InvalidSignature => nativeSemanticError::InvalidSignature,
1842                 }
1843         }
1844         #[allow(unused)]
1845         pub(crate) fn from_native(native: &nativeSemanticError) -> Self {
1846                 match native {
1847                         nativeSemanticError::NoPaymentHash => SemanticError::NoPaymentHash,
1848                         nativeSemanticError::MultiplePaymentHashes => SemanticError::MultiplePaymentHashes,
1849                         nativeSemanticError::NoDescription => SemanticError::NoDescription,
1850                         nativeSemanticError::MultipleDescriptions => SemanticError::MultipleDescriptions,
1851                         nativeSemanticError::MultiplePaymentSecrets => SemanticError::MultiplePaymentSecrets,
1852                         nativeSemanticError::InvalidFeatures => SemanticError::InvalidFeatures,
1853                         nativeSemanticError::InvalidRecoveryId => SemanticError::InvalidRecoveryId,
1854                         nativeSemanticError::InvalidSignature => SemanticError::InvalidSignature,
1855                 }
1856         }
1857         #[allow(unused)]
1858         pub(crate) fn native_into(native: nativeSemanticError) -> Self {
1859                 match native {
1860                         nativeSemanticError::NoPaymentHash => SemanticError::NoPaymentHash,
1861                         nativeSemanticError::MultiplePaymentHashes => SemanticError::MultiplePaymentHashes,
1862                         nativeSemanticError::NoDescription => SemanticError::NoDescription,
1863                         nativeSemanticError::MultipleDescriptions => SemanticError::MultipleDescriptions,
1864                         nativeSemanticError::MultiplePaymentSecrets => SemanticError::MultiplePaymentSecrets,
1865                         nativeSemanticError::InvalidFeatures => SemanticError::InvalidFeatures,
1866                         nativeSemanticError::InvalidRecoveryId => SemanticError::InvalidRecoveryId,
1867                         nativeSemanticError::InvalidSignature => SemanticError::InvalidSignature,
1868                 }
1869         }
1870 }
1871 /// Creates a copy of the SemanticError
1872 #[no_mangle]
1873 pub extern "C" fn SemanticError_clone(orig: &SemanticError) -> SemanticError {
1874         orig.clone()
1875 }
1876 /// Checks if two SemanticErrors contain equal inner contents.
1877 /// This ignores pointers and is_owned flags and looks at the values in fields.
1878 #[no_mangle]
1879 pub extern "C" fn SemanticError_eq(a: &SemanticError, b: &SemanticError) -> bool {
1880         if &a.to_native() == &b.to_native() { true } else { false }
1881 }
1882 #[no_mangle]
1883 /// Get the string representation of a SemanticError object
1884 pub extern "C" fn SemanticError_to_str(o: &crate::lightning_invoice::SemanticError) -> Str {
1885         format!("{}", &o.to_native()).into()
1886 }
1887 /// When signing using a fallible method either an user-supplied `SignError` or a `CreationError`
1888 /// may occur.
1889 #[must_use]
1890 #[derive(Clone)]
1891 #[repr(C)]
1892 pub enum SignOrCreationError {
1893         /// An error occurred during signing
1894         SignError,
1895         /// An error occurred while building the transaction
1896         CreationError(crate::lightning_invoice::CreationError),
1897 }
1898 use lightning_invoice::SignOrCreationError as nativeSignOrCreationError;
1899 impl SignOrCreationError {
1900         #[allow(unused)]
1901         pub(crate) fn to_native(&self) -> nativeSignOrCreationError {
1902                 match self {
1903                         SignOrCreationError::SignError => {
1904                                 nativeSignOrCreationError::SignError (
1905                                         () /*a_nonref*/,
1906                                 )
1907                         },
1908                         SignOrCreationError::CreationError (ref a, ) => {
1909                                 let mut a_nonref = (*a).clone();
1910                                 nativeSignOrCreationError::CreationError (
1911                                         a_nonref.into_native(),
1912                                 )
1913                         },
1914                 }
1915         }
1916         #[allow(unused)]
1917         pub(crate) fn into_native(self) -> nativeSignOrCreationError {
1918                 match self {
1919                         SignOrCreationError::SignError => {
1920                                 nativeSignOrCreationError::SignError (
1921                                         () /*a*/,
1922                                 )
1923                         },
1924                         SignOrCreationError::CreationError (mut a, ) => {
1925                                 nativeSignOrCreationError::CreationError (
1926                                         a.into_native(),
1927                                 )
1928                         },
1929                 }
1930         }
1931         #[allow(unused)]
1932         pub(crate) fn from_native(native: &nativeSignOrCreationError) -> Self {
1933                 match native {
1934                         nativeSignOrCreationError::SignError (ref a, ) => {
1935                                 SignOrCreationError::SignError                  },
1936                         nativeSignOrCreationError::CreationError (ref a, ) => {
1937                                 let mut a_nonref = (*a).clone();
1938                                 SignOrCreationError::CreationError (
1939                                         crate::lightning_invoice::CreationError::native_into(a_nonref),
1940                                 )
1941                         },
1942                 }
1943         }
1944         #[allow(unused)]
1945         pub(crate) fn native_into(native: nativeSignOrCreationError) -> Self {
1946                 match native {
1947                         nativeSignOrCreationError::SignError (mut a, ) => {
1948                                 SignOrCreationError::SignError                  },
1949                         nativeSignOrCreationError::CreationError (mut a, ) => {
1950                                 SignOrCreationError::CreationError (
1951                                         crate::lightning_invoice::CreationError::native_into(a),
1952                                 )
1953                         },
1954                 }
1955         }
1956 }
1957 /// Frees any resources used by the SignOrCreationError
1958 #[no_mangle]
1959 pub extern "C" fn SignOrCreationError_free(this_ptr: SignOrCreationError) { }
1960 /// Creates a copy of the SignOrCreationError
1961 #[no_mangle]
1962 pub extern "C" fn SignOrCreationError_clone(orig: &SignOrCreationError) -> SignOrCreationError {
1963         orig.clone()
1964 }
1965 /// Checks if two SignOrCreationErrors contain equal inner contents.
1966 /// This ignores pointers and is_owned flags and looks at the values in fields.
1967 #[no_mangle]
1968 pub extern "C" fn SignOrCreationError_eq(a: &SignOrCreationError, b: &SignOrCreationError) -> bool {
1969         if &a.to_native() == &b.to_native() { true } else { false }
1970 }
1971 #[no_mangle]
1972 /// Get the string representation of a SignOrCreationError object
1973 pub extern "C" fn SignOrCreationError_to_str(o: &crate::lightning_invoice::SignOrCreationError) -> Str {
1974         format!("{}", &o.to_native()).into()
1975 }