+pub extern "C" fn RecentPaymentDetails_free(this_ptr: RecentPaymentDetails) { }
+/// Creates a copy of the RecentPaymentDetails
+#[no_mangle]
+pub extern "C" fn RecentPaymentDetails_clone(orig: &RecentPaymentDetails) -> RecentPaymentDetails {
+ 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 RecentPaymentDetails_clone_void(this_ptr: *const c_void) -> *mut c_void {
+ Box::into_raw(Box::new(unsafe { (*(this_ptr as *const RecentPaymentDetails)).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 RecentPaymentDetails_free_void(this_ptr: *mut c_void) {
+ let _ = unsafe { Box::from_raw(this_ptr as *mut RecentPaymentDetails) };
+}
+#[no_mangle]
+/// Utility method to constructs a new AwaitingInvoice-variant RecentPaymentDetails
+pub extern "C" fn RecentPaymentDetails_awaiting_invoice(payment_id: crate::c_types::ThirtyTwoBytes) -> RecentPaymentDetails {
+ RecentPaymentDetails::AwaitingInvoice {
+ payment_id,
+ }
+}
+#[no_mangle]
+/// Utility method to constructs a new Pending-variant RecentPaymentDetails
+pub extern "C" fn RecentPaymentDetails_pending(payment_id: crate::c_types::ThirtyTwoBytes, payment_hash: crate::c_types::ThirtyTwoBytes, total_msat: u64) -> RecentPaymentDetails {
+ RecentPaymentDetails::Pending {
+ payment_id,
+ payment_hash,
+ total_msat,
+ }
+}
+#[no_mangle]
+/// Utility method to constructs a new Fulfilled-variant RecentPaymentDetails
+pub extern "C" fn RecentPaymentDetails_fulfilled(payment_id: crate::c_types::ThirtyTwoBytes, payment_hash: crate::c_types::derived::COption_ThirtyTwoBytesZ) -> RecentPaymentDetails {
+ RecentPaymentDetails::Fulfilled {
+ payment_id,
+ payment_hash,
+ }
+}
+#[no_mangle]
+/// Utility method to constructs a new Abandoned-variant RecentPaymentDetails
+pub extern "C" fn RecentPaymentDetails_abandoned(payment_id: crate::c_types::ThirtyTwoBytes, payment_hash: crate::c_types::ThirtyTwoBytes) -> RecentPaymentDetails {
+ RecentPaymentDetails::Abandoned {
+ payment_id,
+ payment_hash,
+ }
+}
+
+use lightning::ln::channelmanager::PhantomRouteHints as nativePhantomRouteHintsImport;
+pub(crate) type nativePhantomRouteHints = nativePhantomRouteHintsImport;
+
+/// Route hints used in constructing invoices for [phantom node payents].
+///
+/// [phantom node payments]: crate::sign::PhantomKeysManager
+#[must_use]
+#[repr(C)]
+pub struct PhantomRouteHints {
+ /// 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 nativePhantomRouteHints,
+ /// 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 PhantomRouteHints {
+ fn drop(&mut self) {
+ if self.is_owned && !<*mut nativePhantomRouteHints>::is_null(self.inner) {
+ let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
+ }
+ }
+}
+/// Frees any resources used by the PhantomRouteHints, if is_owned is set and inner is non-NULL.
+#[no_mangle]
+pub extern "C" fn PhantomRouteHints_free(this_obj: PhantomRouteHints) { }
+#[allow(unused)]
+/// Used only if an object of this type is returned as a trait impl by a method
+pub(crate) extern "C" fn PhantomRouteHints_free_void(this_ptr: *mut c_void) {
+ let _ = unsafe { Box::from_raw(this_ptr as *mut nativePhantomRouteHints) };
+}
+#[allow(unused)]
+impl PhantomRouteHints {
+ pub(crate) fn get_native_ref(&self) -> &'static nativePhantomRouteHints {
+ unsafe { &*ObjOps::untweak_ptr(self.inner) }
+ }
+ pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativePhantomRouteHints {
+ 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 nativePhantomRouteHints {
+ assert!(self.is_owned);
+ let ret = ObjOps::untweak_ptr(self.inner);
+ self.inner = core::ptr::null_mut();
+ ret
+ }
+}
+/// The list of channels to be included in the invoice route hints.
+#[no_mangle]
+pub extern "C" fn PhantomRouteHints_get_channels(this_ptr: &PhantomRouteHints) -> crate::c_types::derived::CVec_ChannelDetailsZ {
+ let mut inner_val = &mut this_ptr.get_native_mut_ref().channels;
+ let mut local_inner_val = Vec::new(); for item in inner_val.iter() { local_inner_val.push( { crate::lightning::ln::channelmanager::ChannelDetails { inner: unsafe { ObjOps::nonnull_ptr_to_inner((item as *const lightning::ln::channelmanager::ChannelDetails<>) as *mut _) }, is_owned: false } }); };
+ local_inner_val.into()
+}
+/// The list of channels to be included in the invoice route hints.
+#[no_mangle]
+pub extern "C" fn PhantomRouteHints_set_channels(this_ptr: &mut PhantomRouteHints, mut val: crate::c_types::derived::CVec_ChannelDetailsZ) {
+ let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { *unsafe { Box::from_raw(item.take_inner()) } }); };
+ unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channels = local_val;
+}
+/// A fake scid used for representing the phantom node's fake channel in generating the invoice
+/// route hints.
+#[no_mangle]
+pub extern "C" fn PhantomRouteHints_get_phantom_scid(this_ptr: &PhantomRouteHints) -> u64 {
+ let mut inner_val = &mut this_ptr.get_native_mut_ref().phantom_scid;
+ *inner_val
+}
+/// A fake scid used for representing the phantom node's fake channel in generating the invoice
+/// route hints.
+#[no_mangle]
+pub extern "C" fn PhantomRouteHints_set_phantom_scid(this_ptr: &mut PhantomRouteHints, mut val: u64) {
+ unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.phantom_scid = val;
+}
+/// The pubkey of the real backing node that would ultimately receive the payment.
+#[no_mangle]
+pub extern "C" fn PhantomRouteHints_get_real_node_pubkey(this_ptr: &PhantomRouteHints) -> crate::c_types::PublicKey {
+ let mut inner_val = &mut this_ptr.get_native_mut_ref().real_node_pubkey;
+ crate::c_types::PublicKey::from_rust(&inner_val)
+}
+/// The pubkey of the real backing node that would ultimately receive the payment.
+#[no_mangle]
+pub extern "C" fn PhantomRouteHints_set_real_node_pubkey(this_ptr: &mut PhantomRouteHints, mut val: crate::c_types::PublicKey) {
+ unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.real_node_pubkey = val.into_rust();
+}
+/// Constructs a new PhantomRouteHints given each field
+#[must_use]
+#[no_mangle]
+pub extern "C" fn PhantomRouteHints_new(mut channels_arg: crate::c_types::derived::CVec_ChannelDetailsZ, mut phantom_scid_arg: u64, mut real_node_pubkey_arg: crate::c_types::PublicKey) -> PhantomRouteHints {
+ let mut local_channels_arg = Vec::new(); for mut item in channels_arg.into_rust().drain(..) { local_channels_arg.push( { *unsafe { Box::from_raw(item.take_inner()) } }); };
+ PhantomRouteHints { inner: ObjOps::heap_alloc(nativePhantomRouteHints {
+ channels: local_channels_arg,
+ phantom_scid: phantom_scid_arg,
+ real_node_pubkey: real_node_pubkey_arg.into_rust(),
+ }), is_owned: true }
+}
+impl Clone for PhantomRouteHints {
+ fn clone(&self) -> Self {
+ Self {
+ inner: if <*mut nativePhantomRouteHints>::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 PhantomRouteHints_clone_void(this_ptr: *const c_void) -> *mut c_void {
+ Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativePhantomRouteHints)).clone() })) as *mut c_void
+}
+#[no_mangle]
+/// Creates a copy of the PhantomRouteHints
+pub extern "C" fn PhantomRouteHints_clone(orig: &PhantomRouteHints) -> PhantomRouteHints {
+ orig.clone()
+}
+/// Constructs a new `ChannelManager` to hold several channels and route between them.
+///
+/// The current time or latest block header time can be provided as the `current_timestamp`.
+///
+/// This is the main \"logic hub\" for all channel-related actions, and implements
+/// [`ChannelMessageHandler`].
+///
+/// Non-proportional fees are fixed according to our risk using the provided fee estimator.
+///
+/// Users need to notify the new `ChannelManager` when a new block is connected or
+/// disconnected using its [`block_connected`] and [`block_disconnected`] methods, starting
+/// from after [`params.best_block.block_hash`]. See [`chain::Listen`] and [`chain::Confirm`] for
+/// more details.
+///
+/// [`block_connected`]: chain::Listen::block_connected
+/// [`block_disconnected`]: chain::Listen::block_disconnected
+/// [`params.best_block.block_hash`]: chain::BestBlock::block_hash
+#[must_use]
+#[no_mangle]
+pub extern "C" fn ChannelManager_new(mut fee_est: crate::lightning::chain::chaininterface::FeeEstimator, mut chain_monitor: crate::lightning::chain::Watch, mut tx_broadcaster: crate::lightning::chain::chaininterface::BroadcasterInterface, mut router: crate::lightning::routing::router::Router, mut logger: crate::lightning::util::logger::Logger, mut entropy_source: crate::lightning::sign::EntropySource, mut node_signer: crate::lightning::sign::NodeSigner, mut signer_provider: crate::lightning::sign::SignerProvider, mut config: crate::lightning::util::config::UserConfig, mut params: crate::lightning::ln::channelmanager::ChainParameters, mut current_timestamp: u32) -> crate::lightning::ln::channelmanager::ChannelManager {
+ let mut ret = lightning::ln::channelmanager::ChannelManager::new(fee_est, chain_monitor, tx_broadcaster, router, logger, entropy_source, node_signer, signer_provider, *unsafe { Box::from_raw(config.take_inner()) }, *unsafe { Box::from_raw(params.take_inner()) }, current_timestamp);
+ crate::lightning::ln::channelmanager::ChannelManager { inner: ObjOps::heap_alloc(ret), is_owned: true }
+}
+
+/// Gets the current configuration applied to all new channels.
+#[must_use]
+#[no_mangle]
+pub extern "C" fn ChannelManager_get_current_default_configuration(this_arg: &crate::lightning::ln::channelmanager::ChannelManager) -> crate::lightning::util::config::UserConfig {
+ let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.get_current_default_configuration();
+ crate::lightning::util::config::UserConfig { inner: unsafe { ObjOps::nonnull_ptr_to_inner((ret as *const lightning::util::config::UserConfig<>) as *mut _) }, is_owned: false }
+}
+
+/// Creates a new outbound channel to the given remote node and with the given value.
+///
+/// `user_channel_id` will be provided back as in
+/// [`Event::FundingGenerationReady::user_channel_id`] to allow tracking of which events
+/// correspond with which `create_channel` call. Note that the `user_channel_id` defaults to a
+/// randomized value for inbound channels. `user_channel_id` has no meaning inside of LDK, it
+/// is simply copied to events and otherwise ignored.
+///
+/// Raises [`APIError::APIMisuseError`] when `channel_value_satoshis` > 2**24 or `push_msat` is
+/// greater than `channel_value_satoshis * 1k` or `channel_value_satoshis < 1000`.
+///
+/// Raises [`APIError::ChannelUnavailable`] if the channel cannot be opened due to failing to
+/// generate a shutdown scriptpubkey or destination script set by
+/// [`SignerProvider::get_shutdown_scriptpubkey`] or [`SignerProvider::get_destination_script`].
+///
+/// Note that we do not check if you are currently connected to the given peer. If no
+/// connection is available, the outbound `open_channel` message may fail to send, resulting in
+/// the channel eventually being silently forgotten (dropped on reload).
+///
+/// Returns the new Channel's temporary `channel_id`. This ID will appear as
+/// [`Event::FundingGenerationReady::temporary_channel_id`] and in
+/// [`ChannelDetails::channel_id`] until after
+/// [`ChannelManager::funding_transaction_generated`] is called, swapping the Channel's ID for
+/// one derived from the funding transaction's TXID. If the counterparty rejects the channel
+/// immediately, this temporary ID will appear in [`Event::ChannelClosed::channel_id`].
+///
+/// [`Event::FundingGenerationReady::user_channel_id`]: events::Event::FundingGenerationReady::user_channel_id
+/// [`Event::FundingGenerationReady::temporary_channel_id`]: events::Event::FundingGenerationReady::temporary_channel_id
+/// [`Event::ChannelClosed::channel_id`]: events::Event::ChannelClosed::channel_id
+///
+/// Note that override_config (or a relevant inner pointer) may be NULL or all-0s to represent None
+#[must_use]
+#[no_mangle]
+pub extern "C" fn ChannelManager_create_channel(this_arg: &crate::lightning::ln::channelmanager::ChannelManager, mut their_network_key: crate::c_types::PublicKey, mut channel_value_satoshis: u64, mut push_msat: u64, mut user_channel_id: crate::c_types::U128, mut override_config: crate::lightning::util::config::UserConfig) -> crate::c_types::derived::CResult_ThirtyTwoBytesAPIErrorZ {
+ let mut local_override_config = if override_config.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(override_config.take_inner()) } }) };
+ let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.create_channel(their_network_key.into_rust(), channel_value_satoshis, push_msat, user_channel_id.into(), local_override_config);
+ let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::c_types::ThirtyTwoBytes { data: o.0 } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::util::errors::APIError::native_into(e) }).into() };
+ local_ret
+}
+
+/// Gets the list of open channels, in random order. See [`ChannelDetails`] field documentation for
+/// more information.
+#[must_use]
+#[no_mangle]
+pub extern "C" fn ChannelManager_list_channels(this_arg: &crate::lightning::ln::channelmanager::ChannelManager) -> crate::c_types::derived::CVec_ChannelDetailsZ {
+ let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.list_channels();
+ let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { crate::lightning::ln::channelmanager::ChannelDetails { inner: ObjOps::heap_alloc(item), is_owned: true } }); };
+ local_ret.into()
+}
+
+/// Gets the list of usable channels, in random order. Useful as an argument to
+/// [`Router::find_route`] to ensure non-announced channels are used.
+///
+/// These are guaranteed to have their [`ChannelDetails::is_usable`] value set to true, see the
+/// documentation for [`ChannelDetails::is_usable`] for more info on exactly what the criteria
+/// are.
+#[must_use]
+#[no_mangle]
+pub extern "C" fn ChannelManager_list_usable_channels(this_arg: &crate::lightning::ln::channelmanager::ChannelManager) -> crate::c_types::derived::CVec_ChannelDetailsZ {
+ let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.list_usable_channels();
+ let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { crate::lightning::ln::channelmanager::ChannelDetails { inner: ObjOps::heap_alloc(item), is_owned: true } }); };
+ local_ret.into()
+}
+
+/// Gets the list of channels we have with a given counterparty, in random order.
+#[must_use]
+#[no_mangle]
+pub extern "C" fn ChannelManager_list_channels_with_counterparty(this_arg: &crate::lightning::ln::channelmanager::ChannelManager, mut counterparty_node_id: crate::c_types::PublicKey) -> crate::c_types::derived::CVec_ChannelDetailsZ {
+ let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.list_channels_with_counterparty(&counterparty_node_id.into_rust());
+ let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { crate::lightning::ln::channelmanager::ChannelDetails { inner: ObjOps::heap_alloc(item), is_owned: true } }); };
+ local_ret.into()
+}
+
+/// Returns in an undefined order recent payments that -- if not fulfilled -- have yet to find a
+/// successful path, or have unresolved HTLCs.
+///
+/// This can be useful for payments that may have been prepared, but ultimately not sent, as a
+/// result of a crash. If such a payment exists, is not listed here, and an
+/// [`Event::PaymentSent`] has not been received, you may consider resending the payment.
+///
+/// [`Event::PaymentSent`]: events::Event::PaymentSent
+#[must_use]
+#[no_mangle]
+pub extern "C" fn ChannelManager_list_recent_payments(this_arg: &crate::lightning::ln::channelmanager::ChannelManager) -> crate::c_types::derived::CVec_RecentPaymentDetailsZ {
+ let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.list_recent_payments();
+ let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { crate::lightning::ln::channelmanager::RecentPaymentDetails::native_into(item) }); };
+ local_ret.into()
+}
+
+/// Begins the process of closing a channel. After this call (plus some timeout), no new HTLCs
+/// will be accepted on the given channel, and after additional timeout/the closing of all
+/// pending HTLCs, the channel will be closed on chain.
+///
+/// * If we are the channel initiator, we will pay between our [`ChannelCloseMinimum`] and
+/// [`ChannelConfig::force_close_avoidance_max_fee_satoshis`] plus our [`NonAnchorChannelFee`]
+/// fee estimate.
+/// * If our counterparty is the channel initiator, we will require a channel closing
+/// transaction feerate of at least our [`ChannelCloseMinimum`] feerate or the feerate which
+/// would appear on a force-closure transaction, whichever is lower. We will allow our
+/// counterparty to pay as much fee as they'd like, however.
+///
+/// May generate a [`SendShutdown`] message event on success, which should be relayed.
+///
+/// Raises [`APIError::ChannelUnavailable`] if the channel cannot be closed due to failing to
+/// generate a shutdown scriptpubkey or destination script set by
+/// [`SignerProvider::get_shutdown_scriptpubkey`]. A force-closure may be needed to close the
+/// channel.
+///
+/// [`ChannelConfig::force_close_avoidance_max_fee_satoshis`]: crate::util::config::ChannelConfig::force_close_avoidance_max_fee_satoshis
+/// [`ChannelCloseMinimum`]: crate::chain::chaininterface::ConfirmationTarget::ChannelCloseMinimum
+/// [`NonAnchorChannelFee`]: crate::chain::chaininterface::ConfirmationTarget::NonAnchorChannelFee
+/// [`SendShutdown`]: crate::events::MessageSendEvent::SendShutdown
+#[must_use]
+#[no_mangle]
+pub extern "C" fn ChannelManager_close_channel(this_arg: &crate::lightning::ln::channelmanager::ChannelManager, channel_id: *const [u8; 32], mut counterparty_node_id: crate::c_types::PublicKey) -> crate::c_types::derived::CResult_NoneAPIErrorZ {
+ let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.close_channel(&::lightning::ln::ChannelId(unsafe { *channel_id }), &counterparty_node_id.into_rust());
+ 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::util::errors::APIError::native_into(e) }).into() };
+ local_ret
+}
+
+/// Begins the process of closing a channel. After this call (plus some timeout), no new HTLCs
+/// will be accepted on the given channel, and after additional timeout/the closing of all
+/// pending HTLCs, the channel will be closed on chain.
+///
+/// `target_feerate_sat_per_1000_weight` has different meanings depending on if we initiated
+/// the channel being closed or not:
+/// * If we are the channel initiator, we will pay at least this feerate on the closing
+/// transaction. The upper-bound is set by
+/// [`ChannelConfig::force_close_avoidance_max_fee_satoshis`] plus our [`NonAnchorChannelFee`]
+/// fee estimate (or `target_feerate_sat_per_1000_weight`, if it is greater).
+/// * If our counterparty is the channel initiator, we will refuse to accept a channel closure
+/// transaction feerate below `target_feerate_sat_per_1000_weight` (or the feerate which
+/// will appear on a force-closure transaction, whichever is lower).
+///
+/// The `shutdown_script` provided will be used as the `scriptPubKey` for the closing transaction.
+/// Will fail if a shutdown script has already been set for this channel by
+/// ['ChannelHandshakeConfig::commit_upfront_shutdown_pubkey`]. The given shutdown script must
+/// also be compatible with our and the counterparty's features.
+///
+/// May generate a [`SendShutdown`] message event on success, which should be relayed.
+///
+/// Raises [`APIError::ChannelUnavailable`] if the channel cannot be closed due to failing to
+/// generate a shutdown scriptpubkey or destination script set by
+/// [`SignerProvider::get_shutdown_scriptpubkey`]. A force-closure may be needed to close the
+/// channel.
+///
+/// [`ChannelConfig::force_close_avoidance_max_fee_satoshis`]: crate::util::config::ChannelConfig::force_close_avoidance_max_fee_satoshis
+/// [`NonAnchorChannelFee`]: crate::chain::chaininterface::ConfirmationTarget::NonAnchorChannelFee
+/// [`SendShutdown`]: crate::events::MessageSendEvent::SendShutdown
+///
+/// Note that shutdown_script (or a relevant inner pointer) may be NULL or all-0s to represent None
+#[must_use]
+#[no_mangle]
+pub extern "C" fn ChannelManager_close_channel_with_feerate_and_script(this_arg: &crate::lightning::ln::channelmanager::ChannelManager, channel_id: *const [u8; 32], mut counterparty_node_id: crate::c_types::PublicKey, mut target_feerate_sats_per_1000_weight: crate::c_types::derived::COption_u32Z, mut shutdown_script: crate::lightning::ln::script::ShutdownScript) -> crate::c_types::derived::CResult_NoneAPIErrorZ {
+ let mut local_target_feerate_sats_per_1000_weight = if target_feerate_sats_per_1000_weight.is_some() { Some( { target_feerate_sats_per_1000_weight.take() }) } else { None };
+ let mut local_shutdown_script = if shutdown_script.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(shutdown_script.take_inner()) } }) };
+ let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.close_channel_with_feerate_and_script(&::lightning::ln::ChannelId(unsafe { *channel_id }), &counterparty_node_id.into_rust(), local_target_feerate_sats_per_1000_weight, local_shutdown_script);
+ 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::util::errors::APIError::native_into(e) }).into() };
+ local_ret
+}
+
+/// Force closes a channel, immediately broadcasting the latest local transaction(s) and
+/// rejecting new HTLCs on the given channel. Fails if `channel_id` is unknown to
+/// the manager, or if the `counterparty_node_id` isn't the counterparty of the corresponding
+/// channel.
+#[must_use]
+#[no_mangle]
+pub extern "C" fn ChannelManager_force_close_broadcasting_latest_txn(this_arg: &crate::lightning::ln::channelmanager::ChannelManager, channel_id: *const [u8; 32], mut counterparty_node_id: crate::c_types::PublicKey) -> crate::c_types::derived::CResult_NoneAPIErrorZ {
+ let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.force_close_broadcasting_latest_txn(&::lightning::ln::ChannelId(unsafe { *channel_id }), &counterparty_node_id.into_rust());
+ 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::util::errors::APIError::native_into(e) }).into() };
+ local_ret
+}
+
+/// Force closes a channel, rejecting new HTLCs on the given channel but skips broadcasting
+/// the latest local transaction(s). Fails if `channel_id` is unknown to the manager, or if the
+/// `counterparty_node_id` isn't the counterparty of the corresponding channel.
+///
+/// You can always get the latest local transaction(s) to broadcast from
+/// [`ChannelMonitor::get_latest_holder_commitment_txn`].
+#[must_use]
+#[no_mangle]
+pub extern "C" fn ChannelManager_force_close_without_broadcasting_txn(this_arg: &crate::lightning::ln::channelmanager::ChannelManager, channel_id: *const [u8; 32], mut counterparty_node_id: crate::c_types::PublicKey) -> crate::c_types::derived::CResult_NoneAPIErrorZ {
+ let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.force_close_without_broadcasting_txn(&::lightning::ln::ChannelId(unsafe { *channel_id }), &counterparty_node_id.into_rust());
+ 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::util::errors::APIError::native_into(e) }).into() };
+ local_ret
+}
+
+/// Force close all channels, immediately broadcasting the latest local commitment transaction
+/// for each to the chain and rejecting new HTLCs on each.
+#[no_mangle]
+pub extern "C" fn ChannelManager_force_close_all_channels_broadcasting_latest_txn(this_arg: &crate::lightning::ln::channelmanager::ChannelManager) {
+ unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.force_close_all_channels_broadcasting_latest_txn()
+}
+
+/// Force close all channels rejecting new HTLCs on each but without broadcasting the latest
+/// local transaction(s).
+#[no_mangle]
+pub extern "C" fn ChannelManager_force_close_all_channels_without_broadcasting_txn(this_arg: &crate::lightning::ln::channelmanager::ChannelManager) {
+ unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.force_close_all_channels_without_broadcasting_txn()
+}
+
+/// Sends a payment along a given route.
+///
+/// Value parameters are provided via the last hop in route, see documentation for [`RouteHop`]
+/// fields for more info.
+///
+/// May generate [`UpdateHTLCs`] message(s) event on success, which should be relayed (e.g. via
+/// [`PeerManager::process_events`]).
+///
+/// # Avoiding Duplicate Payments
+///
+/// If a pending payment is currently in-flight with the same [`PaymentId`] provided, this
+/// method will error with an [`APIError::InvalidRoute`]. Note, however, that once a payment
+/// is no longer pending (either via [`ChannelManager::abandon_payment`], or handling of an
+/// [`Event::PaymentSent`] or [`Event::PaymentFailed`]) LDK will not stop you from sending a
+/// second payment with the same [`PaymentId`].
+///
+/// Thus, in order to ensure duplicate payments are not sent, you should implement your own
+/// tracking of payments, including state to indicate once a payment has completed. Because you
+/// should also ensure that [`PaymentHash`]es are not re-used, for simplicity, you should
+/// consider using the [`PaymentHash`] as the key for tracking payments. In that case, the
+/// [`PaymentId`] should be a copy of the [`PaymentHash`] bytes.
+///
+/// Additionally, in the scenario where we begin the process of sending a payment, but crash
+/// before `send_payment` returns (or prior to [`ChannelMonitorUpdate`] persistence if you're
+/// using [`ChannelMonitorUpdateStatus::InProgress`]), the payment may be lost on restart. See
+/// [`ChannelManager::list_recent_payments`] for more information.
+///
+/// # Possible Error States on [`PaymentSendFailure`]
+///
+/// Each path may have a different return value, and [`PaymentSendFailure`] may return a `Vec` with
+/// each entry matching the corresponding-index entry in the route paths, see
+/// [`PaymentSendFailure`] for more info.
+///
+/// In general, a path may raise:
+/// * [`APIError::InvalidRoute`] when an invalid route or forwarding parameter (cltv_delta, fee,
+/// node public key) is specified.
+/// * [`APIError::ChannelUnavailable`] if the next-hop channel is not available as it has been
+/// closed, doesn't exist, or the peer is currently disconnected.
+/// * [`APIError::MonitorUpdateInProgress`] if a new monitor update failure prevented sending the
+/// relevant updates.
+///
+/// Note that depending on the type of the [`PaymentSendFailure`] the HTLC may have been
+/// irrevocably committed to on our end. In such a case, do NOT retry the payment with a
+/// different route unless you intend to pay twice!
+///
+/// [`RouteHop`]: crate::routing::router::RouteHop
+/// [`Event::PaymentSent`]: events::Event::PaymentSent
+/// [`Event::PaymentFailed`]: events::Event::PaymentFailed
+/// [`UpdateHTLCs`]: events::MessageSendEvent::UpdateHTLCs
+/// [`PeerManager::process_events`]: crate::ln::peer_handler::PeerManager::process_events
+/// [`ChannelMonitorUpdateStatus::InProgress`]: crate::chain::ChannelMonitorUpdateStatus::InProgress
+#[must_use]
+#[no_mangle]
+pub extern "C" fn ChannelManager_send_payment_with_route(this_arg: &crate::lightning::ln::channelmanager::ChannelManager, route: &crate::lightning::routing::router::Route, mut payment_hash: crate::c_types::ThirtyTwoBytes, mut recipient_onion: crate::lightning::ln::outbound_payment::RecipientOnionFields, mut payment_id: crate::c_types::ThirtyTwoBytes) -> crate::c_types::derived::CResult_NonePaymentSendFailureZ {
+ let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.send_payment_with_route(route.get_native_ref(), ::lightning::ln::PaymentHash(payment_hash.data), *unsafe { Box::from_raw(recipient_onion.take_inner()) }, ::lightning::ln::channelmanager::PaymentId(payment_id.data));
+ 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::ln::outbound_payment::PaymentSendFailure::native_into(e) }).into() };
+ local_ret
+}
+
+/// Similar to [`ChannelManager::send_payment_with_route`], but will automatically find a route based on
+/// `route_params` and retry failed payment paths based on `retry_strategy`.
+#[must_use]
+#[no_mangle]
+pub extern "C" fn ChannelManager_send_payment(this_arg: &crate::lightning::ln::channelmanager::ChannelManager, mut payment_hash: crate::c_types::ThirtyTwoBytes, mut recipient_onion: crate::lightning::ln::outbound_payment::RecipientOnionFields, mut payment_id: crate::c_types::ThirtyTwoBytes, mut route_params: crate::lightning::routing::router::RouteParameters, mut retry_strategy: crate::lightning::ln::outbound_payment::Retry) -> crate::c_types::derived::CResult_NoneRetryableSendFailureZ {
+ let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.send_payment(::lightning::ln::PaymentHash(payment_hash.data), *unsafe { Box::from_raw(recipient_onion.take_inner()) }, ::lightning::ln::channelmanager::PaymentId(payment_id.data), *unsafe { Box::from_raw(route_params.take_inner()) }, retry_strategy.into_native());
+ 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::ln::outbound_payment::RetryableSendFailure::native_into(e) }).into() };
+ local_ret
+}
+
+/// Signals that no further attempts for the given payment should occur. Useful if you have a
+/// pending outbound payment with retries remaining, but wish to stop retrying the payment before
+/// retries are exhausted.
+///
+/// # Event Generation
+///
+/// If no [`Event::PaymentFailed`] event had been generated before, one will be generated as soon
+/// as there are no remaining pending HTLCs for this payment.
+///
+/// Note that calling this method does *not* prevent a payment from succeeding. You must still
+/// wait until you receive either a [`Event::PaymentFailed`] or [`Event::PaymentSent`] event to
+/// determine the ultimate status of a payment.
+///
+/// # Requested Invoices
+///
+/// In the case of paying a [`Bolt12Invoice`] via [`ChannelManager::pay_for_offer`], abandoning
+/// the payment prior to receiving the invoice will result in an [`Event::InvoiceRequestFailed`]
+/// and prevent any attempts at paying it once received. The other events may only be generated
+/// once the invoice has been received.
+///
+/// # Restart Behavior
+///
+/// If an [`Event::PaymentFailed`] is generated and we restart without first persisting the
+/// [`ChannelManager`], another [`Event::PaymentFailed`] may be generated; likewise for
+/// [`Event::InvoiceRequestFailed`].
+///
+/// [`Bolt12Invoice`]: crate::offers::invoice::Bolt12Invoice
+#[no_mangle]
+pub extern "C" fn ChannelManager_abandon_payment(this_arg: &crate::lightning::ln::channelmanager::ChannelManager, mut payment_id: crate::c_types::ThirtyTwoBytes) {
+ unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.abandon_payment(::lightning::ln::channelmanager::PaymentId(payment_id.data))
+}
+
+/// Send a spontaneous payment, which is a payment that does not require the recipient to have
+/// generated an invoice. Optionally, you may specify the preimage. If you do choose to specify
+/// the preimage, it must be a cryptographically secure random value that no intermediate node
+/// would be able to guess -- otherwise, an intermediate node may claim the payment and it will
+/// never reach the recipient.
+///
+/// See [`send_payment`] documentation for more details on the return value of this function
+/// and idempotency guarantees provided by the [`PaymentId`] key.
+///
+/// Similar to regular payments, you MUST NOT reuse a `payment_preimage` value. See
+/// [`send_payment`] for more information about the risks of duplicate preimage usage.
+///
+/// [`send_payment`]: Self::send_payment
+#[must_use]
+#[no_mangle]
+pub extern "C" fn ChannelManager_send_spontaneous_payment(this_arg: &crate::lightning::ln::channelmanager::ChannelManager, route: &crate::lightning::routing::router::Route, mut payment_preimage: crate::c_types::derived::COption_ThirtyTwoBytesZ, mut recipient_onion: crate::lightning::ln::outbound_payment::RecipientOnionFields, mut payment_id: crate::c_types::ThirtyTwoBytes) -> crate::c_types::derived::CResult_ThirtyTwoBytesPaymentSendFailureZ {
+ let mut local_payment_preimage = { /*payment_preimage*/ let payment_preimage_opt = payment_preimage; if payment_preimage_opt.is_none() { None } else { Some({ { ::lightning::ln::PaymentPreimage({ payment_preimage_opt.take() }.data) }})} };
+ let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.send_spontaneous_payment(route.get_native_ref(), local_payment_preimage, *unsafe { Box::from_raw(recipient_onion.take_inner()) }, ::lightning::ln::channelmanager::PaymentId(payment_id.data));
+ let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::c_types::ThirtyTwoBytes { data: o.0 } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::outbound_payment::PaymentSendFailure::native_into(e) }).into() };
+ local_ret
+}
+
+/// Similar to [`ChannelManager::send_spontaneous_payment`], but will automatically find a route
+/// based on `route_params` and retry failed payment paths based on `retry_strategy`.
+///
+/// See [`PaymentParameters::for_keysend`] for help in constructing `route_params` for spontaneous
+/// payments.
+///
+/// [`PaymentParameters::for_keysend`]: crate::routing::router::PaymentParameters::for_keysend
+#[must_use]
+#[no_mangle]
+pub extern "C" fn ChannelManager_send_spontaneous_payment_with_retry(this_arg: &crate::lightning::ln::channelmanager::ChannelManager, mut payment_preimage: crate::c_types::derived::COption_ThirtyTwoBytesZ, mut recipient_onion: crate::lightning::ln::outbound_payment::RecipientOnionFields, mut payment_id: crate::c_types::ThirtyTwoBytes, mut route_params: crate::lightning::routing::router::RouteParameters, mut retry_strategy: crate::lightning::ln::outbound_payment::Retry) -> crate::c_types::derived::CResult_ThirtyTwoBytesRetryableSendFailureZ {
+ let mut local_payment_preimage = { /*payment_preimage*/ let payment_preimage_opt = payment_preimage; if payment_preimage_opt.is_none() { None } else { Some({ { ::lightning::ln::PaymentPreimage({ payment_preimage_opt.take() }.data) }})} };
+ let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.send_spontaneous_payment_with_retry(local_payment_preimage, *unsafe { Box::from_raw(recipient_onion.take_inner()) }, ::lightning::ln::channelmanager::PaymentId(payment_id.data), *unsafe { Box::from_raw(route_params.take_inner()) }, retry_strategy.into_native());
+ let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::c_types::ThirtyTwoBytes { data: o.0 } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::outbound_payment::RetryableSendFailure::native_into(e) }).into() };
+ local_ret
+}
+
+/// Send a payment that is probing the given route for liquidity. We calculate the
+/// [`PaymentHash`] of probes based on a static secret and a random [`PaymentId`], which allows
+/// us to easily discern them from real payments.
+#[must_use]
+#[no_mangle]
+pub extern "C" fn ChannelManager_send_probe(this_arg: &crate::lightning::ln::channelmanager::ChannelManager, mut path: crate::lightning::routing::router::Path) -> crate::c_types::derived::CResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZPaymentSendFailureZ {
+ let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.send_probe(*unsafe { Box::from_raw(path.take_inner()) });
+ let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { let (mut orig_ret_0_0, mut orig_ret_0_1) = o; let mut local_ret_0 = (crate::c_types::ThirtyTwoBytes { data: orig_ret_0_0.0 }, crate::c_types::ThirtyTwoBytes { data: orig_ret_0_1.0 }).into(); local_ret_0 }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::outbound_payment::PaymentSendFailure::native_into(e) }).into() };
+ local_ret
+}
+
+/// Sends payment probes over all paths of a route that would be used to pay the given
+/// amount to the given `node_id`.
+///
+/// See [`ChannelManager::send_preflight_probes`] for more information.
+#[must_use]
+#[no_mangle]
+pub extern "C" fn ChannelManager_send_spontaneous_preflight_probes(this_arg: &crate::lightning::ln::channelmanager::ChannelManager, mut node_id: crate::c_types::PublicKey, mut amount_msat: u64, mut final_cltv_expiry_delta: u32, mut liquidity_limit_multiplier: crate::c_types::derived::COption_u64Z) -> crate::c_types::derived::CResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbeSendFailureZ {
+ let mut local_liquidity_limit_multiplier = if liquidity_limit_multiplier.is_some() { Some( { liquidity_limit_multiplier.take() }) } else { None };
+ let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.send_spontaneous_preflight_probes(node_id.into_rust(), amount_msat, final_cltv_expiry_delta, local_liquidity_limit_multiplier);
+ let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { let mut local_ret_0 = Vec::new(); for mut item in o.drain(..) { local_ret_0.push( { let (mut orig_ret_0_0_0, mut orig_ret_0_0_1) = item; let mut local_ret_0_0 = (crate::c_types::ThirtyTwoBytes { data: orig_ret_0_0_0.0 }, crate::c_types::ThirtyTwoBytes { data: orig_ret_0_0_1.0 }).into(); local_ret_0_0 }); }; local_ret_0.into() }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::outbound_payment::ProbeSendFailure::native_into(e) }).into() };
+ local_ret
+}
+
+/// Sends payment probes over all paths of a route that would be used to pay a route found
+/// according to the given [`RouteParameters`].
+///
+/// This may be used to send \"pre-flight\" probes, i.e., to train our scorer before conducting
+/// the actual payment. Note this is only useful if there likely is sufficient time for the
+/// probe to settle before sending out the actual payment, e.g., when waiting for user
+/// confirmation in a wallet UI.
+///
+/// Otherwise, there is a chance the probe could take up some liquidity needed to complete the
+/// actual payment. Users should therefore be cautious and might avoid sending probes if
+/// liquidity is scarce and/or they don't expect the probe to return before they send the
+/// payment. To mitigate this issue, channels with available liquidity less than the required
+/// amount times the given `liquidity_limit_multiplier` won't be used to send pre-flight
+/// probes. If `None` is given as `liquidity_limit_multiplier`, it defaults to `3`.
+#[must_use]
+#[no_mangle]
+pub extern "C" fn ChannelManager_send_preflight_probes(this_arg: &crate::lightning::ln::channelmanager::ChannelManager, mut route_params: crate::lightning::routing::router::RouteParameters, mut liquidity_limit_multiplier: crate::c_types::derived::COption_u64Z) -> crate::c_types::derived::CResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbeSendFailureZ {
+ let mut local_liquidity_limit_multiplier = if liquidity_limit_multiplier.is_some() { Some( { liquidity_limit_multiplier.take() }) } else { None };
+ let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.send_preflight_probes(*unsafe { Box::from_raw(route_params.take_inner()) }, local_liquidity_limit_multiplier);
+ let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { let mut local_ret_0 = Vec::new(); for mut item in o.drain(..) { local_ret_0.push( { let (mut orig_ret_0_0_0, mut orig_ret_0_0_1) = item; let mut local_ret_0_0 = (crate::c_types::ThirtyTwoBytes { data: orig_ret_0_0_0.0 }, crate::c_types::ThirtyTwoBytes { data: orig_ret_0_0_1.0 }).into(); local_ret_0_0 }); }; local_ret_0.into() }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::outbound_payment::ProbeSendFailure::native_into(e) }).into() };
+ local_ret
+}
+
+/// Call this upon creation of a funding transaction for the given channel.
+///
+/// Returns an [`APIError::APIMisuseError`] if the funding_transaction spent non-SegWit outputs
+/// or if no output was found which matches the parameters in [`Event::FundingGenerationReady`].
+///
+/// Returns [`APIError::APIMisuseError`] if the funding transaction is not final for propagation
+/// across the p2p network.
+///
+/// Returns [`APIError::ChannelUnavailable`] if a funding transaction has already been provided
+/// for the channel or if the channel has been closed as indicated by [`Event::ChannelClosed`].
+///
+/// May panic if the output found in the funding transaction is duplicative with some other
+/// channel (note that this should be trivially prevented by using unique funding transaction
+/// keys per-channel).
+///
+/// Do NOT broadcast the funding transaction yourself. When we have safely received our
+/// counterparty's signature the funding transaction will automatically be broadcast via the
+/// [`BroadcasterInterface`] provided when this `ChannelManager` was constructed.
+///
+/// Note that this includes RBF or similar transaction replacement strategies - lightning does
+/// not currently support replacing a funding transaction on an existing channel. Instead,
+/// create a new channel with a conflicting funding transaction.
+///
+/// Note to keep the miner incentives aligned in moving the blockchain forward, we recommend
+/// the wallet software generating the funding transaction to apply anti-fee sniping as
+/// implemented by Bitcoin Core wallet. See <https://bitcoinops.org/en/topics/fee-sniping/>
+/// for more details.
+///
+/// [`Event::FundingGenerationReady`]: crate::events::Event::FundingGenerationReady
+/// [`Event::ChannelClosed`]: crate::events::Event::ChannelClosed
+#[must_use]
+#[no_mangle]
+pub extern "C" fn ChannelManager_funding_transaction_generated(this_arg: &crate::lightning::ln::channelmanager::ChannelManager, temporary_channel_id: *const [u8; 32], mut counterparty_node_id: crate::c_types::PublicKey, mut funding_transaction: crate::c_types::Transaction) -> crate::c_types::derived::CResult_NoneAPIErrorZ {
+ let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.funding_transaction_generated(&::lightning::ln::ChannelId(unsafe { *temporary_channel_id }), &counterparty_node_id.into_rust(), funding_transaction.into_bitcoin());
+ 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::util::errors::APIError::native_into(e) }).into() };
+ local_ret
+}
+
+/// Call this upon creation of a batch funding transaction for the given channels.
+///
+/// Return values are identical to [`Self::funding_transaction_generated`], respective to
+/// each individual channel and transaction output.
+///
+/// Do NOT broadcast the funding transaction yourself. This batch funding transcaction
+/// will only be broadcast when we have safely received and persisted the counterparty's
+/// signature for each channel.
+///
+/// If there is an error, all channels in the batch are to be considered closed.
+#[must_use]
+#[no_mangle]
+pub extern "C" fn ChannelManager_batch_funding_transaction_generated(this_arg: &crate::lightning::ln::channelmanager::ChannelManager, mut temporary_channels: crate::c_types::derived::CVec_C2Tuple_ThirtyTwoBytesPublicKeyZZ, mut funding_transaction: crate::c_types::Transaction) -> crate::c_types::derived::CResult_NoneAPIErrorZ {
+ let mut local_temporary_channels = Vec::new(); for mut item in temporary_channels.into_rust().drain(..) { local_temporary_channels.push( { let (mut orig_temporary_channels_0_0, mut orig_temporary_channels_0_1) = item.to_rust(); let mut local_temporary_channels_0 = (::lightning::ln::ChannelId(orig_temporary_channels_0_0.data), orig_temporary_channels_0_1.into_rust()); local_temporary_channels_0 }); };
+ let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.batch_funding_transaction_generated(&local_temporary_channels.iter().map(|(a, b)| (a, b)).collect::<Vec<_>>()[..], funding_transaction.into_bitcoin());
+ 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::util::errors::APIError::native_into(e) }).into() };
+ local_ret
+}
+
+/// Atomically applies partial updates to the [`ChannelConfig`] of the given channels.
+///
+/// Once the updates are applied, each eligible channel (advertised with a known short channel
+/// ID and a change in [`forwarding_fee_proportional_millionths`], [`forwarding_fee_base_msat`],
+/// or [`cltv_expiry_delta`]) has a [`BroadcastChannelUpdate`] event message generated
+/// containing the new [`ChannelUpdate`] message which should be broadcast to the network.
+///
+/// Returns [`ChannelUnavailable`] when a channel is not found or an incorrect
+/// `counterparty_node_id` is provided.
+///
+/// Returns [`APIMisuseError`] when a [`cltv_expiry_delta`] update is to be applied with a value
+/// below [`MIN_CLTV_EXPIRY_DELTA`].
+///
+/// If an error is returned, none of the updates should be considered applied.
+///
+/// [`forwarding_fee_proportional_millionths`]: ChannelConfig::forwarding_fee_proportional_millionths
+/// [`forwarding_fee_base_msat`]: ChannelConfig::forwarding_fee_base_msat
+/// [`cltv_expiry_delta`]: ChannelConfig::cltv_expiry_delta
+/// [`BroadcastChannelUpdate`]: events::MessageSendEvent::BroadcastChannelUpdate
+/// [`ChannelUpdate`]: msgs::ChannelUpdate
+/// [`ChannelUnavailable`]: APIError::ChannelUnavailable
+/// [`APIMisuseError`]: APIError::APIMisuseError
+#[must_use]
+#[no_mangle]
+pub extern "C" fn ChannelManager_update_partial_channel_config(this_arg: &crate::lightning::ln::channelmanager::ChannelManager, mut counterparty_node_id: crate::c_types::PublicKey, mut channel_ids: crate::c_types::derived::CVec_ThirtyTwoBytesZ, config_update: &crate::lightning::util::config::ChannelConfigUpdate) -> crate::c_types::derived::CResult_NoneAPIErrorZ {
+ let mut local_channel_ids = Vec::new(); for mut item in channel_ids.into_rust().drain(..) { local_channel_ids.push( { ::lightning::ln::ChannelId(item.data) }); };
+ let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.update_partial_channel_config(&counterparty_node_id.into_rust(), local_channel_ids, config_update.get_native_ref());
+ 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::util::errors::APIError::native_into(e) }).into() };
+ local_ret
+}
+
+/// Atomically updates the [`ChannelConfig`] for the given channels.
+///
+/// Once the updates are applied, each eligible channel (advertised with a known short channel
+/// ID and a change in [`forwarding_fee_proportional_millionths`], [`forwarding_fee_base_msat`],
+/// or [`cltv_expiry_delta`]) has a [`BroadcastChannelUpdate`] event message generated
+/// containing the new [`ChannelUpdate`] message which should be broadcast to the network.
+///
+/// Returns [`ChannelUnavailable`] when a channel is not found or an incorrect
+/// `counterparty_node_id` is provided.
+///
+/// Returns [`APIMisuseError`] when a [`cltv_expiry_delta`] update is to be applied with a value
+/// below [`MIN_CLTV_EXPIRY_DELTA`].
+///
+/// If an error is returned, none of the updates should be considered applied.
+///
+/// [`forwarding_fee_proportional_millionths`]: ChannelConfig::forwarding_fee_proportional_millionths
+/// [`forwarding_fee_base_msat`]: ChannelConfig::forwarding_fee_base_msat
+/// [`cltv_expiry_delta`]: ChannelConfig::cltv_expiry_delta
+/// [`BroadcastChannelUpdate`]: events::MessageSendEvent::BroadcastChannelUpdate
+/// [`ChannelUpdate`]: msgs::ChannelUpdate
+/// [`ChannelUnavailable`]: APIError::ChannelUnavailable
+/// [`APIMisuseError`]: APIError::APIMisuseError
+#[must_use]
+#[no_mangle]
+pub extern "C" fn ChannelManager_update_channel_config(this_arg: &crate::lightning::ln::channelmanager::ChannelManager, mut counterparty_node_id: crate::c_types::PublicKey, mut channel_ids: crate::c_types::derived::CVec_ThirtyTwoBytesZ, config: &crate::lightning::util::config::ChannelConfig) -> crate::c_types::derived::CResult_NoneAPIErrorZ {
+ let mut local_channel_ids = Vec::new(); for mut item in channel_ids.into_rust().drain(..) { local_channel_ids.push( { ::lightning::ln::ChannelId(item.data) }); };
+ let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.update_channel_config(&counterparty_node_id.into_rust(), local_channel_ids, config.get_native_ref());
+ 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::util::errors::APIError::native_into(e) }).into() };
+ local_ret
+}
+
+/// Attempts to forward an intercepted HTLC over the provided channel id and with the provided
+/// amount to forward. Should only be called in response to an [`HTLCIntercepted`] event.
+///
+/// Intercepted HTLCs can be useful for Lightning Service Providers (LSPs) to open a just-in-time
+/// channel to a receiving node if the node lacks sufficient inbound liquidity.
+///
+/// To make use of intercepted HTLCs, set [`UserConfig::accept_intercept_htlcs`] and use
+/// [`ChannelManager::get_intercept_scid`] to generate short channel id(s) to put in the
+/// receiver's invoice route hints. These route hints will signal to LDK to generate an
+/// [`HTLCIntercepted`] event when it receives the forwarded HTLC, and this method or
+/// [`ChannelManager::fail_intercepted_htlc`] MUST be called in response to the event.
+///
+/// Note that LDK does not enforce fee requirements in `amt_to_forward_msat`, and will not stop
+/// you from forwarding more than you received. See
+/// [`HTLCIntercepted::expected_outbound_amount_msat`] for more on forwarding a different amount
+/// than expected.
+///
+/// Errors if the event was not handled in time, in which case the HTLC was automatically failed
+/// backwards.
+///
+/// [`UserConfig::accept_intercept_htlcs`]: crate::util::config::UserConfig::accept_intercept_htlcs
+/// [`HTLCIntercepted`]: events::Event::HTLCIntercepted
+/// [`HTLCIntercepted::expected_outbound_amount_msat`]: events::Event::HTLCIntercepted::expected_outbound_amount_msat
+#[must_use]
+#[no_mangle]
+pub extern "C" fn ChannelManager_forward_intercepted_htlc(this_arg: &crate::lightning::ln::channelmanager::ChannelManager, mut intercept_id: crate::c_types::ThirtyTwoBytes, next_hop_channel_id: *const [u8; 32], mut next_node_id: crate::c_types::PublicKey, mut amt_to_forward_msat: u64) -> crate::c_types::derived::CResult_NoneAPIErrorZ {
+ let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.forward_intercepted_htlc(::lightning::ln::channelmanager::InterceptId(intercept_id.data), &::lightning::ln::ChannelId(unsafe { *next_hop_channel_id }), next_node_id.into_rust(), amt_to_forward_msat);
+ 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::util::errors::APIError::native_into(e) }).into() };
+ local_ret
+}
+
+/// Fails the intercepted HTLC indicated by intercept_id. Should only be called in response to
+/// an [`HTLCIntercepted`] event. See [`ChannelManager::forward_intercepted_htlc`].
+///
+/// Errors if the event was not handled in time, in which case the HTLC was automatically failed
+/// backwards.
+///
+/// [`HTLCIntercepted`]: events::Event::HTLCIntercepted
+#[must_use]
+#[no_mangle]
+pub extern "C" fn ChannelManager_fail_intercepted_htlc(this_arg: &crate::lightning::ln::channelmanager::ChannelManager, mut intercept_id: crate::c_types::ThirtyTwoBytes) -> crate::c_types::derived::CResult_NoneAPIErrorZ {
+ let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.fail_intercepted_htlc(::lightning::ln::channelmanager::InterceptId(intercept_id.data));
+ 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::util::errors::APIError::native_into(e) }).into() };
+ local_ret
+}
+
+/// Processes HTLCs which are pending waiting on random forward delay.
+///
+/// Should only really ever be called in response to a PendingHTLCsForwardable event.
+/// Will likely generate further events.