+/// 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 [`Background`] and
+/// [`ChannelConfig::force_close_avoidance_max_fee_satoshis`] plus our [`Normal`] fee
+/// estimate.
+/// * If our counterparty is the channel initiator, we will require a channel closing
+/// transaction feerate of at least our [`Background`] 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
+/// [`Background`]: crate::chain::chaininterface::ConfirmationTarget::Background
+/// [`Normal`]: crate::chain::chaininterface::ConfirmationTarget::Normal
+/// [`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 [`Normal`] 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
+/// [`Background`]: crate::chain::chaininterface::ConfirmationTarget::Background
+/// [`Normal`]: crate::chain::chaininterface::ConfirmationTarget::Normal
+/// [`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.
+///
+/// # Restart Behavior
+///
+/// If an [`Event::PaymentFailed`] is generated and we restart without first persisting the
+/// [`ChannelManager`], another [`Event::PaymentFailed`] may be generated.
+#[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.