/// Read a PaymentPurpose from a byte array, created by PaymentPurpose_write
pub extern "C" fn PaymentPurpose_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_PaymentPurposeDecodeErrorZ {
let res: Result<lightning::util::events::PaymentPurpose, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
- let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::util::events::PaymentPurpose::native_into(o) }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError { inner: ObjOps::heap_alloc(e), is_owned: true } }).into() };
+ let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::util::events::PaymentPurpose::native_into(o) }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() };
local_res
}
/// The reason the channel was closed. See individual variants more details.
/// The peer disconnected prior to funding completing. In this case the spec mandates that we
/// forget the channel entirely - we can attempt again if the peer reconnects.
///
+ /// This includes cases where we restarted prior to funding completion, including prior to the
+ /// initial [`ChannelMonitor`] persistence completing.
+ ///
/// In LDK versions prior to 0.0.107 this could also occur if we were unable to connect to the
/// peer because of mutual incompatibility between us and our channel counterparty.
+ ///
+ /// [`ChannelMonitor`]: crate::chain::channelmonitor::ChannelMonitor
DisconnectedPeer,
- /// Closure generated from `ChannelManager::read` if the ChannelMonitor is newer than
- /// the ChannelManager deserialized.
+ /// Closure generated from `ChannelManager::read` if the [`ChannelMonitor`] is newer than
+ /// the [`ChannelManager`] deserialized.
+ ///
+ /// [`ChannelMonitor`]: crate::chain::channelmonitor::ChannelMonitor
+ /// [`ChannelManager`]: crate::ln::channelmanager::ChannelManager
OutdatedChannelManager,
}
use lightning::util::events::ClosureReason as ClosureReasonImport;
/// Utility method to constructs a new OutdatedChannelManager-variant ClosureReason
pub extern "C" fn ClosureReason_outdated_channel_manager() -> ClosureReason {
ClosureReason::OutdatedChannelManager}
+/// Checks if two ClosureReasons contain equal inner contents.
+/// This ignores pointers and is_owned flags and looks at the values in fields.
+#[no_mangle]
+pub extern "C" fn ClosureReason_eq(a: &ClosureReason, b: &ClosureReason) -> bool {
+ if &a.to_native() == &b.to_native() { true } else { false }
+}
#[no_mangle]
/// Serialize the ClosureReason object into a byte array which can be read by ClosureReason_read
pub extern "C" fn ClosureReason_write(obj: &crate::lightning::util::events::ClosureReason) -> crate::c_types::derived::CVec_u8Z {
/// Read a ClosureReason from a byte array, created by ClosureReason_write
pub extern "C" fn ClosureReason_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_COption_ClosureReasonZDecodeErrorZ {
let res: Result<Option<lightning::util::events::ClosureReason>, lightning::ln::msgs::DecodeError> = crate::c_types::maybe_deserialize_obj(ser);
- let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { let mut local_res_0 = if o.is_none() { crate::c_types::derived::COption_ClosureReasonZ::None } else { crate::c_types::derived::COption_ClosureReasonZ::Some( { crate::lightning::util::events::ClosureReason::native_into(o.unwrap()) }) }; local_res_0 }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError { inner: ObjOps::heap_alloc(e), is_owned: true } }).into() };
+ let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { let mut local_res_0 = if o.is_none() { crate::c_types::derived::COption_ClosureReasonZ::None } else { crate::c_types::derived::COption_ClosureReasonZ::Some( { crate::lightning::util::events::ClosureReason::native_into(o.unwrap()) }) }; local_res_0 }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() };
+ local_res
+}
+/// Intended destination of a failed HTLC as indicated in [`Event::HTLCHandlingFailed`].
+#[derive(Clone)]
+#[must_use]
+#[repr(C)]
+pub enum HTLCDestination {
+ /// We tried forwarding to a channel but failed to do so. An example of such an instance is when
+ /// there is insufficient capacity in our outbound channel.
+ NextHopChannel {
+ /// The `node_id` of the next node. For backwards compatibility, this field is
+ /// marked as optional, versions prior to 0.0.110 may not always be able to provide
+ /// counterparty node information.
+ ///
+ /// Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None
+ node_id: crate::c_types::PublicKey,
+ /// The outgoing `channel_id` between us and the next node.
+ channel_id: crate::c_types::ThirtyTwoBytes,
+ },
+ /// Scenario where we are unsure of the next node to forward the HTLC to.
+ UnknownNextHop {
+ /// Short channel id we are requesting to forward an HTLC to.
+ requested_forward_scid: u64,
+ },
+ /// Failure scenario where an HTLC may have been forwarded to be intended for us,
+ /// but is invalid for some reason, so we reject it.
+ ///
+ /// Some of the reasons may include:
+ /// * HTLC Timeouts
+ /// * Expected MPP amount to claim does not equal HTLC total
+ /// * Claimable amount does not match expected amount
+ FailedPayment {
+ /// The payment hash of the payment we attempted to process.
+ payment_hash: crate::c_types::ThirtyTwoBytes,
+ },
+}
+use lightning::util::events::HTLCDestination as HTLCDestinationImport;
+pub(crate) type nativeHTLCDestination = HTLCDestinationImport;
+
+impl HTLCDestination {
+ #[allow(unused)]
+ pub(crate) fn to_native(&self) -> nativeHTLCDestination {
+ match self {
+ HTLCDestination::NextHopChannel {ref node_id, ref channel_id, } => {
+ let mut node_id_nonref = (*node_id).clone();
+ let mut local_node_id_nonref = if node_id_nonref.is_null() { None } else { Some( { node_id_nonref.into_rust() }) };
+ let mut channel_id_nonref = (*channel_id).clone();
+ nativeHTLCDestination::NextHopChannel {
+ node_id: local_node_id_nonref,
+ channel_id: channel_id_nonref.data,
+ }
+ },
+ HTLCDestination::UnknownNextHop {ref requested_forward_scid, } => {
+ let mut requested_forward_scid_nonref = (*requested_forward_scid).clone();
+ nativeHTLCDestination::UnknownNextHop {
+ requested_forward_scid: requested_forward_scid_nonref,
+ }
+ },
+ HTLCDestination::FailedPayment {ref payment_hash, } => {
+ let mut payment_hash_nonref = (*payment_hash).clone();
+ nativeHTLCDestination::FailedPayment {
+ payment_hash: ::lightning::ln::PaymentHash(payment_hash_nonref.data),
+ }
+ },
+ }
+ }
+ #[allow(unused)]
+ pub(crate) fn into_native(self) -> nativeHTLCDestination {
+ match self {
+ HTLCDestination::NextHopChannel {mut node_id, mut channel_id, } => {
+ let mut local_node_id = if node_id.is_null() { None } else { Some( { node_id.into_rust() }) };
+ nativeHTLCDestination::NextHopChannel {
+ node_id: local_node_id,
+ channel_id: channel_id.data,
+ }
+ },
+ HTLCDestination::UnknownNextHop {mut requested_forward_scid, } => {
+ nativeHTLCDestination::UnknownNextHop {
+ requested_forward_scid: requested_forward_scid,
+ }
+ },
+ HTLCDestination::FailedPayment {mut payment_hash, } => {
+ nativeHTLCDestination::FailedPayment {
+ payment_hash: ::lightning::ln::PaymentHash(payment_hash.data),
+ }
+ },
+ }
+ }
+ #[allow(unused)]
+ pub(crate) fn from_native(native: &nativeHTLCDestination) -> Self {
+ match native {
+ nativeHTLCDestination::NextHopChannel {ref node_id, ref channel_id, } => {
+ let mut node_id_nonref = (*node_id).clone();
+ let mut local_node_id_nonref = if node_id_nonref.is_none() { crate::c_types::PublicKey::null() } else { { crate::c_types::PublicKey::from_rust(&(node_id_nonref.unwrap())) } };
+ let mut channel_id_nonref = (*channel_id).clone();
+ HTLCDestination::NextHopChannel {
+ node_id: local_node_id_nonref,
+ channel_id: crate::c_types::ThirtyTwoBytes { data: channel_id_nonref },
+ }
+ },
+ nativeHTLCDestination::UnknownNextHop {ref requested_forward_scid, } => {
+ let mut requested_forward_scid_nonref = (*requested_forward_scid).clone();
+ HTLCDestination::UnknownNextHop {
+ requested_forward_scid: requested_forward_scid_nonref,
+ }
+ },
+ nativeHTLCDestination::FailedPayment {ref payment_hash, } => {
+ let mut payment_hash_nonref = (*payment_hash).clone();
+ HTLCDestination::FailedPayment {
+ payment_hash: crate::c_types::ThirtyTwoBytes { data: payment_hash_nonref.0 },
+ }
+ },
+ }
+ }
+ #[allow(unused)]
+ pub(crate) fn native_into(native: nativeHTLCDestination) -> Self {
+ match native {
+ nativeHTLCDestination::NextHopChannel {mut node_id, mut channel_id, } => {
+ let mut local_node_id = if node_id.is_none() { crate::c_types::PublicKey::null() } else { { crate::c_types::PublicKey::from_rust(&(node_id.unwrap())) } };
+ HTLCDestination::NextHopChannel {
+ node_id: local_node_id,
+ channel_id: crate::c_types::ThirtyTwoBytes { data: channel_id },
+ }
+ },
+ nativeHTLCDestination::UnknownNextHop {mut requested_forward_scid, } => {
+ HTLCDestination::UnknownNextHop {
+ requested_forward_scid: requested_forward_scid,
+ }
+ },
+ nativeHTLCDestination::FailedPayment {mut payment_hash, } => {
+ HTLCDestination::FailedPayment {
+ payment_hash: crate::c_types::ThirtyTwoBytes { data: payment_hash.0 },
+ }
+ },
+ }
+ }
+}
+/// Frees any resources used by the HTLCDestination
+#[no_mangle]
+pub extern "C" fn HTLCDestination_free(this_ptr: HTLCDestination) { }
+/// Creates a copy of the HTLCDestination
+#[no_mangle]
+pub extern "C" fn HTLCDestination_clone(orig: &HTLCDestination) -> HTLCDestination {
+ orig.clone()
+}
+#[no_mangle]
+/// Utility method to constructs a new NextHopChannel-variant HTLCDestination
+pub extern "C" fn HTLCDestination_next_hop_channel(node_id: crate::c_types::PublicKey, channel_id: crate::c_types::ThirtyTwoBytes) -> HTLCDestination {
+ HTLCDestination::NextHopChannel {
+ node_id,
+ channel_id,
+ }
+}
+#[no_mangle]
+/// Utility method to constructs a new UnknownNextHop-variant HTLCDestination
+pub extern "C" fn HTLCDestination_unknown_next_hop(requested_forward_scid: u64) -> HTLCDestination {
+ HTLCDestination::UnknownNextHop {
+ requested_forward_scid,
+ }
+}
+#[no_mangle]
+/// Utility method to constructs a new FailedPayment-variant HTLCDestination
+pub extern "C" fn HTLCDestination_failed_payment(payment_hash: crate::c_types::ThirtyTwoBytes) -> HTLCDestination {
+ HTLCDestination::FailedPayment {
+ payment_hash,
+ }
+}
+/// Checks if two HTLCDestinations contain equal inner contents.
+/// This ignores pointers and is_owned flags and looks at the values in fields.
+#[no_mangle]
+pub extern "C" fn HTLCDestination_eq(a: &HTLCDestination, b: &HTLCDestination) -> bool {
+ if &a.to_native() == &b.to_native() { true } else { false }
+}
+#[no_mangle]
+/// Serialize the HTLCDestination object into a byte array which can be read by HTLCDestination_read
+pub extern "C" fn HTLCDestination_write(obj: &crate::lightning::util::events::HTLCDestination) -> crate::c_types::derived::CVec_u8Z {
+ crate::c_types::serialize_obj(&unsafe { &*obj }.to_native())
+}
+#[no_mangle]
+/// Read a HTLCDestination from a byte array, created by HTLCDestination_write
+pub extern "C" fn HTLCDestination_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_COption_HTLCDestinationZDecodeErrorZ {
+ let res: Result<Option<lightning::util::events::HTLCDestination>, lightning::ln::msgs::DecodeError> = crate::c_types::maybe_deserialize_obj(ser);
+ let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { let mut local_res_0 = if o.is_none() { crate::c_types::derived::COption_HTLCDestinationZ::None } else { crate::c_types::derived::COption_HTLCDestinationZ::Some( { crate::lightning::util::events::HTLCDestination::native_into(o.unwrap()) }) }; local_res_0 }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() };
local_res
}
/// An Event which you should probably take some action in response to.
/// Indicates the payment was rejected for some reason by the recipient. This implies that
/// the payment has failed, not just the route in question. If this is not set, you may
/// retry the payment via a different route.
- rejected_by_dest: bool,
+ payment_failed_permanently: bool,
/// Any failure information conveyed via the Onion return packet by a node along the failed
/// payment route.
///
/// Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None
retry: crate::lightning::routing::router::RouteParameters,
},
+ /// Indicates that a probe payment we sent returned successful, i.e., only failed at the destination.
+ ProbeSuccessful {
+ /// The id returned by [`ChannelManager::send_probe`].
+ ///
+ /// [`ChannelManager::send_probe`]: crate::ln::channelmanager::ChannelManager::send_probe
+ payment_id: crate::c_types::ThirtyTwoBytes,
+ /// The hash generated by [`ChannelManager::send_probe`].
+ ///
+ /// [`ChannelManager::send_probe`]: crate::ln::channelmanager::ChannelManager::send_probe
+ payment_hash: crate::c_types::ThirtyTwoBytes,
+ /// The payment path that was successful.
+ path: crate::c_types::derived::CVec_RouteHopZ,
+ },
+ /// Indicates that a probe payment we sent failed at an intermediary node on the path.
+ ProbeFailed {
+ /// The id returned by [`ChannelManager::send_probe`].
+ ///
+ /// [`ChannelManager::send_probe`]: crate::ln::channelmanager::ChannelManager::send_probe
+ payment_id: crate::c_types::ThirtyTwoBytes,
+ /// The hash generated by [`ChannelManager::send_probe`].
+ ///
+ /// [`ChannelManager::send_probe`]: crate::ln::channelmanager::ChannelManager::send_probe
+ payment_hash: crate::c_types::ThirtyTwoBytes,
+ /// The payment path that failed.
+ path: crate::c_types::derived::CVec_RouteHopZ,
+ /// The channel responsible for the failed probe.
+ ///
+ /// Note that for route hints or for the first hop in a path this may be an SCID alias and
+ /// may not refer to a channel in the public network graph. These aliases may also collide
+ /// with channels in the public network graph.
+ short_channel_id: crate::c_types::derived::COption_u64Z,
+ },
/// Used to indicate that [`ChannelManager::process_pending_htlc_forwards`] should be called at
/// a time in the future.
///
/// Indicates a request to open a new channel by a peer.
///
/// To accept the request, call [`ChannelManager::accept_inbound_channel`]. To reject the
- /// request, call [`ChannelManager::force_close_channel`].
+ /// request, call [`ChannelManager::force_close_without_broadcasting_txn`].
///
/// The event is only triggered when a new open channel request is received and the
/// [`UserConfig::manually_accept_inbound_channels`] config flag is set to true.
///
/// [`ChannelManager::accept_inbound_channel`]: crate::ln::channelmanager::ChannelManager::accept_inbound_channel
- /// [`ChannelManager::force_close_channel`]: crate::ln::channelmanager::ChannelManager::force_close_channel
+ /// [`ChannelManager::force_close_without_broadcasting_txn`]: crate::ln::channelmanager::ChannelManager::force_close_without_broadcasting_txn
/// [`UserConfig::manually_accept_inbound_channels`]: crate::util::config::UserConfig::manually_accept_inbound_channels
OpenChannelRequest {
/// The temporary channel ID of the channel requested to be opened.
///
/// When responding to the request, the `temporary_channel_id` should be passed
/// back to the ChannelManager through [`ChannelManager::accept_inbound_channel`] to accept,
- /// or through [`ChannelManager::force_close_channel`] to reject.
+ /// or through [`ChannelManager::force_close_without_broadcasting_txn`] to reject.
///
/// [`ChannelManager::accept_inbound_channel`]: crate::ln::channelmanager::ChannelManager::accept_inbound_channel
- /// [`ChannelManager::force_close_channel`]: crate::ln::channelmanager::ChannelManager::force_close_channel
+ /// [`ChannelManager::force_close_without_broadcasting_txn`]: crate::ln::channelmanager::ChannelManager::force_close_without_broadcasting_txn
temporary_channel_id: crate::c_types::ThirtyTwoBytes,
/// The node_id of the counterparty requesting to open the channel.
///
/// When responding to the request, the `counterparty_node_id` should be passed
/// back to the `ChannelManager` through [`ChannelManager::accept_inbound_channel`] to
- /// accept the request, or through [`ChannelManager::force_close_channel`] to reject the
+ /// accept the request, or through [`ChannelManager::force_close_without_broadcasting_txn`] to reject the
/// request.
///
/// [`ChannelManager::accept_inbound_channel`]: crate::ln::channelmanager::ChannelManager::accept_inbound_channel
- /// [`ChannelManager::force_close_channel`]: crate::ln::channelmanager::ChannelManager::force_close_channel
+ /// [`ChannelManager::force_close_without_broadcasting_txn`]: crate::ln::channelmanager::ChannelManager::force_close_without_broadcasting_txn
counterparty_node_id: crate::c_types::PublicKey,
/// The channel value of the requested channel.
funding_satoshis: u64,
/// [`ChannelManager`]: crate::ln::channelmanager::ChannelManager
channel_type: crate::lightning::ln::features::ChannelTypeFeatures,
},
+ /// Indicates that the HTLC was accepted, but could not be processed when or after attempting to
+ /// forward it.
+ ///
+ /// Some scenarios where this event may be sent include:
+ /// * Insufficient capacity in the outbound channel
+ /// * While waiting to forward the HTLC, the channel it is meant to be forwarded through closes
+ /// * When an unknown SCID is requested for forwarding a payment.
+ /// * Claiming an amount for an MPP payment that exceeds the HTLC total
+ /// * The HTLC has timed out
+ ///
+ /// This event, however, does not get generated if an HTLC fails to meet the forwarding
+ /// requirements (i.e. insufficient fees paid, or a CLTV that is too soon).
+ HTLCHandlingFailed {
+ /// The channel over which the HTLC was received.
+ prev_channel_id: crate::c_types::ThirtyTwoBytes,
+ /// Destination of the HTLC that failed to be processed.
+ failed_next_destination: crate::lightning::util::events::HTLCDestination,
+ },
}
use lightning::util::events::Event as EventImport;
pub(crate) type nativeEvent = EventImport;
path: local_path_nonref,
}
},
- Event::PaymentPathFailed {ref payment_id, ref payment_hash, ref rejected_by_dest, ref network_update, ref all_paths_failed, ref path, ref short_channel_id, ref retry, } => {
+ Event::PaymentPathFailed {ref payment_id, ref payment_hash, ref payment_failed_permanently, ref network_update, ref all_paths_failed, ref path, ref short_channel_id, ref retry, } => {
let mut payment_id_nonref = (*payment_id).clone();
let mut local_payment_id_nonref = if payment_id_nonref.data == [0; 32] { None } else { Some( { ::lightning::ln::channelmanager::PaymentId(payment_id_nonref.data) }) };
let mut payment_hash_nonref = (*payment_hash).clone();
- let mut rejected_by_dest_nonref = (*rejected_by_dest).clone();
+ let mut payment_failed_permanently_nonref = (*payment_failed_permanently).clone();
let mut network_update_nonref = (*network_update).clone();
let mut local_network_update_nonref = { /* network_update_nonref*/ let network_update_nonref_opt = network_update_nonref; { } if network_update_nonref_opt.is_none() { None } else { Some({ network_update_nonref_opt.take().into_native() }) } };
let mut all_paths_failed_nonref = (*all_paths_failed).clone();
nativeEvent::PaymentPathFailed {
payment_id: local_payment_id_nonref,
payment_hash: ::lightning::ln::PaymentHash(payment_hash_nonref.data),
- rejected_by_dest: rejected_by_dest_nonref,
+ payment_failed_permanently: payment_failed_permanently_nonref,
network_update: local_network_update_nonref,
all_paths_failed: all_paths_failed_nonref,
path: local_path_nonref,
retry: local_retry_nonref,
}
},
+ Event::ProbeSuccessful {ref payment_id, ref payment_hash, ref path, } => {
+ let mut payment_id_nonref = (*payment_id).clone();
+ let mut payment_hash_nonref = (*payment_hash).clone();
+ let mut path_nonref = (*path).clone();
+ let mut local_path_nonref = Vec::new(); for mut item in path_nonref.into_rust().drain(..) { local_path_nonref.push( { *unsafe { Box::from_raw(item.take_inner()) } }); };
+ nativeEvent::ProbeSuccessful {
+ payment_id: ::lightning::ln::channelmanager::PaymentId(payment_id_nonref.data),
+ payment_hash: ::lightning::ln::PaymentHash(payment_hash_nonref.data),
+ path: local_path_nonref,
+ }
+ },
+ Event::ProbeFailed {ref payment_id, ref payment_hash, ref path, ref short_channel_id, } => {
+ let mut payment_id_nonref = (*payment_id).clone();
+ let mut payment_hash_nonref = (*payment_hash).clone();
+ let mut path_nonref = (*path).clone();
+ let mut local_path_nonref = Vec::new(); for mut item in path_nonref.into_rust().drain(..) { local_path_nonref.push( { *unsafe { Box::from_raw(item.take_inner()) } }); };
+ let mut short_channel_id_nonref = (*short_channel_id).clone();
+ let mut local_short_channel_id_nonref = if short_channel_id_nonref.is_some() { Some( { short_channel_id_nonref.take() }) } else { None };
+ nativeEvent::ProbeFailed {
+ payment_id: ::lightning::ln::channelmanager::PaymentId(payment_id_nonref.data),
+ payment_hash: ::lightning::ln::PaymentHash(payment_hash_nonref.data),
+ path: local_path_nonref,
+ short_channel_id: local_short_channel_id_nonref,
+ }
+ },
Event::PendingHTLCsForwardable {ref time_forwardable, } => {
let mut time_forwardable_nonref = (*time_forwardable).clone();
nativeEvent::PendingHTLCsForwardable {
channel_type: *unsafe { Box::from_raw(channel_type_nonref.take_inner()) },
}
},
+ Event::HTLCHandlingFailed {ref prev_channel_id, ref failed_next_destination, } => {
+ let mut prev_channel_id_nonref = (*prev_channel_id).clone();
+ let mut failed_next_destination_nonref = (*failed_next_destination).clone();
+ nativeEvent::HTLCHandlingFailed {
+ prev_channel_id: prev_channel_id_nonref.data,
+ failed_next_destination: failed_next_destination_nonref.into_native(),
+ }
+ },
}
}
#[allow(unused)]
path: local_path,
}
},
- Event::PaymentPathFailed {mut payment_id, mut payment_hash, mut rejected_by_dest, mut network_update, mut all_paths_failed, mut path, mut short_channel_id, mut retry, } => {
+ Event::PaymentPathFailed {mut payment_id, mut payment_hash, mut payment_failed_permanently, mut network_update, mut all_paths_failed, mut path, mut short_channel_id, mut retry, } => {
let mut local_payment_id = if payment_id.data == [0; 32] { None } else { Some( { ::lightning::ln::channelmanager::PaymentId(payment_id.data) }) };
let mut local_network_update = { /* network_update*/ let network_update_opt = network_update; { } if network_update_opt.is_none() { None } else { Some({ network_update_opt.take().into_native() }) } };
let mut local_path = Vec::new(); for mut item in path.into_rust().drain(..) { local_path.push( { *unsafe { Box::from_raw(item.take_inner()) } }); };
nativeEvent::PaymentPathFailed {
payment_id: local_payment_id,
payment_hash: ::lightning::ln::PaymentHash(payment_hash.data),
- rejected_by_dest: rejected_by_dest,
+ payment_failed_permanently: payment_failed_permanently,
network_update: local_network_update,
all_paths_failed: all_paths_failed,
path: local_path,
retry: local_retry,
}
},
+ Event::ProbeSuccessful {mut payment_id, mut payment_hash, mut path, } => {
+ let mut local_path = Vec::new(); for mut item in path.into_rust().drain(..) { local_path.push( { *unsafe { Box::from_raw(item.take_inner()) } }); };
+ nativeEvent::ProbeSuccessful {
+ payment_id: ::lightning::ln::channelmanager::PaymentId(payment_id.data),
+ payment_hash: ::lightning::ln::PaymentHash(payment_hash.data),
+ path: local_path,
+ }
+ },
+ Event::ProbeFailed {mut payment_id, mut payment_hash, mut path, mut short_channel_id, } => {
+ let mut local_path = Vec::new(); for mut item in path.into_rust().drain(..) { local_path.push( { *unsafe { Box::from_raw(item.take_inner()) } }); };
+ let mut local_short_channel_id = if short_channel_id.is_some() { Some( { short_channel_id.take() }) } else { None };
+ nativeEvent::ProbeFailed {
+ payment_id: ::lightning::ln::channelmanager::PaymentId(payment_id.data),
+ payment_hash: ::lightning::ln::PaymentHash(payment_hash.data),
+ path: local_path,
+ short_channel_id: local_short_channel_id,
+ }
+ },
Event::PendingHTLCsForwardable {mut time_forwardable, } => {
nativeEvent::PendingHTLCsForwardable {
time_forwardable: core::time::Duration::from_secs(time_forwardable),
channel_type: *unsafe { Box::from_raw(channel_type.take_inner()) },
}
},
+ Event::HTLCHandlingFailed {mut prev_channel_id, mut failed_next_destination, } => {
+ nativeEvent::HTLCHandlingFailed {
+ prev_channel_id: prev_channel_id.data,
+ failed_next_destination: failed_next_destination.into_native(),
+ }
+ },
}
}
#[allow(unused)]
path: local_path_nonref.into(),
}
},
- nativeEvent::PaymentPathFailed {ref payment_id, ref payment_hash, ref rejected_by_dest, ref network_update, ref all_paths_failed, ref path, ref short_channel_id, ref retry, } => {
+ nativeEvent::PaymentPathFailed {ref payment_id, ref payment_hash, ref payment_failed_permanently, ref network_update, ref all_paths_failed, ref path, ref short_channel_id, ref retry, } => {
let mut payment_id_nonref = (*payment_id).clone();
let mut local_payment_id_nonref = if payment_id_nonref.is_none() { crate::c_types::ThirtyTwoBytes::null() } else { { crate::c_types::ThirtyTwoBytes { data: (payment_id_nonref.unwrap()).0 } } };
let mut payment_hash_nonref = (*payment_hash).clone();
- let mut rejected_by_dest_nonref = (*rejected_by_dest).clone();
+ let mut payment_failed_permanently_nonref = (*payment_failed_permanently).clone();
let mut network_update_nonref = (*network_update).clone();
let mut local_network_update_nonref = if network_update_nonref.is_none() { crate::c_types::derived::COption_NetworkUpdateZ::None } else { crate::c_types::derived::COption_NetworkUpdateZ::Some( { crate::lightning::routing::gossip::NetworkUpdate::native_into(network_update_nonref.unwrap()) }) };
let mut all_paths_failed_nonref = (*all_paths_failed).clone();
Event::PaymentPathFailed {
payment_id: local_payment_id_nonref,
payment_hash: crate::c_types::ThirtyTwoBytes { data: payment_hash_nonref.0 },
- rejected_by_dest: rejected_by_dest_nonref,
+ payment_failed_permanently: payment_failed_permanently_nonref,
network_update: local_network_update_nonref,
all_paths_failed: all_paths_failed_nonref,
path: local_path_nonref.into(),
retry: local_retry_nonref,
}
},
+ nativeEvent::ProbeSuccessful {ref payment_id, ref payment_hash, ref path, } => {
+ let mut payment_id_nonref = (*payment_id).clone();
+ let mut payment_hash_nonref = (*payment_hash).clone();
+ let mut path_nonref = (*path).clone();
+ let mut local_path_nonref = Vec::new(); for mut item in path_nonref.drain(..) { local_path_nonref.push( { crate::lightning::routing::router::RouteHop { inner: ObjOps::heap_alloc(item), is_owned: true } }); };
+ Event::ProbeSuccessful {
+ payment_id: crate::c_types::ThirtyTwoBytes { data: payment_id_nonref.0 },
+ payment_hash: crate::c_types::ThirtyTwoBytes { data: payment_hash_nonref.0 },
+ path: local_path_nonref.into(),
+ }
+ },
+ nativeEvent::ProbeFailed {ref payment_id, ref payment_hash, ref path, ref short_channel_id, } => {
+ let mut payment_id_nonref = (*payment_id).clone();
+ let mut payment_hash_nonref = (*payment_hash).clone();
+ let mut path_nonref = (*path).clone();
+ let mut local_path_nonref = Vec::new(); for mut item in path_nonref.drain(..) { local_path_nonref.push( { crate::lightning::routing::router::RouteHop { inner: ObjOps::heap_alloc(item), is_owned: true } }); };
+ let mut short_channel_id_nonref = (*short_channel_id).clone();
+ let mut local_short_channel_id_nonref = if short_channel_id_nonref.is_none() { crate::c_types::derived::COption_u64Z::None } else { crate::c_types::derived::COption_u64Z::Some( { short_channel_id_nonref.unwrap() }) };
+ Event::ProbeFailed {
+ payment_id: crate::c_types::ThirtyTwoBytes { data: payment_id_nonref.0 },
+ payment_hash: crate::c_types::ThirtyTwoBytes { data: payment_hash_nonref.0 },
+ path: local_path_nonref.into(),
+ short_channel_id: local_short_channel_id_nonref,
+ }
+ },
nativeEvent::PendingHTLCsForwardable {ref time_forwardable, } => {
let mut time_forwardable_nonref = (*time_forwardable).clone();
Event::PendingHTLCsForwardable {
channel_type: crate::lightning::ln::features::ChannelTypeFeatures { inner: ObjOps::heap_alloc(channel_type_nonref), is_owned: true },
}
},
+ nativeEvent::HTLCHandlingFailed {ref prev_channel_id, ref failed_next_destination, } => {
+ let mut prev_channel_id_nonref = (*prev_channel_id).clone();
+ let mut failed_next_destination_nonref = (*failed_next_destination).clone();
+ Event::HTLCHandlingFailed {
+ prev_channel_id: crate::c_types::ThirtyTwoBytes { data: prev_channel_id_nonref },
+ failed_next_destination: crate::lightning::util::events::HTLCDestination::native_into(failed_next_destination_nonref),
+ }
+ },
}
}
#[allow(unused)]
path: local_path.into(),
}
},
- nativeEvent::PaymentPathFailed {mut payment_id, mut payment_hash, mut rejected_by_dest, mut network_update, mut all_paths_failed, mut path, mut short_channel_id, mut retry, } => {
+ nativeEvent::PaymentPathFailed {mut payment_id, mut payment_hash, mut payment_failed_permanently, mut network_update, mut all_paths_failed, mut path, mut short_channel_id, mut retry, } => {
let mut local_payment_id = if payment_id.is_none() { crate::c_types::ThirtyTwoBytes::null() } else { { crate::c_types::ThirtyTwoBytes { data: (payment_id.unwrap()).0 } } };
let mut local_network_update = if network_update.is_none() { crate::c_types::derived::COption_NetworkUpdateZ::None } else { crate::c_types::derived::COption_NetworkUpdateZ::Some( { crate::lightning::routing::gossip::NetworkUpdate::native_into(network_update.unwrap()) }) };
let mut local_path = Vec::new(); for mut item in path.drain(..) { local_path.push( { crate::lightning::routing::router::RouteHop { inner: ObjOps::heap_alloc(item), is_owned: true } }); };
Event::PaymentPathFailed {
payment_id: local_payment_id,
payment_hash: crate::c_types::ThirtyTwoBytes { data: payment_hash.0 },
- rejected_by_dest: rejected_by_dest,
+ payment_failed_permanently: payment_failed_permanently,
network_update: local_network_update,
all_paths_failed: all_paths_failed,
path: local_path.into(),
retry: local_retry,
}
},
+ nativeEvent::ProbeSuccessful {mut payment_id, mut payment_hash, mut path, } => {
+ let mut local_path = Vec::new(); for mut item in path.drain(..) { local_path.push( { crate::lightning::routing::router::RouteHop { inner: ObjOps::heap_alloc(item), is_owned: true } }); };
+ Event::ProbeSuccessful {
+ payment_id: crate::c_types::ThirtyTwoBytes { data: payment_id.0 },
+ payment_hash: crate::c_types::ThirtyTwoBytes { data: payment_hash.0 },
+ path: local_path.into(),
+ }
+ },
+ nativeEvent::ProbeFailed {mut payment_id, mut payment_hash, mut path, mut short_channel_id, } => {
+ let mut local_path = Vec::new(); for mut item in path.drain(..) { local_path.push( { crate::lightning::routing::router::RouteHop { inner: ObjOps::heap_alloc(item), is_owned: true } }); };
+ let mut local_short_channel_id = if short_channel_id.is_none() { crate::c_types::derived::COption_u64Z::None } else { crate::c_types::derived::COption_u64Z::Some( { short_channel_id.unwrap() }) };
+ Event::ProbeFailed {
+ payment_id: crate::c_types::ThirtyTwoBytes { data: payment_id.0 },
+ payment_hash: crate::c_types::ThirtyTwoBytes { data: payment_hash.0 },
+ path: local_path.into(),
+ short_channel_id: local_short_channel_id,
+ }
+ },
nativeEvent::PendingHTLCsForwardable {mut time_forwardable, } => {
Event::PendingHTLCsForwardable {
time_forwardable: time_forwardable.as_secs(),
channel_type: crate::lightning::ln::features::ChannelTypeFeatures { inner: ObjOps::heap_alloc(channel_type), is_owned: true },
}
},
+ nativeEvent::HTLCHandlingFailed {mut prev_channel_id, mut failed_next_destination, } => {
+ Event::HTLCHandlingFailed {
+ prev_channel_id: crate::c_types::ThirtyTwoBytes { data: prev_channel_id },
+ failed_next_destination: crate::lightning::util::events::HTLCDestination::native_into(failed_next_destination),
+ }
+ },
}
}
}
}
#[no_mangle]
/// Utility method to constructs a new PaymentPathFailed-variant Event
-pub extern "C" fn Event_payment_path_failed(payment_id: crate::c_types::ThirtyTwoBytes, payment_hash: crate::c_types::ThirtyTwoBytes, rejected_by_dest: bool, network_update: crate::c_types::derived::COption_NetworkUpdateZ, all_paths_failed: bool, path: crate::c_types::derived::CVec_RouteHopZ, short_channel_id: crate::c_types::derived::COption_u64Z, retry: crate::lightning::routing::router::RouteParameters) -> Event {
+pub extern "C" fn Event_payment_path_failed(payment_id: crate::c_types::ThirtyTwoBytes, payment_hash: crate::c_types::ThirtyTwoBytes, payment_failed_permanently: bool, network_update: crate::c_types::derived::COption_NetworkUpdateZ, all_paths_failed: bool, path: crate::c_types::derived::CVec_RouteHopZ, short_channel_id: crate::c_types::derived::COption_u64Z, retry: crate::lightning::routing::router::RouteParameters) -> Event {
Event::PaymentPathFailed {
payment_id,
payment_hash,
- rejected_by_dest,
+ payment_failed_permanently,
network_update,
all_paths_failed,
path,
}
}
#[no_mangle]
+/// Utility method to constructs a new ProbeSuccessful-variant Event
+pub extern "C" fn Event_probe_successful(payment_id: crate::c_types::ThirtyTwoBytes, payment_hash: crate::c_types::ThirtyTwoBytes, path: crate::c_types::derived::CVec_RouteHopZ) -> Event {
+ Event::ProbeSuccessful {
+ payment_id,
+ payment_hash,
+ path,
+ }
+}
+#[no_mangle]
+/// Utility method to constructs a new ProbeFailed-variant Event
+pub extern "C" fn Event_probe_failed(payment_id: crate::c_types::ThirtyTwoBytes, payment_hash: crate::c_types::ThirtyTwoBytes, path: crate::c_types::derived::CVec_RouteHopZ, short_channel_id: crate::c_types::derived::COption_u64Z) -> Event {
+ Event::ProbeFailed {
+ payment_id,
+ payment_hash,
+ path,
+ short_channel_id,
+ }
+}
+#[no_mangle]
/// Utility method to constructs a new PendingHTLCsForwardable-variant Event
pub extern "C" fn Event_pending_htlcs_forwardable(time_forwardable: u64) -> Event {
Event::PendingHTLCsForwardable {
}
}
#[no_mangle]
+/// Utility method to constructs a new HTLCHandlingFailed-variant Event
+pub extern "C" fn Event_htlchandling_failed(prev_channel_id: crate::c_types::ThirtyTwoBytes, failed_next_destination: crate::lightning::util::events::HTLCDestination) -> Event {
+ Event::HTLCHandlingFailed {
+ prev_channel_id,
+ failed_next_destination,
+ }
+}
+#[no_mangle]
/// Serialize the Event object into a byte array which can be read by Event_read
pub extern "C" fn Event_write(obj: &crate::lightning::util::events::Event) -> crate::c_types::derived::CVec_u8Z {
crate::c_types::serialize_obj(&unsafe { &*obj }.to_native())
/// Read a Event from a byte array, created by Event_write
pub extern "C" fn Event_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_COption_EventZDecodeErrorZ {
let res: Result<Option<lightning::util::events::Event>, lightning::ln::msgs::DecodeError> = crate::c_types::maybe_deserialize_obj(ser);
- let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { let mut local_res_0 = if o.is_none() { crate::c_types::derived::COption_EventZ::None } else { crate::c_types::derived::COption_EventZ::Some( { crate::lightning::util::events::Event::native_into(o.unwrap()) }) }; local_res_0 }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError { inner: ObjOps::heap_alloc(e), is_owned: true } }).into() };
+ let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { let mut local_res_0 = if o.is_none() { crate::c_types::derived::COption_EventZ::None } else { crate::c_types::derived::COption_EventZ::Some( { crate::lightning::util::events::Event::native_into(o.unwrap()) }) }; local_res_0 }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() };
local_res
}
/// An event generated by ChannelManager which indicates a message should be sent to a peer (or
/// The message which should be sent.
msg: crate::lightning::ln::msgs::ChannelReestablish,
},
+ /// Used to send a channel_announcement and channel_update to a specific peer, likely on
+ /// initial connection to ensure our peers know about our channels.
+ SendChannelAnnouncement {
+ /// The node_id of the node which should receive this message
+ node_id: crate::c_types::PublicKey,
+ /// The channel_announcement which should be sent.
+ msg: crate::lightning::ln::msgs::ChannelAnnouncement,
+ /// The followup channel_update which should be sent.
+ update_msg: crate::lightning::ln::msgs::ChannelUpdate,
+ },
/// Used to indicate that a channel_announcement and channel_update should be broadcast to all
/// peers (except the peer with node_id either msg.contents.node_id_1 or msg.contents.node_id_2).
///
- /// Note that after doing so, you very likely (unless you did so very recently) want to call
- /// ChannelManager::broadcast_node_announcement to trigger a BroadcastNodeAnnouncement event.
- /// This ensures that any nodes which see our channel_announcement also have a relevant
+ /// Note that after doing so, you very likely (unless you did so very recently) want to
+ /// broadcast a node_announcement (e.g. via [`PeerManager::broadcast_node_announcement`]). This
+ /// ensures that any nodes which see our channel_announcement also have a relevant
/// node_announcement, including relevant feature flags which may be important for routing
/// through or to us.
+ ///
+ /// [`PeerManager::broadcast_node_announcement`]: crate::ln::peer_handler::PeerManager::broadcast_node_announcement
BroadcastChannelAnnouncement {
/// The channel_announcement which should be sent.
msg: crate::lightning::ln::msgs::ChannelAnnouncement,
/// The followup channel_update which should be sent.
update_msg: crate::lightning::ln::msgs::ChannelUpdate,
},
- /// Used to indicate that a node_announcement should be broadcast to all peers.
- BroadcastNodeAnnouncement {
- /// The node_announcement which should be sent.
- msg: crate::lightning::ln::msgs::NodeAnnouncement,
- },
/// Used to indicate that a channel_update should be broadcast to all peers.
BroadcastChannelUpdate {
/// The channel_update which should be sent.
msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) },
}
},
- MessageSendEvent::BroadcastChannelAnnouncement {ref msg, ref update_msg, } => {
+ MessageSendEvent::SendChannelAnnouncement {ref node_id, ref msg, ref update_msg, } => {
+ let mut node_id_nonref = (*node_id).clone();
let mut msg_nonref = (*msg).clone();
let mut update_msg_nonref = (*update_msg).clone();
- nativeMessageSendEvent::BroadcastChannelAnnouncement {
+ nativeMessageSendEvent::SendChannelAnnouncement {
+ node_id: node_id_nonref.into_rust(),
msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) },
update_msg: *unsafe { Box::from_raw(update_msg_nonref.take_inner()) },
}
},
- MessageSendEvent::BroadcastNodeAnnouncement {ref msg, } => {
+ MessageSendEvent::BroadcastChannelAnnouncement {ref msg, ref update_msg, } => {
let mut msg_nonref = (*msg).clone();
- nativeMessageSendEvent::BroadcastNodeAnnouncement {
+ let mut update_msg_nonref = (*update_msg).clone();
+ nativeMessageSendEvent::BroadcastChannelAnnouncement {
msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) },
+ update_msg: *unsafe { Box::from_raw(update_msg_nonref.take_inner()) },
}
},
MessageSendEvent::BroadcastChannelUpdate {ref msg, } => {
msg: *unsafe { Box::from_raw(msg.take_inner()) },
}
},
- MessageSendEvent::BroadcastChannelAnnouncement {mut msg, mut update_msg, } => {
- nativeMessageSendEvent::BroadcastChannelAnnouncement {
+ MessageSendEvent::SendChannelAnnouncement {mut node_id, mut msg, mut update_msg, } => {
+ nativeMessageSendEvent::SendChannelAnnouncement {
+ node_id: node_id.into_rust(),
msg: *unsafe { Box::from_raw(msg.take_inner()) },
update_msg: *unsafe { Box::from_raw(update_msg.take_inner()) },
}
},
- MessageSendEvent::BroadcastNodeAnnouncement {mut msg, } => {
- nativeMessageSendEvent::BroadcastNodeAnnouncement {
+ MessageSendEvent::BroadcastChannelAnnouncement {mut msg, mut update_msg, } => {
+ nativeMessageSendEvent::BroadcastChannelAnnouncement {
msg: *unsafe { Box::from_raw(msg.take_inner()) },
+ update_msg: *unsafe { Box::from_raw(update_msg.take_inner()) },
}
},
MessageSendEvent::BroadcastChannelUpdate {mut msg, } => {
msg: crate::lightning::ln::msgs::ChannelReestablish { inner: ObjOps::heap_alloc(msg_nonref), is_owned: true },
}
},
- nativeMessageSendEvent::BroadcastChannelAnnouncement {ref msg, ref update_msg, } => {
+ nativeMessageSendEvent::SendChannelAnnouncement {ref node_id, ref msg, ref update_msg, } => {
+ let mut node_id_nonref = (*node_id).clone();
let mut msg_nonref = (*msg).clone();
let mut update_msg_nonref = (*update_msg).clone();
- MessageSendEvent::BroadcastChannelAnnouncement {
+ MessageSendEvent::SendChannelAnnouncement {
+ node_id: crate::c_types::PublicKey::from_rust(&node_id_nonref),
msg: crate::lightning::ln::msgs::ChannelAnnouncement { inner: ObjOps::heap_alloc(msg_nonref), is_owned: true },
update_msg: crate::lightning::ln::msgs::ChannelUpdate { inner: ObjOps::heap_alloc(update_msg_nonref), is_owned: true },
}
},
- nativeMessageSendEvent::BroadcastNodeAnnouncement {ref msg, } => {
+ nativeMessageSendEvent::BroadcastChannelAnnouncement {ref msg, ref update_msg, } => {
let mut msg_nonref = (*msg).clone();
- MessageSendEvent::BroadcastNodeAnnouncement {
- msg: crate::lightning::ln::msgs::NodeAnnouncement { inner: ObjOps::heap_alloc(msg_nonref), is_owned: true },
+ let mut update_msg_nonref = (*update_msg).clone();
+ MessageSendEvent::BroadcastChannelAnnouncement {
+ msg: crate::lightning::ln::msgs::ChannelAnnouncement { inner: ObjOps::heap_alloc(msg_nonref), is_owned: true },
+ update_msg: crate::lightning::ln::msgs::ChannelUpdate { inner: ObjOps::heap_alloc(update_msg_nonref), is_owned: true },
}
},
nativeMessageSendEvent::BroadcastChannelUpdate {ref msg, } => {
msg: crate::lightning::ln::msgs::ChannelReestablish { inner: ObjOps::heap_alloc(msg), is_owned: true },
}
},
- nativeMessageSendEvent::BroadcastChannelAnnouncement {mut msg, mut update_msg, } => {
- MessageSendEvent::BroadcastChannelAnnouncement {
+ nativeMessageSendEvent::SendChannelAnnouncement {mut node_id, mut msg, mut update_msg, } => {
+ MessageSendEvent::SendChannelAnnouncement {
+ node_id: crate::c_types::PublicKey::from_rust(&node_id),
msg: crate::lightning::ln::msgs::ChannelAnnouncement { inner: ObjOps::heap_alloc(msg), is_owned: true },
update_msg: crate::lightning::ln::msgs::ChannelUpdate { inner: ObjOps::heap_alloc(update_msg), is_owned: true },
}
},
- nativeMessageSendEvent::BroadcastNodeAnnouncement {mut msg, } => {
- MessageSendEvent::BroadcastNodeAnnouncement {
- msg: crate::lightning::ln::msgs::NodeAnnouncement { inner: ObjOps::heap_alloc(msg), is_owned: true },
+ nativeMessageSendEvent::BroadcastChannelAnnouncement {mut msg, mut update_msg, } => {
+ MessageSendEvent::BroadcastChannelAnnouncement {
+ msg: crate::lightning::ln::msgs::ChannelAnnouncement { inner: ObjOps::heap_alloc(msg), is_owned: true },
+ update_msg: crate::lightning::ln::msgs::ChannelUpdate { inner: ObjOps::heap_alloc(update_msg), is_owned: true },
}
},
nativeMessageSendEvent::BroadcastChannelUpdate {mut msg, } => {
}
}
#[no_mangle]
-/// Utility method to constructs a new BroadcastChannelAnnouncement-variant MessageSendEvent
-pub extern "C" fn MessageSendEvent_broadcast_channel_announcement(msg: crate::lightning::ln::msgs::ChannelAnnouncement, update_msg: crate::lightning::ln::msgs::ChannelUpdate) -> MessageSendEvent {
- MessageSendEvent::BroadcastChannelAnnouncement {
+/// Utility method to constructs a new SendChannelAnnouncement-variant MessageSendEvent
+pub extern "C" fn MessageSendEvent_send_channel_announcement(node_id: crate::c_types::PublicKey, msg: crate::lightning::ln::msgs::ChannelAnnouncement, update_msg: crate::lightning::ln::msgs::ChannelUpdate) -> MessageSendEvent {
+ MessageSendEvent::SendChannelAnnouncement {
+ node_id,
msg,
update_msg,
}
}
#[no_mangle]
-/// Utility method to constructs a new BroadcastNodeAnnouncement-variant MessageSendEvent
-pub extern "C" fn MessageSendEvent_broadcast_node_announcement(msg: crate::lightning::ln::msgs::NodeAnnouncement) -> MessageSendEvent {
- MessageSendEvent::BroadcastNodeAnnouncement {
+/// Utility method to constructs a new BroadcastChannelAnnouncement-variant MessageSendEvent
+pub extern "C" fn MessageSendEvent_broadcast_channel_announcement(msg: crate::lightning::ln::msgs::ChannelAnnouncement, update_msg: crate::lightning::ln::msgs::ChannelUpdate) -> MessageSendEvent {
+ MessageSendEvent::BroadcastChannelAnnouncement {
msg,
+ update_msg,
}
}
#[no_mangle]
}
}
}
+/// A trait indicating an object may generate onion messages to send
+#[repr(C)]
+pub struct OnionMessageProvider {
+ /// An opaque pointer which is passed to your function implementations as an argument.
+ /// This has no meaning in the LDK, and can be NULL or any other value.
+ pub this_arg: *mut c_void,
+ /// Gets the next pending onion message for the peer with the given node id.
+ ///
+ /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
+ #[must_use]
+ pub next_onion_message_for_peer: extern "C" fn (this_arg: *const c_void, peer_node_id: crate::c_types::PublicKey) -> crate::lightning::ln::msgs::OnionMessage,
+ /// Frees any resources associated with this object given its this_arg pointer.
+ /// Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed.
+ pub free: Option<extern "C" fn(this_arg: *mut c_void)>,
+}
+unsafe impl Send for OnionMessageProvider {}
+unsafe impl Sync for OnionMessageProvider {}
+#[no_mangle]
+pub(crate) extern "C" fn OnionMessageProvider_clone_fields(orig: &OnionMessageProvider) -> OnionMessageProvider {
+ OnionMessageProvider {
+ this_arg: orig.this_arg,
+ next_onion_message_for_peer: Clone::clone(&orig.next_onion_message_for_peer),
+ free: Clone::clone(&orig.free),
+ }
+}
+
+use lightning::util::events::OnionMessageProvider as rustOnionMessageProvider;
+impl rustOnionMessageProvider for OnionMessageProvider {
+ fn next_onion_message_for_peer(&self, mut peer_node_id: bitcoin::secp256k1::PublicKey) -> Option<lightning::ln::msgs::OnionMessage> {
+ let mut ret = (self.next_onion_message_for_peer)(self.this_arg, crate::c_types::PublicKey::from_rust(&peer_node_id));
+ let mut local_ret = if ret.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(ret.take_inner()) } }) };
+ local_ret
+ }
+}
+
+// We're essentially a pointer already, or at least a set of pointers, so allow us to be used
+// directly as a Deref trait in higher-level structs:
+impl core::ops::Deref for OnionMessageProvider {
+ type Target = Self;
+ fn deref(&self) -> &Self {
+ self
+ }
+}
+/// Calls the free function if one is set
+#[no_mangle]
+pub extern "C" fn OnionMessageProvider_free(this_ptr: OnionMessageProvider) { }
+impl Drop for OnionMessageProvider {
+ fn drop(&mut self) {
+ if let Some(f) = self.free {
+ f(self.this_arg);
+ }
+ }
+}
/// A trait indicating an object may generate events.
///
/// Events are processed by passing an [`EventHandler`] to [`process_pending_events`].
///
/// # Requirements
///
-/// See [`process_pending_events`] for requirements around event processing.
-///
/// When using this trait, [`process_pending_events`] will call [`handle_event`] for each pending
-/// event since the last invocation. The handler must either act upon the event immediately
-/// or preserve it for later handling.
+/// event since the last invocation.
+///
+/// In order to ensure no [`Event`]s are lost, implementors of this trait will persist [`Event`]s
+/// and replay any unhandled events on startup. An [`Event`] is considered handled when
+/// [`process_pending_events`] returns, thus handlers MUST fully handle [`Event`]s and persist any
+/// relevant changes to disk *before* returning.
+///
+/// Further, because an application may crash between an [`Event`] being handled and the
+/// implementor of this trait being re-serialized, [`Event`] handling must be idempotent - in
+/// effect, [`Event`]s may be replayed.
///
/// Note, handlers may call back into the provider and thus deadlocking must be avoided. Be sure to
/// consult the provider's documentation on the implication of processing events and how a handler
pub this_arg: *mut c_void,
/// Processes any events generated since the last call using the given event handler.
///
- /// Subsequent calls must only process new events. However, handlers must be capable of handling
- /// duplicate events across process restarts. This may occur if the provider was recovered from
- /// an old state (i.e., it hadn't been successfully persisted after processing pending events).
+ /// See the trait-level documentation for requirements.
pub process_pending_events: extern "C" fn (this_arg: *const c_void, handler: crate::lightning::util::events::EventHandler),
/// Frees any resources associated with this object given its this_arg pointer.
/// Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed.