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