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