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