// source was automatically generated.
//! This crate provides data structures to represent
-//! [lightning BOLT11](https://github.com/lightningnetwork/lightning-rfc/blob/master/11-payment-encoding.md)
+//! [lightning BOLT11](https://github.com/lightning/bolts/blob/master/11-payment-encoding.md)
//! invoices and functions to create, encode and decode these. If you just want to use the standard
//! en-/decoding functionality this should get you started:
//!
pub mod payment;
pub mod utils;
pub mod constants;
+mod time_utils {
+
+use alloc::str::FromStr;
+use core::ffi::c_void;
+use core::convert::Infallible;
+use bitcoin::hashes::Hash;
+use crate::c_types::*;
+#[cfg(feature="no-std")]
+use alloc::{vec::Vec, boxed::Box};
+
+}
mod de {
use alloc::str::FromStr;
}
/// Errors that indicate what is wrong with the invoice. They have some granularity for debug
/// reasons, but should generally result in an \"invalid BOLT11 invoice\" message for the user.
-#[must_use]
#[derive(Clone)]
+#[must_use]
#[repr(C)]
pub enum ParseError {
- Bech32Error(crate::c_types::Bech32Error),
- ParseAmountError(crate::c_types::Error),
- MalformedSignature(crate::c_types::Secp256k1Error),
+ Bech32Error(
+ crate::c_types::Bech32Error),
+ ParseAmountError(
+ crate::c_types::Error),
+ MalformedSignature(
+ crate::c_types::Secp256k1Error),
BadPrefix,
UnknownCurrency,
UnknownSiPrefix,
MalformedHRP,
TooShortDataPart,
UnexpectedEndOfTaggedFields,
- DescriptionDecodeError(crate::c_types::Error),
+ DescriptionDecodeError(
+ crate::c_types::Error),
PaddingError,
IntegerOverflowError,
InvalidSegWitProgramLength,
InvalidPubKeyHashLength,
InvalidScriptHashLength,
InvalidRecoveryId,
- InvalidSliceLength(crate::c_types::Str),
+ InvalidSliceLength(
+ crate::c_types::Str),
/// Not an error, but used internally to signal that a part of the invoice should be ignored
/// according to BOLT11
Skip,
}
-use lightning_invoice::ParseError as nativeParseError;
+use lightning_invoice::ParseError as ParseErrorImport;
+pub(crate) type nativeParseError = ParseErrorImport;
+
impl ParseError {
#[allow(unused)]
pub(crate) fn to_native(&self) -> nativeParseError {
match self {
ParseError::Bech32Error (ref a, ) => {
- let mut a_nonref = (*a).clone();
+ let mut a_nonref = Clone::clone(a);
nativeParseError::Bech32Error (
a_nonref.into_rust(),
)
},
ParseError::ParseAmountError (ref a, ) => {
- let mut a_nonref = (*a).clone();
+ let mut a_nonref = Clone::clone(a);
nativeParseError::ParseAmountError (
u8::from_str_radix(" a", 10).unwrap_err() /*a_nonref*/,
)
},
ParseError::MalformedSignature (ref a, ) => {
- let mut a_nonref = (*a).clone();
+ let mut a_nonref = Clone::clone(a);
nativeParseError::MalformedSignature (
a_nonref.into_rust(),
)
ParseError::TooShortDataPart => nativeParseError::TooShortDataPart,
ParseError::UnexpectedEndOfTaggedFields => nativeParseError::UnexpectedEndOfTaggedFields,
ParseError::DescriptionDecodeError (ref a, ) => {
- let mut a_nonref = (*a).clone();
+ let mut a_nonref = Clone::clone(a);
nativeParseError::DescriptionDecodeError (
core::str::from_utf8(&[0xff]).unwrap_err() /*a_nonref*/,
)
ParseError::InvalidScriptHashLength => nativeParseError::InvalidScriptHashLength,
ParseError::InvalidRecoveryId => nativeParseError::InvalidRecoveryId,
ParseError::InvalidSliceLength (ref a, ) => {
- let mut a_nonref = (*a).clone();
+ let mut a_nonref = Clone::clone(a);
nativeParseError::InvalidSliceLength (
a_nonref.into_string(),
)
pub(crate) fn from_native(native: &nativeParseError) -> Self {
match native {
nativeParseError::Bech32Error (ref a, ) => {
- let mut a_nonref = (*a).clone();
+ let mut a_nonref = Clone::clone(a);
ParseError::Bech32Error (
crate::c_types::Bech32Error::from_rust(a_nonref),
)
},
nativeParseError::ParseAmountError (ref a, ) => {
- let mut a_nonref = (*a).clone();
+ let mut a_nonref = Clone::clone(a);
ParseError::ParseAmountError (
crate::c_types::Error { _dummy: 0 } /*a_nonref*/,
)
},
nativeParseError::MalformedSignature (ref a, ) => {
- let mut a_nonref = (*a).clone();
+ let mut a_nonref = Clone::clone(a);
ParseError::MalformedSignature (
crate::c_types::Secp256k1Error::from_rust(a_nonref),
)
nativeParseError::TooShortDataPart => ParseError::TooShortDataPart,
nativeParseError::UnexpectedEndOfTaggedFields => ParseError::UnexpectedEndOfTaggedFields,
nativeParseError::DescriptionDecodeError (ref a, ) => {
- let mut a_nonref = (*a).clone();
+ let mut a_nonref = Clone::clone(a);
ParseError::DescriptionDecodeError (
crate::c_types::Error { _dummy: 0 } /*a_nonref*/,
)
nativeParseError::InvalidScriptHashLength => ParseError::InvalidScriptHashLength,
nativeParseError::InvalidRecoveryId => ParseError::InvalidRecoveryId,
nativeParseError::InvalidSliceLength (ref a, ) => {
- let mut a_nonref = (*a).clone();
+ let mut a_nonref = Clone::clone(a);
ParseError::InvalidSliceLength (
a_nonref.into(),
)
/// Utility method to constructs a new Skip-variant ParseError
pub extern "C" fn ParseError_skip() -> ParseError {
ParseError::Skip}
+/// Checks if two ParseErrors contain equal inner contents.
+/// This ignores pointers and is_owned flags and looks at the values in fields.
+#[no_mangle]
+pub extern "C" fn ParseError_eq(a: &ParseError, b: &ParseError) -> bool {
+ if &a.to_native() == &b.to_native() { true } else { false }
+}
/// Indicates that something went wrong while parsing or validating the invoice. Parsing errors
/// should be mostly seen as opaque and are only there for debugging reasons. Semantic errors
/// like wrong signatures, missing fields etc. could mean that someone tampered with the invoice.
-#[must_use]
#[derive(Clone)]
+#[must_use]
#[repr(C)]
pub enum ParseOrSemanticError {
/// The invoice couldn't be decoded
- ParseError(crate::lightning_invoice::ParseError),
+ ParseError(
+ crate::lightning_invoice::ParseError),
/// The invoice could be decoded but violates the BOLT11 standard
- SemanticError(crate::lightning_invoice::SemanticError),
+ SemanticError(
+ crate::lightning_invoice::SemanticError),
}
-use lightning_invoice::ParseOrSemanticError as nativeParseOrSemanticError;
+use lightning_invoice::ParseOrSemanticError as ParseOrSemanticErrorImport;
+pub(crate) type nativeParseOrSemanticError = ParseOrSemanticErrorImport;
+
impl ParseOrSemanticError {
#[allow(unused)]
pub(crate) fn to_native(&self) -> nativeParseOrSemanticError {
match self {
ParseOrSemanticError::ParseError (ref a, ) => {
- let mut a_nonref = (*a).clone();
+ let mut a_nonref = Clone::clone(a);
nativeParseOrSemanticError::ParseError (
a_nonref.into_native(),
)
},
ParseOrSemanticError::SemanticError (ref a, ) => {
- let mut a_nonref = (*a).clone();
+ let mut a_nonref = Clone::clone(a);
nativeParseOrSemanticError::SemanticError (
a_nonref.into_native(),
)
pub(crate) fn from_native(native: &nativeParseOrSemanticError) -> Self {
match native {
nativeParseOrSemanticError::ParseError (ref a, ) => {
- let mut a_nonref = (*a).clone();
+ let mut a_nonref = Clone::clone(a);
ParseOrSemanticError::ParseError (
crate::lightning_invoice::ParseError::native_into(a_nonref),
)
},
nativeParseOrSemanticError::SemanticError (ref a, ) => {
- let mut a_nonref = (*a).clone();
+ let mut a_nonref = Clone::clone(a);
ParseOrSemanticError::SemanticError (
crate::lightning_invoice::SemanticError::native_into(a_nonref),
)
pub extern "C" fn ParseOrSemanticError_semantic_error(a: crate::lightning_invoice::SemanticError) -> ParseOrSemanticError {
ParseOrSemanticError::SemanticError(a, )
}
+/// Checks if two ParseOrSemanticErrors contain equal inner contents.
+/// This ignores pointers and is_owned flags and looks at the values in fields.
+#[no_mangle]
+pub extern "C" fn ParseOrSemanticError_eq(a: &ParseOrSemanticError, b: &ParseOrSemanticError) -> bool {
+ if &a.to_native() == &b.to_native() { true } else { false }
+}
/// The maximum timestamp as [`Duration::as_secs`] since the Unix epoch allowed by [`BOLT 11`].
///
/// [BOLT 11]: https://github.com/lightning/bolts/blob/master/11-payment-encoding.md
#[allow(unused)]
/// Used only if an object of this type is returned as a trait impl by a method
pub(crate) extern "C" fn Invoice_free_void(this_ptr: *mut c_void) {
- unsafe { let _ = Box::from_raw(this_ptr as *mut nativeInvoice); }
+ let _ = unsafe { Box::from_raw(this_ptr as *mut nativeInvoice) };
}
#[allow(unused)]
impl Invoice {
pub extern "C" fn Invoice_clone(orig: &Invoice) -> Invoice {
orig.clone()
}
+/// Checks if two Invoices contain equal inner contents.
+#[no_mangle]
+pub extern "C" fn Invoice_hash(o: &Invoice) -> u64 {
+ if o.inner.is_null() { return 0; }
+ // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
+ #[allow(deprecated)]
+ let mut hasher = core::hash::SipHasher::new();
+ core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
+ core::hash::Hasher::finish(&hasher)
+}
use lightning_invoice::SignedRawInvoice as nativeSignedRawInvoiceImport;
pub(crate) type nativeSignedRawInvoice = nativeSignedRawInvoiceImport;
#[allow(unused)]
/// Used only if an object of this type is returned as a trait impl by a method
pub(crate) extern "C" fn SignedRawInvoice_free_void(this_ptr: *mut c_void) {
- unsafe { let _ = Box::from_raw(this_ptr as *mut nativeSignedRawInvoice); }
+ let _ = unsafe { Box::from_raw(this_ptr as *mut nativeSignedRawInvoice) };
}
#[allow(unused)]
impl SignedRawInvoice {
pub extern "C" fn SignedRawInvoice_clone(orig: &SignedRawInvoice) -> SignedRawInvoice {
orig.clone()
}
+/// Checks if two SignedRawInvoices contain equal inner contents.
+#[no_mangle]
+pub extern "C" fn SignedRawInvoice_hash(o: &SignedRawInvoice) -> u64 {
+ if o.inner.is_null() { return 0; }
+ // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
+ #[allow(deprecated)]
+ let mut hasher = core::hash::SipHasher::new();
+ core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
+ core::hash::Hasher::finish(&hasher)
+}
use lightning_invoice::RawInvoice as nativeRawInvoiceImport;
pub(crate) type nativeRawInvoice = nativeRawInvoiceImport;
#[allow(unused)]
/// Used only if an object of this type is returned as a trait impl by a method
pub(crate) extern "C" fn RawInvoice_free_void(this_ptr: *mut c_void) {
- unsafe { let _ = Box::from_raw(this_ptr as *mut nativeRawInvoice); }
+ let _ = unsafe { Box::from_raw(this_ptr as *mut nativeRawInvoice) };
}
#[allow(unused)]
impl RawInvoice {
pub extern "C" fn RawInvoice_clone(orig: &RawInvoice) -> RawInvoice {
orig.clone()
}
+/// Checks if two RawInvoices contain equal inner contents.
+#[no_mangle]
+pub extern "C" fn RawInvoice_hash(o: &RawInvoice) -> u64 {
+ if o.inner.is_null() { return 0; }
+ // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
+ #[allow(deprecated)]
+ let mut hasher = core::hash::SipHasher::new();
+ core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
+ core::hash::Hasher::finish(&hasher)
+}
use lightning_invoice::RawDataPart as nativeRawDataPartImport;
pub(crate) type nativeRawDataPart = nativeRawDataPartImport;
#[allow(unused)]
/// Used only if an object of this type is returned as a trait impl by a method
pub(crate) extern "C" fn RawDataPart_free_void(this_ptr: *mut c_void) {
- unsafe { let _ = Box::from_raw(this_ptr as *mut nativeRawDataPart); }
+ let _ = unsafe { Box::from_raw(this_ptr as *mut nativeRawDataPart) };
}
#[allow(unused)]
impl RawDataPart {
pub extern "C" fn RawDataPart_clone(orig: &RawDataPart) -> RawDataPart {
orig.clone()
}
+/// Checks if two RawDataParts contain equal inner contents.
+#[no_mangle]
+pub extern "C" fn RawDataPart_hash(o: &RawDataPart) -> u64 {
+ if o.inner.is_null() { return 0; }
+ // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
+ #[allow(deprecated)]
+ let mut hasher = core::hash::SipHasher::new();
+ core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
+ core::hash::Hasher::finish(&hasher)
+}
use lightning_invoice::PositiveTimestamp as nativePositiveTimestampImport;
pub(crate) type nativePositiveTimestamp = nativePositiveTimestampImport;
#[allow(unused)]
/// Used only if an object of this type is returned as a trait impl by a method
pub(crate) extern "C" fn PositiveTimestamp_free_void(this_ptr: *mut c_void) {
- unsafe { let _ = Box::from_raw(this_ptr as *mut nativePositiveTimestamp); }
+ let _ = unsafe { Box::from_raw(this_ptr as *mut nativePositiveTimestamp) };
}
#[allow(unused)]
impl PositiveTimestamp {
pub extern "C" fn PositiveTimestamp_clone(orig: &PositiveTimestamp) -> PositiveTimestamp {
orig.clone()
}
+/// Checks if two PositiveTimestamps contain equal inner contents.
+#[no_mangle]
+pub extern "C" fn PositiveTimestamp_hash(o: &PositiveTimestamp) -> u64 {
+ if o.inner.is_null() { return 0; }
+ // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
+ #[allow(deprecated)]
+ let mut hasher = core::hash::SipHasher::new();
+ core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
+ core::hash::Hasher::finish(&hasher)
+}
/// SI prefixes for the human readable part
-#[must_use]
#[derive(Clone)]
+#[must_use]
#[repr(C)]
pub enum SiPrefix {
/// 10^-3
/// 10^-12
Pico,
}
-use lightning_invoice::SiPrefix as nativeSiPrefix;
+use lightning_invoice::SiPrefix as SiPrefixImport;
+pub(crate) type nativeSiPrefix = SiPrefixImport;
+
impl SiPrefix {
#[allow(unused)]
pub(crate) fn to_native(&self) -> nativeSiPrefix {
pub extern "C" fn SiPrefix_eq(a: &SiPrefix, b: &SiPrefix) -> bool {
if &a.to_native() == &b.to_native() { true } else { false }
}
+/// Checks if two SiPrefixs contain equal inner contents.
+#[no_mangle]
+pub extern "C" fn SiPrefix_hash(o: &SiPrefix) -> u64 {
+ // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
+ #[allow(deprecated)]
+ let mut hasher = core::hash::SipHasher::new();
+ core::hash::Hash::hash(&o.to_native(), &mut hasher);
+ core::hash::Hasher::finish(&hasher)
+}
/// Returns the multiplier to go from a BTC value to picoBTC implied by this SiPrefix.
/// This is effectively 10^12 * the prefix multiplier
#[must_use]
#[no_mangle]
-pub extern "C" fn SiPrefix_multiplier(this_arg: &SiPrefix) -> u64 {
+pub extern "C" fn SiPrefix_multiplier(this_arg: &crate::lightning_invoice::SiPrefix) -> u64 {
let mut ret = this_arg.to_native().multiplier();
ret
}
/// Enum representing the crypto currencies (or networks) supported by this library
-#[must_use]
#[derive(Clone)]
+#[must_use]
#[repr(C)]
pub enum Currency {
/// Bitcoin mainnet
/// Bitcoin signet
Signet,
}
-use lightning_invoice::Currency as nativeCurrency;
+use lightning_invoice::Currency as CurrencyImport;
+pub(crate) type nativeCurrency = CurrencyImport;
+
impl Currency {
#[allow(unused)]
pub(crate) fn to_native(&self) -> nativeCurrency {
#[allow(unused)]
/// Used only if an object of this type is returned as a trait impl by a method
pub(crate) extern "C" fn Sha256_free_void(this_ptr: *mut c_void) {
- unsafe { let _ = Box::from_raw(this_ptr as *mut nativeSha256); }
+ let _ = unsafe { Box::from_raw(this_ptr as *mut nativeSha256) };
}
#[allow(unused)]
impl Sha256 {
#[allow(unused)]
/// Used only if an object of this type is returned as a trait impl by a method
pub(crate) extern "C" fn Description_free_void(this_ptr: *mut c_void) {
- unsafe { let _ = Box::from_raw(this_ptr as *mut nativeDescription); }
+ let _ = unsafe { Box::from_raw(this_ptr as *mut nativeDescription) };
}
#[allow(unused)]
impl Description {
#[allow(unused)]
/// Used only if an object of this type is returned as a trait impl by a method
pub(crate) extern "C" fn PayeePubKey_free_void(this_ptr: *mut c_void) {
- unsafe { let _ = Box::from_raw(this_ptr as *mut nativePayeePubKey); }
+ let _ = unsafe { Box::from_raw(this_ptr as *mut nativePayeePubKey) };
}
#[allow(unused)]
impl PayeePubKey {
#[allow(unused)]
/// Used only if an object of this type is returned as a trait impl by a method
pub(crate) extern "C" fn ExpiryTime_free_void(this_ptr: *mut c_void) {
- unsafe { let _ = Box::from_raw(this_ptr as *mut nativeExpiryTime); }
+ let _ = unsafe { Box::from_raw(this_ptr as *mut nativeExpiryTime) };
}
#[allow(unused)]
impl ExpiryTime {
#[allow(unused)]
/// Used only if an object of this type is returned as a trait impl by a method
pub(crate) extern "C" fn MinFinalCltvExpiry_free_void(this_ptr: *mut c_void) {
- unsafe { let _ = Box::from_raw(this_ptr as *mut nativeMinFinalCltvExpiry); }
+ let _ = unsafe { Box::from_raw(this_ptr as *mut nativeMinFinalCltvExpiry) };
}
#[allow(unused)]
impl MinFinalCltvExpiry {
if a.get_native_ref() == b.get_native_ref() { true } else { false }
}
/// Fallback address in case no LN payment is possible
-#[must_use]
#[derive(Clone)]
+#[must_use]
#[repr(C)]
pub enum Fallback {
SegWitProgram {
- version: crate::c_types::u5,
+ version: crate::c_types::U5,
program: crate::c_types::derived::CVec_u8Z,
},
- PubKeyHash(crate::c_types::TwentyBytes),
- ScriptHash(crate::c_types::TwentyBytes),
+ PubKeyHash(
+ crate::c_types::TwentyBytes),
+ ScriptHash(
+ crate::c_types::TwentyBytes),
}
-use lightning_invoice::Fallback as nativeFallback;
+use lightning_invoice::Fallback as FallbackImport;
+pub(crate) type nativeFallback = FallbackImport;
+
impl Fallback {
#[allow(unused)]
pub(crate) fn to_native(&self) -> nativeFallback {
match self {
Fallback::SegWitProgram {ref version, ref program, } => {
- let mut version_nonref = (*version).clone();
- let mut program_nonref = (*program).clone();
+ let mut version_nonref = Clone::clone(version);
+ let mut program_nonref = Clone::clone(program);
let mut local_program_nonref = Vec::new(); for mut item in program_nonref.into_rust().drain(..) { local_program_nonref.push( { item }); };
nativeFallback::SegWitProgram {
version: version_nonref.into(),
}
},
Fallback::PubKeyHash (ref a, ) => {
- let mut a_nonref = (*a).clone();
+ let mut a_nonref = Clone::clone(a);
nativeFallback::PubKeyHash (
a_nonref.data,
)
},
Fallback::ScriptHash (ref a, ) => {
- let mut a_nonref = (*a).clone();
+ let mut a_nonref = Clone::clone(a);
nativeFallback::ScriptHash (
a_nonref.data,
)
pub(crate) fn from_native(native: &nativeFallback) -> Self {
match native {
nativeFallback::SegWitProgram {ref version, ref program, } => {
- let mut version_nonref = (*version).clone();
- let mut program_nonref = (*program).clone();
+ let mut version_nonref = Clone::clone(version);
+ let mut program_nonref = Clone::clone(program);
let mut local_program_nonref = Vec::new(); for mut item in program_nonref.drain(..) { local_program_nonref.push( { item }); };
Fallback::SegWitProgram {
version: version_nonref.into(),
}
},
nativeFallback::PubKeyHash (ref a, ) => {
- let mut a_nonref = (*a).clone();
+ let mut a_nonref = Clone::clone(a);
Fallback::PubKeyHash (
crate::c_types::TwentyBytes { data: a_nonref },
)
},
nativeFallback::ScriptHash (ref a, ) => {
- let mut a_nonref = (*a).clone();
+ let mut a_nonref = Clone::clone(a);
Fallback::ScriptHash (
crate::c_types::TwentyBytes { data: a_nonref },
)
}
#[no_mangle]
/// Utility method to constructs a new SegWitProgram-variant Fallback
-pub extern "C" fn Fallback_seg_wit_program(version: crate::c_types::u5, program: crate::c_types::derived::CVec_u8Z) -> Fallback {
+pub extern "C" fn Fallback_seg_wit_program(version: crate::c_types::U5, program: crate::c_types::derived::CVec_u8Z) -> Fallback {
Fallback::SegWitProgram {
version,
program,
#[allow(unused)]
/// Used only if an object of this type is returned as a trait impl by a method
pub(crate) extern "C" fn InvoiceSignature_free_void(this_ptr: *mut c_void) {
- unsafe { let _ = Box::from_raw(this_ptr as *mut nativeInvoiceSignature); }
+ let _ = unsafe { Box::from_raw(this_ptr as *mut nativeInvoiceSignature) };
}
#[allow(unused)]
impl InvoiceSignature {
orig.clone()
}
/// Checks if two InvoiceSignatures contain equal inner contents.
+#[no_mangle]
+pub extern "C" fn InvoiceSignature_hash(o: &InvoiceSignature) -> u64 {
+ if o.inner.is_null() { return 0; }
+ // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
+ #[allow(deprecated)]
+ let mut hasher = core::hash::SipHasher::new();
+ core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
+ core::hash::Hasher::finish(&hasher)
+}
+/// Checks if two InvoiceSignatures contain equal inner contents.
/// This ignores pointers and is_owned flags and looks at the values in fields.
/// Two objects with NULL inner values will be considered "equal" here.
#[no_mangle]
#[allow(unused)]
/// Used only if an object of this type is returned as a trait impl by a method
pub(crate) extern "C" fn PrivateRoute_free_void(this_ptr: *mut c_void) {
- unsafe { let _ = Box::from_raw(this_ptr as *mut nativePrivateRoute); }
+ let _ = unsafe { Box::from_raw(this_ptr as *mut nativePrivateRoute) };
}
#[allow(unused)]
impl PrivateRoute {
/// 3. signature
#[must_use]
#[no_mangle]
-pub extern "C" fn SignedRawInvoice_into_parts(mut this_arg: SignedRawInvoice) -> crate::c_types::derived::C3Tuple_RawInvoice_u832InvoiceSignatureZ {
+pub extern "C" fn SignedRawInvoice_into_parts(mut this_arg: crate::lightning_invoice::SignedRawInvoice) -> crate::c_types::derived::C3Tuple_RawInvoice_u832InvoiceSignatureZ {
let mut ret = (*unsafe { Box::from_raw(this_arg.take_inner()) }).into_parts();
let (mut orig_ret_0, mut orig_ret_1, mut orig_ret_2) = ret; let mut local_ret = (crate::lightning_invoice::RawInvoice { inner: ObjOps::heap_alloc(orig_ret_0), is_owned: true }, crate::c_types::ThirtyTwoBytes { data: orig_ret_1 }, crate::lightning_invoice::InvoiceSignature { inner: ObjOps::heap_alloc(orig_ret_2), is_owned: true }).into();
local_ret
/// The `RawInvoice` which was signed.
#[must_use]
#[no_mangle]
-pub extern "C" fn SignedRawInvoice_raw_invoice(this_arg: &SignedRawInvoice) -> crate::lightning_invoice::RawInvoice {
+pub extern "C" fn SignedRawInvoice_raw_invoice(this_arg: &crate::lightning_invoice::SignedRawInvoice) -> crate::lightning_invoice::RawInvoice {
let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.raw_invoice();
crate::lightning_invoice::RawInvoice { inner: unsafe { ObjOps::nonnull_ptr_to_inner((ret as *const lightning_invoice::RawInvoice<>) as *mut _) }, is_owned: false }
}
/// The hash of the `RawInvoice` that was signed.
#[must_use]
#[no_mangle]
-pub extern "C" fn SignedRawInvoice_hash(this_arg: &SignedRawInvoice) -> *const [u8; 32] {
- let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.hash();
+pub extern "C" fn SignedRawInvoice_signable_hash(this_arg: &crate::lightning_invoice::SignedRawInvoice) -> *const [u8; 32] {
+ let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.signable_hash();
ret
}
/// InvoiceSignature for the invoice.
#[must_use]
#[no_mangle]
-pub extern "C" fn SignedRawInvoice_signature(this_arg: &SignedRawInvoice) -> crate::lightning_invoice::InvoiceSignature {
+pub extern "C" fn SignedRawInvoice_signature(this_arg: &crate::lightning_invoice::SignedRawInvoice) -> crate::lightning_invoice::InvoiceSignature {
let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.signature();
crate::lightning_invoice::InvoiceSignature { inner: unsafe { ObjOps::nonnull_ptr_to_inner((ret as *const lightning_invoice::InvoiceSignature<>) as *mut _) }, is_owned: false }
}
/// Recovers the public key used for signing the invoice from the recoverable signature.
#[must_use]
#[no_mangle]
-pub extern "C" fn SignedRawInvoice_recover_payee_pub_key(this_arg: &SignedRawInvoice) -> crate::c_types::derived::CResult_PayeePubKeyErrorZ {
+pub extern "C" fn SignedRawInvoice_recover_payee_pub_key(this_arg: &crate::lightning_invoice::SignedRawInvoice) -> crate::c_types::derived::CResult_PayeePubKeyErrorZ {
let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.recover_payee_pub_key();
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() };
local_ret
/// valid for the recovered signature (which should always be true?).
#[must_use]
#[no_mangle]
-pub extern "C" fn SignedRawInvoice_check_signature(this_arg: &SignedRawInvoice) -> bool {
+pub extern "C" fn SignedRawInvoice_check_signature(this_arg: &crate::lightning_invoice::SignedRawInvoice) -> bool {
let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.check_signature();
ret
}
-/// Calculate the hash of the encoded `RawInvoice`
+/// Calculate the hash of the encoded `RawInvoice` which should be signed.
#[must_use]
#[no_mangle]
-pub extern "C" fn RawInvoice_hash(this_arg: &RawInvoice) -> crate::c_types::ThirtyTwoBytes {
- let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.hash();
+pub extern "C" fn RawInvoice_signable_hash(this_arg: &crate::lightning_invoice::RawInvoice) -> crate::c_types::ThirtyTwoBytes {
+ let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.signable_hash();
crate::c_types::ThirtyTwoBytes { data: ret }
}
/// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
#[must_use]
#[no_mangle]
-pub extern "C" fn RawInvoice_payment_hash(this_arg: &RawInvoice) -> crate::lightning_invoice::Sha256 {
+pub extern "C" fn RawInvoice_payment_hash(this_arg: &crate::lightning_invoice::RawInvoice) -> crate::lightning_invoice::Sha256 {
let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.payment_hash();
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 };
local_ret
/// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
#[must_use]
#[no_mangle]
-pub extern "C" fn RawInvoice_description(this_arg: &RawInvoice) -> crate::lightning_invoice::Description {
+pub extern "C" fn RawInvoice_description(this_arg: &crate::lightning_invoice::RawInvoice) -> crate::lightning_invoice::Description {
let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.description();
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 };
local_ret
/// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
#[must_use]
#[no_mangle]
-pub extern "C" fn RawInvoice_payee_pub_key(this_arg: &RawInvoice) -> crate::lightning_invoice::PayeePubKey {
+pub extern "C" fn RawInvoice_payee_pub_key(this_arg: &crate::lightning_invoice::RawInvoice) -> crate::lightning_invoice::PayeePubKey {
let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.payee_pub_key();
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 };
local_ret
/// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
#[must_use]
#[no_mangle]
-pub extern "C" fn RawInvoice_description_hash(this_arg: &RawInvoice) -> crate::lightning_invoice::Sha256 {
+pub extern "C" fn RawInvoice_description_hash(this_arg: &crate::lightning_invoice::RawInvoice) -> crate::lightning_invoice::Sha256 {
let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.description_hash();
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 };
local_ret
/// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
#[must_use]
#[no_mangle]
-pub extern "C" fn RawInvoice_expiry_time(this_arg: &RawInvoice) -> crate::lightning_invoice::ExpiryTime {
+pub extern "C" fn RawInvoice_expiry_time(this_arg: &crate::lightning_invoice::RawInvoice) -> crate::lightning_invoice::ExpiryTime {
let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.expiry_time();
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 };
local_ret
/// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
#[must_use]
#[no_mangle]
-pub extern "C" fn RawInvoice_min_final_cltv_expiry(this_arg: &RawInvoice) -> crate::lightning_invoice::MinFinalCltvExpiry {
+pub extern "C" fn RawInvoice_min_final_cltv_expiry(this_arg: &crate::lightning_invoice::RawInvoice) -> crate::lightning_invoice::MinFinalCltvExpiry {
let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.min_final_cltv_expiry();
let mut local_ret = crate::lightning_invoice::MinFinalCltvExpiry { inner: unsafe { (if ret.is_none() { core::ptr::null() } else { ObjOps::nonnull_ptr_to_inner( { (ret.unwrap()) }) } as *const lightning_invoice::MinFinalCltvExpiry<>) as *mut _ }, is_owned: false };
local_ret
/// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
#[must_use]
#[no_mangle]
-pub extern "C" fn RawInvoice_payment_secret(this_arg: &RawInvoice) -> crate::c_types::ThirtyTwoBytes {
+pub extern "C" fn RawInvoice_payment_secret(this_arg: &crate::lightning_invoice::RawInvoice) -> crate::c_types::ThirtyTwoBytes {
let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.payment_secret();
let mut local_ret = if ret.is_none() { crate::c_types::ThirtyTwoBytes::null() } else { { crate::c_types::ThirtyTwoBytes { data: (ret.unwrap()).0 } } };
local_ret
/// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
#[must_use]
#[no_mangle]
-pub extern "C" fn RawInvoice_features(this_arg: &RawInvoice) -> crate::lightning::ln::features::InvoiceFeatures {
+pub extern "C" fn RawInvoice_features(this_arg: &crate::lightning_invoice::RawInvoice) -> crate::lightning::ln::features::InvoiceFeatures {
let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.features();
let mut local_ret = crate::lightning::ln::features::InvoiceFeatures { inner: unsafe { (if ret.is_none() { core::ptr::null() } else { ObjOps::nonnull_ptr_to_inner( { (ret.unwrap()) }) } as *const lightning::ln::features::InvoiceFeatures<>) as *mut _ }, is_owned: false };
local_ret
#[must_use]
#[no_mangle]
-pub extern "C" fn RawInvoice_private_routes(this_arg: &RawInvoice) -> crate::c_types::derived::CVec_PrivateRouteZ {
+pub extern "C" fn RawInvoice_private_routes(this_arg: &crate::lightning_invoice::RawInvoice) -> crate::c_types::derived::CVec_PrivateRouteZ {
let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.private_routes();
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 } }); };
local_ret.into()
#[must_use]
#[no_mangle]
-pub extern "C" fn RawInvoice_amount_pico_btc(this_arg: &RawInvoice) -> crate::c_types::derived::COption_u64Z {
+pub extern "C" fn RawInvoice_amount_pico_btc(this_arg: &crate::lightning_invoice::RawInvoice) -> crate::c_types::derived::COption_u64Z {
let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.amount_pico_btc();
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() }) };
local_ret
#[must_use]
#[no_mangle]
-pub extern "C" fn RawInvoice_currency(this_arg: &RawInvoice) -> crate::lightning_invoice::Currency {
+pub extern "C" fn RawInvoice_currency(this_arg: &crate::lightning_invoice::RawInvoice) -> crate::lightning_invoice::Currency {
let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.currency();
crate::lightning_invoice::Currency::native_into(ret)
}
/// Creates a `PositiveTimestamp` from a [`SystemTime`] with a corresponding Unix timestamp in
/// the range `0..=MAX_TIMESTAMP`.
///
+/// Note that the subsecond part is dropped as it is not representable in BOLT 11 invoices.
+///
/// Otherwise, returns a [`CreationError::TimestampOutOfBounds`].
#[must_use]
#[no_mangle]
/// Creates a `PositiveTimestamp` from a [`Duration`] since the Unix epoch in the range
/// `0..=MAX_TIMESTAMP`.
///
+/// Note that the subsecond part is dropped as it is not representable in BOLT 11 invoices.
+///
/// Otherwise, returns a [`CreationError::TimestampOutOfBounds`].
#[must_use]
#[no_mangle]
/// Returns the Unix timestamp representing the stored time
#[must_use]
#[no_mangle]
-pub extern "C" fn PositiveTimestamp_as_unix_timestamp(this_arg: &PositiveTimestamp) -> u64 {
+pub extern "C" fn PositiveTimestamp_as_unix_timestamp(this_arg: &crate::lightning_invoice::PositiveTimestamp) -> u64 {
let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.as_unix_timestamp();
ret
}
/// Returns the duration of the stored time since the Unix epoch
#[must_use]
#[no_mangle]
-pub extern "C" fn PositiveTimestamp_as_duration_since_epoch(this_arg: &PositiveTimestamp) -> u64 {
+pub extern "C" fn PositiveTimestamp_as_duration_since_epoch(this_arg: &crate::lightning_invoice::PositiveTimestamp) -> u64 {
let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.as_duration_since_epoch();
ret.as_secs()
}
/// Returns the [`SystemTime`] representing the stored time
#[must_use]
#[no_mangle]
-pub extern "C" fn PositiveTimestamp_as_time(this_arg: &PositiveTimestamp) -> u64 {
+pub extern "C" fn PositiveTimestamp_as_time(this_arg: &crate::lightning_invoice::PositiveTimestamp) -> u64 {
let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.as_time();
ret.duration_since(::std::time::SystemTime::UNIX_EPOCH).expect("Times must be post-1970").as_secs()
}
/// Transform the `Invoice` into it's unchecked version
#[must_use]
#[no_mangle]
-pub extern "C" fn Invoice_into_signed_raw(mut this_arg: Invoice) -> crate::lightning_invoice::SignedRawInvoice {
+pub extern "C" fn Invoice_into_signed_raw(mut this_arg: crate::lightning_invoice::Invoice) -> crate::lightning_invoice::SignedRawInvoice {
let mut ret = (*unsafe { Box::from_raw(this_arg.take_inner()) }).into_signed_raw();
crate::lightning_invoice::SignedRawInvoice { inner: ObjOps::heap_alloc(ret), is_owned: true }
}
/// Check that the invoice is signed correctly and that key recovery works
#[must_use]
#[no_mangle]
-pub extern "C" fn Invoice_check_signature(this_arg: &Invoice) -> crate::c_types::derived::CResult_NoneSemanticErrorZ {
+pub extern "C" fn Invoice_check_signature(this_arg: &crate::lightning_invoice::Invoice) -> crate::c_types::derived::CResult_NoneSemanticErrorZ {
let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.check_signature();
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::SemanticError::native_into(e) }).into() };
local_ret
/// Returns the `Invoice`'s timestamp (should equal its creation time)
#[must_use]
#[no_mangle]
-pub extern "C" fn Invoice_timestamp(this_arg: &Invoice) -> u64 {
+pub extern "C" fn Invoice_timestamp(this_arg: &crate::lightning_invoice::Invoice) -> u64 {
let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.timestamp();
ret.duration_since(::std::time::SystemTime::UNIX_EPOCH).expect("Times must be post-1970").as_secs()
}
/// Returns the `Invoice`'s timestamp as a duration since the Unix epoch
#[must_use]
#[no_mangle]
-pub extern "C" fn Invoice_duration_since_epoch(this_arg: &Invoice) -> u64 {
+pub extern "C" fn Invoice_duration_since_epoch(this_arg: &crate::lightning_invoice::Invoice) -> u64 {
let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.duration_since_epoch();
ret.as_secs()
}
/// Returns the hash to which we will receive the preimage on completion of the payment
#[must_use]
#[no_mangle]
-pub extern "C" fn Invoice_payment_hash(this_arg: &Invoice) -> *const [u8; 32] {
+pub extern "C" fn Invoice_payment_hash(this_arg: &crate::lightning_invoice::Invoice) -> *const [u8; 32] {
let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.payment_hash();
ret.as_inner()
}
/// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
#[must_use]
#[no_mangle]
-pub extern "C" fn Invoice_payee_pub_key(this_arg: &Invoice) -> crate::c_types::PublicKey {
+pub extern "C" fn Invoice_payee_pub_key(this_arg: &crate::lightning_invoice::Invoice) -> crate::c_types::PublicKey {
let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.payee_pub_key();
let mut local_ret = if ret.is_none() { crate::c_types::PublicKey::null() } else { { crate::c_types::PublicKey::from_rust(&(ret.unwrap())) } };
local_ret
/// Get the payment secret if one was included in the invoice
#[must_use]
#[no_mangle]
-pub extern "C" fn Invoice_payment_secret(this_arg: &Invoice) -> *const [u8; 32] {
+pub extern "C" fn Invoice_payment_secret(this_arg: &crate::lightning_invoice::Invoice) -> *const [u8; 32] {
let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.payment_secret();
&ret.0
}
/// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
#[must_use]
#[no_mangle]
-pub extern "C" fn Invoice_features(this_arg: &Invoice) -> crate::lightning::ln::features::InvoiceFeatures {
+pub extern "C" fn Invoice_features(this_arg: &crate::lightning_invoice::Invoice) -> crate::lightning::ln::features::InvoiceFeatures {
let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.features();
let mut local_ret = crate::lightning::ln::features::InvoiceFeatures { inner: unsafe { (if ret.is_none() { core::ptr::null() } else { ObjOps::nonnull_ptr_to_inner( { (ret.unwrap()) }) } as *const lightning::ln::features::InvoiceFeatures<>) as *mut _ }, is_owned: false };
local_ret
/// Recover the payee's public key (only to be used if none was included in the invoice)
#[must_use]
#[no_mangle]
-pub extern "C" fn Invoice_recover_payee_pub_key(this_arg: &Invoice) -> crate::c_types::PublicKey {
+pub extern "C" fn Invoice_recover_payee_pub_key(this_arg: &crate::lightning_invoice::Invoice) -> crate::c_types::PublicKey {
let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.recover_payee_pub_key();
crate::c_types::PublicKey::from_rust(&ret)
}
/// Returns the invoice's expiry time, if present, otherwise [`DEFAULT_EXPIRY_TIME`].
#[must_use]
#[no_mangle]
-pub extern "C" fn Invoice_expiry_time(this_arg: &Invoice) -> u64 {
+pub extern "C" fn Invoice_expiry_time(this_arg: &crate::lightning_invoice::Invoice) -> u64 {
let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.expiry_time();
ret.as_secs()
}
/// Returns whether the invoice has expired.
#[must_use]
#[no_mangle]
-pub extern "C" fn Invoice_is_expired(this_arg: &Invoice) -> bool {
+pub extern "C" fn Invoice_is_expired(this_arg: &crate::lightning_invoice::Invoice) -> bool {
let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.is_expired();
ret
}
/// `at_time` is the timestamp as a duration since the Unix epoch.
#[must_use]
#[no_mangle]
-pub extern "C" fn Invoice_would_expire(this_arg: &Invoice, mut at_time: u64) -> bool {
+pub extern "C" fn Invoice_would_expire(this_arg: &crate::lightning_invoice::Invoice, mut at_time: u64) -> bool {
let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.would_expire(core::time::Duration::from_secs(at_time));
ret
}
/// [`DEFAULT_MIN_FINAL_CLTV_EXPIRY`].
#[must_use]
#[no_mangle]
-pub extern "C" fn Invoice_min_final_cltv_expiry(this_arg: &Invoice) -> u64 {
+pub extern "C" fn Invoice_min_final_cltv_expiry(this_arg: &crate::lightning_invoice::Invoice) -> u64 {
let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.min_final_cltv_expiry();
ret
}
/// Returns a list of all routes included in the invoice
#[must_use]
#[no_mangle]
-pub extern "C" fn Invoice_private_routes(this_arg: &Invoice) -> crate::c_types::derived::CVec_PrivateRouteZ {
+pub extern "C" fn Invoice_private_routes(this_arg: &crate::lightning_invoice::Invoice) -> crate::c_types::derived::CVec_PrivateRouteZ {
let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.private_routes();
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 } }); };
local_ret.into()
/// Returns a list of all routes included in the invoice as the underlying hints
#[must_use]
#[no_mangle]
-pub extern "C" fn Invoice_route_hints(this_arg: &Invoice) -> crate::c_types::derived::CVec_RouteHintZ {
+pub extern "C" fn Invoice_route_hints(this_arg: &crate::lightning_invoice::Invoice) -> crate::c_types::derived::CVec_RouteHintZ {
let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.route_hints();
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 } }); };
local_ret.into()
/// Returns the currency for which the invoice was issued
#[must_use]
#[no_mangle]
-pub extern "C" fn Invoice_currency(this_arg: &Invoice) -> crate::lightning_invoice::Currency {
+pub extern "C" fn Invoice_currency(this_arg: &crate::lightning_invoice::Invoice) -> crate::lightning_invoice::Currency {
let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.currency();
crate::lightning_invoice::Currency::native_into(ret)
}
/// Returns the amount if specified in the invoice as millisatoshis.
#[must_use]
#[no_mangle]
-pub extern "C" fn Invoice_amount_milli_satoshis(this_arg: &Invoice) -> crate::c_types::derived::COption_u64Z {
+pub extern "C" fn Invoice_amount_milli_satoshis(this_arg: &crate::lightning_invoice::Invoice) -> crate::c_types::derived::COption_u64Z {
let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.amount_milli_satoshis();
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() }) };
local_ret
/// Returns the underlying description `String`
#[must_use]
#[no_mangle]
-pub extern "C" fn Description_into_inner(mut this_arg: Description) -> crate::c_types::Str {
+pub extern "C" fn Description_into_inner(mut this_arg: crate::lightning_invoice::Description) -> crate::c_types::Str {
let mut ret = (*unsafe { Box::from_raw(this_arg.take_inner()) }).into_inner();
ret.into()
}
crate::lightning_invoice::ExpiryTime { inner: ObjOps::heap_alloc(ret), is_owned: true }
}
-/// Construct an `ExpiryTime` from a `Duration`.
+/// Construct an `ExpiryTime` from a `Duration`, dropping the sub-second part.
#[must_use]
#[no_mangle]
pub extern "C" fn ExpiryTime_from_duration(mut duration: u64) -> crate::lightning_invoice::ExpiryTime {
/// Returns the expiry time in seconds
#[must_use]
#[no_mangle]
-pub extern "C" fn ExpiryTime_as_seconds(this_arg: &ExpiryTime) -> u64 {
+pub extern "C" fn ExpiryTime_as_seconds(this_arg: &crate::lightning_invoice::ExpiryTime) -> u64 {
let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.as_seconds();
ret
}
/// Returns a reference to the underlying `Duration` (=expiry time)
#[must_use]
#[no_mangle]
-pub extern "C" fn ExpiryTime_as_duration(this_arg: &ExpiryTime) -> u64 {
+pub extern "C" fn ExpiryTime_as_duration(this_arg: &crate::lightning_invoice::ExpiryTime) -> u64 {
let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.as_duration();
ret.as_secs()
}
/// Returns the underlying list of hops
#[must_use]
#[no_mangle]
-pub extern "C" fn PrivateRoute_into_inner(mut this_arg: PrivateRoute) -> crate::lightning::routing::router::RouteHint {
+pub extern "C" fn PrivateRoute_into_inner(mut this_arg: crate::lightning_invoice::PrivateRoute) -> crate::lightning::routing::router::RouteHint {
let mut ret = (*unsafe { Box::from_raw(this_arg.take_inner()) }).into_inner();
crate::lightning::routing::router::RouteHint { inner: ObjOps::heap_alloc(ret), is_owned: true }
}
/// Errors that may occur when constructing a new `RawInvoice` or `Invoice`
-#[must_use]
#[derive(Clone)]
+#[must_use]
#[repr(C)]
pub enum CreationError {
/// The supplied description string was longer than 639 __bytes__ (see [`Description::new(…)`](./struct.Description.html#method.new))
/// [phantom invoices]: crate::utils::create_phantom_invoice
MissingRouteHints,
}
-use lightning_invoice::CreationError as nativeCreationError;
+use lightning_invoice::CreationError as CreationErrorImport;
+pub(crate) type nativeCreationError = CreationErrorImport;
+
impl CreationError {
#[allow(unused)]
pub(crate) fn to_native(&self) -> nativeCreationError {
}
/// Errors that may occur when converting a `RawInvoice` to an `Invoice`. They relate to the
/// requirements sections in BOLT #11
-#[must_use]
#[derive(Clone)]
+#[must_use]
#[repr(C)]
pub enum SemanticError {
/// The invoice is missing the mandatory payment hash
/// The invoice's amount was not a whole number of millisatoshis
ImpreciseAmount,
}
-use lightning_invoice::SemanticError as nativeSemanticError;
+use lightning_invoice::SemanticError as SemanticErrorImport;
+pub(crate) type nativeSemanticError = SemanticErrorImport;
+
impl SemanticError {
#[allow(unused)]
pub(crate) fn to_native(&self) -> nativeSemanticError {
}
/// When signing using a fallible method either an user-supplied `SignError` or a `CreationError`
/// may occur.
-#[must_use]
#[derive(Clone)]
+#[must_use]
#[repr(C)]
pub enum SignOrCreationError {
/// An error occurred during signing
SignError,
/// An error occurred while building the transaction
- CreationError(crate::lightning_invoice::CreationError),
+ CreationError(
+ crate::lightning_invoice::CreationError),
}
-use lightning_invoice::SignOrCreationError as nativeSignOrCreationError;
+use lightning_invoice::SignOrCreationError as SignOrCreationErrorImport;
+pub(crate) type nativeSignOrCreationError = SignOrCreationErrorImport<>;
+
impl SignOrCreationError {
#[allow(unused)]
pub(crate) fn to_native(&self) -> nativeSignOrCreationError {
)
},
SignOrCreationError::CreationError (ref a, ) => {
- let mut a_nonref = (*a).clone();
+ let mut a_nonref = Clone::clone(a);
nativeSignOrCreationError::CreationError (
a_nonref.into_native(),
)
nativeSignOrCreationError::SignError (ref a, ) => {
SignOrCreationError::SignError },
nativeSignOrCreationError::CreationError (ref a, ) => {
- let mut a_nonref = (*a).clone();
+ let mut a_nonref = Clone::clone(a);
SignOrCreationError::CreationError (
crate::lightning_invoice::CreationError::native_into(a_nonref),
)