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