1 // This file is Copyright its original authors, visible in version control
2 // history and in the source files from which this was generated.
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.
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:
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
18 //! [`Bolt11Invoice::from_str`]: crate::Bolt11Invoice#impl-FromStr
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};
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};
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};
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()) {
60 crate::c_types::CResultTempl::ok(
61 crate::lightning_invoice::SiPrefix::native_into(r)
65 crate::c_types::CResultTempl::err(
66 crate::lightning_invoice::Bolt11ParseError::native_into(e)
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()) {
76 crate::c_types::CResultTempl::ok(
77 crate::lightning_invoice::Bolt11Invoice { inner: ObjOps::heap_alloc(r), is_owned: true }
81 crate::c_types::CResultTempl::err(
82 crate::lightning_invoice::ParseOrSemanticError::native_into(e)
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()) {
92 crate::c_types::CResultTempl::ok(
93 crate::lightning_invoice::SignedRawBolt11Invoice { inner: ObjOps::heap_alloc(r), is_owned: true }
97 crate::c_types::CResultTempl::err(
98 crate::lightning_invoice::Bolt11ParseError::native_into(e)
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()
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()
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};
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()
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()
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()
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()
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};
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};
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};
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.
187 pub enum Bolt11ParseError {
189 crate::c_types::Bech32Error),
191 crate::c_types::Error),
193 crate::c_types::Secp256k1Error),
199 UnexpectedEndOfTaggedFields,
200 DescriptionDecodeError(
201 crate::c_types::Error),
203 IntegerOverflowError,
204 InvalidSegWitProgramLength,
205 InvalidPubKeyHashLength,
206 InvalidScriptHashLength,
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
214 use lightning_invoice::Bolt11ParseError as Bolt11ParseErrorImport;
215 pub(crate) type nativeBolt11ParseError = Bolt11ParseErrorImport;
217 impl Bolt11ParseError {
219 pub(crate) fn to_native(&self) -> nativeBolt11ParseError {
221 Bolt11ParseError::Bech32Error (ref a, ) => {
222 let mut a_nonref = Clone::clone(a);
223 nativeBolt11ParseError::Bech32Error (
224 a_nonref.into_rust(),
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*/,
233 Bolt11ParseError::MalformedSignature (ref a, ) => {
234 let mut a_nonref = Clone::clone(a);
235 nativeBolt11ParseError::MalformedSignature (
236 a_nonref.into_rust(),
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*/,
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(),
263 Bolt11ParseError::Skip => nativeBolt11ParseError::Skip,
267 pub(crate) fn into_native(self) -> nativeBolt11ParseError {
269 Bolt11ParseError::Bech32Error (mut a, ) => {
270 nativeBolt11ParseError::Bech32Error (
274 Bolt11ParseError::ParseAmountError (mut a, ) => {
275 nativeBolt11ParseError::ParseAmountError (
276 u8::from_str_radix(" a", 10).unwrap_err() /*a*/,
279 Bolt11ParseError::MalformedSignature (mut a, ) => {
280 nativeBolt11ParseError::MalformedSignature (
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*/,
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 (
306 Bolt11ParseError::Skip => nativeBolt11ParseError::Skip,
310 pub(crate) fn from_native(native: &nativeBolt11ParseError) -> Self {
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),
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*/,
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),
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*/,
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 (
354 nativeBolt11ParseError::Skip => Bolt11ParseError::Skip,
358 pub(crate) fn native_into(native: nativeBolt11ParseError) -> Self {
360 nativeBolt11ParseError::Bech32Error (mut a, ) => {
361 Bolt11ParseError::Bech32Error (
362 crate::c_types::Bech32Error::from_rust(a),
365 nativeBolt11ParseError::ParseAmountError (mut a, ) => {
366 Bolt11ParseError::ParseAmountError (
367 crate::c_types::Error { _dummy: 0 } /*a*/,
370 nativeBolt11ParseError::MalformedSignature (mut a, ) => {
371 Bolt11ParseError::MalformedSignature (
372 crate::c_types::Secp256k1Error::from_rust(a),
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*/,
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 (
397 nativeBolt11ParseError::Skip => Bolt11ParseError::Skip,
401 /// Frees any resources used by the Bolt11ParseError
403 pub extern "C" fn Bolt11ParseError_free(this_ptr: Bolt11ParseError) { }
404 /// Creates a copy of the Bolt11ParseError
406 pub extern "C" fn Bolt11ParseError_clone(orig: &Bolt11ParseError) -> Bolt11ParseError {
410 /// Used only if an object of this type is returned as a trait impl by a method
411 pub(crate) extern "C" fn Bolt11ParseError_clone_void(this_ptr: *const c_void) -> *mut c_void {
412 Box::into_raw(Box::new(unsafe { (*(this_ptr as *const Bolt11ParseError)).clone() })) as *mut c_void
415 /// Used only if an object of this type is returned as a trait impl by a method
416 pub(crate) extern "C" fn Bolt11ParseError_free_void(this_ptr: *mut c_void) {
417 let _ = unsafe { Box::from_raw(this_ptr as *mut Bolt11ParseError) };
420 /// Utility method to constructs a new Bech32Error-variant Bolt11ParseError
421 pub extern "C" fn Bolt11ParseError_bech32_error(a: crate::c_types::Bech32Error) -> Bolt11ParseError {
422 Bolt11ParseError::Bech32Error(a, )
425 /// Utility method to constructs a new ParseAmountError-variant Bolt11ParseError
426 pub extern "C" fn Bolt11ParseError_parse_amount_error(a: crate::c_types::Error) -> Bolt11ParseError {
427 Bolt11ParseError::ParseAmountError(a, )
430 /// Utility method to constructs a new MalformedSignature-variant Bolt11ParseError
431 pub extern "C" fn Bolt11ParseError_malformed_signature(a: crate::c_types::Secp256k1Error) -> Bolt11ParseError {
432 Bolt11ParseError::MalformedSignature(a, )
435 /// Utility method to constructs a new BadPrefix-variant Bolt11ParseError
436 pub extern "C" fn Bolt11ParseError_bad_prefix() -> Bolt11ParseError {
437 Bolt11ParseError::BadPrefix}
439 /// Utility method to constructs a new UnknownCurrency-variant Bolt11ParseError
440 pub extern "C" fn Bolt11ParseError_unknown_currency() -> Bolt11ParseError {
441 Bolt11ParseError::UnknownCurrency}
443 /// Utility method to constructs a new UnknownSiPrefix-variant Bolt11ParseError
444 pub extern "C" fn Bolt11ParseError_unknown_si_prefix() -> Bolt11ParseError {
445 Bolt11ParseError::UnknownSiPrefix}
447 /// Utility method to constructs a new MalformedHRP-variant Bolt11ParseError
448 pub extern "C" fn Bolt11ParseError_malformed_hrp() -> Bolt11ParseError {
449 Bolt11ParseError::MalformedHRP}
451 /// Utility method to constructs a new TooShortDataPart-variant Bolt11ParseError
452 pub extern "C" fn Bolt11ParseError_too_short_data_part() -> Bolt11ParseError {
453 Bolt11ParseError::TooShortDataPart}
455 /// Utility method to constructs a new UnexpectedEndOfTaggedFields-variant Bolt11ParseError
456 pub extern "C" fn Bolt11ParseError_unexpected_end_of_tagged_fields() -> Bolt11ParseError {
457 Bolt11ParseError::UnexpectedEndOfTaggedFields}
459 /// Utility method to constructs a new DescriptionDecodeError-variant Bolt11ParseError
460 pub extern "C" fn Bolt11ParseError_description_decode_error(a: crate::c_types::Error) -> Bolt11ParseError {
461 Bolt11ParseError::DescriptionDecodeError(a, )
464 /// Utility method to constructs a new PaddingError-variant Bolt11ParseError
465 pub extern "C" fn Bolt11ParseError_padding_error() -> Bolt11ParseError {
466 Bolt11ParseError::PaddingError}
468 /// Utility method to constructs a new IntegerOverflowError-variant Bolt11ParseError
469 pub extern "C" fn Bolt11ParseError_integer_overflow_error() -> Bolt11ParseError {
470 Bolt11ParseError::IntegerOverflowError}
472 /// Utility method to constructs a new InvalidSegWitProgramLength-variant Bolt11ParseError
473 pub extern "C" fn Bolt11ParseError_invalid_seg_wit_program_length() -> Bolt11ParseError {
474 Bolt11ParseError::InvalidSegWitProgramLength}
476 /// Utility method to constructs a new InvalidPubKeyHashLength-variant Bolt11ParseError
477 pub extern "C" fn Bolt11ParseError_invalid_pub_key_hash_length() -> Bolt11ParseError {
478 Bolt11ParseError::InvalidPubKeyHashLength}
480 /// Utility method to constructs a new InvalidScriptHashLength-variant Bolt11ParseError
481 pub extern "C" fn Bolt11ParseError_invalid_script_hash_length() -> Bolt11ParseError {
482 Bolt11ParseError::InvalidScriptHashLength}
484 /// Utility method to constructs a new InvalidRecoveryId-variant Bolt11ParseError
485 pub extern "C" fn Bolt11ParseError_invalid_recovery_id() -> Bolt11ParseError {
486 Bolt11ParseError::InvalidRecoveryId}
488 /// Utility method to constructs a new InvalidSliceLength-variant Bolt11ParseError
489 pub extern "C" fn Bolt11ParseError_invalid_slice_length(a: crate::c_types::Str) -> Bolt11ParseError {
490 Bolt11ParseError::InvalidSliceLength(a, )
493 /// Utility method to constructs a new Skip-variant Bolt11ParseError
494 pub extern "C" fn Bolt11ParseError_skip() -> Bolt11ParseError {
495 Bolt11ParseError::Skip}
496 /// Checks if two Bolt11ParseErrors contain equal inner contents.
497 /// This ignores pointers and is_owned flags and looks at the values in fields.
499 pub extern "C" fn Bolt11ParseError_eq(a: &Bolt11ParseError, b: &Bolt11ParseError) -> bool {
500 if &a.to_native() == &b.to_native() { true } else { false }
502 /// Indicates that something went wrong while parsing or validating the invoice. Parsing errors
503 /// should be mostly seen as opaque and are only there for debugging reasons. Semantic errors
504 /// like wrong signatures, missing fields etc. could mean that someone tampered with the invoice.
508 pub enum ParseOrSemanticError {
509 /// The invoice couldn't be decoded
511 crate::lightning_invoice::Bolt11ParseError),
512 /// The invoice could be decoded but violates the BOLT11 standard
514 crate::lightning_invoice::Bolt11SemanticError),
516 use lightning_invoice::ParseOrSemanticError as ParseOrSemanticErrorImport;
517 pub(crate) type nativeParseOrSemanticError = ParseOrSemanticErrorImport;
519 impl ParseOrSemanticError {
521 pub(crate) fn to_native(&self) -> nativeParseOrSemanticError {
523 ParseOrSemanticError::ParseError (ref a, ) => {
524 let mut a_nonref = Clone::clone(a);
525 nativeParseOrSemanticError::ParseError (
526 a_nonref.into_native(),
529 ParseOrSemanticError::SemanticError (ref a, ) => {
530 let mut a_nonref = Clone::clone(a);
531 nativeParseOrSemanticError::SemanticError (
532 a_nonref.into_native(),
538 pub(crate) fn into_native(self) -> nativeParseOrSemanticError {
540 ParseOrSemanticError::ParseError (mut a, ) => {
541 nativeParseOrSemanticError::ParseError (
545 ParseOrSemanticError::SemanticError (mut a, ) => {
546 nativeParseOrSemanticError::SemanticError (
553 pub(crate) fn from_native(native: &nativeParseOrSemanticError) -> Self {
555 nativeParseOrSemanticError::ParseError (ref a, ) => {
556 let mut a_nonref = Clone::clone(a);
557 ParseOrSemanticError::ParseError (
558 crate::lightning_invoice::Bolt11ParseError::native_into(a_nonref),
561 nativeParseOrSemanticError::SemanticError (ref a, ) => {
562 let mut a_nonref = Clone::clone(a);
563 ParseOrSemanticError::SemanticError (
564 crate::lightning_invoice::Bolt11SemanticError::native_into(a_nonref),
570 pub(crate) fn native_into(native: nativeParseOrSemanticError) -> Self {
572 nativeParseOrSemanticError::ParseError (mut a, ) => {
573 ParseOrSemanticError::ParseError (
574 crate::lightning_invoice::Bolt11ParseError::native_into(a),
577 nativeParseOrSemanticError::SemanticError (mut a, ) => {
578 ParseOrSemanticError::SemanticError (
579 crate::lightning_invoice::Bolt11SemanticError::native_into(a),
585 /// Frees any resources used by the ParseOrSemanticError
587 pub extern "C" fn ParseOrSemanticError_free(this_ptr: ParseOrSemanticError) { }
588 /// Creates a copy of the ParseOrSemanticError
590 pub extern "C" fn ParseOrSemanticError_clone(orig: &ParseOrSemanticError) -> ParseOrSemanticError {
594 /// Used only if an object of this type is returned as a trait impl by a method
595 pub(crate) extern "C" fn ParseOrSemanticError_clone_void(this_ptr: *const c_void) -> *mut c_void {
596 Box::into_raw(Box::new(unsafe { (*(this_ptr as *const ParseOrSemanticError)).clone() })) as *mut c_void
599 /// Used only if an object of this type is returned as a trait impl by a method
600 pub(crate) extern "C" fn ParseOrSemanticError_free_void(this_ptr: *mut c_void) {
601 let _ = unsafe { Box::from_raw(this_ptr as *mut ParseOrSemanticError) };
604 /// Utility method to constructs a new ParseError-variant ParseOrSemanticError
605 pub extern "C" fn ParseOrSemanticError_parse_error(a: crate::lightning_invoice::Bolt11ParseError) -> ParseOrSemanticError {
606 ParseOrSemanticError::ParseError(a, )
609 /// Utility method to constructs a new SemanticError-variant ParseOrSemanticError
610 pub extern "C" fn ParseOrSemanticError_semantic_error(a: crate::lightning_invoice::Bolt11SemanticError) -> ParseOrSemanticError {
611 ParseOrSemanticError::SemanticError(a, )
613 /// Checks if two ParseOrSemanticErrors contain equal inner contents.
614 /// This ignores pointers and is_owned flags and looks at the values in fields.
616 pub extern "C" fn ParseOrSemanticError_eq(a: &ParseOrSemanticError, b: &ParseOrSemanticError) -> bool {
617 if &a.to_native() == &b.to_native() { true } else { false }
619 /// The maximum timestamp as [`Duration::as_secs`] since the Unix epoch allowed by [`BOLT 11`].
621 /// [BOLT 11]: https://github.com/lightning/bolts/blob/master/11-payment-encoding.md
624 pub static MAX_TIMESTAMP: u64 = lightning_invoice::MAX_TIMESTAMP;
625 /// Default expiry time as defined by [BOLT 11].
627 /// [BOLT 11]: https://github.com/lightning/bolts/blob/master/11-payment-encoding.md
630 pub static DEFAULT_EXPIRY_TIME: u64 = lightning_invoice::DEFAULT_EXPIRY_TIME;
631 /// Default minimum final CLTV expiry as defined by [BOLT 11].
633 /// Note that this is *not* the same value as rust-lightning's minimum CLTV expiry, which is
634 /// provided in [`MIN_FINAL_CLTV_EXPIRY_DELTA`].
636 /// [BOLT 11]: https://github.com/lightning/bolts/blob/master/11-payment-encoding.md
637 /// [`MIN_FINAL_CLTV_EXPIRY_DELTA`]: lightning::ln::channelmanager::MIN_FINAL_CLTV_EXPIRY_DELTA
640 pub static DEFAULT_MIN_FINAL_CLTV_EXPIRY_DELTA: u64 = lightning_invoice::DEFAULT_MIN_FINAL_CLTV_EXPIRY_DELTA;
642 use lightning_invoice::Bolt11Invoice as nativeBolt11InvoiceImport;
643 pub(crate) type nativeBolt11Invoice = nativeBolt11InvoiceImport;
645 /// Represents a syntactically and semantically correct lightning BOLT11 invoice.
647 /// There are three ways to construct a `Bolt11Invoice`:
648 /// 1. using [`InvoiceBuilder`]
649 /// 2. using [`Bolt11Invoice::from_signed`]
650 /// 3. using `str::parse::<Bolt11Invoice>(&str)` (see [`Bolt11Invoice::from_str`])
652 /// [`Bolt11Invoice::from_str`]: crate::Bolt11Invoice#impl-FromStr
655 pub struct Bolt11Invoice {
656 /// A pointer to the opaque Rust object.
658 /// Nearly everywhere, inner must be non-null, however in places where
659 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
660 pub inner: *mut nativeBolt11Invoice,
661 /// Indicates that this is the only struct which contains the same pointer.
663 /// Rust functions which take ownership of an object provided via an argument require
664 /// this to be true and invalidate the object pointed to by inner.
668 impl Drop for Bolt11Invoice {
670 if self.is_owned && !<*mut nativeBolt11Invoice>::is_null(self.inner) {
671 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
675 /// Frees any resources used by the Bolt11Invoice, if is_owned is set and inner is non-NULL.
677 pub extern "C" fn Bolt11Invoice_free(this_obj: Bolt11Invoice) { }
679 /// Used only if an object of this type is returned as a trait impl by a method
680 pub(crate) extern "C" fn Bolt11Invoice_free_void(this_ptr: *mut c_void) {
681 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeBolt11Invoice) };
685 pub(crate) fn get_native_ref(&self) -> &'static nativeBolt11Invoice {
686 unsafe { &*ObjOps::untweak_ptr(self.inner) }
688 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeBolt11Invoice {
689 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
691 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
692 pub(crate) fn take_inner(mut self) -> *mut nativeBolt11Invoice {
693 assert!(self.is_owned);
694 let ret = ObjOps::untweak_ptr(self.inner);
695 self.inner = core::ptr::null_mut();
699 /// Checks if two Bolt11Invoices contain equal inner contents.
700 /// This ignores pointers and is_owned flags and looks at the values in fields.
701 /// Two objects with NULL inner values will be considered "equal" here.
703 pub extern "C" fn Bolt11Invoice_eq(a: &Bolt11Invoice, b: &Bolt11Invoice) -> bool {
704 if a.inner == b.inner { return true; }
705 if a.inner.is_null() || b.inner.is_null() { return false; }
706 if a.get_native_ref() == b.get_native_ref() { true } else { false }
708 impl Clone for Bolt11Invoice {
709 fn clone(&self) -> Self {
711 inner: if <*mut nativeBolt11Invoice>::is_null(self.inner) { core::ptr::null_mut() } else {
712 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
718 /// Used only if an object of this type is returned as a trait impl by a method
719 pub(crate) extern "C" fn Bolt11Invoice_clone_void(this_ptr: *const c_void) -> *mut c_void {
720 Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeBolt11Invoice)).clone() })) as *mut c_void
723 /// Creates a copy of the Bolt11Invoice
724 pub extern "C" fn Bolt11Invoice_clone(orig: &Bolt11Invoice) -> Bolt11Invoice {
727 /// Generates a non-cryptographic 64-bit hash of the Bolt11Invoice.
729 pub extern "C" fn Bolt11Invoice_hash(o: &Bolt11Invoice) -> u64 {
730 if o.inner.is_null() { return 0; }
731 // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
733 let mut hasher = core::hash::SipHasher::new();
734 core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
735 core::hash::Hasher::finish(&hasher)
738 use lightning_invoice::SignedRawBolt11Invoice as nativeSignedRawBolt11InvoiceImport;
739 pub(crate) type nativeSignedRawBolt11Invoice = nativeSignedRawBolt11InvoiceImport;
741 /// Represents a signed [`RawBolt11Invoice`] with cached hash. The signature is not checked and may be
745 /// The hash has to be either from the deserialized invoice or from the serialized [`RawBolt11Invoice`].
748 pub struct SignedRawBolt11Invoice {
749 /// A pointer to the opaque Rust object.
751 /// Nearly everywhere, inner must be non-null, however in places where
752 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
753 pub inner: *mut nativeSignedRawBolt11Invoice,
754 /// Indicates that this is the only struct which contains the same pointer.
756 /// Rust functions which take ownership of an object provided via an argument require
757 /// this to be true and invalidate the object pointed to by inner.
761 impl Drop for SignedRawBolt11Invoice {
763 if self.is_owned && !<*mut nativeSignedRawBolt11Invoice>::is_null(self.inner) {
764 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
768 /// Frees any resources used by the SignedRawBolt11Invoice, if is_owned is set and inner is non-NULL.
770 pub extern "C" fn SignedRawBolt11Invoice_free(this_obj: SignedRawBolt11Invoice) { }
772 /// Used only if an object of this type is returned as a trait impl by a method
773 pub(crate) extern "C" fn SignedRawBolt11Invoice_free_void(this_ptr: *mut c_void) {
774 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeSignedRawBolt11Invoice) };
777 impl SignedRawBolt11Invoice {
778 pub(crate) fn get_native_ref(&self) -> &'static nativeSignedRawBolt11Invoice {
779 unsafe { &*ObjOps::untweak_ptr(self.inner) }
781 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeSignedRawBolt11Invoice {
782 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
784 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
785 pub(crate) fn take_inner(mut self) -> *mut nativeSignedRawBolt11Invoice {
786 assert!(self.is_owned);
787 let ret = ObjOps::untweak_ptr(self.inner);
788 self.inner = core::ptr::null_mut();
792 /// Checks if two SignedRawBolt11Invoices contain equal inner contents.
793 /// This ignores pointers and is_owned flags and looks at the values in fields.
794 /// Two objects with NULL inner values will be considered "equal" here.
796 pub extern "C" fn SignedRawBolt11Invoice_eq(a: &SignedRawBolt11Invoice, b: &SignedRawBolt11Invoice) -> bool {
797 if a.inner == b.inner { return true; }
798 if a.inner.is_null() || b.inner.is_null() { return false; }
799 if a.get_native_ref() == b.get_native_ref() { true } else { false }
801 impl Clone for SignedRawBolt11Invoice {
802 fn clone(&self) -> Self {
804 inner: if <*mut nativeSignedRawBolt11Invoice>::is_null(self.inner) { core::ptr::null_mut() } else {
805 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
811 /// Used only if an object of this type is returned as a trait impl by a method
812 pub(crate) extern "C" fn SignedRawBolt11Invoice_clone_void(this_ptr: *const c_void) -> *mut c_void {
813 Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeSignedRawBolt11Invoice)).clone() })) as *mut c_void
816 /// Creates a copy of the SignedRawBolt11Invoice
817 pub extern "C" fn SignedRawBolt11Invoice_clone(orig: &SignedRawBolt11Invoice) -> SignedRawBolt11Invoice {
820 /// Generates a non-cryptographic 64-bit hash of the SignedRawBolt11Invoice.
822 pub extern "C" fn SignedRawBolt11Invoice_hash(o: &SignedRawBolt11Invoice) -> u64 {
823 if o.inner.is_null() { return 0; }
824 // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
826 let mut hasher = core::hash::SipHasher::new();
827 core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
828 core::hash::Hasher::finish(&hasher)
831 use lightning_invoice::RawBolt11Invoice as nativeRawBolt11InvoiceImport;
832 pub(crate) type nativeRawBolt11Invoice = nativeRawBolt11InvoiceImport;
834 /// Represents an syntactically correct [`Bolt11Invoice`] for a payment on the lightning network,
835 /// but without the signature information.
836 /// Decoding and encoding should not lead to information loss but may lead to different hashes.
838 /// For methods without docs see the corresponding methods in [`Bolt11Invoice`].
841 pub struct RawBolt11Invoice {
842 /// A pointer to the opaque Rust object.
844 /// Nearly everywhere, inner must be non-null, however in places where
845 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
846 pub inner: *mut nativeRawBolt11Invoice,
847 /// Indicates that this is the only struct which contains the same pointer.
849 /// Rust functions which take ownership of an object provided via an argument require
850 /// this to be true and invalidate the object pointed to by inner.
854 impl Drop for RawBolt11Invoice {
856 if self.is_owned && !<*mut nativeRawBolt11Invoice>::is_null(self.inner) {
857 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
861 /// Frees any resources used by the RawBolt11Invoice, if is_owned is set and inner is non-NULL.
863 pub extern "C" fn RawBolt11Invoice_free(this_obj: RawBolt11Invoice) { }
865 /// Used only if an object of this type is returned as a trait impl by a method
866 pub(crate) extern "C" fn RawBolt11Invoice_free_void(this_ptr: *mut c_void) {
867 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeRawBolt11Invoice) };
870 impl RawBolt11Invoice {
871 pub(crate) fn get_native_ref(&self) -> &'static nativeRawBolt11Invoice {
872 unsafe { &*ObjOps::untweak_ptr(self.inner) }
874 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeRawBolt11Invoice {
875 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
877 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
878 pub(crate) fn take_inner(mut self) -> *mut nativeRawBolt11Invoice {
879 assert!(self.is_owned);
880 let ret = ObjOps::untweak_ptr(self.inner);
881 self.inner = core::ptr::null_mut();
887 pub extern "C" fn RawBolt11Invoice_get_data(this_ptr: &RawBolt11Invoice) -> crate::lightning_invoice::RawDataPart {
888 let mut inner_val = &mut this_ptr.get_native_mut_ref().data;
889 crate::lightning_invoice::RawDataPart { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning_invoice::RawDataPart<>) as *mut _) }, is_owned: false }
893 pub extern "C" fn RawBolt11Invoice_set_data(this_ptr: &mut RawBolt11Invoice, mut val: crate::lightning_invoice::RawDataPart) {
894 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.data = *unsafe { Box::from_raw(val.take_inner()) };
896 /// Checks if two RawBolt11Invoices contain equal inner contents.
897 /// This ignores pointers and is_owned flags and looks at the values in fields.
898 /// Two objects with NULL inner values will be considered "equal" here.
900 pub extern "C" fn RawBolt11Invoice_eq(a: &RawBolt11Invoice, b: &RawBolt11Invoice) -> bool {
901 if a.inner == b.inner { return true; }
902 if a.inner.is_null() || b.inner.is_null() { return false; }
903 if a.get_native_ref() == b.get_native_ref() { true } else { false }
905 impl Clone for RawBolt11Invoice {
906 fn clone(&self) -> Self {
908 inner: if <*mut nativeRawBolt11Invoice>::is_null(self.inner) { core::ptr::null_mut() } else {
909 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
915 /// Used only if an object of this type is returned as a trait impl by a method
916 pub(crate) extern "C" fn RawBolt11Invoice_clone_void(this_ptr: *const c_void) -> *mut c_void {
917 Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeRawBolt11Invoice)).clone() })) as *mut c_void
920 /// Creates a copy of the RawBolt11Invoice
921 pub extern "C" fn RawBolt11Invoice_clone(orig: &RawBolt11Invoice) -> RawBolt11Invoice {
924 /// Generates a non-cryptographic 64-bit hash of the RawBolt11Invoice.
926 pub extern "C" fn RawBolt11Invoice_hash(o: &RawBolt11Invoice) -> u64 {
927 if o.inner.is_null() { return 0; }
928 // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
930 let mut hasher = core::hash::SipHasher::new();
931 core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
932 core::hash::Hasher::finish(&hasher)
935 use lightning_invoice::RawDataPart as nativeRawDataPartImport;
936 pub(crate) type nativeRawDataPart = nativeRawDataPartImport;
938 /// Data of the [`RawBolt11Invoice`] that is encoded in the data part
941 pub struct RawDataPart {
942 /// A pointer to the opaque Rust object.
944 /// Nearly everywhere, inner must be non-null, however in places where
945 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
946 pub inner: *mut nativeRawDataPart,
947 /// Indicates that this is the only struct which contains the same pointer.
949 /// Rust functions which take ownership of an object provided via an argument require
950 /// this to be true and invalidate the object pointed to by inner.
954 impl Drop for RawDataPart {
956 if self.is_owned && !<*mut nativeRawDataPart>::is_null(self.inner) {
957 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
961 /// Frees any resources used by the RawDataPart, if is_owned is set and inner is non-NULL.
963 pub extern "C" fn RawDataPart_free(this_obj: RawDataPart) { }
965 /// Used only if an object of this type is returned as a trait impl by a method
966 pub(crate) extern "C" fn RawDataPart_free_void(this_ptr: *mut c_void) {
967 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeRawDataPart) };
971 pub(crate) fn get_native_ref(&self) -> &'static nativeRawDataPart {
972 unsafe { &*ObjOps::untweak_ptr(self.inner) }
974 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeRawDataPart {
975 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
977 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
978 pub(crate) fn take_inner(mut self) -> *mut nativeRawDataPart {
979 assert!(self.is_owned);
980 let ret = ObjOps::untweak_ptr(self.inner);
981 self.inner = core::ptr::null_mut();
985 /// generation time of the invoice
987 pub extern "C" fn RawDataPart_get_timestamp(this_ptr: &RawDataPart) -> crate::lightning_invoice::PositiveTimestamp {
988 let mut inner_val = &mut this_ptr.get_native_mut_ref().timestamp;
989 crate::lightning_invoice::PositiveTimestamp { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning_invoice::PositiveTimestamp<>) as *mut _) }, is_owned: false }
991 /// generation time of the invoice
993 pub extern "C" fn RawDataPart_set_timestamp(this_ptr: &mut RawDataPart, mut val: crate::lightning_invoice::PositiveTimestamp) {
994 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.timestamp = *unsafe { Box::from_raw(val.take_inner()) };
996 /// Checks if two RawDataParts contain equal inner contents.
997 /// This ignores pointers and is_owned flags and looks at the values in fields.
998 /// Two objects with NULL inner values will be considered "equal" here.
1000 pub extern "C" fn RawDataPart_eq(a: &RawDataPart, b: &RawDataPart) -> bool {
1001 if a.inner == b.inner { return true; }
1002 if a.inner.is_null() || b.inner.is_null() { return false; }
1003 if a.get_native_ref() == b.get_native_ref() { true } else { false }
1005 impl Clone for RawDataPart {
1006 fn clone(&self) -> Self {
1008 inner: if <*mut nativeRawDataPart>::is_null(self.inner) { core::ptr::null_mut() } else {
1009 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
1015 /// Used only if an object of this type is returned as a trait impl by a method
1016 pub(crate) extern "C" fn RawDataPart_clone_void(this_ptr: *const c_void) -> *mut c_void {
1017 Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeRawDataPart)).clone() })) as *mut c_void
1020 /// Creates a copy of the RawDataPart
1021 pub extern "C" fn RawDataPart_clone(orig: &RawDataPart) -> RawDataPart {
1024 /// Generates a non-cryptographic 64-bit hash of the RawDataPart.
1026 pub extern "C" fn RawDataPart_hash(o: &RawDataPart) -> u64 {
1027 if o.inner.is_null() { return 0; }
1028 // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
1029 #[allow(deprecated)]
1030 let mut hasher = core::hash::SipHasher::new();
1031 core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
1032 core::hash::Hasher::finish(&hasher)
1035 use lightning_invoice::PositiveTimestamp as nativePositiveTimestampImport;
1036 pub(crate) type nativePositiveTimestamp = nativePositiveTimestampImport;
1038 /// A timestamp that refers to a date after 1 January 1970.
1042 /// The Unix timestamp representing the stored time has to be positive and no greater than
1043 /// [`MAX_TIMESTAMP`].
1046 pub struct PositiveTimestamp {
1047 /// A pointer to the opaque Rust object.
1049 /// Nearly everywhere, inner must be non-null, however in places where
1050 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
1051 pub inner: *mut nativePositiveTimestamp,
1052 /// Indicates that this is the only struct which contains the same pointer.
1054 /// Rust functions which take ownership of an object provided via an argument require
1055 /// this to be true and invalidate the object pointed to by inner.
1059 impl Drop for PositiveTimestamp {
1060 fn drop(&mut self) {
1061 if self.is_owned && !<*mut nativePositiveTimestamp>::is_null(self.inner) {
1062 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
1066 /// Frees any resources used by the PositiveTimestamp, if is_owned is set and inner is non-NULL.
1068 pub extern "C" fn PositiveTimestamp_free(this_obj: PositiveTimestamp) { }
1070 /// Used only if an object of this type is returned as a trait impl by a method
1071 pub(crate) extern "C" fn PositiveTimestamp_free_void(this_ptr: *mut c_void) {
1072 let _ = unsafe { Box::from_raw(this_ptr as *mut nativePositiveTimestamp) };
1075 impl PositiveTimestamp {
1076 pub(crate) fn get_native_ref(&self) -> &'static nativePositiveTimestamp {
1077 unsafe { &*ObjOps::untweak_ptr(self.inner) }
1079 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativePositiveTimestamp {
1080 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
1082 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
1083 pub(crate) fn take_inner(mut self) -> *mut nativePositiveTimestamp {
1084 assert!(self.is_owned);
1085 let ret = ObjOps::untweak_ptr(self.inner);
1086 self.inner = core::ptr::null_mut();
1090 /// Checks if two PositiveTimestamps contain equal inner contents.
1091 /// This ignores pointers and is_owned flags and looks at the values in fields.
1092 /// Two objects with NULL inner values will be considered "equal" here.
1094 pub extern "C" fn PositiveTimestamp_eq(a: &PositiveTimestamp, b: &PositiveTimestamp) -> bool {
1095 if a.inner == b.inner { return true; }
1096 if a.inner.is_null() || b.inner.is_null() { return false; }
1097 if a.get_native_ref() == b.get_native_ref() { true } else { false }
1099 impl Clone for PositiveTimestamp {
1100 fn clone(&self) -> Self {
1102 inner: if <*mut nativePositiveTimestamp>::is_null(self.inner) { core::ptr::null_mut() } else {
1103 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
1109 /// Used only if an object of this type is returned as a trait impl by a method
1110 pub(crate) extern "C" fn PositiveTimestamp_clone_void(this_ptr: *const c_void) -> *mut c_void {
1111 Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativePositiveTimestamp)).clone() })) as *mut c_void
1114 /// Creates a copy of the PositiveTimestamp
1115 pub extern "C" fn PositiveTimestamp_clone(orig: &PositiveTimestamp) -> PositiveTimestamp {
1118 /// Generates a non-cryptographic 64-bit hash of the PositiveTimestamp.
1120 pub extern "C" fn PositiveTimestamp_hash(o: &PositiveTimestamp) -> u64 {
1121 if o.inner.is_null() { return 0; }
1122 // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
1123 #[allow(deprecated)]
1124 let mut hasher = core::hash::SipHasher::new();
1125 core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
1126 core::hash::Hasher::finish(&hasher)
1128 /// SI prefixes for the human readable part
1142 use lightning_invoice::SiPrefix as SiPrefixImport;
1143 pub(crate) type nativeSiPrefix = SiPrefixImport;
1147 pub(crate) fn to_native(&self) -> nativeSiPrefix {
1149 SiPrefix::Milli => nativeSiPrefix::Milli,
1150 SiPrefix::Micro => nativeSiPrefix::Micro,
1151 SiPrefix::Nano => nativeSiPrefix::Nano,
1152 SiPrefix::Pico => nativeSiPrefix::Pico,
1156 pub(crate) fn into_native(self) -> nativeSiPrefix {
1158 SiPrefix::Milli => nativeSiPrefix::Milli,
1159 SiPrefix::Micro => nativeSiPrefix::Micro,
1160 SiPrefix::Nano => nativeSiPrefix::Nano,
1161 SiPrefix::Pico => nativeSiPrefix::Pico,
1165 pub(crate) fn from_native(native: &nativeSiPrefix) -> Self {
1167 nativeSiPrefix::Milli => SiPrefix::Milli,
1168 nativeSiPrefix::Micro => SiPrefix::Micro,
1169 nativeSiPrefix::Nano => SiPrefix::Nano,
1170 nativeSiPrefix::Pico => SiPrefix::Pico,
1174 pub(crate) fn native_into(native: nativeSiPrefix) -> Self {
1176 nativeSiPrefix::Milli => SiPrefix::Milli,
1177 nativeSiPrefix::Micro => SiPrefix::Micro,
1178 nativeSiPrefix::Nano => SiPrefix::Nano,
1179 nativeSiPrefix::Pico => SiPrefix::Pico,
1183 /// Creates a copy of the SiPrefix
1185 pub extern "C" fn SiPrefix_clone(orig: &SiPrefix) -> SiPrefix {
1189 /// Used only if an object of this type is returned as a trait impl by a method
1190 pub(crate) extern "C" fn SiPrefix_clone_void(this_ptr: *const c_void) -> *mut c_void {
1191 Box::into_raw(Box::new(unsafe { (*(this_ptr as *const SiPrefix)).clone() })) as *mut c_void
1194 /// Used only if an object of this type is returned as a trait impl by a method
1195 pub(crate) extern "C" fn SiPrefix_free_void(this_ptr: *mut c_void) {
1196 let _ = unsafe { Box::from_raw(this_ptr as *mut SiPrefix) };
1199 /// Utility method to constructs a new Milli-variant SiPrefix
1200 pub extern "C" fn SiPrefix_milli() -> SiPrefix {
1203 /// Utility method to constructs a new Micro-variant SiPrefix
1204 pub extern "C" fn SiPrefix_micro() -> SiPrefix {
1207 /// Utility method to constructs a new Nano-variant SiPrefix
1208 pub extern "C" fn SiPrefix_nano() -> SiPrefix {
1211 /// Utility method to constructs a new Pico-variant SiPrefix
1212 pub extern "C" fn SiPrefix_pico() -> SiPrefix {
1214 /// Checks if two SiPrefixs contain equal inner contents.
1215 /// This ignores pointers and is_owned flags and looks at the values in fields.
1217 pub extern "C" fn SiPrefix_eq(a: &SiPrefix, b: &SiPrefix) -> bool {
1218 if &a.to_native() == &b.to_native() { true } else { false }
1220 /// Generates a non-cryptographic 64-bit hash of the SiPrefix.
1222 pub extern "C" fn SiPrefix_hash(o: &SiPrefix) -> u64 {
1223 // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
1224 #[allow(deprecated)]
1225 let mut hasher = core::hash::SipHasher::new();
1226 core::hash::Hash::hash(&o.to_native(), &mut hasher);
1227 core::hash::Hasher::finish(&hasher)
1229 /// Returns the multiplier to go from a BTC value to picoBTC implied by this SiPrefix.
1230 /// This is effectively 10^12 * the prefix multiplier
1233 pub extern "C" fn SiPrefix_multiplier(this_arg: &crate::lightning_invoice::SiPrefix) -> u64 {
1234 let mut ret = this_arg.to_native().multiplier();
1238 /// Enum representing the crypto currencies (or networks) supported by this library
1254 use lightning_invoice::Currency as CurrencyImport;
1255 pub(crate) type nativeCurrency = CurrencyImport;
1259 pub(crate) fn to_native(&self) -> nativeCurrency {
1261 Currency::Bitcoin => nativeCurrency::Bitcoin,
1262 Currency::BitcoinTestnet => nativeCurrency::BitcoinTestnet,
1263 Currency::Regtest => nativeCurrency::Regtest,
1264 Currency::Simnet => nativeCurrency::Simnet,
1265 Currency::Signet => nativeCurrency::Signet,
1269 pub(crate) fn into_native(self) -> nativeCurrency {
1271 Currency::Bitcoin => nativeCurrency::Bitcoin,
1272 Currency::BitcoinTestnet => nativeCurrency::BitcoinTestnet,
1273 Currency::Regtest => nativeCurrency::Regtest,
1274 Currency::Simnet => nativeCurrency::Simnet,
1275 Currency::Signet => nativeCurrency::Signet,
1279 pub(crate) fn from_native(native: &nativeCurrency) -> Self {
1281 nativeCurrency::Bitcoin => Currency::Bitcoin,
1282 nativeCurrency::BitcoinTestnet => Currency::BitcoinTestnet,
1283 nativeCurrency::Regtest => Currency::Regtest,
1284 nativeCurrency::Simnet => Currency::Simnet,
1285 nativeCurrency::Signet => Currency::Signet,
1289 pub(crate) fn native_into(native: nativeCurrency) -> Self {
1291 nativeCurrency::Bitcoin => Currency::Bitcoin,
1292 nativeCurrency::BitcoinTestnet => Currency::BitcoinTestnet,
1293 nativeCurrency::Regtest => Currency::Regtest,
1294 nativeCurrency::Simnet => Currency::Simnet,
1295 nativeCurrency::Signet => Currency::Signet,
1299 /// Creates a copy of the Currency
1301 pub extern "C" fn Currency_clone(orig: &Currency) -> Currency {
1305 /// Used only if an object of this type is returned as a trait impl by a method
1306 pub(crate) extern "C" fn Currency_clone_void(this_ptr: *const c_void) -> *mut c_void {
1307 Box::into_raw(Box::new(unsafe { (*(this_ptr as *const Currency)).clone() })) as *mut c_void
1310 /// Used only if an object of this type is returned as a trait impl by a method
1311 pub(crate) extern "C" fn Currency_free_void(this_ptr: *mut c_void) {
1312 let _ = unsafe { Box::from_raw(this_ptr as *mut Currency) };
1315 /// Utility method to constructs a new Bitcoin-variant Currency
1316 pub extern "C" fn Currency_bitcoin() -> Currency {
1319 /// Utility method to constructs a new BitcoinTestnet-variant Currency
1320 pub extern "C" fn Currency_bitcoin_testnet() -> Currency {
1321 Currency::BitcoinTestnet}
1323 /// Utility method to constructs a new Regtest-variant Currency
1324 pub extern "C" fn Currency_regtest() -> Currency {
1327 /// Utility method to constructs a new Simnet-variant Currency
1328 pub extern "C" fn Currency_simnet() -> Currency {
1331 /// Utility method to constructs a new Signet-variant Currency
1332 pub extern "C" fn Currency_signet() -> Currency {
1334 /// Generates a non-cryptographic 64-bit hash of the Currency.
1336 pub extern "C" fn Currency_hash(o: &Currency) -> u64 {
1337 // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
1338 #[allow(deprecated)]
1339 let mut hasher = core::hash::SipHasher::new();
1340 core::hash::Hash::hash(&o.to_native(), &mut hasher);
1341 core::hash::Hasher::finish(&hasher)
1343 /// Checks if two Currencys contain equal inner contents.
1344 /// This ignores pointers and is_owned flags and looks at the values in fields.
1346 pub extern "C" fn Currency_eq(a: &Currency, b: &Currency) -> bool {
1347 if &a.to_native() == &b.to_native() { true } else { false }
1350 use lightning_invoice::Sha256 as nativeSha256Import;
1351 pub(crate) type nativeSha256 = nativeSha256Import;
1357 /// A pointer to the opaque Rust object.
1359 /// Nearly everywhere, inner must be non-null, however in places where
1360 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
1361 pub inner: *mut nativeSha256,
1362 /// Indicates that this is the only struct which contains the same pointer.
1364 /// Rust functions which take ownership of an object provided via an argument require
1365 /// this to be true and invalidate the object pointed to by inner.
1369 impl Drop for Sha256 {
1370 fn drop(&mut self) {
1371 if self.is_owned && !<*mut nativeSha256>::is_null(self.inner) {
1372 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
1376 /// Frees any resources used by the Sha256, if is_owned is set and inner is non-NULL.
1378 pub extern "C" fn Sha256_free(this_obj: Sha256) { }
1380 /// Used only if an object of this type is returned as a trait impl by a method
1381 pub(crate) extern "C" fn Sha256_free_void(this_ptr: *mut c_void) {
1382 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeSha256) };
1386 pub(crate) fn get_native_ref(&self) -> &'static nativeSha256 {
1387 unsafe { &*ObjOps::untweak_ptr(self.inner) }
1389 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeSha256 {
1390 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
1392 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
1393 pub(crate) fn take_inner(mut self) -> *mut nativeSha256 {
1394 assert!(self.is_owned);
1395 let ret = ObjOps::untweak_ptr(self.inner);
1396 self.inner = core::ptr::null_mut();
1400 impl Clone for Sha256 {
1401 fn clone(&self) -> Self {
1403 inner: if <*mut nativeSha256>::is_null(self.inner) { core::ptr::null_mut() } else {
1404 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
1410 /// Used only if an object of this type is returned as a trait impl by a method
1411 pub(crate) extern "C" fn Sha256_clone_void(this_ptr: *const c_void) -> *mut c_void {
1412 Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeSha256)).clone() })) as *mut c_void
1415 /// Creates a copy of the Sha256
1416 pub extern "C" fn Sha256_clone(orig: &Sha256) -> Sha256 {
1419 /// Generates a non-cryptographic 64-bit hash of the Sha256.
1421 pub extern "C" fn Sha256_hash(o: &Sha256) -> u64 {
1422 if o.inner.is_null() { return 0; }
1423 // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
1424 #[allow(deprecated)]
1425 let mut hasher = core::hash::SipHasher::new();
1426 core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
1427 core::hash::Hasher::finish(&hasher)
1429 /// Checks if two Sha256s contain equal inner contents.
1430 /// This ignores pointers and is_owned flags and looks at the values in fields.
1431 /// Two objects with NULL inner values will be considered "equal" here.
1433 pub extern "C" fn Sha256_eq(a: &Sha256, b: &Sha256) -> bool {
1434 if a.inner == b.inner { return true; }
1435 if a.inner.is_null() || b.inner.is_null() { return false; }
1436 if a.get_native_ref() == b.get_native_ref() { true } else { false }
1438 /// Constructs a new [`Sha256`] from the given bytes, which are assumed to be the output of a
1439 /// single sha256 hash.
1442 pub extern "C" fn Sha256_from_bytes(bytes: *const [u8; 32]) -> crate::lightning_invoice::Sha256 {
1443 let mut ret = lightning_invoice::Sha256::from_bytes(unsafe { &*bytes});
1444 crate::lightning_invoice::Sha256 { inner: ObjOps::heap_alloc(ret), is_owned: true }
1448 use lightning_invoice::Description as nativeDescriptionImport;
1449 pub(crate) type nativeDescription = nativeDescriptionImport;
1451 /// Description string
1454 /// The description can be at most 639 __bytes__ long
1457 pub struct Description {
1458 /// A pointer to the opaque Rust object.
1460 /// Nearly everywhere, inner must be non-null, however in places where
1461 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
1462 pub inner: *mut nativeDescription,
1463 /// Indicates that this is the only struct which contains the same pointer.
1465 /// Rust functions which take ownership of an object provided via an argument require
1466 /// this to be true and invalidate the object pointed to by inner.
1470 impl Drop for Description {
1471 fn drop(&mut self) {
1472 if self.is_owned && !<*mut nativeDescription>::is_null(self.inner) {
1473 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
1477 /// Frees any resources used by the Description, if is_owned is set and inner is non-NULL.
1479 pub extern "C" fn Description_free(this_obj: Description) { }
1481 /// Used only if an object of this type is returned as a trait impl by a method
1482 pub(crate) extern "C" fn Description_free_void(this_ptr: *mut c_void) {
1483 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeDescription) };
1487 pub(crate) fn get_native_ref(&self) -> &'static nativeDescription {
1488 unsafe { &*ObjOps::untweak_ptr(self.inner) }
1490 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeDescription {
1491 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
1493 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
1494 pub(crate) fn take_inner(mut self) -> *mut nativeDescription {
1495 assert!(self.is_owned);
1496 let ret = ObjOps::untweak_ptr(self.inner);
1497 self.inner = core::ptr::null_mut();
1501 impl Clone for Description {
1502 fn clone(&self) -> Self {
1504 inner: if <*mut nativeDescription>::is_null(self.inner) { core::ptr::null_mut() } else {
1505 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
1511 /// Used only if an object of this type is returned as a trait impl by a method
1512 pub(crate) extern "C" fn Description_clone_void(this_ptr: *const c_void) -> *mut c_void {
1513 Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeDescription)).clone() })) as *mut c_void
1516 /// Creates a copy of the Description
1517 pub extern "C" fn Description_clone(orig: &Description) -> Description {
1520 /// Generates a non-cryptographic 64-bit hash of the Description.
1522 pub extern "C" fn Description_hash(o: &Description) -> u64 {
1523 if o.inner.is_null() { return 0; }
1524 // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
1525 #[allow(deprecated)]
1526 let mut hasher = core::hash::SipHasher::new();
1527 core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
1528 core::hash::Hasher::finish(&hasher)
1530 /// Checks if two Descriptions contain equal inner contents.
1531 /// This ignores pointers and is_owned flags and looks at the values in fields.
1532 /// Two objects with NULL inner values will be considered "equal" here.
1534 pub extern "C" fn Description_eq(a: &Description, b: &Description) -> bool {
1535 if a.inner == b.inner { return true; }
1536 if a.inner.is_null() || b.inner.is_null() { return false; }
1537 if a.get_native_ref() == b.get_native_ref() { true } else { false }
1540 use lightning_invoice::PayeePubKey as nativePayeePubKeyImport;
1541 pub(crate) type nativePayeePubKey = nativePayeePubKeyImport;
1543 /// Payee public key
1546 pub struct PayeePubKey {
1547 /// A pointer to the opaque Rust object.
1549 /// Nearly everywhere, inner must be non-null, however in places where
1550 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
1551 pub inner: *mut nativePayeePubKey,
1552 /// Indicates that this is the only struct which contains the same pointer.
1554 /// Rust functions which take ownership of an object provided via an argument require
1555 /// this to be true and invalidate the object pointed to by inner.
1559 impl Drop for PayeePubKey {
1560 fn drop(&mut self) {
1561 if self.is_owned && !<*mut nativePayeePubKey>::is_null(self.inner) {
1562 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
1566 /// Frees any resources used by the PayeePubKey, if is_owned is set and inner is non-NULL.
1568 pub extern "C" fn PayeePubKey_free(this_obj: PayeePubKey) { }
1570 /// Used only if an object of this type is returned as a trait impl by a method
1571 pub(crate) extern "C" fn PayeePubKey_free_void(this_ptr: *mut c_void) {
1572 let _ = unsafe { Box::from_raw(this_ptr as *mut nativePayeePubKey) };
1576 pub(crate) fn get_native_ref(&self) -> &'static nativePayeePubKey {
1577 unsafe { &*ObjOps::untweak_ptr(self.inner) }
1579 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativePayeePubKey {
1580 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
1582 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
1583 pub(crate) fn take_inner(mut self) -> *mut nativePayeePubKey {
1584 assert!(self.is_owned);
1585 let ret = ObjOps::untweak_ptr(self.inner);
1586 self.inner = core::ptr::null_mut();
1591 pub extern "C" fn PayeePubKey_get_a(this_ptr: &PayeePubKey) -> crate::c_types::PublicKey {
1592 let mut inner_val = &mut this_ptr.get_native_mut_ref().0;
1593 crate::c_types::PublicKey::from_rust(&inner_val)
1596 pub extern "C" fn PayeePubKey_set_a(this_ptr: &mut PayeePubKey, mut val: crate::c_types::PublicKey) {
1597 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.0 = val.into_rust();
1599 /// Constructs a new PayeePubKey given each field
1602 pub extern "C" fn PayeePubKey_new(mut a_arg: crate::c_types::PublicKey) -> PayeePubKey {
1603 PayeePubKey { inner: ObjOps::heap_alloc(lightning_invoice::PayeePubKey (
1605 )), is_owned: true }
1607 impl Clone for PayeePubKey {
1608 fn clone(&self) -> Self {
1610 inner: if <*mut nativePayeePubKey>::is_null(self.inner) { core::ptr::null_mut() } else {
1611 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
1617 /// Used only if an object of this type is returned as a trait impl by a method
1618 pub(crate) extern "C" fn PayeePubKey_clone_void(this_ptr: *const c_void) -> *mut c_void {
1619 Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativePayeePubKey)).clone() })) as *mut c_void
1622 /// Creates a copy of the PayeePubKey
1623 pub extern "C" fn PayeePubKey_clone(orig: &PayeePubKey) -> PayeePubKey {
1626 /// Generates a non-cryptographic 64-bit hash of the PayeePubKey.
1628 pub extern "C" fn PayeePubKey_hash(o: &PayeePubKey) -> u64 {
1629 if o.inner.is_null() { return 0; }
1630 // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
1631 #[allow(deprecated)]
1632 let mut hasher = core::hash::SipHasher::new();
1633 core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
1634 core::hash::Hasher::finish(&hasher)
1636 /// Checks if two PayeePubKeys contain equal inner contents.
1637 /// This ignores pointers and is_owned flags and looks at the values in fields.
1638 /// Two objects with NULL inner values will be considered "equal" here.
1640 pub extern "C" fn PayeePubKey_eq(a: &PayeePubKey, b: &PayeePubKey) -> bool {
1641 if a.inner == b.inner { return true; }
1642 if a.inner.is_null() || b.inner.is_null() { return false; }
1643 if a.get_native_ref() == b.get_native_ref() { true } else { false }
1646 use lightning_invoice::ExpiryTime as nativeExpiryTimeImport;
1647 pub(crate) type nativeExpiryTime = nativeExpiryTimeImport;
1649 /// Positive duration that defines when (relatively to the timestamp) in the future the invoice
1653 pub struct ExpiryTime {
1654 /// A pointer to the opaque Rust object.
1656 /// Nearly everywhere, inner must be non-null, however in places where
1657 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
1658 pub inner: *mut nativeExpiryTime,
1659 /// Indicates that this is the only struct which contains the same pointer.
1661 /// Rust functions which take ownership of an object provided via an argument require
1662 /// this to be true and invalidate the object pointed to by inner.
1666 impl Drop for ExpiryTime {
1667 fn drop(&mut self) {
1668 if self.is_owned && !<*mut nativeExpiryTime>::is_null(self.inner) {
1669 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
1673 /// Frees any resources used by the ExpiryTime, if is_owned is set and inner is non-NULL.
1675 pub extern "C" fn ExpiryTime_free(this_obj: ExpiryTime) { }
1677 /// Used only if an object of this type is returned as a trait impl by a method
1678 pub(crate) extern "C" fn ExpiryTime_free_void(this_ptr: *mut c_void) {
1679 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeExpiryTime) };
1683 pub(crate) fn get_native_ref(&self) -> &'static nativeExpiryTime {
1684 unsafe { &*ObjOps::untweak_ptr(self.inner) }
1686 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeExpiryTime {
1687 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
1689 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
1690 pub(crate) fn take_inner(mut self) -> *mut nativeExpiryTime {
1691 assert!(self.is_owned);
1692 let ret = ObjOps::untweak_ptr(self.inner);
1693 self.inner = core::ptr::null_mut();
1697 impl Clone for ExpiryTime {
1698 fn clone(&self) -> Self {
1700 inner: if <*mut nativeExpiryTime>::is_null(self.inner) { core::ptr::null_mut() } else {
1701 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
1707 /// Used only if an object of this type is returned as a trait impl by a method
1708 pub(crate) extern "C" fn ExpiryTime_clone_void(this_ptr: *const c_void) -> *mut c_void {
1709 Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeExpiryTime)).clone() })) as *mut c_void
1712 /// Creates a copy of the ExpiryTime
1713 pub extern "C" fn ExpiryTime_clone(orig: &ExpiryTime) -> ExpiryTime {
1716 /// Generates a non-cryptographic 64-bit hash of the ExpiryTime.
1718 pub extern "C" fn ExpiryTime_hash(o: &ExpiryTime) -> u64 {
1719 if o.inner.is_null() { return 0; }
1720 // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
1721 #[allow(deprecated)]
1722 let mut hasher = core::hash::SipHasher::new();
1723 core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
1724 core::hash::Hasher::finish(&hasher)
1726 /// Checks if two ExpiryTimes contain equal inner contents.
1727 /// This ignores pointers and is_owned flags and looks at the values in fields.
1728 /// Two objects with NULL inner values will be considered "equal" here.
1730 pub extern "C" fn ExpiryTime_eq(a: &ExpiryTime, b: &ExpiryTime) -> bool {
1731 if a.inner == b.inner { return true; }
1732 if a.inner.is_null() || b.inner.is_null() { return false; }
1733 if a.get_native_ref() == b.get_native_ref() { true } else { false }
1736 use lightning_invoice::MinFinalCltvExpiryDelta as nativeMinFinalCltvExpiryDeltaImport;
1737 pub(crate) type nativeMinFinalCltvExpiryDelta = nativeMinFinalCltvExpiryDeltaImport;
1739 /// `min_final_cltv_expiry_delta` to use for the last HTLC in the route
1742 pub struct MinFinalCltvExpiryDelta {
1743 /// A pointer to the opaque Rust object.
1745 /// Nearly everywhere, inner must be non-null, however in places where
1746 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
1747 pub inner: *mut nativeMinFinalCltvExpiryDelta,
1748 /// Indicates that this is the only struct which contains the same pointer.
1750 /// Rust functions which take ownership of an object provided via an argument require
1751 /// this to be true and invalidate the object pointed to by inner.
1755 impl Drop for MinFinalCltvExpiryDelta {
1756 fn drop(&mut self) {
1757 if self.is_owned && !<*mut nativeMinFinalCltvExpiryDelta>::is_null(self.inner) {
1758 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
1762 /// Frees any resources used by the MinFinalCltvExpiryDelta, if is_owned is set and inner is non-NULL.
1764 pub extern "C" fn MinFinalCltvExpiryDelta_free(this_obj: MinFinalCltvExpiryDelta) { }
1766 /// Used only if an object of this type is returned as a trait impl by a method
1767 pub(crate) extern "C" fn MinFinalCltvExpiryDelta_free_void(this_ptr: *mut c_void) {
1768 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeMinFinalCltvExpiryDelta) };
1771 impl MinFinalCltvExpiryDelta {
1772 pub(crate) fn get_native_ref(&self) -> &'static nativeMinFinalCltvExpiryDelta {
1773 unsafe { &*ObjOps::untweak_ptr(self.inner) }
1775 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeMinFinalCltvExpiryDelta {
1776 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
1778 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
1779 pub(crate) fn take_inner(mut self) -> *mut nativeMinFinalCltvExpiryDelta {
1780 assert!(self.is_owned);
1781 let ret = ObjOps::untweak_ptr(self.inner);
1782 self.inner = core::ptr::null_mut();
1787 pub extern "C" fn MinFinalCltvExpiryDelta_get_a(this_ptr: &MinFinalCltvExpiryDelta) -> u64 {
1788 let mut inner_val = &mut this_ptr.get_native_mut_ref().0;
1792 pub extern "C" fn MinFinalCltvExpiryDelta_set_a(this_ptr: &mut MinFinalCltvExpiryDelta, mut val: u64) {
1793 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.0 = val;
1795 /// Constructs a new MinFinalCltvExpiryDelta given each field
1798 pub extern "C" fn MinFinalCltvExpiryDelta_new(mut a_arg: u64) -> MinFinalCltvExpiryDelta {
1799 MinFinalCltvExpiryDelta { inner: ObjOps::heap_alloc(lightning_invoice::MinFinalCltvExpiryDelta (
1801 )), is_owned: true }
1803 impl Clone for MinFinalCltvExpiryDelta {
1804 fn clone(&self) -> Self {
1806 inner: if <*mut nativeMinFinalCltvExpiryDelta>::is_null(self.inner) { core::ptr::null_mut() } else {
1807 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
1813 /// Used only if an object of this type is returned as a trait impl by a method
1814 pub(crate) extern "C" fn MinFinalCltvExpiryDelta_clone_void(this_ptr: *const c_void) -> *mut c_void {
1815 Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeMinFinalCltvExpiryDelta)).clone() })) as *mut c_void
1818 /// Creates a copy of the MinFinalCltvExpiryDelta
1819 pub extern "C" fn MinFinalCltvExpiryDelta_clone(orig: &MinFinalCltvExpiryDelta) -> MinFinalCltvExpiryDelta {
1822 /// Generates a non-cryptographic 64-bit hash of the MinFinalCltvExpiryDelta.
1824 pub extern "C" fn MinFinalCltvExpiryDelta_hash(o: &MinFinalCltvExpiryDelta) -> u64 {
1825 if o.inner.is_null() { return 0; }
1826 // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
1827 #[allow(deprecated)]
1828 let mut hasher = core::hash::SipHasher::new();
1829 core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
1830 core::hash::Hasher::finish(&hasher)
1832 /// Checks if two MinFinalCltvExpiryDeltas contain equal inner contents.
1833 /// This ignores pointers and is_owned flags and looks at the values in fields.
1834 /// Two objects with NULL inner values will be considered "equal" here.
1836 pub extern "C" fn MinFinalCltvExpiryDelta_eq(a: &MinFinalCltvExpiryDelta, b: &MinFinalCltvExpiryDelta) -> bool {
1837 if a.inner == b.inner { return true; }
1838 if a.inner.is_null() || b.inner.is_null() { return false; }
1839 if a.get_native_ref() == b.get_native_ref() { true } else { false }
1841 /// Fallback address in case no LN payment is possible
1847 version: crate::c_types::WitnessVersion,
1848 program: crate::c_types::derived::CVec_u8Z,
1851 crate::c_types::TwentyBytes),
1853 crate::c_types::TwentyBytes),
1855 use lightning_invoice::Fallback as FallbackImport;
1856 pub(crate) type nativeFallback = FallbackImport;
1860 pub(crate) fn to_native(&self) -> nativeFallback {
1862 Fallback::SegWitProgram {ref version, ref program, } => {
1863 let mut version_nonref = Clone::clone(version);
1864 let mut program_nonref = Clone::clone(program);
1865 let mut local_program_nonref = Vec::new(); for mut item in program_nonref.into_rust().drain(..) { local_program_nonref.push( { item }); };
1866 nativeFallback::SegWitProgram {
1867 version: version_nonref.into(),
1868 program: local_program_nonref,
1871 Fallback::PubKeyHash (ref a, ) => {
1872 let mut a_nonref = Clone::clone(a);
1873 nativeFallback::PubKeyHash (
1874 bitcoin::hash_types::PubkeyHash::from_hash(bitcoin::hashes::Hash::from_inner(a_nonref.data)),
1877 Fallback::ScriptHash (ref a, ) => {
1878 let mut a_nonref = Clone::clone(a);
1879 nativeFallback::ScriptHash (
1880 bitcoin::hash_types::ScriptHash::from_hash(bitcoin::hashes::Hash::from_inner(a_nonref.data)),
1886 pub(crate) fn into_native(self) -> nativeFallback {
1888 Fallback::SegWitProgram {mut version, mut program, } => {
1889 let mut local_program = Vec::new(); for mut item in program.into_rust().drain(..) { local_program.push( { item }); };
1890 nativeFallback::SegWitProgram {
1891 version: version.into(),
1892 program: local_program,
1895 Fallback::PubKeyHash (mut a, ) => {
1896 nativeFallback::PubKeyHash (
1897 bitcoin::hash_types::PubkeyHash::from_hash(bitcoin::hashes::Hash::from_inner(a.data)),
1900 Fallback::ScriptHash (mut a, ) => {
1901 nativeFallback::ScriptHash (
1902 bitcoin::hash_types::ScriptHash::from_hash(bitcoin::hashes::Hash::from_inner(a.data)),
1908 pub(crate) fn from_native(native: &nativeFallback) -> Self {
1910 nativeFallback::SegWitProgram {ref version, ref program, } => {
1911 let mut version_nonref = Clone::clone(version);
1912 let mut program_nonref = Clone::clone(program);
1913 let mut local_program_nonref = Vec::new(); for mut item in program_nonref.drain(..) { local_program_nonref.push( { item }); };
1914 Fallback::SegWitProgram {
1915 version: version_nonref.into(),
1916 program: local_program_nonref.into(),
1919 nativeFallback::PubKeyHash (ref a, ) => {
1920 let mut a_nonref = Clone::clone(a);
1921 Fallback::PubKeyHash (
1922 crate::c_types::TwentyBytes { data: a_nonref.as_hash().into_inner() },
1925 nativeFallback::ScriptHash (ref a, ) => {
1926 let mut a_nonref = Clone::clone(a);
1927 Fallback::ScriptHash (
1928 crate::c_types::TwentyBytes { data: a_nonref.as_hash().into_inner() },
1934 pub(crate) fn native_into(native: nativeFallback) -> Self {
1936 nativeFallback::SegWitProgram {mut version, mut program, } => {
1937 let mut local_program = Vec::new(); for mut item in program.drain(..) { local_program.push( { item }); };
1938 Fallback::SegWitProgram {
1939 version: version.into(),
1940 program: local_program.into(),
1943 nativeFallback::PubKeyHash (mut a, ) => {
1944 Fallback::PubKeyHash (
1945 crate::c_types::TwentyBytes { data: a.as_hash().into_inner() },
1948 nativeFallback::ScriptHash (mut a, ) => {
1949 Fallback::ScriptHash (
1950 crate::c_types::TwentyBytes { data: a.as_hash().into_inner() },
1956 /// Frees any resources used by the Fallback
1958 pub extern "C" fn Fallback_free(this_ptr: Fallback) { }
1959 /// Creates a copy of the Fallback
1961 pub extern "C" fn Fallback_clone(orig: &Fallback) -> Fallback {
1965 /// Used only if an object of this type is returned as a trait impl by a method
1966 pub(crate) extern "C" fn Fallback_clone_void(this_ptr: *const c_void) -> *mut c_void {
1967 Box::into_raw(Box::new(unsafe { (*(this_ptr as *const Fallback)).clone() })) as *mut c_void
1970 /// Used only if an object of this type is returned as a trait impl by a method
1971 pub(crate) extern "C" fn Fallback_free_void(this_ptr: *mut c_void) {
1972 let _ = unsafe { Box::from_raw(this_ptr as *mut Fallback) };
1975 /// Utility method to constructs a new SegWitProgram-variant Fallback
1976 pub extern "C" fn Fallback_seg_wit_program(version: crate::c_types::WitnessVersion, program: crate::c_types::derived::CVec_u8Z) -> Fallback {
1977 Fallback::SegWitProgram {
1983 /// Utility method to constructs a new PubKeyHash-variant Fallback
1984 pub extern "C" fn Fallback_pub_key_hash(a: crate::c_types::TwentyBytes) -> Fallback {
1985 Fallback::PubKeyHash(a, )
1988 /// Utility method to constructs a new ScriptHash-variant Fallback
1989 pub extern "C" fn Fallback_script_hash(a: crate::c_types::TwentyBytes) -> Fallback {
1990 Fallback::ScriptHash(a, )
1992 /// Generates a non-cryptographic 64-bit hash of the Fallback.
1994 pub extern "C" fn Fallback_hash(o: &Fallback) -> u64 {
1995 // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
1996 #[allow(deprecated)]
1997 let mut hasher = core::hash::SipHasher::new();
1998 core::hash::Hash::hash(&o.to_native(), &mut hasher);
1999 core::hash::Hasher::finish(&hasher)
2001 /// Checks if two Fallbacks contain equal inner contents.
2002 /// This ignores pointers and is_owned flags and looks at the values in fields.
2004 pub extern "C" fn Fallback_eq(a: &Fallback, b: &Fallback) -> bool {
2005 if &a.to_native() == &b.to_native() { true } else { false }
2008 use lightning_invoice::Bolt11InvoiceSignature as nativeBolt11InvoiceSignatureImport;
2009 pub(crate) type nativeBolt11InvoiceSignature = nativeBolt11InvoiceSignatureImport;
2011 /// Recoverable signature
2014 pub struct Bolt11InvoiceSignature {
2015 /// A pointer to the opaque Rust object.
2017 /// Nearly everywhere, inner must be non-null, however in places where
2018 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
2019 pub inner: *mut nativeBolt11InvoiceSignature,
2020 /// Indicates that this is the only struct which contains the same pointer.
2022 /// Rust functions which take ownership of an object provided via an argument require
2023 /// this to be true and invalidate the object pointed to by inner.
2027 impl Drop for Bolt11InvoiceSignature {
2028 fn drop(&mut self) {
2029 if self.is_owned && !<*mut nativeBolt11InvoiceSignature>::is_null(self.inner) {
2030 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
2034 /// Frees any resources used by the Bolt11InvoiceSignature, if is_owned is set and inner is non-NULL.
2036 pub extern "C" fn Bolt11InvoiceSignature_free(this_obj: Bolt11InvoiceSignature) { }
2038 /// Used only if an object of this type is returned as a trait impl by a method
2039 pub(crate) extern "C" fn Bolt11InvoiceSignature_free_void(this_ptr: *mut c_void) {
2040 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeBolt11InvoiceSignature) };
2043 impl Bolt11InvoiceSignature {
2044 pub(crate) fn get_native_ref(&self) -> &'static nativeBolt11InvoiceSignature {
2045 unsafe { &*ObjOps::untweak_ptr(self.inner) }
2047 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeBolt11InvoiceSignature {
2048 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
2050 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
2051 pub(crate) fn take_inner(mut self) -> *mut nativeBolt11InvoiceSignature {
2052 assert!(self.is_owned);
2053 let ret = ObjOps::untweak_ptr(self.inner);
2054 self.inner = core::ptr::null_mut();
2058 impl Clone for Bolt11InvoiceSignature {
2059 fn clone(&self) -> Self {
2061 inner: if <*mut nativeBolt11InvoiceSignature>::is_null(self.inner) { core::ptr::null_mut() } else {
2062 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
2068 /// Used only if an object of this type is returned as a trait impl by a method
2069 pub(crate) extern "C" fn Bolt11InvoiceSignature_clone_void(this_ptr: *const c_void) -> *mut c_void {
2070 Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeBolt11InvoiceSignature)).clone() })) as *mut c_void
2073 /// Creates a copy of the Bolt11InvoiceSignature
2074 pub extern "C" fn Bolt11InvoiceSignature_clone(orig: &Bolt11InvoiceSignature) -> Bolt11InvoiceSignature {
2077 /// Generates a non-cryptographic 64-bit hash of the Bolt11InvoiceSignature.
2079 pub extern "C" fn Bolt11InvoiceSignature_hash(o: &Bolt11InvoiceSignature) -> u64 {
2080 if o.inner.is_null() { return 0; }
2081 // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
2082 #[allow(deprecated)]
2083 let mut hasher = core::hash::SipHasher::new();
2084 core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
2085 core::hash::Hasher::finish(&hasher)
2087 /// Checks if two Bolt11InvoiceSignatures contain equal inner contents.
2088 /// This ignores pointers and is_owned flags and looks at the values in fields.
2089 /// Two objects with NULL inner values will be considered "equal" here.
2091 pub extern "C" fn Bolt11InvoiceSignature_eq(a: &Bolt11InvoiceSignature, b: &Bolt11InvoiceSignature) -> bool {
2092 if a.inner == b.inner { return true; }
2093 if a.inner.is_null() || b.inner.is_null() { return false; }
2094 if a.get_native_ref() == b.get_native_ref() { true } else { false }
2097 use lightning_invoice::PrivateRoute as nativePrivateRouteImport;
2098 pub(crate) type nativePrivateRoute = nativePrivateRouteImport;
2100 /// Private routing information
2103 /// The encoded route has to be <1024 5bit characters long (<=639 bytes or <=12 hops)
2107 pub struct PrivateRoute {
2108 /// A pointer to the opaque Rust object.
2110 /// Nearly everywhere, inner must be non-null, however in places where
2111 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
2112 pub inner: *mut nativePrivateRoute,
2113 /// Indicates that this is the only struct which contains the same pointer.
2115 /// Rust functions which take ownership of an object provided via an argument require
2116 /// this to be true and invalidate the object pointed to by inner.
2120 impl Drop for PrivateRoute {
2121 fn drop(&mut self) {
2122 if self.is_owned && !<*mut nativePrivateRoute>::is_null(self.inner) {
2123 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
2127 /// Frees any resources used by the PrivateRoute, if is_owned is set and inner is non-NULL.
2129 pub extern "C" fn PrivateRoute_free(this_obj: PrivateRoute) { }
2131 /// Used only if an object of this type is returned as a trait impl by a method
2132 pub(crate) extern "C" fn PrivateRoute_free_void(this_ptr: *mut c_void) {
2133 let _ = unsafe { Box::from_raw(this_ptr as *mut nativePrivateRoute) };
2137 pub(crate) fn get_native_ref(&self) -> &'static nativePrivateRoute {
2138 unsafe { &*ObjOps::untweak_ptr(self.inner) }
2140 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativePrivateRoute {
2141 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
2143 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
2144 pub(crate) fn take_inner(mut self) -> *mut nativePrivateRoute {
2145 assert!(self.is_owned);
2146 let ret = ObjOps::untweak_ptr(self.inner);
2147 self.inner = core::ptr::null_mut();
2151 impl Clone for PrivateRoute {
2152 fn clone(&self) -> Self {
2154 inner: if <*mut nativePrivateRoute>::is_null(self.inner) { core::ptr::null_mut() } else {
2155 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
2161 /// Used only if an object of this type is returned as a trait impl by a method
2162 pub(crate) extern "C" fn PrivateRoute_clone_void(this_ptr: *const c_void) -> *mut c_void {
2163 Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativePrivateRoute)).clone() })) as *mut c_void
2166 /// Creates a copy of the PrivateRoute
2167 pub extern "C" fn PrivateRoute_clone(orig: &PrivateRoute) -> PrivateRoute {
2170 /// Generates a non-cryptographic 64-bit hash of the PrivateRoute.
2172 pub extern "C" fn PrivateRoute_hash(o: &PrivateRoute) -> u64 {
2173 if o.inner.is_null() { return 0; }
2174 // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
2175 #[allow(deprecated)]
2176 let mut hasher = core::hash::SipHasher::new();
2177 core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
2178 core::hash::Hasher::finish(&hasher)
2180 /// Checks if two PrivateRoutes contain equal inner contents.
2181 /// This ignores pointers and is_owned flags and looks at the values in fields.
2182 /// Two objects with NULL inner values will be considered "equal" here.
2184 pub extern "C" fn PrivateRoute_eq(a: &PrivateRoute, b: &PrivateRoute) -> bool {
2185 if a.inner == b.inner { return true; }
2186 if a.inner.is_null() || b.inner.is_null() { return false; }
2187 if a.get_native_ref() == b.get_native_ref() { true } else { false }
2189 /// Disassembles the `SignedRawBolt11Invoice` into its three parts:
2191 /// 2. hash of the raw invoice
2195 pub extern "C" fn SignedRawBolt11Invoice_into_parts(mut this_arg: crate::lightning_invoice::SignedRawBolt11Invoice) -> crate::c_types::derived::C3Tuple_RawBolt11Invoice_u832Bolt11InvoiceSignatureZ {
2196 let mut ret = (*unsafe { Box::from_raw(this_arg.take_inner()) }).into_parts();
2197 let (mut orig_ret_0, mut orig_ret_1, mut orig_ret_2) = ret; let mut local_ret = (crate::lightning_invoice::RawBolt11Invoice { inner: ObjOps::heap_alloc(orig_ret_0), is_owned: true }, crate::c_types::ThirtyTwoBytes { data: orig_ret_1 }, crate::lightning_invoice::Bolt11InvoiceSignature { inner: ObjOps::heap_alloc(orig_ret_2), is_owned: true }).into();
2201 /// The [`RawBolt11Invoice`] which was signed.
2204 pub extern "C" fn SignedRawBolt11Invoice_raw_invoice(this_arg: &crate::lightning_invoice::SignedRawBolt11Invoice) -> crate::lightning_invoice::RawBolt11Invoice {
2205 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.raw_invoice();
2206 crate::lightning_invoice::RawBolt11Invoice { inner: unsafe { ObjOps::nonnull_ptr_to_inner((ret as *const lightning_invoice::RawBolt11Invoice<>) as *mut _) }, is_owned: false }
2209 /// The hash of the [`RawBolt11Invoice`] that was signed.
2212 pub extern "C" fn SignedRawBolt11Invoice_signable_hash(this_arg: &crate::lightning_invoice::SignedRawBolt11Invoice) -> *const [u8; 32] {
2213 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.signable_hash();
2217 /// Signature for the invoice.
2220 pub extern "C" fn SignedRawBolt11Invoice_signature(this_arg: &crate::lightning_invoice::SignedRawBolt11Invoice) -> crate::lightning_invoice::Bolt11InvoiceSignature {
2221 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.signature();
2222 crate::lightning_invoice::Bolt11InvoiceSignature { inner: unsafe { ObjOps::nonnull_ptr_to_inner((ret as *const lightning_invoice::Bolt11InvoiceSignature<>) as *mut _) }, is_owned: false }
2225 /// Recovers the public key used for signing the invoice from the recoverable signature.
2228 pub extern "C" fn SignedRawBolt11Invoice_recover_payee_pub_key(this_arg: &crate::lightning_invoice::SignedRawBolt11Invoice) -> crate::c_types::derived::CResult_PayeePubKeySecp256k1ErrorZ {
2229 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.recover_payee_pub_key();
2230 let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning_invoice::PayeePubKey { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::c_types::Secp256k1Error::from_rust(e) }).into() };
2234 /// Checks if the signature is valid for the included payee public key or if none exists if it's
2235 /// valid for the recovered signature (which should always be true?).
2238 pub extern "C" fn SignedRawBolt11Invoice_check_signature(this_arg: &crate::lightning_invoice::SignedRawBolt11Invoice) -> bool {
2239 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.check_signature();
2243 /// Calculate the hash of the encoded `RawBolt11Invoice` which should be signed.
2246 pub extern "C" fn RawBolt11Invoice_signable_hash(this_arg: &crate::lightning_invoice::RawBolt11Invoice) -> crate::c_types::ThirtyTwoBytes {
2247 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.signable_hash();
2248 crate::c_types::ThirtyTwoBytes { data: ret }
2252 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
2255 pub extern "C" fn RawBolt11Invoice_payment_hash(this_arg: &crate::lightning_invoice::RawBolt11Invoice) -> crate::lightning_invoice::Sha256 {
2256 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.payment_hash();
2257 let mut local_ret = crate::lightning_invoice::Sha256 { inner: unsafe { (if ret.is_none() { core::ptr::null() } else { ObjOps::nonnull_ptr_to_inner( { (ret.unwrap()) }) } as *const lightning_invoice::Sha256<>) as *mut _ }, is_owned: false };
2262 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
2265 pub extern "C" fn RawBolt11Invoice_description(this_arg: &crate::lightning_invoice::RawBolt11Invoice) -> crate::lightning_invoice::Description {
2266 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.description();
2267 let mut local_ret = crate::lightning_invoice::Description { inner: unsafe { (if ret.is_none() { core::ptr::null() } else { ObjOps::nonnull_ptr_to_inner( { (ret.unwrap()) }) } as *const lightning_invoice::Description<>) as *mut _ }, is_owned: false };
2272 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
2275 pub extern "C" fn RawBolt11Invoice_payee_pub_key(this_arg: &crate::lightning_invoice::RawBolt11Invoice) -> crate::lightning_invoice::PayeePubKey {
2276 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.payee_pub_key();
2277 let mut local_ret = crate::lightning_invoice::PayeePubKey { inner: unsafe { (if ret.is_none() { core::ptr::null() } else { ObjOps::nonnull_ptr_to_inner( { (ret.unwrap()) }) } as *const lightning_invoice::PayeePubKey<>) as *mut _ }, is_owned: false };
2282 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
2285 pub extern "C" fn RawBolt11Invoice_description_hash(this_arg: &crate::lightning_invoice::RawBolt11Invoice) -> crate::lightning_invoice::Sha256 {
2286 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.description_hash();
2287 let mut local_ret = crate::lightning_invoice::Sha256 { inner: unsafe { (if ret.is_none() { core::ptr::null() } else { ObjOps::nonnull_ptr_to_inner( { (ret.unwrap()) }) } as *const lightning_invoice::Sha256<>) as *mut _ }, is_owned: false };
2292 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
2295 pub extern "C" fn RawBolt11Invoice_expiry_time(this_arg: &crate::lightning_invoice::RawBolt11Invoice) -> crate::lightning_invoice::ExpiryTime {
2296 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.expiry_time();
2297 let mut local_ret = crate::lightning_invoice::ExpiryTime { inner: unsafe { (if ret.is_none() { core::ptr::null() } else { ObjOps::nonnull_ptr_to_inner( { (ret.unwrap()) }) } as *const lightning_invoice::ExpiryTime<>) as *mut _ }, is_owned: false };
2302 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
2305 pub extern "C" fn RawBolt11Invoice_min_final_cltv_expiry_delta(this_arg: &crate::lightning_invoice::RawBolt11Invoice) -> crate::lightning_invoice::MinFinalCltvExpiryDelta {
2306 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.min_final_cltv_expiry_delta();
2307 let mut local_ret = crate::lightning_invoice::MinFinalCltvExpiryDelta { inner: unsafe { (if ret.is_none() { core::ptr::null() } else { ObjOps::nonnull_ptr_to_inner( { (ret.unwrap()) }) } as *const lightning_invoice::MinFinalCltvExpiryDelta<>) as *mut _ }, is_owned: false };
2313 pub extern "C" fn RawBolt11Invoice_payment_secret(this_arg: &crate::lightning_invoice::RawBolt11Invoice) -> crate::c_types::derived::COption_ThirtyTwoBytesZ {
2314 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.payment_secret();
2315 let mut local_ret = if ret.is_none() { crate::c_types::derived::COption_ThirtyTwoBytesZ::None } else { crate::c_types::derived::COption_ThirtyTwoBytesZ::Some(/* WARNING: CLONING CONVERSION HERE! &Option<Enum> is otherwise un-expressable. */ { crate::c_types::ThirtyTwoBytes { data: (*ret.as_ref().unwrap()).clone().0 } }) };
2321 pub extern "C" fn RawBolt11Invoice_payment_metadata(this_arg: &crate::lightning_invoice::RawBolt11Invoice) -> crate::c_types::derived::COption_CVec_u8ZZ {
2322 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.payment_metadata();
2323 let mut local_ret = if ret.is_none() { crate::c_types::derived::COption_CVec_u8ZZ::None } else { crate::c_types::derived::COption_CVec_u8ZZ::Some(/* WARNING: CLONING CONVERSION HERE! &Option<Enum> is otherwise un-expressable. */ { let mut local_ret_0 = Vec::new(); for mut item in (*ret.as_ref().unwrap()).clone().drain(..) { local_ret_0.push( { item }); }; local_ret_0.into() }) };
2328 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
2331 pub extern "C" fn RawBolt11Invoice_features(this_arg: &crate::lightning_invoice::RawBolt11Invoice) -> crate::lightning::ln::features::Bolt11InvoiceFeatures {
2332 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.features();
2333 let mut local_ret = crate::lightning::ln::features::Bolt11InvoiceFeatures { inner: unsafe { (if ret.is_none() { core::ptr::null() } else { ObjOps::nonnull_ptr_to_inner( { (ret.unwrap()) }) } as *const lightning::ln::features::Bolt11InvoiceFeatures<>) as *mut _ }, is_owned: false };
2339 pub extern "C" fn RawBolt11Invoice_private_routes(this_arg: &crate::lightning_invoice::RawBolt11Invoice) -> crate::c_types::derived::CVec_PrivateRouteZ {
2340 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.private_routes();
2341 let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { crate::lightning_invoice::PrivateRoute { inner: unsafe { ObjOps::nonnull_ptr_to_inner((item as *const lightning_invoice::PrivateRoute<>) as *mut _) }, is_owned: false } }); };
2347 pub extern "C" fn RawBolt11Invoice_amount_pico_btc(this_arg: &crate::lightning_invoice::RawBolt11Invoice) -> crate::c_types::derived::COption_u64Z {
2348 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.amount_pico_btc();
2349 let mut local_ret = if ret.is_none() { crate::c_types::derived::COption_u64Z::None } else { crate::c_types::derived::COption_u64Z::Some( { ret.unwrap() }) };
2355 pub extern "C" fn RawBolt11Invoice_currency(this_arg: &crate::lightning_invoice::RawBolt11Invoice) -> crate::lightning_invoice::Currency {
2356 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.currency();
2357 crate::lightning_invoice::Currency::native_into(ret)
2360 /// Creates a `PositiveTimestamp` from a Unix timestamp in the range `0..=MAX_TIMESTAMP`.
2362 /// Otherwise, returns a [`CreationError::TimestampOutOfBounds`].
2365 pub extern "C" fn PositiveTimestamp_from_unix_timestamp(mut unix_seconds: u64) -> crate::c_types::derived::CResult_PositiveTimestampCreationErrorZ {
2366 let mut ret = lightning_invoice::PositiveTimestamp::from_unix_timestamp(unix_seconds);
2367 let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning_invoice::PositiveTimestamp { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning_invoice::CreationError::native_into(e) }).into() };
2371 /// Creates a `PositiveTimestamp` from a [`SystemTime`] with a corresponding Unix timestamp in
2372 /// the range `0..=MAX_TIMESTAMP`.
2374 /// Note that the subsecond part is dropped as it is not representable in BOLT 11 invoices.
2376 /// Otherwise, returns a [`CreationError::TimestampOutOfBounds`].
2379 pub extern "C" fn PositiveTimestamp_from_system_time(mut time: u64) -> crate::c_types::derived::CResult_PositiveTimestampCreationErrorZ {
2380 let mut ret = lightning_invoice::PositiveTimestamp::from_system_time((::std::time::SystemTime::UNIX_EPOCH + std::time::Duration::from_secs(time)));
2381 let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning_invoice::PositiveTimestamp { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning_invoice::CreationError::native_into(e) }).into() };
2385 /// Creates a `PositiveTimestamp` from a [`Duration`] since the Unix epoch in the range
2386 /// `0..=MAX_TIMESTAMP`.
2388 /// Note that the subsecond part is dropped as it is not representable in BOLT 11 invoices.
2390 /// Otherwise, returns a [`CreationError::TimestampOutOfBounds`].
2393 pub extern "C" fn PositiveTimestamp_from_duration_since_epoch(mut duration: u64) -> crate::c_types::derived::CResult_PositiveTimestampCreationErrorZ {
2394 let mut ret = lightning_invoice::PositiveTimestamp::from_duration_since_epoch(core::time::Duration::from_secs(duration));
2395 let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning_invoice::PositiveTimestamp { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning_invoice::CreationError::native_into(e) }).into() };
2399 /// Returns the Unix timestamp representing the stored time
2402 pub extern "C" fn PositiveTimestamp_as_unix_timestamp(this_arg: &crate::lightning_invoice::PositiveTimestamp) -> u64 {
2403 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.as_unix_timestamp();
2407 /// Returns the duration of the stored time since the Unix epoch
2410 pub extern "C" fn PositiveTimestamp_as_duration_since_epoch(this_arg: &crate::lightning_invoice::PositiveTimestamp) -> u64 {
2411 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.as_duration_since_epoch();
2415 /// Returns the [`SystemTime`] representing the stored time
2418 pub extern "C" fn PositiveTimestamp_as_time(this_arg: &crate::lightning_invoice::PositiveTimestamp) -> u64 {
2419 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.as_time();
2420 ret.duration_since(::std::time::SystemTime::UNIX_EPOCH).expect("Times must be post-1970").as_secs()
2423 /// The hash of the [`RawBolt11Invoice`] that was signed.
2426 pub extern "C" fn Bolt11Invoice_signable_hash(this_arg: &crate::lightning_invoice::Bolt11Invoice) -> crate::c_types::ThirtyTwoBytes {
2427 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.signable_hash();
2428 crate::c_types::ThirtyTwoBytes { data: ret }
2431 /// Transform the `Bolt11Invoice` into its unchecked version.
2434 pub extern "C" fn Bolt11Invoice_into_signed_raw(mut this_arg: crate::lightning_invoice::Bolt11Invoice) -> crate::lightning_invoice::SignedRawBolt11Invoice {
2435 let mut ret = (*unsafe { Box::from_raw(this_arg.take_inner()) }).into_signed_raw();
2436 crate::lightning_invoice::SignedRawBolt11Invoice { inner: ObjOps::heap_alloc(ret), is_owned: true }
2439 /// Check that the invoice is signed correctly and that key recovery works
2442 pub extern "C" fn Bolt11Invoice_check_signature(this_arg: &crate::lightning_invoice::Bolt11Invoice) -> crate::c_types::derived::CResult_NoneBolt11SemanticErrorZ {
2443 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.check_signature();
2444 let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { () /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning_invoice::Bolt11SemanticError::native_into(e) }).into() };
2448 /// Constructs a `Bolt11Invoice` from a [`SignedRawBolt11Invoice`] by checking all its invariants.
2450 /// use lightning_invoice::*;
2452 /// let invoice = \"lnbc100p1psj9jhxdqud3jxktt5w46x7unfv9kz6mn0v3jsnp4q0d3p2sfluzdx45tqcs\\
2453 /// h2pu5qc7lgq0xs578ngs6s0s68ua4h7cvspp5q6rmq35js88zp5dvwrv9m459tnk2zunwj5jalqtyxqulh0l\\
2454 /// 5gflssp5nf55ny5gcrfl30xuhzj3nphgj27rstekmr9fw3ny5989s300gyus9qyysgqcqpcrzjqw2sxwe993\\
2455 /// h5pcm4dxzpvttgza8zhkqxpgffcrf5v25nwpr3cmfg7z54kuqq8rgqqqqqqqq2qqqqq9qq9qrzjqd0ylaqcl\\
2456 /// j9424x9m8h2vcukcgnm6s56xfgu3j78zyqzhgs4hlpzvznlugqq9vsqqqqqqqlgqqqqqeqq9qrzjqwldmj9d\\
2457 /// ha74df76zhx6l9we0vjdquygcdt3kssupehe64g6yyp5yz5rhuqqwccqqyqqqqlgqqqqjcqq9qrzjqf9e58a\\
2458 /// guqr0rcun0ajlvmzq3ek63cw2w282gv3z5uupmuwvgjtq2z55qsqqg6qqqyqqqrtnqqqzq3cqygrzjqvphms\\
2459 /// ywntrrhqjcraumvc4y6r8v4z5v593trte429v4hredj7ms5z52usqq9ngqqqqqqqlgqqqqqqgq9qrzjq2v0v\\
2460 /// p62g49p7569ev48cmulecsxe59lvaw3wlxm7r982zxa9zzj7z5l0cqqxusqqyqqqqlgqqqqqzsqygarl9fh3\\
2461 /// 8s0gyuxjjgux34w75dnc6xp2l35j7es3jd4ugt3lu0xzre26yg5m7ke54n2d5sym4xcmxtl8238xxvw5h5h5\\
2462 /// j5r6drg6k6zcqj0fcwg\";
2464 /// let signed = invoice.parse::<SignedRawBolt11Invoice>().unwrap();
2466 /// assert!(Bolt11Invoice::from_signed(signed).is_ok());
2470 pub extern "C" fn Bolt11Invoice_from_signed(mut signed_invoice: crate::lightning_invoice::SignedRawBolt11Invoice) -> crate::c_types::derived::CResult_Bolt11InvoiceBolt11SemanticErrorZ {
2471 let mut ret = lightning_invoice::Bolt11Invoice::from_signed(*unsafe { Box::from_raw(signed_invoice.take_inner()) });
2472 let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning_invoice::Bolt11Invoice { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning_invoice::Bolt11SemanticError::native_into(e) }).into() };
2476 /// Returns the `Bolt11Invoice`'s timestamp (should equal its creation time)
2479 pub extern "C" fn Bolt11Invoice_timestamp(this_arg: &crate::lightning_invoice::Bolt11Invoice) -> u64 {
2480 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.timestamp();
2481 ret.duration_since(::std::time::SystemTime::UNIX_EPOCH).expect("Times must be post-1970").as_secs()
2484 /// Returns the `Bolt11Invoice`'s timestamp as a duration since the Unix epoch
2487 pub extern "C" fn Bolt11Invoice_duration_since_epoch(this_arg: &crate::lightning_invoice::Bolt11Invoice) -> u64 {
2488 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.duration_since_epoch();
2492 /// Returns the hash to which we will receive the preimage on completion of the payment
2495 pub extern "C" fn Bolt11Invoice_payment_hash(this_arg: &crate::lightning_invoice::Bolt11Invoice) -> *const [u8; 32] {
2496 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.payment_hash();
2500 /// Get the payee's public key if one was included in the invoice
2502 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
2505 pub extern "C" fn Bolt11Invoice_payee_pub_key(this_arg: &crate::lightning_invoice::Bolt11Invoice) -> crate::c_types::PublicKey {
2506 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.payee_pub_key();
2507 let mut local_ret = if ret.is_none() { crate::c_types::PublicKey::null() } else { { crate::c_types::PublicKey::from_rust(&(ret.unwrap())) } };
2511 /// Get the payment secret if one was included in the invoice
2514 pub extern "C" fn Bolt11Invoice_payment_secret(this_arg: &crate::lightning_invoice::Bolt11Invoice) -> *const [u8; 32] {
2515 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.payment_secret();
2519 /// Get the payment metadata blob if one was included in the invoice
2522 pub extern "C" fn Bolt11Invoice_payment_metadata(this_arg: &crate::lightning_invoice::Bolt11Invoice) -> crate::c_types::derived::COption_CVec_u8ZZ {
2523 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.payment_metadata();
2524 let mut local_ret = if ret.is_none() { crate::c_types::derived::COption_CVec_u8ZZ::None } else { crate::c_types::derived::COption_CVec_u8ZZ::Some(/* WARNING: CLONING CONVERSION HERE! &Option<Enum> is otherwise un-expressable. */ { let mut local_ret_0 = Vec::new(); for mut item in (*ret.as_ref().unwrap()).clone().drain(..) { local_ret_0.push( { item }); }; local_ret_0.into() }) };
2528 /// Get the invoice features if they were included in the invoice
2530 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
2533 pub extern "C" fn Bolt11Invoice_features(this_arg: &crate::lightning_invoice::Bolt11Invoice) -> crate::lightning::ln::features::Bolt11InvoiceFeatures {
2534 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.features();
2535 let mut local_ret = crate::lightning::ln::features::Bolt11InvoiceFeatures { inner: unsafe { (if ret.is_none() { core::ptr::null() } else { ObjOps::nonnull_ptr_to_inner( { (ret.unwrap()) }) } as *const lightning::ln::features::Bolt11InvoiceFeatures<>) as *mut _ }, is_owned: false };
2539 /// Recover the payee's public key (only to be used if none was included in the invoice)
2542 pub extern "C" fn Bolt11Invoice_recover_payee_pub_key(this_arg: &crate::lightning_invoice::Bolt11Invoice) -> crate::c_types::PublicKey {
2543 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.recover_payee_pub_key();
2544 crate::c_types::PublicKey::from_rust(&ret)
2547 /// Returns the Duration since the Unix epoch at which the invoice expires.
2548 /// Returning None if overflow occurred.
2551 pub extern "C" fn Bolt11Invoice_expires_at(this_arg: &crate::lightning_invoice::Bolt11Invoice) -> crate::c_types::derived::COption_u64Z {
2552 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.expires_at();
2553 let mut local_ret = if ret.is_none() { crate::c_types::derived::COption_u64Z::None } else { crate::c_types::derived::COption_u64Z::Some( { ret.unwrap().as_secs() }) };
2557 /// Returns the invoice's expiry time, if present, otherwise [`DEFAULT_EXPIRY_TIME`].
2560 pub extern "C" fn Bolt11Invoice_expiry_time(this_arg: &crate::lightning_invoice::Bolt11Invoice) -> u64 {
2561 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.expiry_time();
2565 /// Returns whether the invoice has expired.
2568 pub extern "C" fn Bolt11Invoice_is_expired(this_arg: &crate::lightning_invoice::Bolt11Invoice) -> bool {
2569 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.is_expired();
2573 /// Returns the Duration remaining until the invoice expires.
2576 pub extern "C" fn Bolt11Invoice_duration_until_expiry(this_arg: &crate::lightning_invoice::Bolt11Invoice) -> u64 {
2577 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.duration_until_expiry();
2581 /// Returns the Duration remaining until the invoice expires given the current time.
2582 /// `time` is the timestamp as a duration since the Unix epoch.
2585 pub extern "C" fn Bolt11Invoice_expiration_remaining_from_epoch(this_arg: &crate::lightning_invoice::Bolt11Invoice, mut time: u64) -> u64 {
2586 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.expiration_remaining_from_epoch(core::time::Duration::from_secs(time));
2590 /// Returns whether the expiry time would pass at the given point in time.
2591 /// `at_time` is the timestamp as a duration since the Unix epoch.
2594 pub extern "C" fn Bolt11Invoice_would_expire(this_arg: &crate::lightning_invoice::Bolt11Invoice, mut at_time: u64) -> bool {
2595 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.would_expire(core::time::Duration::from_secs(at_time));
2599 /// Returns the invoice's `min_final_cltv_expiry_delta` time, if present, otherwise
2600 /// [`DEFAULT_MIN_FINAL_CLTV_EXPIRY_DELTA`].
2603 pub extern "C" fn Bolt11Invoice_min_final_cltv_expiry_delta(this_arg: &crate::lightning_invoice::Bolt11Invoice) -> u64 {
2604 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.min_final_cltv_expiry_delta();
2608 /// Returns a list of all fallback addresses as [`Address`]es
2611 pub extern "C" fn Bolt11Invoice_fallback_addresses(this_arg: &crate::lightning_invoice::Bolt11Invoice) -> crate::c_types::derived::CVec_StrZ {
2612 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.fallback_addresses();
2613 let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { alloc::string::ToString::to_string(&item).into() }); };
2617 /// Returns a list of all routes included in the invoice
2620 pub extern "C" fn Bolt11Invoice_private_routes(this_arg: &crate::lightning_invoice::Bolt11Invoice) -> crate::c_types::derived::CVec_PrivateRouteZ {
2621 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.private_routes();
2622 let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { crate::lightning_invoice::PrivateRoute { inner: unsafe { ObjOps::nonnull_ptr_to_inner((item as *const lightning_invoice::PrivateRoute<>) as *mut _) }, is_owned: false } }); };
2626 /// Returns a list of all routes included in the invoice as the underlying hints
2629 pub extern "C" fn Bolt11Invoice_route_hints(this_arg: &crate::lightning_invoice::Bolt11Invoice) -> crate::c_types::derived::CVec_RouteHintZ {
2630 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.route_hints();
2631 let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { crate::lightning::routing::router::RouteHint { inner: ObjOps::heap_alloc(item), is_owned: true } }); };
2635 /// Returns the currency for which the invoice was issued
2638 pub extern "C" fn Bolt11Invoice_currency(this_arg: &crate::lightning_invoice::Bolt11Invoice) -> crate::lightning_invoice::Currency {
2639 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.currency();
2640 crate::lightning_invoice::Currency::native_into(ret)
2643 /// Returns the amount if specified in the invoice as millisatoshis.
2646 pub extern "C" fn Bolt11Invoice_amount_milli_satoshis(this_arg: &crate::lightning_invoice::Bolt11Invoice) -> crate::c_types::derived::COption_u64Z {
2647 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.amount_milli_satoshis();
2648 let mut local_ret = if ret.is_none() { crate::c_types::derived::COption_u64Z::None } else { crate::c_types::derived::COption_u64Z::Some( { ret.unwrap() }) };
2652 /// Creates a new `Description` if `description` is at most 1023 __bytes__ long,
2653 /// returns [`CreationError::DescriptionTooLong`] otherwise
2655 /// Please note that single characters may use more than one byte due to UTF8 encoding.
2658 pub extern "C" fn Description_new(mut description: crate::c_types::Str) -> crate::c_types::derived::CResult_DescriptionCreationErrorZ {
2659 let mut ret = lightning_invoice::Description::new(description.into_string());
2660 let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning_invoice::Description { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning_invoice::CreationError::native_into(e) }).into() };
2664 /// Returns the underlying description [`String`]
2667 pub extern "C" fn Description_into_inner(mut this_arg: crate::lightning_invoice::Description) -> crate::c_types::Str {
2668 let mut ret = (*unsafe { Box::from_raw(this_arg.take_inner()) }).into_inner();
2672 /// Construct an `ExpiryTime` from seconds.
2675 pub extern "C" fn ExpiryTime_from_seconds(mut seconds: u64) -> crate::lightning_invoice::ExpiryTime {
2676 let mut ret = lightning_invoice::ExpiryTime::from_seconds(seconds);
2677 crate::lightning_invoice::ExpiryTime { inner: ObjOps::heap_alloc(ret), is_owned: true }
2680 /// Construct an `ExpiryTime` from a [`Duration`], dropping the sub-second part.
2683 pub extern "C" fn ExpiryTime_from_duration(mut duration: u64) -> crate::lightning_invoice::ExpiryTime {
2684 let mut ret = lightning_invoice::ExpiryTime::from_duration(core::time::Duration::from_secs(duration));
2685 crate::lightning_invoice::ExpiryTime { inner: ObjOps::heap_alloc(ret), is_owned: true }
2688 /// Returns the expiry time in seconds
2691 pub extern "C" fn ExpiryTime_as_seconds(this_arg: &crate::lightning_invoice::ExpiryTime) -> u64 {
2692 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.as_seconds();
2696 /// Returns a reference to the underlying [`Duration`] (=expiry time)
2699 pub extern "C" fn ExpiryTime_as_duration(this_arg: &crate::lightning_invoice::ExpiryTime) -> u64 {
2700 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.as_duration();
2704 /// Creates a new (partial) route from a list of hops
2707 pub extern "C" fn PrivateRoute_new(mut hops: crate::lightning::routing::router::RouteHint) -> crate::c_types::derived::CResult_PrivateRouteCreationErrorZ {
2708 let mut ret = lightning_invoice::PrivateRoute::new(*unsafe { Box::from_raw(hops.take_inner()) });
2709 let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning_invoice::PrivateRoute { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning_invoice::CreationError::native_into(e) }).into() };
2713 /// Returns the underlying list of hops
2716 pub extern "C" fn PrivateRoute_into_inner(mut this_arg: crate::lightning_invoice::PrivateRoute) -> crate::lightning::routing::router::RouteHint {
2717 let mut ret = (*unsafe { Box::from_raw(this_arg.take_inner()) }).into_inner();
2718 crate::lightning::routing::router::RouteHint { inner: ObjOps::heap_alloc(ret), is_owned: true }
2721 /// Errors that may occur when constructing a new [`RawBolt11Invoice`] or [`Bolt11Invoice`]
2725 pub enum CreationError {
2726 /// The supplied description string was longer than 639 __bytes__ (see [`Description::new`])
2728 /// The specified route has too many hops and can't be encoded
2730 /// The Unix timestamp of the supplied date is less than zero or greater than 35-bits
2731 TimestampOutOfBounds,
2732 /// The supplied millisatoshi amount was greater than the total bitcoin supply.
2734 /// Route hints were required for this invoice and were missing. Applies to
2735 /// [phantom invoices].
2737 /// [phantom invoices]: crate::utils::create_phantom_invoice
2739 /// The provided `min_final_cltv_expiry_delta` was less than [`MIN_FINAL_CLTV_EXPIRY_DELTA`].
2741 /// [`MIN_FINAL_CLTV_EXPIRY_DELTA`]: lightning::ln::channelmanager::MIN_FINAL_CLTV_EXPIRY_DELTA
2742 MinFinalCltvExpiryDeltaTooShort,
2744 use lightning_invoice::CreationError as CreationErrorImport;
2745 pub(crate) type nativeCreationError = CreationErrorImport;
2747 impl CreationError {
2749 pub(crate) fn to_native(&self) -> nativeCreationError {
2751 CreationError::DescriptionTooLong => nativeCreationError::DescriptionTooLong,
2752 CreationError::RouteTooLong => nativeCreationError::RouteTooLong,
2753 CreationError::TimestampOutOfBounds => nativeCreationError::TimestampOutOfBounds,
2754 CreationError::InvalidAmount => nativeCreationError::InvalidAmount,
2755 CreationError::MissingRouteHints => nativeCreationError::MissingRouteHints,
2756 CreationError::MinFinalCltvExpiryDeltaTooShort => nativeCreationError::MinFinalCltvExpiryDeltaTooShort,
2760 pub(crate) fn into_native(self) -> nativeCreationError {
2762 CreationError::DescriptionTooLong => nativeCreationError::DescriptionTooLong,
2763 CreationError::RouteTooLong => nativeCreationError::RouteTooLong,
2764 CreationError::TimestampOutOfBounds => nativeCreationError::TimestampOutOfBounds,
2765 CreationError::InvalidAmount => nativeCreationError::InvalidAmount,
2766 CreationError::MissingRouteHints => nativeCreationError::MissingRouteHints,
2767 CreationError::MinFinalCltvExpiryDeltaTooShort => nativeCreationError::MinFinalCltvExpiryDeltaTooShort,
2771 pub(crate) fn from_native(native: &nativeCreationError) -> Self {
2773 nativeCreationError::DescriptionTooLong => CreationError::DescriptionTooLong,
2774 nativeCreationError::RouteTooLong => CreationError::RouteTooLong,
2775 nativeCreationError::TimestampOutOfBounds => CreationError::TimestampOutOfBounds,
2776 nativeCreationError::InvalidAmount => CreationError::InvalidAmount,
2777 nativeCreationError::MissingRouteHints => CreationError::MissingRouteHints,
2778 nativeCreationError::MinFinalCltvExpiryDeltaTooShort => CreationError::MinFinalCltvExpiryDeltaTooShort,
2782 pub(crate) fn native_into(native: nativeCreationError) -> Self {
2784 nativeCreationError::DescriptionTooLong => CreationError::DescriptionTooLong,
2785 nativeCreationError::RouteTooLong => CreationError::RouteTooLong,
2786 nativeCreationError::TimestampOutOfBounds => CreationError::TimestampOutOfBounds,
2787 nativeCreationError::InvalidAmount => CreationError::InvalidAmount,
2788 nativeCreationError::MissingRouteHints => CreationError::MissingRouteHints,
2789 nativeCreationError::MinFinalCltvExpiryDeltaTooShort => CreationError::MinFinalCltvExpiryDeltaTooShort,
2793 /// Creates a copy of the CreationError
2795 pub extern "C" fn CreationError_clone(orig: &CreationError) -> CreationError {
2799 /// Used only if an object of this type is returned as a trait impl by a method
2800 pub(crate) extern "C" fn CreationError_clone_void(this_ptr: *const c_void) -> *mut c_void {
2801 Box::into_raw(Box::new(unsafe { (*(this_ptr as *const CreationError)).clone() })) as *mut c_void
2804 /// Used only if an object of this type is returned as a trait impl by a method
2805 pub(crate) extern "C" fn CreationError_free_void(this_ptr: *mut c_void) {
2806 let _ = unsafe { Box::from_raw(this_ptr as *mut CreationError) };
2809 /// Utility method to constructs a new DescriptionTooLong-variant CreationError
2810 pub extern "C" fn CreationError_description_too_long() -> CreationError {
2811 CreationError::DescriptionTooLong}
2813 /// Utility method to constructs a new RouteTooLong-variant CreationError
2814 pub extern "C" fn CreationError_route_too_long() -> CreationError {
2815 CreationError::RouteTooLong}
2817 /// Utility method to constructs a new TimestampOutOfBounds-variant CreationError
2818 pub extern "C" fn CreationError_timestamp_out_of_bounds() -> CreationError {
2819 CreationError::TimestampOutOfBounds}
2821 /// Utility method to constructs a new InvalidAmount-variant CreationError
2822 pub extern "C" fn CreationError_invalid_amount() -> CreationError {
2823 CreationError::InvalidAmount}
2825 /// Utility method to constructs a new MissingRouteHints-variant CreationError
2826 pub extern "C" fn CreationError_missing_route_hints() -> CreationError {
2827 CreationError::MissingRouteHints}
2829 /// Utility method to constructs a new MinFinalCltvExpiryDeltaTooShort-variant CreationError
2830 pub extern "C" fn CreationError_min_final_cltv_expiry_delta_too_short() -> CreationError {
2831 CreationError::MinFinalCltvExpiryDeltaTooShort}
2832 /// Checks if two CreationErrors contain equal inner contents.
2833 /// This ignores pointers and is_owned flags and looks at the values in fields.
2835 pub extern "C" fn CreationError_eq(a: &CreationError, b: &CreationError) -> bool {
2836 if &a.to_native() == &b.to_native() { true } else { false }
2839 /// Get the string representation of a CreationError object
2840 pub extern "C" fn CreationError_to_str(o: &crate::lightning_invoice::CreationError) -> Str {
2841 alloc::format!("{}", &o.to_native()).into()
2843 /// Errors that may occur when converting a [`RawBolt11Invoice`] to a [`Bolt11Invoice`]. They relate to
2844 /// the requirements sections in BOLT #11
2848 pub enum Bolt11SemanticError {
2849 /// The invoice is missing the mandatory payment hash
2851 /// The invoice has multiple payment hashes which isn't allowed
2852 MultiplePaymentHashes,
2853 /// No description or description hash are part of the invoice
2855 /// The invoice contains multiple descriptions and/or description hashes which isn't allowed
2856 MultipleDescriptions,
2857 /// The invoice is missing the mandatory payment secret, which all modern lightning nodes
2860 /// The invoice contains multiple payment secrets
2861 MultiplePaymentSecrets,
2862 /// The invoice's features are invalid
2864 /// The recovery id doesn't fit the signature/pub key
2866 /// The invoice's signature is invalid
2868 /// The invoice's amount was not a whole number of millisatoshis
2871 use lightning_invoice::Bolt11SemanticError as Bolt11SemanticErrorImport;
2872 pub(crate) type nativeBolt11SemanticError = Bolt11SemanticErrorImport;
2874 impl Bolt11SemanticError {
2876 pub(crate) fn to_native(&self) -> nativeBolt11SemanticError {
2878 Bolt11SemanticError::NoPaymentHash => nativeBolt11SemanticError::NoPaymentHash,
2879 Bolt11SemanticError::MultiplePaymentHashes => nativeBolt11SemanticError::MultiplePaymentHashes,
2880 Bolt11SemanticError::NoDescription => nativeBolt11SemanticError::NoDescription,
2881 Bolt11SemanticError::MultipleDescriptions => nativeBolt11SemanticError::MultipleDescriptions,
2882 Bolt11SemanticError::NoPaymentSecret => nativeBolt11SemanticError::NoPaymentSecret,
2883 Bolt11SemanticError::MultiplePaymentSecrets => nativeBolt11SemanticError::MultiplePaymentSecrets,
2884 Bolt11SemanticError::InvalidFeatures => nativeBolt11SemanticError::InvalidFeatures,
2885 Bolt11SemanticError::InvalidRecoveryId => nativeBolt11SemanticError::InvalidRecoveryId,
2886 Bolt11SemanticError::InvalidSignature => nativeBolt11SemanticError::InvalidSignature,
2887 Bolt11SemanticError::ImpreciseAmount => nativeBolt11SemanticError::ImpreciseAmount,
2891 pub(crate) fn into_native(self) -> nativeBolt11SemanticError {
2893 Bolt11SemanticError::NoPaymentHash => nativeBolt11SemanticError::NoPaymentHash,
2894 Bolt11SemanticError::MultiplePaymentHashes => nativeBolt11SemanticError::MultiplePaymentHashes,
2895 Bolt11SemanticError::NoDescription => nativeBolt11SemanticError::NoDescription,
2896 Bolt11SemanticError::MultipleDescriptions => nativeBolt11SemanticError::MultipleDescriptions,
2897 Bolt11SemanticError::NoPaymentSecret => nativeBolt11SemanticError::NoPaymentSecret,
2898 Bolt11SemanticError::MultiplePaymentSecrets => nativeBolt11SemanticError::MultiplePaymentSecrets,
2899 Bolt11SemanticError::InvalidFeatures => nativeBolt11SemanticError::InvalidFeatures,
2900 Bolt11SemanticError::InvalidRecoveryId => nativeBolt11SemanticError::InvalidRecoveryId,
2901 Bolt11SemanticError::InvalidSignature => nativeBolt11SemanticError::InvalidSignature,
2902 Bolt11SemanticError::ImpreciseAmount => nativeBolt11SemanticError::ImpreciseAmount,
2906 pub(crate) fn from_native(native: &nativeBolt11SemanticError) -> Self {
2908 nativeBolt11SemanticError::NoPaymentHash => Bolt11SemanticError::NoPaymentHash,
2909 nativeBolt11SemanticError::MultiplePaymentHashes => Bolt11SemanticError::MultiplePaymentHashes,
2910 nativeBolt11SemanticError::NoDescription => Bolt11SemanticError::NoDescription,
2911 nativeBolt11SemanticError::MultipleDescriptions => Bolt11SemanticError::MultipleDescriptions,
2912 nativeBolt11SemanticError::NoPaymentSecret => Bolt11SemanticError::NoPaymentSecret,
2913 nativeBolt11SemanticError::MultiplePaymentSecrets => Bolt11SemanticError::MultiplePaymentSecrets,
2914 nativeBolt11SemanticError::InvalidFeatures => Bolt11SemanticError::InvalidFeatures,
2915 nativeBolt11SemanticError::InvalidRecoveryId => Bolt11SemanticError::InvalidRecoveryId,
2916 nativeBolt11SemanticError::InvalidSignature => Bolt11SemanticError::InvalidSignature,
2917 nativeBolt11SemanticError::ImpreciseAmount => Bolt11SemanticError::ImpreciseAmount,
2921 pub(crate) fn native_into(native: nativeBolt11SemanticError) -> Self {
2923 nativeBolt11SemanticError::NoPaymentHash => Bolt11SemanticError::NoPaymentHash,
2924 nativeBolt11SemanticError::MultiplePaymentHashes => Bolt11SemanticError::MultiplePaymentHashes,
2925 nativeBolt11SemanticError::NoDescription => Bolt11SemanticError::NoDescription,
2926 nativeBolt11SemanticError::MultipleDescriptions => Bolt11SemanticError::MultipleDescriptions,
2927 nativeBolt11SemanticError::NoPaymentSecret => Bolt11SemanticError::NoPaymentSecret,
2928 nativeBolt11SemanticError::MultiplePaymentSecrets => Bolt11SemanticError::MultiplePaymentSecrets,
2929 nativeBolt11SemanticError::InvalidFeatures => Bolt11SemanticError::InvalidFeatures,
2930 nativeBolt11SemanticError::InvalidRecoveryId => Bolt11SemanticError::InvalidRecoveryId,
2931 nativeBolt11SemanticError::InvalidSignature => Bolt11SemanticError::InvalidSignature,
2932 nativeBolt11SemanticError::ImpreciseAmount => Bolt11SemanticError::ImpreciseAmount,
2936 /// Creates a copy of the Bolt11SemanticError
2938 pub extern "C" fn Bolt11SemanticError_clone(orig: &Bolt11SemanticError) -> Bolt11SemanticError {
2942 /// Used only if an object of this type is returned as a trait impl by a method
2943 pub(crate) extern "C" fn Bolt11SemanticError_clone_void(this_ptr: *const c_void) -> *mut c_void {
2944 Box::into_raw(Box::new(unsafe { (*(this_ptr as *const Bolt11SemanticError)).clone() })) as *mut c_void
2947 /// Used only if an object of this type is returned as a trait impl by a method
2948 pub(crate) extern "C" fn Bolt11SemanticError_free_void(this_ptr: *mut c_void) {
2949 let _ = unsafe { Box::from_raw(this_ptr as *mut Bolt11SemanticError) };
2952 /// Utility method to constructs a new NoPaymentHash-variant Bolt11SemanticError
2953 pub extern "C" fn Bolt11SemanticError_no_payment_hash() -> Bolt11SemanticError {
2954 Bolt11SemanticError::NoPaymentHash}
2956 /// Utility method to constructs a new MultiplePaymentHashes-variant Bolt11SemanticError
2957 pub extern "C" fn Bolt11SemanticError_multiple_payment_hashes() -> Bolt11SemanticError {
2958 Bolt11SemanticError::MultiplePaymentHashes}
2960 /// Utility method to constructs a new NoDescription-variant Bolt11SemanticError
2961 pub extern "C" fn Bolt11SemanticError_no_description() -> Bolt11SemanticError {
2962 Bolt11SemanticError::NoDescription}
2964 /// Utility method to constructs a new MultipleDescriptions-variant Bolt11SemanticError
2965 pub extern "C" fn Bolt11SemanticError_multiple_descriptions() -> Bolt11SemanticError {
2966 Bolt11SemanticError::MultipleDescriptions}
2968 /// Utility method to constructs a new NoPaymentSecret-variant Bolt11SemanticError
2969 pub extern "C" fn Bolt11SemanticError_no_payment_secret() -> Bolt11SemanticError {
2970 Bolt11SemanticError::NoPaymentSecret}
2972 /// Utility method to constructs a new MultiplePaymentSecrets-variant Bolt11SemanticError
2973 pub extern "C" fn Bolt11SemanticError_multiple_payment_secrets() -> Bolt11SemanticError {
2974 Bolt11SemanticError::MultiplePaymentSecrets}
2976 /// Utility method to constructs a new InvalidFeatures-variant Bolt11SemanticError
2977 pub extern "C" fn Bolt11SemanticError_invalid_features() -> Bolt11SemanticError {
2978 Bolt11SemanticError::InvalidFeatures}
2980 /// Utility method to constructs a new InvalidRecoveryId-variant Bolt11SemanticError
2981 pub extern "C" fn Bolt11SemanticError_invalid_recovery_id() -> Bolt11SemanticError {
2982 Bolt11SemanticError::InvalidRecoveryId}
2984 /// Utility method to constructs a new InvalidSignature-variant Bolt11SemanticError
2985 pub extern "C" fn Bolt11SemanticError_invalid_signature() -> Bolt11SemanticError {
2986 Bolt11SemanticError::InvalidSignature}
2988 /// Utility method to constructs a new ImpreciseAmount-variant Bolt11SemanticError
2989 pub extern "C" fn Bolt11SemanticError_imprecise_amount() -> Bolt11SemanticError {
2990 Bolt11SemanticError::ImpreciseAmount}
2991 /// Checks if two Bolt11SemanticErrors contain equal inner contents.
2992 /// This ignores pointers and is_owned flags and looks at the values in fields.
2994 pub extern "C" fn Bolt11SemanticError_eq(a: &Bolt11SemanticError, b: &Bolt11SemanticError) -> bool {
2995 if &a.to_native() == &b.to_native() { true } else { false }
2998 /// Get the string representation of a Bolt11SemanticError object
2999 pub extern "C" fn Bolt11SemanticError_to_str(o: &crate::lightning_invoice::Bolt11SemanticError) -> Str {
3000 alloc::format!("{}", &o.to_native()).into()
3002 /// When signing using a fallible method either an user-supplied `SignError` or a [`CreationError`]
3007 pub enum SignOrCreationError {
3008 /// An error occurred during signing
3010 /// An error occurred while building the transaction
3012 crate::lightning_invoice::CreationError),
3014 use lightning_invoice::SignOrCreationError as SignOrCreationErrorImport;
3015 pub(crate) type nativeSignOrCreationError = SignOrCreationErrorImport<>;
3017 impl SignOrCreationError {
3019 pub(crate) fn to_native(&self) -> nativeSignOrCreationError {
3021 SignOrCreationError::SignError => {
3022 nativeSignOrCreationError::SignError (
3026 SignOrCreationError::CreationError (ref a, ) => {
3027 let mut a_nonref = Clone::clone(a);
3028 nativeSignOrCreationError::CreationError (
3029 a_nonref.into_native(),
3035 pub(crate) fn into_native(self) -> nativeSignOrCreationError {
3037 SignOrCreationError::SignError => {
3038 nativeSignOrCreationError::SignError (
3042 SignOrCreationError::CreationError (mut a, ) => {
3043 nativeSignOrCreationError::CreationError (
3050 pub(crate) fn from_native(native: &nativeSignOrCreationError) -> Self {
3052 nativeSignOrCreationError::SignError (ref a, ) => {
3053 SignOrCreationError::SignError },
3054 nativeSignOrCreationError::CreationError (ref a, ) => {
3055 let mut a_nonref = Clone::clone(a);
3056 SignOrCreationError::CreationError (
3057 crate::lightning_invoice::CreationError::native_into(a_nonref),
3063 pub(crate) fn native_into(native: nativeSignOrCreationError) -> Self {
3065 nativeSignOrCreationError::SignError (mut a, ) => {
3066 SignOrCreationError::SignError },
3067 nativeSignOrCreationError::CreationError (mut a, ) => {
3068 SignOrCreationError::CreationError (
3069 crate::lightning_invoice::CreationError::native_into(a),
3075 /// Frees any resources used by the SignOrCreationError
3077 pub extern "C" fn SignOrCreationError_free(this_ptr: SignOrCreationError) { }
3078 /// Creates a copy of the SignOrCreationError
3080 pub extern "C" fn SignOrCreationError_clone(orig: &SignOrCreationError) -> SignOrCreationError {
3084 /// Used only if an object of this type is returned as a trait impl by a method
3085 pub(crate) extern "C" fn SignOrCreationError_clone_void(this_ptr: *const c_void) -> *mut c_void {
3086 Box::into_raw(Box::new(unsafe { (*(this_ptr as *const SignOrCreationError)).clone() })) as *mut c_void
3089 /// Used only if an object of this type is returned as a trait impl by a method
3090 pub(crate) extern "C" fn SignOrCreationError_free_void(this_ptr: *mut c_void) {
3091 let _ = unsafe { Box::from_raw(this_ptr as *mut SignOrCreationError) };
3094 /// Utility method to constructs a new SignError-variant SignOrCreationError
3095 pub extern "C" fn SignOrCreationError_sign_error() -> SignOrCreationError {
3096 SignOrCreationError::SignError
3099 /// Utility method to constructs a new CreationError-variant SignOrCreationError
3100 pub extern "C" fn SignOrCreationError_creation_error(a: crate::lightning_invoice::CreationError) -> SignOrCreationError {
3101 SignOrCreationError::CreationError(a, )
3103 /// Checks if two SignOrCreationErrors contain equal inner contents.
3104 /// This ignores pointers and is_owned flags and looks at the values in fields.
3106 pub extern "C" fn SignOrCreationError_eq(a: &SignOrCreationError, b: &SignOrCreationError) -> bool {
3107 if &a.to_native() == &b.to_native() { true } else { false }
3110 /// Get the string representation of a SignOrCreationError object
3111 pub extern "C" fn SignOrCreationError_to_str(o: &crate::lightning_invoice::SignOrCreationError) -> Str {
3112 alloc::format!("{}", &o.to_native()).into()