+#[allow(unused)]
+/// Used only if an object of this type is returned as a trait impl by a method
+pub(crate) extern "C" fn PendingHTLCInfo_clone_void(this_ptr: *const c_void) -> *mut c_void {
+ Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativePendingHTLCInfo)).clone() })) as *mut c_void
+}
+#[no_mangle]
+/// Creates a copy of the PendingHTLCInfo
+pub extern "C" fn PendingHTLCInfo_clone(orig: &PendingHTLCInfo) -> PendingHTLCInfo {
+ orig.clone()
+}
+/// Whether this blinded HTLC is being failed backwards by the introduction node or a blinded node,
+/// which determines the failure message that should be used.
+#[derive(Clone)]
+#[must_use]
+#[repr(C)]
+pub enum BlindedFailure {
+ /// This HTLC is being failed backwards by the introduction node, and thus should be failed with
+ /// [`msgs::UpdateFailHTLC`] and error code `0x8000|0x4000|24`.
+ FromIntroductionNode,
+ /// This HTLC is being failed backwards by a blinded node within the path, and thus should be
+ /// failed with [`msgs::UpdateFailMalformedHTLC`] and error code `0x8000|0x4000|24`.
+ FromBlindedNode,
+}
+use lightning::ln::channelmanager::BlindedFailure as BlindedFailureImport;
+pub(crate) type nativeBlindedFailure = BlindedFailureImport;
+
+impl BlindedFailure {
+ #[allow(unused)]
+ pub(crate) fn to_native(&self) -> nativeBlindedFailure {
+ match self {
+ BlindedFailure::FromIntroductionNode => nativeBlindedFailure::FromIntroductionNode,
+ BlindedFailure::FromBlindedNode => nativeBlindedFailure::FromBlindedNode,
+ }
+ }
+ #[allow(unused)]
+ pub(crate) fn into_native(self) -> nativeBlindedFailure {
+ match self {
+ BlindedFailure::FromIntroductionNode => nativeBlindedFailure::FromIntroductionNode,
+ BlindedFailure::FromBlindedNode => nativeBlindedFailure::FromBlindedNode,
+ }
+ }
+ #[allow(unused)]
+ pub(crate) fn from_native(native: &BlindedFailureImport) -> Self {
+ let native = unsafe { &*(native as *const _ as *const c_void as *const nativeBlindedFailure) };
+ match native {
+ nativeBlindedFailure::FromIntroductionNode => BlindedFailure::FromIntroductionNode,
+ nativeBlindedFailure::FromBlindedNode => BlindedFailure::FromBlindedNode,
+ }
+ }
+ #[allow(unused)]
+ pub(crate) fn native_into(native: nativeBlindedFailure) -> Self {
+ match native {
+ nativeBlindedFailure::FromIntroductionNode => BlindedFailure::FromIntroductionNode,
+ nativeBlindedFailure::FromBlindedNode => BlindedFailure::FromBlindedNode,
+ }
+ }
+}
+/// Creates a copy of the BlindedFailure
+#[no_mangle]
+pub extern "C" fn BlindedFailure_clone(orig: &BlindedFailure) -> BlindedFailure {
+ 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 BlindedFailure_clone_void(this_ptr: *const c_void) -> *mut c_void {
+ Box::into_raw(Box::new(unsafe { (*(this_ptr as *const BlindedFailure)).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 BlindedFailure_free_void(this_ptr: *mut c_void) {
+ let _ = unsafe { Box::from_raw(this_ptr as *mut BlindedFailure) };
+}
+#[no_mangle]
+/// Utility method to constructs a new FromIntroductionNode-variant BlindedFailure
+pub extern "C" fn BlindedFailure_from_introduction_node() -> BlindedFailure {
+ BlindedFailure::FromIntroductionNode}
+#[no_mangle]
+/// Utility method to constructs a new FromBlindedNode-variant BlindedFailure
+pub extern "C" fn BlindedFailure_from_blinded_node() -> BlindedFailure {
+ BlindedFailure::FromBlindedNode}
+/// Get a string which allows debug introspection of a BlindedFailure object
+pub extern "C" fn BlindedFailure_debug_str_void(o: *const c_void) -> Str {
+ alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::channelmanager::BlindedFailure }).into()}
+/// Generates a non-cryptographic 64-bit hash of the BlindedFailure.
+#[no_mangle]
+pub extern "C" fn BlindedFailure_hash(o: &BlindedFailure) -> 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)
+}
+/// Checks if two BlindedFailures contain equal inner contents.
+/// This ignores pointers and is_owned flags and looks at the values in fields.
+#[no_mangle]
+pub extern "C" fn BlindedFailure_eq(a: &BlindedFailure, b: &BlindedFailure) -> bool {
+ if &a.to_native() == &b.to_native() { true } else { false }
+}
+/// This enum is used to specify which error data to send to peers when failing back an HTLC
+/// using [`ChannelManager::fail_htlc_backwards_with_reason`].
+///
+/// For more info on failure codes, see <https://github.com/lightning/bolts/blob/master/04-onion-routing.md#failure-messages>.
+#[derive(Clone)]
+#[must_use]
+#[repr(C)]
+pub enum FailureCode {
+ /// We had a temporary error processing the payment. Useful if no other error codes fit
+ /// and you want to indicate that the payer may want to retry.
+ TemporaryNodeFailure,
+ /// We have a required feature which was not in this onion. For example, you may require
+ /// some additional metadata that was not provided with this payment.
+ RequiredNodeFeatureMissing,
+ /// You may wish to use this when a `payment_preimage` is unknown, or the CLTV expiry of
+ /// the HTLC is too close to the current block height for safe handling.
+ /// Using this failure code in [`ChannelManager::fail_htlc_backwards_with_reason`] is
+ /// equivalent to calling [`ChannelManager::fail_htlc_backwards`].
+ IncorrectOrUnknownPaymentDetails,
+ /// We failed to process the payload after the onion was decrypted. You may wish to
+ /// use this when receiving custom HTLC TLVs with even type numbers that you don't recognize.
+ ///
+ /// If available, the tuple data may include the type number and byte offset in the
+ /// decrypted byte stream where the failure occurred.
+ InvalidOnionPayload(
+ crate::c_types::derived::COption_C2Tuple_u64u16ZZ),
+}
+use lightning::ln::channelmanager::FailureCode as FailureCodeImport;
+pub(crate) type nativeFailureCode = FailureCodeImport;
+
+impl FailureCode {
+ #[allow(unused)]
+ pub(crate) fn to_native(&self) -> nativeFailureCode {
+ match self {
+ FailureCode::TemporaryNodeFailure => nativeFailureCode::TemporaryNodeFailure,
+ FailureCode::RequiredNodeFeatureMissing => nativeFailureCode::RequiredNodeFeatureMissing,
+ FailureCode::IncorrectOrUnknownPaymentDetails => nativeFailureCode::IncorrectOrUnknownPaymentDetails,
+ FailureCode::InvalidOnionPayload (ref a, ) => {
+ let mut a_nonref = Clone::clone(a);
+ let mut local_a_nonref = if a_nonref.is_some() { Some( { let (mut orig_a_nonref_0_0, mut orig_a_nonref_0_1) = a_nonref.take().to_rust(); let mut local_a_nonref_0 = (orig_a_nonref_0_0, orig_a_nonref_0_1); local_a_nonref_0 }) } else { None };
+ nativeFailureCode::InvalidOnionPayload (
+ local_a_nonref,
+ )
+ },
+ }
+ }
+ #[allow(unused)]
+ pub(crate) fn into_native(self) -> nativeFailureCode {
+ match self {
+ FailureCode::TemporaryNodeFailure => nativeFailureCode::TemporaryNodeFailure,
+ FailureCode::RequiredNodeFeatureMissing => nativeFailureCode::RequiredNodeFeatureMissing,
+ FailureCode::IncorrectOrUnknownPaymentDetails => nativeFailureCode::IncorrectOrUnknownPaymentDetails,
+ FailureCode::InvalidOnionPayload (mut a, ) => {
+ let mut local_a = if a.is_some() { Some( { let (mut orig_a_0_0, mut orig_a_0_1) = a.take().to_rust(); let mut local_a_0 = (orig_a_0_0, orig_a_0_1); local_a_0 }) } else { None };
+ nativeFailureCode::InvalidOnionPayload (
+ local_a,
+ )
+ },
+ }
+ }
+ #[allow(unused)]
+ pub(crate) fn from_native(native: &FailureCodeImport) -> Self {
+ let native = unsafe { &*(native as *const _ as *const c_void as *const nativeFailureCode) };
+ match native {
+ nativeFailureCode::TemporaryNodeFailure => FailureCode::TemporaryNodeFailure,
+ nativeFailureCode::RequiredNodeFeatureMissing => FailureCode::RequiredNodeFeatureMissing,
+ nativeFailureCode::IncorrectOrUnknownPaymentDetails => FailureCode::IncorrectOrUnknownPaymentDetails,
+ nativeFailureCode::InvalidOnionPayload (ref a, ) => {
+ let mut a_nonref = Clone::clone(a);
+ let mut local_a_nonref = if a_nonref.is_none() { crate::c_types::derived::COption_C2Tuple_u64u16ZZ::None } else { crate::c_types::derived::COption_C2Tuple_u64u16ZZ::Some( { let (mut orig_a_nonref_0_0, mut orig_a_nonref_0_1) = (a_nonref.unwrap()); let mut local_a_nonref_0 = (orig_a_nonref_0_0, orig_a_nonref_0_1).into(); local_a_nonref_0 }) };
+ FailureCode::InvalidOnionPayload (
+ local_a_nonref,
+ )
+ },
+ }
+ }
+ #[allow(unused)]
+ pub(crate) fn native_into(native: nativeFailureCode) -> Self {
+ match native {
+ nativeFailureCode::TemporaryNodeFailure => FailureCode::TemporaryNodeFailure,
+ nativeFailureCode::RequiredNodeFeatureMissing => FailureCode::RequiredNodeFeatureMissing,
+ nativeFailureCode::IncorrectOrUnknownPaymentDetails => FailureCode::IncorrectOrUnknownPaymentDetails,
+ nativeFailureCode::InvalidOnionPayload (mut a, ) => {
+ let mut local_a = if a.is_none() { crate::c_types::derived::COption_C2Tuple_u64u16ZZ::None } else { crate::c_types::derived::COption_C2Tuple_u64u16ZZ::Some( { let (mut orig_a_0_0, mut orig_a_0_1) = (a.unwrap()); let mut local_a_0 = (orig_a_0_0, orig_a_0_1).into(); local_a_0 }) };
+ FailureCode::InvalidOnionPayload (
+ local_a,
+ )
+ },
+ }
+ }
+}
+/// Frees any resources used by the FailureCode
+#[no_mangle]
+pub extern "C" fn FailureCode_free(this_ptr: FailureCode) { }
+/// Creates a copy of the FailureCode
+#[no_mangle]
+pub extern "C" fn FailureCode_clone(orig: &FailureCode) -> FailureCode {
+ 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 FailureCode_clone_void(this_ptr: *const c_void) -> *mut c_void {
+ Box::into_raw(Box::new(unsafe { (*(this_ptr as *const FailureCode)).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 FailureCode_free_void(this_ptr: *mut c_void) {
+ let _ = unsafe { Box::from_raw(this_ptr as *mut FailureCode) };
+}
+#[no_mangle]
+/// Utility method to constructs a new TemporaryNodeFailure-variant FailureCode
+pub extern "C" fn FailureCode_temporary_node_failure() -> FailureCode {
+ FailureCode::TemporaryNodeFailure}
+#[no_mangle]
+/// Utility method to constructs a new RequiredNodeFeatureMissing-variant FailureCode
+pub extern "C" fn FailureCode_required_node_feature_missing() -> FailureCode {
+ FailureCode::RequiredNodeFeatureMissing}
+#[no_mangle]
+/// Utility method to constructs a new IncorrectOrUnknownPaymentDetails-variant FailureCode
+pub extern "C" fn FailureCode_incorrect_or_unknown_payment_details() -> FailureCode {
+ FailureCode::IncorrectOrUnknownPaymentDetails}
+#[no_mangle]
+/// Utility method to constructs a new InvalidOnionPayload-variant FailureCode
+pub extern "C" fn FailureCode_invalid_onion_payload(a: crate::c_types::derived::COption_C2Tuple_u64u16ZZ) -> FailureCode {
+ FailureCode::InvalidOnionPayload(a, )
+}
+
+use lightning::ln::channelmanager::ChannelManager as nativeChannelManagerImport;
+pub(crate) type nativeChannelManager = nativeChannelManagerImport<crate::lightning::chain::Watch, crate::lightning::chain::chaininterface::BroadcasterInterface, crate::lightning::sign::EntropySource, crate::lightning::sign::NodeSigner, crate::lightning::sign::SignerProvider, crate::lightning::chain::chaininterface::FeeEstimator, crate::lightning::routing::router::Router, crate::lightning::util::logger::Logger>;
+
+/// Manager which keeps track of a number of channels and sends messages to the appropriate
+/// channel, also tracking HTLC preimages and forwarding onion packets appropriately.
+///
+/// Implements [`ChannelMessageHandler`], handling the multi-channel parts and passing things through
+/// to individual Channels.
+///
+/// Implements [`Writeable`] to write out all channel state to disk. Implies [`peer_disconnected`] for
+/// all peers during write/read (though does not modify this instance, only the instance being
+/// serialized). This will result in any channels which have not yet exchanged [`funding_created`] (i.e.,
+/// called [`funding_transaction_generated`] for outbound channels) being closed.
+///
+/// Note that you can be a bit lazier about writing out `ChannelManager` than you can be with
+/// [`ChannelMonitor`]. With [`ChannelMonitor`] you MUST durably write each
+/// [`ChannelMonitorUpdate`] before returning from
+/// [`chain::Watch::watch_channel`]/[`update_channel`] or before completing async writes. With
+/// `ChannelManager`s, writing updates happens out-of-band (and will prevent any other
+/// `ChannelManager` operations from occurring during the serialization process). If the
+/// deserialized version is out-of-date compared to the [`ChannelMonitor`] passed by reference to
+/// [`read`], those channels will be force-closed based on the `ChannelMonitor` state and no funds
+/// will be lost (modulo on-chain transaction fees).
+///
+/// Note that the deserializer is only implemented for `(`[`BlockHash`]`, `[`ChannelManager`]`)`, which
+/// tells you the last block hash which was connected. You should get the best block tip before using the manager.
+/// See [`chain::Listen`] and [`chain::Confirm`] for more details.
+///
+/// Note that `ChannelManager` is responsible for tracking liveness of its channels and generating
+/// [`ChannelUpdate`] messages informing peers that the channel is temporarily disabled. To avoid
+/// spam due to quick disconnection/reconnection, updates are not sent until the channel has been
+/// offline for a full minute. In order to track this, you must call
+/// [`timer_tick_occurred`] roughly once per minute, though it doesn't have to be perfect.
+///
+/// To avoid trivial DoS issues, `ChannelManager` limits the number of inbound connections and
+/// inbound channels without confirmed funding transactions. This may result in nodes which we do
+/// not have a channel with being unable to connect to us or open new channels with us if we have
+/// many peers with unfunded channels.
+///
+/// Because it is an indication of trust, inbound channels which we've accepted as 0conf are
+/// exempted from the count of unfunded channels. Similarly, outbound channels and connections are
+/// never limited. Please ensure you limit the count of such channels yourself.
+///
+/// Rather than using a plain `ChannelManager`, it is preferable to use either a [`SimpleArcChannelManager`]
+/// a [`SimpleRefChannelManager`], for conciseness. See their documentation for more details, but
+/// essentially you should default to using a [`SimpleRefChannelManager`], and use a
+/// [`SimpleArcChannelManager`] when you require a `ChannelManager` with a static lifetime, such as when
+/// you're using lightning-net-tokio.
+///
+/// [`peer_disconnected`]: msgs::ChannelMessageHandler::peer_disconnected
+/// [`funding_created`]: msgs::FundingCreated
+/// [`funding_transaction_generated`]: Self::funding_transaction_generated
+/// [`BlockHash`]: bitcoin::hash_types::BlockHash
+/// [`update_channel`]: chain::Watch::update_channel
+/// [`ChannelUpdate`]: msgs::ChannelUpdate
+/// [`timer_tick_occurred`]: Self::timer_tick_occurred
+/// [`read`]: ReadableArgs::read
+#[must_use]
+#[repr(C)]
+pub struct ChannelManager {
+ /// A pointer to the opaque Rust object.
+
+ /// Nearly everywhere, inner must be non-null, however in places where
+ /// the Rust equivalent takes an Option, it may be set to null to indicate None.
+ pub inner: *mut nativeChannelManager,
+ /// Indicates that this is the only struct which contains the same pointer.
+
+ /// Rust functions which take ownership of an object provided via an argument require
+ /// this to be true and invalidate the object pointed to by inner.
+ pub is_owned: bool,
+}
+
+impl Drop for ChannelManager {
+ fn drop(&mut self) {
+ if self.is_owned && !<*mut nativeChannelManager>::is_null(self.inner) {
+ let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
+ }
+ }
+}
+/// Frees any resources used by the ChannelManager, if is_owned is set and inner is non-NULL.
+#[no_mangle]
+pub extern "C" fn ChannelManager_free(this_obj: ChannelManager) { }
+#[allow(unused)]
+/// Used only if an object of this type is returned as a trait impl by a method
+pub(crate) extern "C" fn ChannelManager_free_void(this_ptr: *mut c_void) {
+ let _ = unsafe { Box::from_raw(this_ptr as *mut nativeChannelManager) };
+}
+#[allow(unused)]
+impl ChannelManager {
+ pub(crate) fn get_native_ref(&self) -> &'static nativeChannelManager {
+ unsafe { &*ObjOps::untweak_ptr(self.inner) }
+ }
+ pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeChannelManager {
+ unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
+ }
+ /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
+ pub(crate) fn take_inner(mut self) -> *mut nativeChannelManager {
+ assert!(self.is_owned);
+ let ret = ObjOps::untweak_ptr(self.inner);
+ self.inner = core::ptr::null_mut();
+ ret
+ }
+}
+
+use lightning::ln::channelmanager::ChainParameters as nativeChainParametersImport;
+pub(crate) type nativeChainParameters = nativeChainParametersImport;
+
+/// Chain-related parameters used to construct a new `ChannelManager`.
+///
+/// Typically, the block-specific parameters are derived from the best block hash for the network,
+/// as a newly constructed `ChannelManager` will not have created any channels yet. These parameters
+/// are not needed when deserializing a previously constructed `ChannelManager`.
+#[must_use]
+#[repr(C)]
+pub struct ChainParameters {
+ /// A pointer to the opaque Rust object.
+
+ /// Nearly everywhere, inner must be non-null, however in places where
+ /// the Rust equivalent takes an Option, it may be set to null to indicate None.
+ pub inner: *mut nativeChainParameters,
+ /// Indicates that this is the only struct which contains the same pointer.
+
+ /// Rust functions which take ownership of an object provided via an argument require
+ /// this to be true and invalidate the object pointed to by inner.
+ pub is_owned: bool,
+}
+
+impl Drop for ChainParameters {
+ fn drop(&mut self) {
+ if self.is_owned && !<*mut nativeChainParameters>::is_null(self.inner) {
+ let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
+ }
+ }
+}
+/// Frees any resources used by the ChainParameters, if is_owned is set and inner is non-NULL.
+#[no_mangle]
+pub extern "C" fn ChainParameters_free(this_obj: ChainParameters) { }
+#[allow(unused)]
+/// Used only if an object of this type is returned as a trait impl by a method
+pub(crate) extern "C" fn ChainParameters_free_void(this_ptr: *mut c_void) {
+ let _ = unsafe { Box::from_raw(this_ptr as *mut nativeChainParameters) };
+}
+#[allow(unused)]
+impl ChainParameters {
+ pub(crate) fn get_native_ref(&self) -> &'static nativeChainParameters {
+ unsafe { &*ObjOps::untweak_ptr(self.inner) }
+ }
+ pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeChainParameters {
+ unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
+ }
+ /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
+ pub(crate) fn take_inner(mut self) -> *mut nativeChainParameters {
+ assert!(self.is_owned);
+ let ret = ObjOps::untweak_ptr(self.inner);
+ self.inner = core::ptr::null_mut();
+ ret
+ }
+}
+/// The network for determining the `chain_hash` in Lightning messages.
+#[no_mangle]
+pub extern "C" fn ChainParameters_get_network(this_ptr: &ChainParameters) -> crate::bitcoin::network::Network {
+ let mut inner_val = &mut this_ptr.get_native_mut_ref().network;
+ crate::bitcoin::network::Network::from_bitcoin(inner_val)
+}
+/// The network for determining the `chain_hash` in Lightning messages.
+#[no_mangle]
+pub extern "C" fn ChainParameters_set_network(this_ptr: &mut ChainParameters, mut val: crate::bitcoin::network::Network) {
+ unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.network = val.into_bitcoin();
+}
+/// The hash and height of the latest block successfully connected.
+///
+/// Used to track on-chain channel funding outputs and send payments with reliable timelocks.
+#[no_mangle]
+pub extern "C" fn ChainParameters_get_best_block(this_ptr: &ChainParameters) -> crate::lightning::chain::BestBlock {
+ let mut inner_val = &mut this_ptr.get_native_mut_ref().best_block;
+ crate::lightning::chain::BestBlock { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::chain::BestBlock<>) as *mut _) }, is_owned: false }
+}
+/// The hash and height of the latest block successfully connected.
+///
+/// Used to track on-chain channel funding outputs and send payments with reliable timelocks.
+#[no_mangle]
+pub extern "C" fn ChainParameters_set_best_block(this_ptr: &mut ChainParameters, mut val: crate::lightning::chain::BestBlock) {
+ unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.best_block = *unsafe { Box::from_raw(val.take_inner()) };
+}
+/// Constructs a new ChainParameters given each field
+#[must_use]
+#[no_mangle]
+pub extern "C" fn ChainParameters_new(mut network_arg: crate::bitcoin::network::Network, mut best_block_arg: crate::lightning::chain::BestBlock) -> ChainParameters {
+ ChainParameters { inner: ObjOps::heap_alloc(nativeChainParameters {
+ network: network_arg.into_bitcoin(),
+ best_block: *unsafe { Box::from_raw(best_block_arg.take_inner()) },
+ }), is_owned: true }
+}
+impl Clone for ChainParameters {
+ fn clone(&self) -> Self {
+ Self {
+ inner: if <*mut nativeChainParameters>::is_null(self.inner) { core::ptr::null_mut() } else {
+ ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
+ is_owned: true,
+ }
+ }
+}
+#[allow(unused)]
+/// Used only if an object of this type is returned as a trait impl by a method
+pub(crate) extern "C" fn ChainParameters_clone_void(this_ptr: *const c_void) -> *mut c_void {
+ Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeChainParameters)).clone() })) as *mut c_void
+}
+#[no_mangle]
+/// Creates a copy of the ChainParameters
+pub extern "C" fn ChainParameters_clone(orig: &ChainParameters) -> ChainParameters {
+ orig.clone()
+}
+/// The amount of time in blocks we require our counterparty wait to claim their money (ie time
+/// between when we, or our watchtower, must check for them having broadcast a theft transaction).
+///
+/// This can be increased (but not decreased) through [`ChannelHandshakeConfig::our_to_self_delay`]
+///
+/// [`ChannelHandshakeConfig::our_to_self_delay`]: crate::util::config::ChannelHandshakeConfig::our_to_self_delay
+
+#[no_mangle]
+pub static BREAKDOWN_TIMEOUT: u16 = lightning::ln::channelmanager::BREAKDOWN_TIMEOUT;
+/// The minimum number of blocks between an inbound HTLC's CLTV and the corresponding outbound
+/// HTLC's CLTV. The current default represents roughly seven hours of blocks at six blocks/hour.
+///
+/// This can be increased (but not decreased) through [`ChannelConfig::cltv_expiry_delta`]
+///
+/// [`ChannelConfig::cltv_expiry_delta`]: crate::util::config::ChannelConfig::cltv_expiry_delta
+
+#[no_mangle]
+pub static MIN_CLTV_EXPIRY_DELTA: u16 = lightning::ln::channelmanager::MIN_CLTV_EXPIRY_DELTA;
+/// Minimum CLTV difference between the current block height and received inbound payments.
+/// Invoices generated for payment to us must set their `min_final_cltv_expiry_delta` field to at least
+/// this value.
+
+#[no_mangle]
+pub static MIN_FINAL_CLTV_EXPIRY_DELTA: u16 = lightning::ln::channelmanager::MIN_FINAL_CLTV_EXPIRY_DELTA;
+
+use lightning::ln::channelmanager::CounterpartyForwardingInfo as nativeCounterpartyForwardingInfoImport;
+pub(crate) type nativeCounterpartyForwardingInfo = nativeCounterpartyForwardingInfoImport;
+
+/// Information needed for constructing an invoice route hint for this channel.
+#[must_use]
+#[repr(C)]
+pub struct CounterpartyForwardingInfo {
+ /// A pointer to the opaque Rust object.
+
+ /// Nearly everywhere, inner must be non-null, however in places where
+ /// the Rust equivalent takes an Option, it may be set to null to indicate None.
+ pub inner: *mut nativeCounterpartyForwardingInfo,
+ /// Indicates that this is the only struct which contains the same pointer.
+
+ /// Rust functions which take ownership of an object provided via an argument require
+ /// this to be true and invalidate the object pointed to by inner.
+ pub is_owned: bool,
+}
+
+impl Drop for CounterpartyForwardingInfo {
+ fn drop(&mut self) {
+ if self.is_owned && !<*mut nativeCounterpartyForwardingInfo>::is_null(self.inner) {
+ let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
+ }
+ }
+}
+/// Frees any resources used by the CounterpartyForwardingInfo, if is_owned is set and inner is non-NULL.
+#[no_mangle]
+pub extern "C" fn CounterpartyForwardingInfo_free(this_obj: CounterpartyForwardingInfo) { }
+#[allow(unused)]
+/// Used only if an object of this type is returned as a trait impl by a method
+pub(crate) extern "C" fn CounterpartyForwardingInfo_free_void(this_ptr: *mut c_void) {
+ let _ = unsafe { Box::from_raw(this_ptr as *mut nativeCounterpartyForwardingInfo) };
+}
+#[allow(unused)]
+impl CounterpartyForwardingInfo {
+ pub(crate) fn get_native_ref(&self) -> &'static nativeCounterpartyForwardingInfo {
+ unsafe { &*ObjOps::untweak_ptr(self.inner) }
+ }
+ pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeCounterpartyForwardingInfo {
+ unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
+ }
+ /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
+ pub(crate) fn take_inner(mut self) -> *mut nativeCounterpartyForwardingInfo {
+ assert!(self.is_owned);
+ let ret = ObjOps::untweak_ptr(self.inner);
+ self.inner = core::ptr::null_mut();
+ ret
+ }
+}
+/// Base routing fee in millisatoshis.
+#[no_mangle]
+pub extern "C" fn CounterpartyForwardingInfo_get_fee_base_msat(this_ptr: &CounterpartyForwardingInfo) -> u32 {
+ let mut inner_val = &mut this_ptr.get_native_mut_ref().fee_base_msat;
+ *inner_val
+}
+/// Base routing fee in millisatoshis.
+#[no_mangle]
+pub extern "C" fn CounterpartyForwardingInfo_set_fee_base_msat(this_ptr: &mut CounterpartyForwardingInfo, mut val: u32) {
+ unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.fee_base_msat = val;
+}
+/// Amount in millionths of a satoshi the channel will charge per transferred satoshi.
+#[no_mangle]
+pub extern "C" fn CounterpartyForwardingInfo_get_fee_proportional_millionths(this_ptr: &CounterpartyForwardingInfo) -> u32 {
+ let mut inner_val = &mut this_ptr.get_native_mut_ref().fee_proportional_millionths;
+ *inner_val
+}
+/// Amount in millionths of a satoshi the channel will charge per transferred satoshi.
+#[no_mangle]
+pub extern "C" fn CounterpartyForwardingInfo_set_fee_proportional_millionths(this_ptr: &mut CounterpartyForwardingInfo, mut val: u32) {
+ unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.fee_proportional_millionths = val;
+}
+/// The minimum difference in cltv_expiry between an ingoing HTLC and its outgoing counterpart,
+/// such that the outgoing HTLC is forwardable to this counterparty. See `msgs::ChannelUpdate`'s
+/// `cltv_expiry_delta` for more details.
+#[no_mangle]
+pub extern "C" fn CounterpartyForwardingInfo_get_cltv_expiry_delta(this_ptr: &CounterpartyForwardingInfo) -> u16 {
+ let mut inner_val = &mut this_ptr.get_native_mut_ref().cltv_expiry_delta;
+ *inner_val
+}
+/// The minimum difference in cltv_expiry between an ingoing HTLC and its outgoing counterpart,
+/// such that the outgoing HTLC is forwardable to this counterparty. See `msgs::ChannelUpdate`'s
+/// `cltv_expiry_delta` for more details.
+#[no_mangle]
+pub extern "C" fn CounterpartyForwardingInfo_set_cltv_expiry_delta(this_ptr: &mut CounterpartyForwardingInfo, mut val: u16) {
+ unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.cltv_expiry_delta = val;
+}
+/// Constructs a new CounterpartyForwardingInfo given each field
+#[must_use]
+#[no_mangle]
+pub extern "C" fn CounterpartyForwardingInfo_new(mut fee_base_msat_arg: u32, mut fee_proportional_millionths_arg: u32, mut cltv_expiry_delta_arg: u16) -> CounterpartyForwardingInfo {
+ CounterpartyForwardingInfo { inner: ObjOps::heap_alloc(nativeCounterpartyForwardingInfo {
+ fee_base_msat: fee_base_msat_arg,
+ fee_proportional_millionths: fee_proportional_millionths_arg,
+ cltv_expiry_delta: cltv_expiry_delta_arg,
+ }), is_owned: true }
+}
+impl Clone for CounterpartyForwardingInfo {
+ fn clone(&self) -> Self {
+ Self {
+ inner: if <*mut nativeCounterpartyForwardingInfo>::is_null(self.inner) { core::ptr::null_mut() } else {
+ ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
+ is_owned: true,
+ }
+ }
+}
+#[allow(unused)]
+/// Used only if an object of this type is returned as a trait impl by a method
+pub(crate) extern "C" fn CounterpartyForwardingInfo_clone_void(this_ptr: *const c_void) -> *mut c_void {
+ Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeCounterpartyForwardingInfo)).clone() })) as *mut c_void
+}
+#[no_mangle]
+/// Creates a copy of the CounterpartyForwardingInfo
+pub extern "C" fn CounterpartyForwardingInfo_clone(orig: &CounterpartyForwardingInfo) -> CounterpartyForwardingInfo {
+ orig.clone()
+}
+/// Get a string which allows debug introspection of a CounterpartyForwardingInfo object
+pub extern "C" fn CounterpartyForwardingInfo_debug_str_void(o: *const c_void) -> Str {
+ alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::channelmanager::CounterpartyForwardingInfo }).into()}
+
+use lightning::ln::channelmanager::ChannelCounterparty as nativeChannelCounterpartyImport;
+pub(crate) type nativeChannelCounterparty = nativeChannelCounterpartyImport;
+
+/// Channel parameters which apply to our counterparty. These are split out from [`ChannelDetails`]
+/// to better separate parameters.
+#[must_use]
+#[repr(C)]
+pub struct ChannelCounterparty {
+ /// A pointer to the opaque Rust object.
+
+ /// Nearly everywhere, inner must be non-null, however in places where
+ /// the Rust equivalent takes an Option, it may be set to null to indicate None.
+ pub inner: *mut nativeChannelCounterparty,
+ /// Indicates that this is the only struct which contains the same pointer.
+
+ /// Rust functions which take ownership of an object provided via an argument require
+ /// this to be true and invalidate the object pointed to by inner.
+ pub is_owned: bool,
+}
+
+impl Drop for ChannelCounterparty {
+ fn drop(&mut self) {
+ if self.is_owned && !<*mut nativeChannelCounterparty>::is_null(self.inner) {
+ let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
+ }
+ }
+}
+/// Frees any resources used by the ChannelCounterparty, if is_owned is set and inner is non-NULL.
+#[no_mangle]
+pub extern "C" fn ChannelCounterparty_free(this_obj: ChannelCounterparty) { }
+#[allow(unused)]
+/// Used only if an object of this type is returned as a trait impl by a method
+pub(crate) extern "C" fn ChannelCounterparty_free_void(this_ptr: *mut c_void) {
+ let _ = unsafe { Box::from_raw(this_ptr as *mut nativeChannelCounterparty) };
+}
+#[allow(unused)]
+impl ChannelCounterparty {
+ pub(crate) fn get_native_ref(&self) -> &'static nativeChannelCounterparty {
+ unsafe { &*ObjOps::untweak_ptr(self.inner) }
+ }
+ pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeChannelCounterparty {
+ unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
+ }
+ /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
+ pub(crate) fn take_inner(mut self) -> *mut nativeChannelCounterparty {
+ assert!(self.is_owned);
+ let ret = ObjOps::untweak_ptr(self.inner);
+ self.inner = core::ptr::null_mut();
+ ret
+ }
+}
+/// The node_id of our counterparty
+#[no_mangle]
+pub extern "C" fn ChannelCounterparty_get_node_id(this_ptr: &ChannelCounterparty) -> crate::c_types::PublicKey {
+ let mut inner_val = &mut this_ptr.get_native_mut_ref().node_id;
+ crate::c_types::PublicKey::from_rust(&inner_val)
+}
+/// The node_id of our counterparty
+#[no_mangle]
+pub extern "C" fn ChannelCounterparty_set_node_id(this_ptr: &mut ChannelCounterparty, mut val: crate::c_types::PublicKey) {
+ unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.node_id = val.into_rust();
+}
+/// The Features the channel counterparty provided upon last connection.
+/// Useful for routing as it is the most up-to-date copy of the counterparty's features and
+/// many routing-relevant features are present in the init context.
+#[no_mangle]
+pub extern "C" fn ChannelCounterparty_get_features(this_ptr: &ChannelCounterparty) -> crate::lightning::ln::features::InitFeatures {
+ let mut inner_val = &mut this_ptr.get_native_mut_ref().features;
+ crate::lightning::ln::features::InitFeatures { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::ln::features::InitFeatures<>) as *mut _) }, is_owned: false }
+}
+/// The Features the channel counterparty provided upon last connection.
+/// Useful for routing as it is the most up-to-date copy of the counterparty's features and
+/// many routing-relevant features are present in the init context.
+#[no_mangle]
+pub extern "C" fn ChannelCounterparty_set_features(this_ptr: &mut ChannelCounterparty, mut val: crate::lightning::ln::features::InitFeatures) {
+ unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.features = *unsafe { Box::from_raw(val.take_inner()) };
+}
+/// The value, in satoshis, that must always be held in the channel for our counterparty. This
+/// value ensures that if our counterparty broadcasts a revoked state, we can punish them by
+/// claiming at least this value on chain.
+///
+/// This value is not included in [`inbound_capacity_msat`] as it can never be spent.
+///
+/// [`inbound_capacity_msat`]: ChannelDetails::inbound_capacity_msat
+#[no_mangle]
+pub extern "C" fn ChannelCounterparty_get_unspendable_punishment_reserve(this_ptr: &ChannelCounterparty) -> u64 {
+ let mut inner_val = &mut this_ptr.get_native_mut_ref().unspendable_punishment_reserve;
+ *inner_val
+}
+/// The value, in satoshis, that must always be held in the channel for our counterparty. This
+/// value ensures that if our counterparty broadcasts a revoked state, we can punish them by
+/// claiming at least this value on chain.
+///
+/// This value is not included in [`inbound_capacity_msat`] as it can never be spent.
+///
+/// [`inbound_capacity_msat`]: ChannelDetails::inbound_capacity_msat
+#[no_mangle]
+pub extern "C" fn ChannelCounterparty_set_unspendable_punishment_reserve(this_ptr: &mut ChannelCounterparty, mut val: u64) {
+ unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.unspendable_punishment_reserve = val;
+}
+/// Information on the fees and requirements that the counterparty requires when forwarding
+/// payments to us through this channel.
+///
+/// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
+#[no_mangle]
+pub extern "C" fn ChannelCounterparty_get_forwarding_info(this_ptr: &ChannelCounterparty) -> crate::lightning::ln::channelmanager::CounterpartyForwardingInfo {
+ let mut inner_val = &mut this_ptr.get_native_mut_ref().forwarding_info;
+ let mut local_inner_val = crate::lightning::ln::channelmanager::CounterpartyForwardingInfo { inner: unsafe { (if inner_val.is_none() { core::ptr::null() } else { ObjOps::nonnull_ptr_to_inner( { (inner_val.as_ref().unwrap()) }) } as *const lightning::ln::channelmanager::CounterpartyForwardingInfo<>) as *mut _ }, is_owned: false };
+ local_inner_val
+}
+/// Information on the fees and requirements that the counterparty requires when forwarding
+/// payments to us through this channel.
+///
+/// Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
+#[no_mangle]
+pub extern "C" fn ChannelCounterparty_set_forwarding_info(this_ptr: &mut ChannelCounterparty, mut val: crate::lightning::ln::channelmanager::CounterpartyForwardingInfo) {
+ let mut local_val = if val.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(val.take_inner()) } }) };
+ unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.forwarding_info = local_val;
+}
+/// The smallest value HTLC (in msat) the remote peer will accept, for this channel. This field
+/// is only `None` before we have received either the `OpenChannel` or `AcceptChannel` message
+/// from the remote peer, or for `ChannelCounterparty` objects serialized prior to LDK 0.0.107.
+#[no_mangle]
+pub extern "C" fn ChannelCounterparty_get_outbound_htlc_minimum_msat(this_ptr: &ChannelCounterparty) -> crate::c_types::derived::COption_u64Z {
+ let mut inner_val = &mut this_ptr.get_native_mut_ref().outbound_htlc_minimum_msat;
+ let mut local_inner_val = if inner_val.is_none() { crate::c_types::derived::COption_u64Z::None } else { crate::c_types::derived::COption_u64Z::Some( { inner_val.unwrap() }) };
+ local_inner_val
+}
+/// The smallest value HTLC (in msat) the remote peer will accept, for this channel. This field
+/// is only `None` before we have received either the `OpenChannel` or `AcceptChannel` message
+/// from the remote peer, or for `ChannelCounterparty` objects serialized prior to LDK 0.0.107.
+#[no_mangle]
+pub extern "C" fn ChannelCounterparty_set_outbound_htlc_minimum_msat(this_ptr: &mut ChannelCounterparty, mut val: crate::c_types::derived::COption_u64Z) {
+ let mut local_val = if val.is_some() { Some( { val.take() }) } else { None };
+ unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.outbound_htlc_minimum_msat = local_val;
+}
+/// The largest value HTLC (in msat) the remote peer currently will accept, for this channel.
+#[no_mangle]
+pub extern "C" fn ChannelCounterparty_get_outbound_htlc_maximum_msat(this_ptr: &ChannelCounterparty) -> crate::c_types::derived::COption_u64Z {
+ let mut inner_val = &mut this_ptr.get_native_mut_ref().outbound_htlc_maximum_msat;
+ let mut local_inner_val = if inner_val.is_none() { crate::c_types::derived::COption_u64Z::None } else { crate::c_types::derived::COption_u64Z::Some( { inner_val.unwrap() }) };
+ local_inner_val
+}
+/// The largest value HTLC (in msat) the remote peer currently will accept, for this channel.
+#[no_mangle]
+pub extern "C" fn ChannelCounterparty_set_outbound_htlc_maximum_msat(this_ptr: &mut ChannelCounterparty, mut val: crate::c_types::derived::COption_u64Z) {
+ let mut local_val = if val.is_some() { Some( { val.take() }) } else { None };
+ unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.outbound_htlc_maximum_msat = local_val;
+}
+/// Constructs a new ChannelCounterparty given each field
+///
+/// Note that forwarding_info_arg (or a relevant inner pointer) may be NULL or all-0s to represent None
+#[must_use]
+#[no_mangle]
+pub extern "C" fn ChannelCounterparty_new(mut node_id_arg: crate::c_types::PublicKey, mut features_arg: crate::lightning::ln::features::InitFeatures, mut unspendable_punishment_reserve_arg: u64, mut forwarding_info_arg: crate::lightning::ln::channelmanager::CounterpartyForwardingInfo, mut outbound_htlc_minimum_msat_arg: crate::c_types::derived::COption_u64Z, mut outbound_htlc_maximum_msat_arg: crate::c_types::derived::COption_u64Z) -> ChannelCounterparty {
+ let mut local_forwarding_info_arg = if forwarding_info_arg.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(forwarding_info_arg.take_inner()) } }) };
+ let mut local_outbound_htlc_minimum_msat_arg = if outbound_htlc_minimum_msat_arg.is_some() { Some( { outbound_htlc_minimum_msat_arg.take() }) } else { None };
+ let mut local_outbound_htlc_maximum_msat_arg = if outbound_htlc_maximum_msat_arg.is_some() { Some( { outbound_htlc_maximum_msat_arg.take() }) } else { None };
+ ChannelCounterparty { inner: ObjOps::heap_alloc(nativeChannelCounterparty {
+ node_id: node_id_arg.into_rust(),
+ features: *unsafe { Box::from_raw(features_arg.take_inner()) },
+ unspendable_punishment_reserve: unspendable_punishment_reserve_arg,
+ forwarding_info: local_forwarding_info_arg,
+ outbound_htlc_minimum_msat: local_outbound_htlc_minimum_msat_arg,
+ outbound_htlc_maximum_msat: local_outbound_htlc_maximum_msat_arg,
+ }), is_owned: true }
+}
+impl Clone for ChannelCounterparty {
+ fn clone(&self) -> Self {
+ Self {
+ inner: if <*mut nativeChannelCounterparty>::is_null(self.inner) { core::ptr::null_mut() } else {
+ ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
+ is_owned: true,
+ }
+ }
+}
+#[allow(unused)]
+/// Used only if an object of this type is returned as a trait impl by a method
+pub(crate) extern "C" fn ChannelCounterparty_clone_void(this_ptr: *const c_void) -> *mut c_void {
+ Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeChannelCounterparty)).clone() })) as *mut c_void
+}
+#[no_mangle]
+/// Creates a copy of the ChannelCounterparty
+pub extern "C" fn ChannelCounterparty_clone(orig: &ChannelCounterparty) -> ChannelCounterparty {
+ orig.clone()
+}
+/// Get a string which allows debug introspection of a ChannelCounterparty object
+pub extern "C" fn ChannelCounterparty_debug_str_void(o: *const c_void) -> Str {
+ alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::channelmanager::ChannelCounterparty }).into()}
+
+use lightning::ln::channelmanager::ChannelDetails as nativeChannelDetailsImport;
+pub(crate) type nativeChannelDetails = nativeChannelDetailsImport;
+
+/// Details of a channel, as returned by [`ChannelManager::list_channels`] and [`ChannelManager::list_usable_channels`]
+#[must_use]
+#[repr(C)]
+pub struct ChannelDetails {
+ /// A pointer to the opaque Rust object.
+
+ /// Nearly everywhere, inner must be non-null, however in places where
+ /// the Rust equivalent takes an Option, it may be set to null to indicate None.
+ pub inner: *mut nativeChannelDetails,
+ /// Indicates that this is the only struct which contains the same pointer.
+
+ /// Rust functions which take ownership of an object provided via an argument require
+ /// this to be true and invalidate the object pointed to by inner.
+ pub is_owned: bool,
+}
+
+impl Drop for ChannelDetails {
+ fn drop(&mut self) {
+ if self.is_owned && !<*mut nativeChannelDetails>::is_null(self.inner) {
+ let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
+ }
+ }
+}
+/// Frees any resources used by the ChannelDetails, if is_owned is set and inner is non-NULL.
+#[no_mangle]
+pub extern "C" fn ChannelDetails_free(this_obj: ChannelDetails) { }
+#[allow(unused)]
+/// Used only if an object of this type is returned as a trait impl by a method
+pub(crate) extern "C" fn ChannelDetails_free_void(this_ptr: *mut c_void) {
+ let _ = unsafe { Box::from_raw(this_ptr as *mut nativeChannelDetails) };
+}
+#[allow(unused)]
+impl ChannelDetails {
+ pub(crate) fn get_native_ref(&self) -> &'static nativeChannelDetails {
+ unsafe { &*ObjOps::untweak_ptr(self.inner) }
+ }
+ pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeChannelDetails {
+ unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
+ }
+ /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
+ pub(crate) fn take_inner(mut self) -> *mut nativeChannelDetails {
+ assert!(self.is_owned);
+ let ret = ObjOps::untweak_ptr(self.inner);
+ self.inner = core::ptr::null_mut();
+ ret
+ }
+}
+/// The channel's ID (prior to funding transaction generation, this is a random 32 bytes,
+/// thereafter this is the txid of the funding transaction xor the funding transaction output).
+/// Note that this means this value is *not* persistent - it can change once during the
+/// lifetime of the channel.
+#[no_mangle]
+pub extern "C" fn ChannelDetails_get_channel_id(this_ptr: &ChannelDetails) -> *const [u8; 32] {
+ let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
+ &inner_val.0
+}
+/// The channel's ID (prior to funding transaction generation, this is a random 32 bytes,
+/// thereafter this is the txid of the funding transaction xor the funding transaction output).
+/// Note that this means this value is *not* persistent - it can change once during the
+/// lifetime of the channel.
+#[no_mangle]
+pub extern "C" fn ChannelDetails_set_channel_id(this_ptr: &mut ChannelDetails, mut val: crate::c_types::ThirtyTwoBytes) {
+ unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = ::lightning::ln::ChannelId(val.data);
+}
+/// Parameters which apply to our counterparty. See individual fields for more information.
+#[no_mangle]
+pub extern "C" fn ChannelDetails_get_counterparty(this_ptr: &ChannelDetails) -> crate::lightning::ln::channelmanager::ChannelCounterparty {
+ let mut inner_val = &mut this_ptr.get_native_mut_ref().counterparty;
+ crate::lightning::ln::channelmanager::ChannelCounterparty { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::ln::channelmanager::ChannelCounterparty<>) as *mut _) }, is_owned: false }
+}
+/// Parameters which apply to our counterparty. See individual fields for more information.
+#[no_mangle]
+pub extern "C" fn ChannelDetails_set_counterparty(this_ptr: &mut ChannelDetails, mut val: crate::lightning::ln::channelmanager::ChannelCounterparty) {
+ unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.counterparty = *unsafe { Box::from_raw(val.take_inner()) };
+}
+/// The Channel's funding transaction output, if we've negotiated the funding transaction with
+/// our counterparty already.
+///
+/// Note that, if this has been set, `channel_id` will be equivalent to
+/// `funding_txo.unwrap().to_channel_id()`.
+///
+/// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
+#[no_mangle]
+pub extern "C" fn ChannelDetails_get_funding_txo(this_ptr: &ChannelDetails) -> crate::lightning::chain::transaction::OutPoint {
+ let mut inner_val = &mut this_ptr.get_native_mut_ref().funding_txo;
+ let mut local_inner_val = crate::lightning::chain::transaction::OutPoint { inner: unsafe { (if inner_val.is_none() { core::ptr::null() } else { ObjOps::nonnull_ptr_to_inner( { (inner_val.as_ref().unwrap()) }) } as *const lightning::chain::transaction::OutPoint<>) as *mut _ }, is_owned: false };
+ local_inner_val
+}
+/// The Channel's funding transaction output, if we've negotiated the funding transaction with
+/// our counterparty already.
+///
+/// Note that, if this has been set, `channel_id` will be equivalent to
+/// `funding_txo.unwrap().to_channel_id()`.
+///
+/// Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
+#[no_mangle]
+pub extern "C" fn ChannelDetails_set_funding_txo(this_ptr: &mut ChannelDetails, mut val: crate::lightning::chain::transaction::OutPoint) {
+ let mut local_val = if val.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(val.take_inner()) } }) };
+ unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.funding_txo = local_val;
+}
+/// The features which this channel operates with. See individual features for more info.
+///
+/// `None` until negotiation completes and the channel type is finalized.
+///
+/// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
+#[no_mangle]
+pub extern "C" fn ChannelDetails_get_channel_type(this_ptr: &ChannelDetails) -> crate::lightning::ln::features::ChannelTypeFeatures {
+ let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_type;
+ let mut local_inner_val = crate::lightning::ln::features::ChannelTypeFeatures { inner: unsafe { (if inner_val.is_none() { core::ptr::null() } else { ObjOps::nonnull_ptr_to_inner( { (inner_val.as_ref().unwrap()) }) } as *const lightning::ln::features::ChannelTypeFeatures<>) as *mut _ }, is_owned: false };
+ local_inner_val
+}
+/// The features which this channel operates with. See individual features for more info.
+///
+/// `None` until negotiation completes and the channel type is finalized.
+///
+/// Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
+#[no_mangle]
+pub extern "C" fn ChannelDetails_set_channel_type(this_ptr: &mut ChannelDetails, mut val: crate::lightning::ln::features::ChannelTypeFeatures) {
+ let mut local_val = if val.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(val.take_inner()) } }) };
+ unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_type = local_val;
+}
+/// The position of the funding transaction in the chain. None if the funding transaction has
+/// not yet been confirmed and the channel fully opened.
+///
+/// Note that if [`inbound_scid_alias`] is set, it must be used for invoices and inbound
+/// payments instead of this. See [`get_inbound_payment_scid`].
+///
+/// For channels with [`confirmations_required`] set to `Some(0)`, [`outbound_scid_alias`] may
+/// be used in place of this in outbound routes. See [`get_outbound_payment_scid`].
+///
+/// [`inbound_scid_alias`]: Self::inbound_scid_alias
+/// [`outbound_scid_alias`]: Self::outbound_scid_alias
+/// [`get_inbound_payment_scid`]: Self::get_inbound_payment_scid
+/// [`get_outbound_payment_scid`]: Self::get_outbound_payment_scid
+/// [`confirmations_required`]: Self::confirmations_required
+#[no_mangle]
+pub extern "C" fn ChannelDetails_get_short_channel_id(this_ptr: &ChannelDetails) -> crate::c_types::derived::COption_u64Z {
+ let mut inner_val = &mut this_ptr.get_native_mut_ref().short_channel_id;
+ let mut local_inner_val = if inner_val.is_none() { crate::c_types::derived::COption_u64Z::None } else { crate::c_types::derived::COption_u64Z::Some( { inner_val.unwrap() }) };
+ local_inner_val
+}
+/// The position of the funding transaction in the chain. None if the funding transaction has
+/// not yet been confirmed and the channel fully opened.
+///
+/// Note that if [`inbound_scid_alias`] is set, it must be used for invoices and inbound
+/// payments instead of this. See [`get_inbound_payment_scid`].
+///
+/// For channels with [`confirmations_required`] set to `Some(0)`, [`outbound_scid_alias`] may
+/// be used in place of this in outbound routes. See [`get_outbound_payment_scid`].
+///
+/// [`inbound_scid_alias`]: Self::inbound_scid_alias
+/// [`outbound_scid_alias`]: Self::outbound_scid_alias
+/// [`get_inbound_payment_scid`]: Self::get_inbound_payment_scid
+/// [`get_outbound_payment_scid`]: Self::get_outbound_payment_scid
+/// [`confirmations_required`]: Self::confirmations_required
+#[no_mangle]
+pub extern "C" fn ChannelDetails_set_short_channel_id(this_ptr: &mut ChannelDetails, mut val: crate::c_types::derived::COption_u64Z) {
+ let mut local_val = if val.is_some() { Some( { val.take() }) } else { None };
+ unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.short_channel_id = local_val;
+}
+/// An optional [`short_channel_id`] alias for this channel, randomly generated by us and
+/// usable in place of [`short_channel_id`] to reference the channel in outbound routes when
+/// the channel has not yet been confirmed (as long as [`confirmations_required`] is
+/// `Some(0)`).
+///
+/// This will be `None` as long as the channel is not available for routing outbound payments.
+///
+/// [`short_channel_id`]: Self::short_channel_id
+/// [`confirmations_required`]: Self::confirmations_required
+#[no_mangle]
+pub extern "C" fn ChannelDetails_get_outbound_scid_alias(this_ptr: &ChannelDetails) -> crate::c_types::derived::COption_u64Z {
+ let mut inner_val = &mut this_ptr.get_native_mut_ref().outbound_scid_alias;
+ let mut local_inner_val = if inner_val.is_none() { crate::c_types::derived::COption_u64Z::None } else { crate::c_types::derived::COption_u64Z::Some( { inner_val.unwrap() }) };
+ local_inner_val
+}
+/// An optional [`short_channel_id`] alias for this channel, randomly generated by us and
+/// usable in place of [`short_channel_id`] to reference the channel in outbound routes when
+/// the channel has not yet been confirmed (as long as [`confirmations_required`] is
+/// `Some(0)`).
+///
+/// This will be `None` as long as the channel is not available for routing outbound payments.
+///
+/// [`short_channel_id`]: Self::short_channel_id
+/// [`confirmations_required`]: Self::confirmations_required
+#[no_mangle]
+pub extern "C" fn ChannelDetails_set_outbound_scid_alias(this_ptr: &mut ChannelDetails, mut val: crate::c_types::derived::COption_u64Z) {
+ let mut local_val = if val.is_some() { Some( { val.take() }) } else { None };
+ unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.outbound_scid_alias = local_val;
+}
+/// An optional [`short_channel_id`] alias for this channel, randomly generated by our
+/// counterparty and usable in place of [`short_channel_id`] in invoice route hints. Our
+/// counterparty will recognize the alias provided here in place of the [`short_channel_id`]
+/// when they see a payment to be routed to us.
+///
+/// Our counterparty may choose to rotate this value at any time, though will always recognize
+/// previous values for inbound payment forwarding.
+///
+/// [`short_channel_id`]: Self::short_channel_id
+#[no_mangle]
+pub extern "C" fn ChannelDetails_get_inbound_scid_alias(this_ptr: &ChannelDetails) -> crate::c_types::derived::COption_u64Z {
+ let mut inner_val = &mut this_ptr.get_native_mut_ref().inbound_scid_alias;
+ let mut local_inner_val = if inner_val.is_none() { crate::c_types::derived::COption_u64Z::None } else { crate::c_types::derived::COption_u64Z::Some( { inner_val.unwrap() }) };
+ local_inner_val
+}
+/// An optional [`short_channel_id`] alias for this channel, randomly generated by our
+/// counterparty and usable in place of [`short_channel_id`] in invoice route hints. Our
+/// counterparty will recognize the alias provided here in place of the [`short_channel_id`]
+/// when they see a payment to be routed to us.
+///
+/// Our counterparty may choose to rotate this value at any time, though will always recognize
+/// previous values for inbound payment forwarding.
+///
+/// [`short_channel_id`]: Self::short_channel_id
+#[no_mangle]
+pub extern "C" fn ChannelDetails_set_inbound_scid_alias(this_ptr: &mut ChannelDetails, mut val: crate::c_types::derived::COption_u64Z) {
+ let mut local_val = if val.is_some() { Some( { val.take() }) } else { None };
+ unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.inbound_scid_alias = local_val;
+}
+/// The value, in satoshis, of this channel as appears in the funding output
+#[no_mangle]
+pub extern "C" fn ChannelDetails_get_channel_value_satoshis(this_ptr: &ChannelDetails) -> u64 {
+ let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_value_satoshis;
+ *inner_val
+}
+/// The value, in satoshis, of this channel as appears in the funding output
+#[no_mangle]
+pub extern "C" fn ChannelDetails_set_channel_value_satoshis(this_ptr: &mut ChannelDetails, mut val: u64) {
+ unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_value_satoshis = val;
+}
+/// The value, in satoshis, that must always be held in the channel for us. This value ensures
+/// that if we broadcast a revoked state, our counterparty can punish us by claiming at least
+/// this value on chain.
+///
+/// This value is not included in [`outbound_capacity_msat`] as it can never be spent.
+///
+/// This value will be `None` for outbound channels until the counterparty accepts the channel.
+///
+/// [`outbound_capacity_msat`]: ChannelDetails::outbound_capacity_msat
+#[no_mangle]
+pub extern "C" fn ChannelDetails_get_unspendable_punishment_reserve(this_ptr: &ChannelDetails) -> crate::c_types::derived::COption_u64Z {
+ let mut inner_val = &mut this_ptr.get_native_mut_ref().unspendable_punishment_reserve;
+ let mut local_inner_val = if inner_val.is_none() { crate::c_types::derived::COption_u64Z::None } else { crate::c_types::derived::COption_u64Z::Some( { inner_val.unwrap() }) };
+ local_inner_val
+}
+/// The value, in satoshis, that must always be held in the channel for us. This value ensures
+/// that if we broadcast a revoked state, our counterparty can punish us by claiming at least
+/// this value on chain.
+///
+/// This value is not included in [`outbound_capacity_msat`] as it can never be spent.
+///
+/// This value will be `None` for outbound channels until the counterparty accepts the channel.
+///
+/// [`outbound_capacity_msat`]: ChannelDetails::outbound_capacity_msat
+#[no_mangle]
+pub extern "C" fn ChannelDetails_set_unspendable_punishment_reserve(this_ptr: &mut ChannelDetails, mut val: crate::c_types::derived::COption_u64Z) {
+ let mut local_val = if val.is_some() { Some( { val.take() }) } else { None };
+ unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.unspendable_punishment_reserve = local_val;
+}
+/// The `user_channel_id` value passed in to [`ChannelManager::create_channel`] for outbound
+/// channels, or to [`ChannelManager::accept_inbound_channel`] for inbound channels if
+/// [`UserConfig::manually_accept_inbound_channels`] config flag is set to true. Otherwise
+/// `user_channel_id` will be randomized for an inbound channel. This may be zero for objects
+/// serialized with LDK versions prior to 0.0.113.
+///
+/// [`ChannelManager::create_channel`]: crate::ln::channelmanager::ChannelManager::create_channel
+/// [`ChannelManager::accept_inbound_channel`]: crate::ln::channelmanager::ChannelManager::accept_inbound_channel
+/// [`UserConfig::manually_accept_inbound_channels`]: crate::util::config::UserConfig::manually_accept_inbound_channels
+#[no_mangle]
+pub extern "C" fn ChannelDetails_get_user_channel_id(this_ptr: &ChannelDetails) -> crate::c_types::U128 {
+ let mut inner_val = &mut this_ptr.get_native_mut_ref().user_channel_id;
+ inner_val.into()
+}
+/// The `user_channel_id` value passed in to [`ChannelManager::create_channel`] for outbound
+/// channels, or to [`ChannelManager::accept_inbound_channel`] for inbound channels if
+/// [`UserConfig::manually_accept_inbound_channels`] config flag is set to true. Otherwise
+/// `user_channel_id` will be randomized for an inbound channel. This may be zero for objects
+/// serialized with LDK versions prior to 0.0.113.
+///
+/// [`ChannelManager::create_channel`]: crate::ln::channelmanager::ChannelManager::create_channel
+/// [`ChannelManager::accept_inbound_channel`]: crate::ln::channelmanager::ChannelManager::accept_inbound_channel
+/// [`UserConfig::manually_accept_inbound_channels`]: crate::util::config::UserConfig::manually_accept_inbound_channels
+#[no_mangle]
+pub extern "C" fn ChannelDetails_set_user_channel_id(this_ptr: &mut ChannelDetails, mut val: crate::c_types::U128) {
+ unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.user_channel_id = val.into();
+}
+/// The currently negotiated fee rate denominated in satoshi per 1000 weight units,
+/// which is applied to commitment and HTLC transactions.
+///
+/// This value will be `None` for objects serialized with LDK versions prior to 0.0.115.
+#[no_mangle]
+pub extern "C" fn ChannelDetails_get_feerate_sat_per_1000_weight(this_ptr: &ChannelDetails) -> crate::c_types::derived::COption_u32Z {
+ let mut inner_val = &mut this_ptr.get_native_mut_ref().feerate_sat_per_1000_weight;
+ let mut local_inner_val = if inner_val.is_none() { crate::c_types::derived::COption_u32Z::None } else { crate::c_types::derived::COption_u32Z::Some( { inner_val.unwrap() }) };
+ local_inner_val
+}
+/// The currently negotiated fee rate denominated in satoshi per 1000 weight units,
+/// which is applied to commitment and HTLC transactions.
+///
+/// This value will be `None` for objects serialized with LDK versions prior to 0.0.115.
+#[no_mangle]
+pub extern "C" fn ChannelDetails_set_feerate_sat_per_1000_weight(this_ptr: &mut ChannelDetails, mut val: crate::c_types::derived::COption_u32Z) {
+ let mut local_val = if val.is_some() { Some( { val.take() }) } else { None };
+ unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.feerate_sat_per_1000_weight = local_val;
+}
+/// Our total balance. This is the amount we would get if we close the channel.
+/// This value is not exact. Due to various in-flight changes and feerate changes, exactly this
+/// amount is not likely to be recoverable on close.
+///
+/// This does not include any pending HTLCs which are not yet fully resolved (and, thus, whose
+/// balance is not available for inclusion in new outbound HTLCs). This further does not include
+/// any pending outgoing HTLCs which are awaiting some other resolution to be sent.
+/// This does not consider any on-chain fees.
+///
+/// See also [`ChannelDetails::outbound_capacity_msat`]
+#[no_mangle]
+pub extern "C" fn ChannelDetails_get_balance_msat(this_ptr: &ChannelDetails) -> u64 {
+ let mut inner_val = &mut this_ptr.get_native_mut_ref().balance_msat;
+ *inner_val
+}
+/// Our total balance. This is the amount we would get if we close the channel.
+/// This value is not exact. Due to various in-flight changes and feerate changes, exactly this
+/// amount is not likely to be recoverable on close.
+///
+/// This does not include any pending HTLCs which are not yet fully resolved (and, thus, whose
+/// balance is not available for inclusion in new outbound HTLCs). This further does not include
+/// any pending outgoing HTLCs which are awaiting some other resolution to be sent.
+/// This does not consider any on-chain fees.
+///
+/// See also [`ChannelDetails::outbound_capacity_msat`]
+#[no_mangle]
+pub extern "C" fn ChannelDetails_set_balance_msat(this_ptr: &mut ChannelDetails, mut val: u64) {
+ unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.balance_msat = val;
+}
+/// The available outbound capacity for sending HTLCs to the remote peer. This does not include
+/// any pending HTLCs which are not yet fully resolved (and, thus, whose balance is not
+/// available for inclusion in new outbound HTLCs). This further does not include any pending
+/// outgoing HTLCs which are awaiting some other resolution to be sent.
+///
+/// See also [`ChannelDetails::balance_msat`]
+///
+/// This value is not exact. Due to various in-flight changes, feerate changes, and our
+/// conflict-avoidance policy, exactly this amount is not likely to be spendable. However, we
+/// should be able to spend nearly this amount.
+#[no_mangle]
+pub extern "C" fn ChannelDetails_get_outbound_capacity_msat(this_ptr: &ChannelDetails) -> u64 {
+ let mut inner_val = &mut this_ptr.get_native_mut_ref().outbound_capacity_msat;
+ *inner_val
+}
+/// The available outbound capacity for sending HTLCs to the remote peer. This does not include
+/// any pending HTLCs which are not yet fully resolved (and, thus, whose balance is not
+/// available for inclusion in new outbound HTLCs). This further does not include any pending
+/// outgoing HTLCs which are awaiting some other resolution to be sent.
+///
+/// See also [`ChannelDetails::balance_msat`]
+///
+/// This value is not exact. Due to various in-flight changes, feerate changes, and our
+/// conflict-avoidance policy, exactly this amount is not likely to be spendable. However, we
+/// should be able to spend nearly this amount.
+#[no_mangle]
+pub extern "C" fn ChannelDetails_set_outbound_capacity_msat(this_ptr: &mut ChannelDetails, mut val: u64) {
+ unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.outbound_capacity_msat = val;
+}
+/// The available outbound capacity for sending a single HTLC to the remote peer. This is
+/// similar to [`ChannelDetails::outbound_capacity_msat`] but it may be further restricted by
+/// the current state and per-HTLC limit(s). This is intended for use when routing, allowing us
+/// to use a limit as close as possible to the HTLC limit we can currently send.
+///
+/// See also [`ChannelDetails::next_outbound_htlc_minimum_msat`],
+/// [`ChannelDetails::balance_msat`], and [`ChannelDetails::outbound_capacity_msat`].
+#[no_mangle]
+pub extern "C" fn ChannelDetails_get_next_outbound_htlc_limit_msat(this_ptr: &ChannelDetails) -> u64 {
+ let mut inner_val = &mut this_ptr.get_native_mut_ref().next_outbound_htlc_limit_msat;
+ *inner_val
+}
+/// The available outbound capacity for sending a single HTLC to the remote peer. This is
+/// similar to [`ChannelDetails::outbound_capacity_msat`] but it may be further restricted by
+/// the current state and per-HTLC limit(s). This is intended for use when routing, allowing us
+/// to use a limit as close as possible to the HTLC limit we can currently send.
+///
+/// See also [`ChannelDetails::next_outbound_htlc_minimum_msat`],
+/// [`ChannelDetails::balance_msat`], and [`ChannelDetails::outbound_capacity_msat`].
+#[no_mangle]
+pub extern "C" fn ChannelDetails_set_next_outbound_htlc_limit_msat(this_ptr: &mut ChannelDetails, mut val: u64) {
+ unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.next_outbound_htlc_limit_msat = val;
+}
+/// The minimum value for sending a single HTLC to the remote peer. This is the equivalent of
+/// [`ChannelDetails::next_outbound_htlc_limit_msat`] but represents a lower-bound, rather than
+/// an upper-bound. This is intended for use when routing, allowing us to ensure we pick a
+/// route which is valid.
+#[no_mangle]
+pub extern "C" fn ChannelDetails_get_next_outbound_htlc_minimum_msat(this_ptr: &ChannelDetails) -> u64 {
+ let mut inner_val = &mut this_ptr.get_native_mut_ref().next_outbound_htlc_minimum_msat;
+ *inner_val
+}
+/// The minimum value for sending a single HTLC to the remote peer. This is the equivalent of
+/// [`ChannelDetails::next_outbound_htlc_limit_msat`] but represents a lower-bound, rather than
+/// an upper-bound. This is intended for use when routing, allowing us to ensure we pick a
+/// route which is valid.
+#[no_mangle]
+pub extern "C" fn ChannelDetails_set_next_outbound_htlc_minimum_msat(this_ptr: &mut ChannelDetails, mut val: u64) {
+ unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.next_outbound_htlc_minimum_msat = val;
+}
+/// The available inbound capacity for the remote peer to send HTLCs to us. This does not
+/// include any pending HTLCs which are not yet fully resolved (and, thus, whose balance is not
+/// available for inclusion in new inbound HTLCs).
+/// Note that there are some corner cases not fully handled here, so the actual available
+/// inbound capacity may be slightly higher than this.
+///
+/// This value is not exact. Due to various in-flight changes, feerate changes, and our
+/// counterparty's conflict-avoidance policy, exactly this amount is not likely to be spendable.
+/// However, our counterparty should be able to spend nearly this amount.
+#[no_mangle]
+pub extern "C" fn ChannelDetails_get_inbound_capacity_msat(this_ptr: &ChannelDetails) -> u64 {
+ let mut inner_val = &mut this_ptr.get_native_mut_ref().inbound_capacity_msat;
+ *inner_val
+}
+/// The available inbound capacity for the remote peer to send HTLCs to us. This does not
+/// include any pending HTLCs which are not yet fully resolved (and, thus, whose balance is not
+/// available for inclusion in new inbound HTLCs).
+/// Note that there are some corner cases not fully handled here, so the actual available
+/// inbound capacity may be slightly higher than this.
+///
+/// This value is not exact. Due to various in-flight changes, feerate changes, and our
+/// counterparty's conflict-avoidance policy, exactly this amount is not likely to be spendable.
+/// However, our counterparty should be able to spend nearly this amount.