+#[cfg(feature="no-std")]
+use alloc::{vec::Vec, boxed::Box};
+
+/// Maximum number of one-way in-flight HTLC (protocol-level value).
+
+#[no_mangle]
+pub static MAX_HTLCS: u16 = lightning::ln::chan_utils::MAX_HTLCS;
+/// The weight of a BIP141 witnessScript for a BOLT3's \"offered HTLC output\" on a commitment transaction, non-anchor variant.
+
+#[no_mangle]
+pub static OFFERED_HTLC_SCRIPT_WEIGHT: usize = lightning::ln::chan_utils::OFFERED_HTLC_SCRIPT_WEIGHT;
+/// The weight of a BIP141 witnessScript for a BOLT3's \"offered HTLC output\" on a commitment transaction, anchor variant.
+
+#[no_mangle]
+pub static OFFERED_HTLC_SCRIPT_WEIGHT_ANCHORS: usize = lightning::ln::chan_utils::OFFERED_HTLC_SCRIPT_WEIGHT_ANCHORS;
+/// The weight of a BIP141 witnessScript for a BOLT3's \"received HTLC output\" can vary in function of its CLTV argument value.
+/// We define a range that encompasses both its non-anchors and anchors variants.
+/// This is the maximum post-anchor value.
+
+#[no_mangle]
+pub static MAX_ACCEPTED_HTLC_SCRIPT_WEIGHT: usize = lightning::ln::chan_utils::MAX_ACCEPTED_HTLC_SCRIPT_WEIGHT;
+/// The upper bound weight of an anchor input.
+
+#[no_mangle]
+pub static ANCHOR_INPUT_WITNESS_WEIGHT: u64 = lightning::ln::chan_utils::ANCHOR_INPUT_WITNESS_WEIGHT;
+/// The upper bound weight of an HTLC timeout input from a commitment transaction with anchor
+/// outputs.
+
+#[no_mangle]
+pub static HTLC_TIMEOUT_INPUT_ANCHOR_WITNESS_WEIGHT: u64 = lightning::ln::chan_utils::HTLC_TIMEOUT_INPUT_ANCHOR_WITNESS_WEIGHT;
+/// The upper bound weight of an HTLC success input from a commitment transaction with anchor
+/// outputs.
+
+#[no_mangle]
+pub static HTLC_SUCCESS_INPUT_ANCHOR_WITNESS_WEIGHT: u64 = lightning::ln::chan_utils::HTLC_SUCCESS_INPUT_ANCHOR_WITNESS_WEIGHT;
+/// Gets the weight for an HTLC-Success transaction.
+#[no_mangle]
+pub extern "C" fn htlc_success_tx_weight(channel_type_features: &crate::lightning_types::features::ChannelTypeFeatures) -> u64 {
+ let mut ret = lightning::ln::chan_utils::htlc_success_tx_weight(channel_type_features.get_native_ref());
+ ret
+}
+
+/// Gets the weight for an HTLC-Timeout transaction.
+#[no_mangle]
+pub extern "C" fn htlc_timeout_tx_weight(channel_type_features: &crate::lightning_types::features::ChannelTypeFeatures) -> u64 {
+ let mut ret = lightning::ln::chan_utils::htlc_timeout_tx_weight(channel_type_features.get_native_ref());
+ ret
+}
+
+/// Describes the type of HTLC claim as determined by analyzing the witness.
+#[derive(Clone)]
+#[must_use]
+#[repr(C)]
+pub enum HTLCClaim {
+ /// Claims an offered output on a commitment transaction through the timeout path.
+ OfferedTimeout,
+ /// Claims an offered output on a commitment transaction through the success path.
+ OfferedPreimage,
+ /// Claims an accepted output on a commitment transaction through the timeout path.
+ AcceptedTimeout,
+ /// Claims an accepted output on a commitment transaction through the success path.
+ AcceptedPreimage,
+ /// Claims an offered/accepted output on a commitment transaction through the revocation path.
+ Revocation,
+}
+use lightning::ln::chan_utils::HTLCClaim as HTLCClaimImport;
+pub(crate) type nativeHTLCClaim = HTLCClaimImport;
+
+impl HTLCClaim {
+ #[allow(unused)]
+ pub(crate) fn to_native(&self) -> nativeHTLCClaim {
+ match self {
+ HTLCClaim::OfferedTimeout => nativeHTLCClaim::OfferedTimeout,
+ HTLCClaim::OfferedPreimage => nativeHTLCClaim::OfferedPreimage,
+ HTLCClaim::AcceptedTimeout => nativeHTLCClaim::AcceptedTimeout,
+ HTLCClaim::AcceptedPreimage => nativeHTLCClaim::AcceptedPreimage,
+ HTLCClaim::Revocation => nativeHTLCClaim::Revocation,
+ }
+ }
+ #[allow(unused)]
+ pub(crate) fn into_native(self) -> nativeHTLCClaim {
+ match self {
+ HTLCClaim::OfferedTimeout => nativeHTLCClaim::OfferedTimeout,
+ HTLCClaim::OfferedPreimage => nativeHTLCClaim::OfferedPreimage,
+ HTLCClaim::AcceptedTimeout => nativeHTLCClaim::AcceptedTimeout,
+ HTLCClaim::AcceptedPreimage => nativeHTLCClaim::AcceptedPreimage,
+ HTLCClaim::Revocation => nativeHTLCClaim::Revocation,
+ }
+ }
+ #[allow(unused)]
+ pub(crate) fn from_native(native: &HTLCClaimImport) -> Self {
+ let native = unsafe { &*(native as *const _ as *const c_void as *const nativeHTLCClaim) };
+ match native {
+ nativeHTLCClaim::OfferedTimeout => HTLCClaim::OfferedTimeout,
+ nativeHTLCClaim::OfferedPreimage => HTLCClaim::OfferedPreimage,
+ nativeHTLCClaim::AcceptedTimeout => HTLCClaim::AcceptedTimeout,
+ nativeHTLCClaim::AcceptedPreimage => HTLCClaim::AcceptedPreimage,
+ nativeHTLCClaim::Revocation => HTLCClaim::Revocation,
+ }
+ }
+ #[allow(unused)]
+ pub(crate) fn native_into(native: nativeHTLCClaim) -> Self {
+ match native {
+ nativeHTLCClaim::OfferedTimeout => HTLCClaim::OfferedTimeout,
+ nativeHTLCClaim::OfferedPreimage => HTLCClaim::OfferedPreimage,
+ nativeHTLCClaim::AcceptedTimeout => HTLCClaim::AcceptedTimeout,
+ nativeHTLCClaim::AcceptedPreimage => HTLCClaim::AcceptedPreimage,
+ nativeHTLCClaim::Revocation => HTLCClaim::Revocation,
+ }
+ }
+}
+/// Creates a copy of the HTLCClaim
+#[no_mangle]
+pub extern "C" fn HTLCClaim_clone(orig: &HTLCClaim) -> HTLCClaim {
+ orig.clone()
+}
+#[allow(unused)]
+/// Used only if an object of this type is returned as a trait impl by a method
+pub(crate) extern "C" fn HTLCClaim_clone_void(this_ptr: *const c_void) -> *mut c_void {
+ Box::into_raw(Box::new(unsafe { (*(this_ptr as *const HTLCClaim)).clone() })) as *mut c_void
+}
+#[allow(unused)]
+/// Used only if an object of this type is returned as a trait impl by a method
+pub(crate) extern "C" fn HTLCClaim_free_void(this_ptr: *mut c_void) {
+ let _ = unsafe { Box::from_raw(this_ptr as *mut HTLCClaim) };
+}
+#[no_mangle]
+/// Utility method to constructs a new OfferedTimeout-variant HTLCClaim
+pub extern "C" fn HTLCClaim_offered_timeout() -> HTLCClaim {
+ HTLCClaim::OfferedTimeout}
+#[no_mangle]
+/// Utility method to constructs a new OfferedPreimage-variant HTLCClaim
+pub extern "C" fn HTLCClaim_offered_preimage() -> HTLCClaim {
+ HTLCClaim::OfferedPreimage}
+#[no_mangle]
+/// Utility method to constructs a new AcceptedTimeout-variant HTLCClaim
+pub extern "C" fn HTLCClaim_accepted_timeout() -> HTLCClaim {
+ HTLCClaim::AcceptedTimeout}
+#[no_mangle]
+/// Utility method to constructs a new AcceptedPreimage-variant HTLCClaim
+pub extern "C" fn HTLCClaim_accepted_preimage() -> HTLCClaim {
+ HTLCClaim::AcceptedPreimage}
+#[no_mangle]
+/// Utility method to constructs a new Revocation-variant HTLCClaim
+pub extern "C" fn HTLCClaim_revocation() -> HTLCClaim {
+ HTLCClaim::Revocation}
+/// Checks if two HTLCClaims contain equal inner contents.
+/// This ignores pointers and is_owned flags and looks at the values in fields.
+#[no_mangle]
+pub extern "C" fn HTLCClaim_eq(a: &HTLCClaim, b: &HTLCClaim) -> bool {
+ if &a.to_native() == &b.to_native() { true } else { false }
+}
+/// Check if a given input witness attempts to claim a HTLC.
+#[must_use]
+#[no_mangle]
+pub extern "C" fn HTLCClaim_from_witness(mut witness: crate::c_types::Witness) -> crate::c_types::derived::COption_HTLCClaimZ {
+ let mut ret = lightning::ln::chan_utils::HTLCClaim::from_witness(&witness.into_bitcoin());
+ let mut local_ret = if ret.is_none() { crate::c_types::derived::COption_HTLCClaimZ::None } else { crate::c_types::derived::COption_HTLCClaimZ::Some( { crate::lightning::ln::chan_utils::HTLCClaim::native_into(ret.unwrap()) }) };
+ local_ret
+}