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