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