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