1 // This file is Copyright its original authors, visible in version control
2 // history and in the source files from which this was generated.
4 // This file is licensed under the license available in the LICENSE or LICENSE.md
5 // file in the root of this repository or, if no such file exists, the same
6 // license as that which applies to the original source files from which this
7 // source was automatically generated.
9 //! Events are returned from various bits in the library which indicate some action must be taken
12 //! Because we don't have a built-in runtime, it's up to the client to call events at a time in the
13 //! future, as well as generate and broadcast funding transactions handle payment preimages and a
16 use alloc::str::FromStr;
17 use core::ffi::c_void;
18 use core::convert::Infallible;
19 use bitcoin::hashes::Hash;
20 use crate::c_types::*;
21 #[cfg(feature="no-std")]
22 use alloc::{vec::Vec, boxed::Box};
24 /// Some information provided on receipt of payment depends on whether the payment received is a
25 /// spontaneous payment or a \"conventional\" lightning payment that's paying an invoice.
29 pub enum PaymentPurpose {
30 /// Information for receiving a payment that we generated an invoice for.
32 /// The preimage to the payment_hash, if the payment hash (and secret) were fetched via
33 /// [`ChannelManager::create_inbound_payment`]. If provided, this can be handed directly to
34 /// [`ChannelManager::claim_funds`].
36 /// [`ChannelManager::create_inbound_payment`]: crate::ln::channelmanager::ChannelManager::create_inbound_payment
37 /// [`ChannelManager::claim_funds`]: crate::ln::channelmanager::ChannelManager::claim_funds
39 /// Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None
40 payment_preimage: crate::c_types::ThirtyTwoBytes,
41 /// The \"payment secret\". This authenticates the sender to the recipient, preventing a
42 /// number of deanonymization attacks during the routing process.
43 /// It is provided here for your reference, however its accuracy is enforced directly by
44 /// [`ChannelManager`] using the values you previously provided to
45 /// [`ChannelManager::create_inbound_payment`] or
46 /// [`ChannelManager::create_inbound_payment_for_hash`].
48 /// [`ChannelManager`]: crate::ln::channelmanager::ChannelManager
49 /// [`ChannelManager::create_inbound_payment`]: crate::ln::channelmanager::ChannelManager::create_inbound_payment
50 /// [`ChannelManager::create_inbound_payment_for_hash`]: crate::ln::channelmanager::ChannelManager::create_inbound_payment_for_hash
51 payment_secret: crate::c_types::ThirtyTwoBytes,
53 /// Because this is a spontaneous payment, the payer generated their own preimage rather than us
54 /// (the payee) providing a preimage.
56 crate::c_types::ThirtyTwoBytes),
58 use lightning::util::events::PaymentPurpose as PaymentPurposeImport;
59 pub(crate) type nativePaymentPurpose = PaymentPurposeImport;
63 pub(crate) fn to_native(&self) -> nativePaymentPurpose {
65 PaymentPurpose::InvoicePayment {ref payment_preimage, ref payment_secret, } => {
66 let mut payment_preimage_nonref = (*payment_preimage).clone();
67 let mut local_payment_preimage_nonref = if payment_preimage_nonref.data == [0; 32] { None } else { Some( { ::lightning::ln::PaymentPreimage(payment_preimage_nonref.data) }) };
68 let mut payment_secret_nonref = (*payment_secret).clone();
69 nativePaymentPurpose::InvoicePayment {
70 payment_preimage: local_payment_preimage_nonref,
71 payment_secret: ::lightning::ln::PaymentSecret(payment_secret_nonref.data),
74 PaymentPurpose::SpontaneousPayment (ref a, ) => {
75 let mut a_nonref = (*a).clone();
76 nativePaymentPurpose::SpontaneousPayment (
77 ::lightning::ln::PaymentPreimage(a_nonref.data),
83 pub(crate) fn into_native(self) -> nativePaymentPurpose {
85 PaymentPurpose::InvoicePayment {mut payment_preimage, mut payment_secret, } => {
86 let mut local_payment_preimage = if payment_preimage.data == [0; 32] { None } else { Some( { ::lightning::ln::PaymentPreimage(payment_preimage.data) }) };
87 nativePaymentPurpose::InvoicePayment {
88 payment_preimage: local_payment_preimage,
89 payment_secret: ::lightning::ln::PaymentSecret(payment_secret.data),
92 PaymentPurpose::SpontaneousPayment (mut a, ) => {
93 nativePaymentPurpose::SpontaneousPayment (
94 ::lightning::ln::PaymentPreimage(a.data),
100 pub(crate) fn from_native(native: &nativePaymentPurpose) -> Self {
102 nativePaymentPurpose::InvoicePayment {ref payment_preimage, ref payment_secret, } => {
103 let mut payment_preimage_nonref = (*payment_preimage).clone();
104 let mut local_payment_preimage_nonref = if payment_preimage_nonref.is_none() { crate::c_types::ThirtyTwoBytes::null() } else { { crate::c_types::ThirtyTwoBytes { data: (payment_preimage_nonref.unwrap()).0 } } };
105 let mut payment_secret_nonref = (*payment_secret).clone();
106 PaymentPurpose::InvoicePayment {
107 payment_preimage: local_payment_preimage_nonref,
108 payment_secret: crate::c_types::ThirtyTwoBytes { data: payment_secret_nonref.0 },
111 nativePaymentPurpose::SpontaneousPayment (ref a, ) => {
112 let mut a_nonref = (*a).clone();
113 PaymentPurpose::SpontaneousPayment (
114 crate::c_types::ThirtyTwoBytes { data: a_nonref.0 },
120 pub(crate) fn native_into(native: nativePaymentPurpose) -> Self {
122 nativePaymentPurpose::InvoicePayment {mut payment_preimage, mut payment_secret, } => {
123 let mut local_payment_preimage = if payment_preimage.is_none() { crate::c_types::ThirtyTwoBytes::null() } else { { crate::c_types::ThirtyTwoBytes { data: (payment_preimage.unwrap()).0 } } };
124 PaymentPurpose::InvoicePayment {
125 payment_preimage: local_payment_preimage,
126 payment_secret: crate::c_types::ThirtyTwoBytes { data: payment_secret.0 },
129 nativePaymentPurpose::SpontaneousPayment (mut a, ) => {
130 PaymentPurpose::SpontaneousPayment (
131 crate::c_types::ThirtyTwoBytes { data: a.0 },
137 /// Frees any resources used by the PaymentPurpose
139 pub extern "C" fn PaymentPurpose_free(this_ptr: PaymentPurpose) { }
140 /// Creates a copy of the PaymentPurpose
142 pub extern "C" fn PaymentPurpose_clone(orig: &PaymentPurpose) -> PaymentPurpose {
146 /// Utility method to constructs a new InvoicePayment-variant PaymentPurpose
147 pub extern "C" fn PaymentPurpose_invoice_payment(payment_preimage: crate::c_types::ThirtyTwoBytes, payment_secret: crate::c_types::ThirtyTwoBytes) -> PaymentPurpose {
148 PaymentPurpose::InvoicePayment {
154 /// Utility method to constructs a new SpontaneousPayment-variant PaymentPurpose
155 pub extern "C" fn PaymentPurpose_spontaneous_payment(a: crate::c_types::ThirtyTwoBytes) -> PaymentPurpose {
156 PaymentPurpose::SpontaneousPayment(a, )
159 /// Serialize the PaymentPurpose object into a byte array which can be read by PaymentPurpose_read
160 pub extern "C" fn PaymentPurpose_write(obj: &crate::lightning::util::events::PaymentPurpose) -> crate::c_types::derived::CVec_u8Z {
161 crate::c_types::serialize_obj(&unsafe { &*obj }.to_native())
164 /// Read a PaymentPurpose from a byte array, created by PaymentPurpose_write
165 pub extern "C" fn PaymentPurpose_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_PaymentPurposeDecodeErrorZ {
166 let res: Result<lightning::util::events::PaymentPurpose, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
167 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() };
170 /// The reason the channel was closed. See individual variants more details.
174 pub enum ClosureReason {
175 /// Closure generated from receiving a peer error message.
177 /// Our counterparty may have broadcasted their latest commitment state, and we have
179 CounterpartyForceClosed {
180 /// The error which the peer sent us.
182 /// The string should be sanitized before it is used (e.g emitted to logs
183 /// or printed to stdout). Otherwise, a well crafted error message may exploit
184 /// a security vulnerability in the terminal emulator or the logging subsystem.
185 peer_msg: crate::c_types::Str,
187 /// Closure generated from [`ChannelManager::force_close_channel`], called by the user.
189 /// [`ChannelManager::force_close_channel`]: crate::ln::channelmanager::ChannelManager::force_close_channel.
191 /// The channel was closed after negotiating a cooperative close and we've now broadcasted
192 /// the cooperative close transaction. Note the shutdown may have been initiated by us.
194 /// A commitment transaction was confirmed on chain, closing the channel. Most likely this
195 /// commitment transaction came from our counterparty, but it may also have come from
196 /// a copy of our own `ChannelMonitor`.
197 CommitmentTxConfirmed,
198 /// The funding transaction failed to confirm in a timely manner on an inbound channel.
200 /// Closure generated from processing an event, likely a HTLC forward/relay/reception.
202 /// A developer-readable error message which we generated.
203 err: crate::c_types::Str,
205 /// The peer disconnected prior to funding completing. In this case the spec mandates that we
206 /// forget the channel entirely - we can attempt again if the peer reconnects.
208 /// This includes cases where we restarted prior to funding completion, including prior to the
209 /// initial [`ChannelMonitor`] persistence completing.
211 /// In LDK versions prior to 0.0.107 this could also occur if we were unable to connect to the
212 /// peer because of mutual incompatibility between us and our channel counterparty.
214 /// [`ChannelMonitor`]: crate::chain::channelmonitor::ChannelMonitor
216 /// Closure generated from `ChannelManager::read` if the [`ChannelMonitor`] is newer than
217 /// the [`ChannelManager`] deserialized.
219 /// [`ChannelMonitor`]: crate::chain::channelmonitor::ChannelMonitor
220 /// [`ChannelManager`]: crate::ln::channelmanager::ChannelManager
221 OutdatedChannelManager,
223 use lightning::util::events::ClosureReason as ClosureReasonImport;
224 pub(crate) type nativeClosureReason = ClosureReasonImport;
228 pub(crate) fn to_native(&self) -> nativeClosureReason {
230 ClosureReason::CounterpartyForceClosed {ref peer_msg, } => {
231 let mut peer_msg_nonref = (*peer_msg).clone();
232 nativeClosureReason::CounterpartyForceClosed {
233 peer_msg: peer_msg_nonref.into_string(),
236 ClosureReason::HolderForceClosed => nativeClosureReason::HolderForceClosed,
237 ClosureReason::CooperativeClosure => nativeClosureReason::CooperativeClosure,
238 ClosureReason::CommitmentTxConfirmed => nativeClosureReason::CommitmentTxConfirmed,
239 ClosureReason::FundingTimedOut => nativeClosureReason::FundingTimedOut,
240 ClosureReason::ProcessingError {ref err, } => {
241 let mut err_nonref = (*err).clone();
242 nativeClosureReason::ProcessingError {
243 err: err_nonref.into_string(),
246 ClosureReason::DisconnectedPeer => nativeClosureReason::DisconnectedPeer,
247 ClosureReason::OutdatedChannelManager => nativeClosureReason::OutdatedChannelManager,
251 pub(crate) fn into_native(self) -> nativeClosureReason {
253 ClosureReason::CounterpartyForceClosed {mut peer_msg, } => {
254 nativeClosureReason::CounterpartyForceClosed {
255 peer_msg: peer_msg.into_string(),
258 ClosureReason::HolderForceClosed => nativeClosureReason::HolderForceClosed,
259 ClosureReason::CooperativeClosure => nativeClosureReason::CooperativeClosure,
260 ClosureReason::CommitmentTxConfirmed => nativeClosureReason::CommitmentTxConfirmed,
261 ClosureReason::FundingTimedOut => nativeClosureReason::FundingTimedOut,
262 ClosureReason::ProcessingError {mut err, } => {
263 nativeClosureReason::ProcessingError {
264 err: err.into_string(),
267 ClosureReason::DisconnectedPeer => nativeClosureReason::DisconnectedPeer,
268 ClosureReason::OutdatedChannelManager => nativeClosureReason::OutdatedChannelManager,
272 pub(crate) fn from_native(native: &nativeClosureReason) -> Self {
274 nativeClosureReason::CounterpartyForceClosed {ref peer_msg, } => {
275 let mut peer_msg_nonref = (*peer_msg).clone();
276 ClosureReason::CounterpartyForceClosed {
277 peer_msg: peer_msg_nonref.into(),
280 nativeClosureReason::HolderForceClosed => ClosureReason::HolderForceClosed,
281 nativeClosureReason::CooperativeClosure => ClosureReason::CooperativeClosure,
282 nativeClosureReason::CommitmentTxConfirmed => ClosureReason::CommitmentTxConfirmed,
283 nativeClosureReason::FundingTimedOut => ClosureReason::FundingTimedOut,
284 nativeClosureReason::ProcessingError {ref err, } => {
285 let mut err_nonref = (*err).clone();
286 ClosureReason::ProcessingError {
287 err: err_nonref.into(),
290 nativeClosureReason::DisconnectedPeer => ClosureReason::DisconnectedPeer,
291 nativeClosureReason::OutdatedChannelManager => ClosureReason::OutdatedChannelManager,
295 pub(crate) fn native_into(native: nativeClosureReason) -> Self {
297 nativeClosureReason::CounterpartyForceClosed {mut peer_msg, } => {
298 ClosureReason::CounterpartyForceClosed {
299 peer_msg: peer_msg.into(),
302 nativeClosureReason::HolderForceClosed => ClosureReason::HolderForceClosed,
303 nativeClosureReason::CooperativeClosure => ClosureReason::CooperativeClosure,
304 nativeClosureReason::CommitmentTxConfirmed => ClosureReason::CommitmentTxConfirmed,
305 nativeClosureReason::FundingTimedOut => ClosureReason::FundingTimedOut,
306 nativeClosureReason::ProcessingError {mut err, } => {
307 ClosureReason::ProcessingError {
311 nativeClosureReason::DisconnectedPeer => ClosureReason::DisconnectedPeer,
312 nativeClosureReason::OutdatedChannelManager => ClosureReason::OutdatedChannelManager,
316 /// Frees any resources used by the ClosureReason
318 pub extern "C" fn ClosureReason_free(this_ptr: ClosureReason) { }
319 /// Creates a copy of the ClosureReason
321 pub extern "C" fn ClosureReason_clone(orig: &ClosureReason) -> ClosureReason {
325 /// Utility method to constructs a new CounterpartyForceClosed-variant ClosureReason
326 pub extern "C" fn ClosureReason_counterparty_force_closed(peer_msg: crate::c_types::Str) -> ClosureReason {
327 ClosureReason::CounterpartyForceClosed {
332 /// Utility method to constructs a new HolderForceClosed-variant ClosureReason
333 pub extern "C" fn ClosureReason_holder_force_closed() -> ClosureReason {
334 ClosureReason::HolderForceClosed}
336 /// Utility method to constructs a new CooperativeClosure-variant ClosureReason
337 pub extern "C" fn ClosureReason_cooperative_closure() -> ClosureReason {
338 ClosureReason::CooperativeClosure}
340 /// Utility method to constructs a new CommitmentTxConfirmed-variant ClosureReason
341 pub extern "C" fn ClosureReason_commitment_tx_confirmed() -> ClosureReason {
342 ClosureReason::CommitmentTxConfirmed}
344 /// Utility method to constructs a new FundingTimedOut-variant ClosureReason
345 pub extern "C" fn ClosureReason_funding_timed_out() -> ClosureReason {
346 ClosureReason::FundingTimedOut}
348 /// Utility method to constructs a new ProcessingError-variant ClosureReason
349 pub extern "C" fn ClosureReason_processing_error(err: crate::c_types::Str) -> ClosureReason {
350 ClosureReason::ProcessingError {
355 /// Utility method to constructs a new DisconnectedPeer-variant ClosureReason
356 pub extern "C" fn ClosureReason_disconnected_peer() -> ClosureReason {
357 ClosureReason::DisconnectedPeer}
359 /// Utility method to constructs a new OutdatedChannelManager-variant ClosureReason
360 pub extern "C" fn ClosureReason_outdated_channel_manager() -> ClosureReason {
361 ClosureReason::OutdatedChannelManager}
362 /// Checks if two ClosureReasons contain equal inner contents.
363 /// This ignores pointers and is_owned flags and looks at the values in fields.
365 pub extern "C" fn ClosureReason_eq(a: &ClosureReason, b: &ClosureReason) -> bool {
366 if &a.to_native() == &b.to_native() { true } else { false }
369 /// Serialize the ClosureReason object into a byte array which can be read by ClosureReason_read
370 pub extern "C" fn ClosureReason_write(obj: &crate::lightning::util::events::ClosureReason) -> crate::c_types::derived::CVec_u8Z {
371 crate::c_types::serialize_obj(&unsafe { &*obj }.to_native())
374 /// Read a ClosureReason from a byte array, created by ClosureReason_write
375 pub extern "C" fn ClosureReason_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_COption_ClosureReasonZDecodeErrorZ {
376 let res: Result<Option<lightning::util::events::ClosureReason>, lightning::ln::msgs::DecodeError> = crate::c_types::maybe_deserialize_obj(ser);
377 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() };
380 /// Intended destination of a failed HTLC as indicated in [`Event::HTLCHandlingFailed`].
384 pub enum HTLCDestination {
385 /// We tried forwarding to a channel but failed to do so. An example of such an instance is when
386 /// there is insufficient capacity in our outbound channel.
388 /// The `node_id` of the next node. For backwards compatibility, this field is
389 /// marked as optional, versions prior to 0.0.110 may not always be able to provide
390 /// counterparty node information.
392 /// Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None
393 node_id: crate::c_types::PublicKey,
394 /// The outgoing `channel_id` between us and the next node.
395 channel_id: crate::c_types::ThirtyTwoBytes,
397 /// Scenario where we are unsure of the next node to forward the HTLC to.
399 /// Short channel id we are requesting to forward an HTLC to.
400 requested_forward_scid: u64,
402 /// Failure scenario where an HTLC may have been forwarded to be intended for us,
403 /// but is invalid for some reason, so we reject it.
405 /// Some of the reasons may include:
407 /// * Expected MPP amount to claim does not equal HTLC total
408 /// * Claimable amount does not match expected amount
410 /// The payment hash of the payment we attempted to process.
411 payment_hash: crate::c_types::ThirtyTwoBytes,
414 use lightning::util::events::HTLCDestination as HTLCDestinationImport;
415 pub(crate) type nativeHTLCDestination = HTLCDestinationImport;
417 impl HTLCDestination {
419 pub(crate) fn to_native(&self) -> nativeHTLCDestination {
421 HTLCDestination::NextHopChannel {ref node_id, ref channel_id, } => {
422 let mut node_id_nonref = (*node_id).clone();
423 let mut local_node_id_nonref = if node_id_nonref.is_null() { None } else { Some( { node_id_nonref.into_rust() }) };
424 let mut channel_id_nonref = (*channel_id).clone();
425 nativeHTLCDestination::NextHopChannel {
426 node_id: local_node_id_nonref,
427 channel_id: channel_id_nonref.data,
430 HTLCDestination::UnknownNextHop {ref requested_forward_scid, } => {
431 let mut requested_forward_scid_nonref = (*requested_forward_scid).clone();
432 nativeHTLCDestination::UnknownNextHop {
433 requested_forward_scid: requested_forward_scid_nonref,
436 HTLCDestination::FailedPayment {ref payment_hash, } => {
437 let mut payment_hash_nonref = (*payment_hash).clone();
438 nativeHTLCDestination::FailedPayment {
439 payment_hash: ::lightning::ln::PaymentHash(payment_hash_nonref.data),
445 pub(crate) fn into_native(self) -> nativeHTLCDestination {
447 HTLCDestination::NextHopChannel {mut node_id, mut channel_id, } => {
448 let mut local_node_id = if node_id.is_null() { None } else { Some( { node_id.into_rust() }) };
449 nativeHTLCDestination::NextHopChannel {
450 node_id: local_node_id,
451 channel_id: channel_id.data,
454 HTLCDestination::UnknownNextHop {mut requested_forward_scid, } => {
455 nativeHTLCDestination::UnknownNextHop {
456 requested_forward_scid: requested_forward_scid,
459 HTLCDestination::FailedPayment {mut payment_hash, } => {
460 nativeHTLCDestination::FailedPayment {
461 payment_hash: ::lightning::ln::PaymentHash(payment_hash.data),
467 pub(crate) fn from_native(native: &nativeHTLCDestination) -> Self {
469 nativeHTLCDestination::NextHopChannel {ref node_id, ref channel_id, } => {
470 let mut node_id_nonref = (*node_id).clone();
471 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())) } };
472 let mut channel_id_nonref = (*channel_id).clone();
473 HTLCDestination::NextHopChannel {
474 node_id: local_node_id_nonref,
475 channel_id: crate::c_types::ThirtyTwoBytes { data: channel_id_nonref },
478 nativeHTLCDestination::UnknownNextHop {ref requested_forward_scid, } => {
479 let mut requested_forward_scid_nonref = (*requested_forward_scid).clone();
480 HTLCDestination::UnknownNextHop {
481 requested_forward_scid: requested_forward_scid_nonref,
484 nativeHTLCDestination::FailedPayment {ref payment_hash, } => {
485 let mut payment_hash_nonref = (*payment_hash).clone();
486 HTLCDestination::FailedPayment {
487 payment_hash: crate::c_types::ThirtyTwoBytes { data: payment_hash_nonref.0 },
493 pub(crate) fn native_into(native: nativeHTLCDestination) -> Self {
495 nativeHTLCDestination::NextHopChannel {mut node_id, mut channel_id, } => {
496 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())) } };
497 HTLCDestination::NextHopChannel {
498 node_id: local_node_id,
499 channel_id: crate::c_types::ThirtyTwoBytes { data: channel_id },
502 nativeHTLCDestination::UnknownNextHop {mut requested_forward_scid, } => {
503 HTLCDestination::UnknownNextHop {
504 requested_forward_scid: requested_forward_scid,
507 nativeHTLCDestination::FailedPayment {mut payment_hash, } => {
508 HTLCDestination::FailedPayment {
509 payment_hash: crate::c_types::ThirtyTwoBytes { data: payment_hash.0 },
515 /// Frees any resources used by the HTLCDestination
517 pub extern "C" fn HTLCDestination_free(this_ptr: HTLCDestination) { }
518 /// Creates a copy of the HTLCDestination
520 pub extern "C" fn HTLCDestination_clone(orig: &HTLCDestination) -> HTLCDestination {
524 /// Utility method to constructs a new NextHopChannel-variant HTLCDestination
525 pub extern "C" fn HTLCDestination_next_hop_channel(node_id: crate::c_types::PublicKey, channel_id: crate::c_types::ThirtyTwoBytes) -> HTLCDestination {
526 HTLCDestination::NextHopChannel {
532 /// Utility method to constructs a new UnknownNextHop-variant HTLCDestination
533 pub extern "C" fn HTLCDestination_unknown_next_hop(requested_forward_scid: u64) -> HTLCDestination {
534 HTLCDestination::UnknownNextHop {
535 requested_forward_scid,
539 /// Utility method to constructs a new FailedPayment-variant HTLCDestination
540 pub extern "C" fn HTLCDestination_failed_payment(payment_hash: crate::c_types::ThirtyTwoBytes) -> HTLCDestination {
541 HTLCDestination::FailedPayment {
545 /// Checks if two HTLCDestinations contain equal inner contents.
546 /// This ignores pointers and is_owned flags and looks at the values in fields.
548 pub extern "C" fn HTLCDestination_eq(a: &HTLCDestination, b: &HTLCDestination) -> bool {
549 if &a.to_native() == &b.to_native() { true } else { false }
552 /// Serialize the HTLCDestination object into a byte array which can be read by HTLCDestination_read
553 pub extern "C" fn HTLCDestination_write(obj: &crate::lightning::util::events::HTLCDestination) -> crate::c_types::derived::CVec_u8Z {
554 crate::c_types::serialize_obj(&unsafe { &*obj }.to_native())
557 /// Read a HTLCDestination from a byte array, created by HTLCDestination_write
558 pub extern "C" fn HTLCDestination_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_COption_HTLCDestinationZDecodeErrorZ {
559 let res: Result<Option<lightning::util::events::HTLCDestination>, lightning::ln::msgs::DecodeError> = crate::c_types::maybe_deserialize_obj(ser);
560 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() };
563 /// An Event which you should probably take some action in response to.
565 /// Note that while Writeable and Readable are implemented for Event, you probably shouldn't use
566 /// them directly as they don't round-trip exactly (for example FundingGenerationReady is never
567 /// written as it makes no sense to respond to it after reconnecting to peers).
572 /// Used to indicate that the client should generate a funding transaction with the given
573 /// parameters and then call [`ChannelManager::funding_transaction_generated`].
574 /// Generated in [`ChannelManager`] message handling.
575 /// Note that *all inputs* in the funding transaction must spend SegWit outputs or your
576 /// counterparty can steal your funds!
578 /// [`ChannelManager`]: crate::ln::channelmanager::ChannelManager
579 /// [`ChannelManager::funding_transaction_generated`]: crate::ln::channelmanager::ChannelManager::funding_transaction_generated
580 FundingGenerationReady {
581 /// The random channel_id we picked which you'll need to pass into
582 /// [`ChannelManager::funding_transaction_generated`].
584 /// [`ChannelManager::funding_transaction_generated`]: crate::ln::channelmanager::ChannelManager::funding_transaction_generated
585 temporary_channel_id: crate::c_types::ThirtyTwoBytes,
586 /// The counterparty's node_id, which you'll need to pass back into
587 /// [`ChannelManager::funding_transaction_generated`].
589 /// [`ChannelManager::funding_transaction_generated`]: crate::ln::channelmanager::ChannelManager::funding_transaction_generated
590 counterparty_node_id: crate::c_types::PublicKey,
591 /// The value, in satoshis, that the output should have.
592 channel_value_satoshis: u64,
593 /// The script which should be used in the transaction output.
594 output_script: crate::c_types::derived::CVec_u8Z,
595 /// The `user_channel_id` value passed in to [`ChannelManager::create_channel`], or 0 for
596 /// an inbound channel.
598 /// [`ChannelManager::create_channel`]: crate::ln::channelmanager::ChannelManager::create_channel
599 user_channel_id: u64,
601 /// Indicates we've received (an offer of) money! Just gotta dig out that payment preimage and
602 /// feed it to [`ChannelManager::claim_funds`] to get it....
604 /// Note that if the preimage is not known, you should call
605 /// [`ChannelManager::fail_htlc_backwards`] to free up resources for this HTLC and avoid
606 /// network congestion.
607 /// If you fail to call either [`ChannelManager::claim_funds`] or
608 /// [`ChannelManager::fail_htlc_backwards`] within the HTLC's timeout, the HTLC will be
609 /// automatically failed.
612 /// LDK will not stop an inbound payment from being paid multiple times, so multiple
613 /// `PaymentReceived` events may be generated for the same payment.
615 /// [`ChannelManager::claim_funds`]: crate::ln::channelmanager::ChannelManager::claim_funds
616 /// [`ChannelManager::fail_htlc_backwards`]: crate::ln::channelmanager::ChannelManager::fail_htlc_backwards
618 /// The hash for which the preimage should be handed to the ChannelManager. Note that LDK will
619 /// not stop you from registering duplicate payment hashes for inbound payments.
620 payment_hash: crate::c_types::ThirtyTwoBytes,
621 /// The value, in thousandths of a satoshi, that this payment is for.
623 /// Information for claiming this received payment, based on whether the purpose of the
624 /// payment is to pay an invoice or to send a spontaneous payment.
625 purpose: crate::lightning::util::events::PaymentPurpose,
627 /// Indicates a payment has been claimed and we've received money!
629 /// This most likely occurs when [`ChannelManager::claim_funds`] has been called in response
630 /// to an [`Event::PaymentReceived`]. However, if we previously crashed during a
631 /// [`ChannelManager::claim_funds`] call you may see this event without a corresponding
632 /// [`Event::PaymentReceived`] event.
635 /// LDK will not stop an inbound payment from being paid multiple times, so multiple
636 /// `PaymentReceived` events may be generated for the same payment. If you then call
637 /// [`ChannelManager::claim_funds`] twice for the same [`Event::PaymentReceived`] you may get
638 /// multiple `PaymentClaimed` events.
640 /// [`ChannelManager::claim_funds`]: crate::ln::channelmanager::ChannelManager::claim_funds
642 /// The payment hash of the claimed payment. Note that LDK will not stop you from
643 /// registering duplicate payment hashes for inbound payments.
644 payment_hash: crate::c_types::ThirtyTwoBytes,
645 /// The value, in thousandths of a satoshi, that this payment is for.
647 /// The purpose of this claimed payment, i.e. whether the payment was for an invoice or a
648 /// spontaneous payment.
649 purpose: crate::lightning::util::events::PaymentPurpose,
651 /// Indicates an outbound payment we made succeeded (i.e. it made it all the way to its target
652 /// and we got back the payment preimage for it).
654 /// Note for MPP payments: in rare cases, this event may be preceded by a `PaymentPathFailed`
655 /// event. In this situation, you SHOULD treat this payment as having succeeded.
657 /// The id returned by [`ChannelManager::send_payment`] and used with
658 /// [`ChannelManager::retry_payment`].
660 /// [`ChannelManager::send_payment`]: crate::ln::channelmanager::ChannelManager::send_payment
661 /// [`ChannelManager::retry_payment`]: crate::ln::channelmanager::ChannelManager::retry_payment
663 /// Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None
664 payment_id: crate::c_types::ThirtyTwoBytes,
665 /// The preimage to the hash given to ChannelManager::send_payment.
666 /// Note that this serves as a payment receipt, if you wish to have such a thing, you must
667 /// store it somehow!
668 payment_preimage: crate::c_types::ThirtyTwoBytes,
669 /// The hash that was given to [`ChannelManager::send_payment`].
671 /// [`ChannelManager::send_payment`]: crate::ln::channelmanager::ChannelManager::send_payment
672 payment_hash: crate::c_types::ThirtyTwoBytes,
673 /// The total fee which was spent at intermediate hops in this payment, across all paths.
675 /// Note that, like [`Route::get_total_fees`] this does *not* include any potential
676 /// overpayment to the recipient node.
678 /// If the recipient or an intermediate node misbehaves and gives us free money, this may
679 /// overstate the amount paid, though this is unlikely.
681 /// [`Route::get_total_fees`]: crate::routing::router::Route::get_total_fees
682 fee_paid_msat: crate::c_types::derived::COption_u64Z,
684 /// Indicates an outbound payment failed. Individual [`Event::PaymentPathFailed`] events
685 /// provide failure information for each MPP part in the payment.
687 /// This event is provided once there are no further pending HTLCs for the payment and the
688 /// payment is no longer retryable, either due to a several-block timeout or because
689 /// [`ChannelManager::abandon_payment`] was previously called for the corresponding payment.
691 /// [`ChannelManager::abandon_payment`]: crate::ln::channelmanager::ChannelManager::abandon_payment
693 /// The id returned by [`ChannelManager::send_payment`] and used with
694 /// [`ChannelManager::retry_payment`] and [`ChannelManager::abandon_payment`].
696 /// [`ChannelManager::send_payment`]: crate::ln::channelmanager::ChannelManager::send_payment
697 /// [`ChannelManager::retry_payment`]: crate::ln::channelmanager::ChannelManager::retry_payment
698 /// [`ChannelManager::abandon_payment`]: crate::ln::channelmanager::ChannelManager::abandon_payment
699 payment_id: crate::c_types::ThirtyTwoBytes,
700 /// The hash that was given to [`ChannelManager::send_payment`].
702 /// [`ChannelManager::send_payment`]: crate::ln::channelmanager::ChannelManager::send_payment
703 payment_hash: crate::c_types::ThirtyTwoBytes,
705 /// Indicates that a path for an outbound payment was successful.
707 /// Always generated after [`Event::PaymentSent`] and thus useful for scoring channels. See
708 /// [`Event::PaymentSent`] for obtaining the payment preimage.
709 PaymentPathSuccessful {
710 /// The id returned by [`ChannelManager::send_payment`] and used with
711 /// [`ChannelManager::retry_payment`].
713 /// [`ChannelManager::send_payment`]: crate::ln::channelmanager::ChannelManager::send_payment
714 /// [`ChannelManager::retry_payment`]: crate::ln::channelmanager::ChannelManager::retry_payment
715 payment_id: crate::c_types::ThirtyTwoBytes,
716 /// The hash that was given to [`ChannelManager::send_payment`].
718 /// [`ChannelManager::send_payment`]: crate::ln::channelmanager::ChannelManager::send_payment
720 /// Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None
721 payment_hash: crate::c_types::ThirtyTwoBytes,
722 /// The payment path that was successful.
724 /// May contain a closed channel if the HTLC sent along the path was fulfilled on chain.
725 path: crate::c_types::derived::CVec_RouteHopZ,
727 /// Indicates an outbound HTLC we sent failed. Probably some intermediary node dropped
728 /// something. You may wish to retry with a different route.
730 /// Note that this does *not* indicate that all paths for an MPP payment have failed, see
731 /// [`Event::PaymentFailed`] and [`all_paths_failed`].
733 /// [`all_paths_failed`]: Self::PaymentPathFailed::all_paths_failed
735 /// The id returned by [`ChannelManager::send_payment`] and used with
736 /// [`ChannelManager::retry_payment`] and [`ChannelManager::abandon_payment`].
738 /// [`ChannelManager::send_payment`]: crate::ln::channelmanager::ChannelManager::send_payment
739 /// [`ChannelManager::retry_payment`]: crate::ln::channelmanager::ChannelManager::retry_payment
740 /// [`ChannelManager::abandon_payment`]: crate::ln::channelmanager::ChannelManager::abandon_payment
742 /// Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None
743 payment_id: crate::c_types::ThirtyTwoBytes,
744 /// The hash that was given to [`ChannelManager::send_payment`].
746 /// [`ChannelManager::send_payment`]: crate::ln::channelmanager::ChannelManager::send_payment
747 payment_hash: crate::c_types::ThirtyTwoBytes,
748 /// Indicates the payment was rejected for some reason by the recipient. This implies that
749 /// the payment has failed, not just the route in question. If this is not set, you may
750 /// retry the payment via a different route.
751 payment_failed_permanently: bool,
752 /// Any failure information conveyed via the Onion return packet by a node along the failed
755 /// Should be applied to the [`NetworkGraph`] so that routing decisions can take into
756 /// account the update.
758 /// [`NetworkGraph`]: crate::routing::gossip::NetworkGraph
759 network_update: crate::c_types::derived::COption_NetworkUpdateZ,
760 /// For both single-path and multi-path payments, this is set if all paths of the payment have
761 /// failed. This will be set to false if (1) this is an MPP payment and (2) other parts of the
762 /// larger MPP payment were still in flight when this event was generated.
764 /// Note that if you are retrying individual MPP parts, using this value to determine if a
765 /// payment has fully failed is race-y. Because multiple failures can happen prior to events
766 /// being processed, you may retry in response to a first failure, with a second failure
767 /// (with `all_paths_failed` set) still pending. Then, when the second failure is processed
768 /// you will see `all_paths_failed` set even though the retry of the first failure still
769 /// has an associated in-flight HTLC. See (1) for an example of such a failure.
771 /// If you wish to retry individual MPP parts and learn when a payment has failed, you must
772 /// call [`ChannelManager::abandon_payment`] and wait for a [`Event::PaymentFailed`] event.
774 /// (1) <https://github.com/lightningdevkit/rust-lightning/issues/1164>
776 /// [`ChannelManager::abandon_payment`]: crate::ln::channelmanager::ChannelManager::abandon_payment
777 all_paths_failed: bool,
778 /// The payment path that failed.
779 path: crate::c_types::derived::CVec_RouteHopZ,
780 /// The channel responsible for the failed payment path.
782 /// Note that for route hints or for the first hop in a path this may be an SCID alias and
783 /// may not refer to a channel in the public network graph. These aliases may also collide
784 /// with channels in the public network graph.
786 /// If this is `Some`, then the corresponding channel should be avoided when the payment is
787 /// retried. May be `None` for older [`Event`] serializations.
788 short_channel_id: crate::c_types::derived::COption_u64Z,
789 /// Parameters needed to compute a new [`Route`] when retrying the failed payment path.
791 /// See [`find_route`] for details.
793 /// [`Route`]: crate::routing::router::Route
794 /// [`find_route`]: crate::routing::router::find_route
796 /// Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None
797 retry: crate::lightning::routing::router::RouteParameters,
799 /// Indicates that a probe payment we sent returned successful, i.e., only failed at the destination.
801 /// The id returned by [`ChannelManager::send_probe`].
803 /// [`ChannelManager::send_probe`]: crate::ln::channelmanager::ChannelManager::send_probe
804 payment_id: crate::c_types::ThirtyTwoBytes,
805 /// The hash generated by [`ChannelManager::send_probe`].
807 /// [`ChannelManager::send_probe`]: crate::ln::channelmanager::ChannelManager::send_probe
808 payment_hash: crate::c_types::ThirtyTwoBytes,
809 /// The payment path that was successful.
810 path: crate::c_types::derived::CVec_RouteHopZ,
812 /// Indicates that a probe payment we sent failed at an intermediary node on the path.
814 /// The id returned by [`ChannelManager::send_probe`].
816 /// [`ChannelManager::send_probe`]: crate::ln::channelmanager::ChannelManager::send_probe
817 payment_id: crate::c_types::ThirtyTwoBytes,
818 /// The hash generated by [`ChannelManager::send_probe`].
820 /// [`ChannelManager::send_probe`]: crate::ln::channelmanager::ChannelManager::send_probe
821 payment_hash: crate::c_types::ThirtyTwoBytes,
822 /// The payment path that failed.
823 path: crate::c_types::derived::CVec_RouteHopZ,
824 /// The channel responsible for the failed probe.
826 /// Note that for route hints or for the first hop in a path this may be an SCID alias and
827 /// may not refer to a channel in the public network graph. These aliases may also collide
828 /// with channels in the public network graph.
829 short_channel_id: crate::c_types::derived::COption_u64Z,
831 /// Used to indicate that [`ChannelManager::process_pending_htlc_forwards`] should be called at
832 /// a time in the future.
834 /// [`ChannelManager::process_pending_htlc_forwards`]: crate::ln::channelmanager::ChannelManager::process_pending_htlc_forwards
835 PendingHTLCsForwardable {
836 /// The minimum amount of time that should be waited prior to calling
837 /// process_pending_htlc_forwards. To increase the effort required to correlate payments,
838 /// you should wait a random amount of time in roughly the range (now + time_forwardable,
839 /// now + 5*time_forwardable).
840 time_forwardable: u64,
842 /// Used to indicate that an output which you should know how to spend was confirmed on chain
843 /// and is now spendable.
844 /// Such an output will *not* ever be spent by rust-lightning, and are not at risk of your
845 /// counterparty spending them due to some kind of timeout. Thus, you need to store them
846 /// somewhere and spend them when you create on-chain transactions.
848 /// The outputs which you should store as spendable by you.
849 outputs: crate::c_types::derived::CVec_SpendableOutputDescriptorZ,
851 /// This event is generated when a payment has been successfully forwarded through us and a
852 /// forwarding fee earned.
854 /// The incoming channel between the previous node and us. This is only `None` for events
855 /// generated or serialized by versions prior to 0.0.107.
857 /// Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None
858 prev_channel_id: crate::c_types::ThirtyTwoBytes,
859 /// The outgoing channel between the next node and us. This is only `None` for events
860 /// generated or serialized by versions prior to 0.0.107.
862 /// Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None
863 next_channel_id: crate::c_types::ThirtyTwoBytes,
864 /// The fee, in milli-satoshis, which was earned as a result of the payment.
866 /// Note that if we force-closed the channel over which we forwarded an HTLC while the HTLC
867 /// was pending, the amount the next hop claimed will have been rounded down to the nearest
868 /// whole satoshi. Thus, the fee calculated here may be higher than expected as we still
869 /// claimed the full value in millisatoshis from the source. In this case,
870 /// `claim_from_onchain_tx` will be set.
872 /// If the channel which sent us the payment has been force-closed, we will claim the funds
873 /// via an on-chain transaction. In that case we do not yet know the on-chain transaction
874 /// fees which we will spend and will instead set this to `None`. It is possible duplicate
875 /// `PaymentForwarded` events are generated for the same payment iff `fee_earned_msat` is
877 fee_earned_msat: crate::c_types::derived::COption_u64Z,
878 /// If this is `true`, the forwarded HTLC was claimed by our counterparty via an on-chain
880 claim_from_onchain_tx: bool,
882 /// Used to indicate that a previously opened channel with the given `channel_id` is in the
883 /// process of closure.
885 /// The channel_id of the channel which has been closed. Note that on-chain transactions
886 /// resolving the channel are likely still awaiting confirmation.
887 channel_id: crate::c_types::ThirtyTwoBytes,
888 /// The `user_channel_id` value passed in to [`ChannelManager::create_channel`] for outbound
889 /// channels, or to [`ChannelManager::accept_inbound_channel`] for inbound channels if
890 /// [`UserConfig::manually_accept_inbound_channels`] config flag is set to true. Otherwise
891 /// `user_channel_id` will be 0 for an inbound channel.
892 /// This will always be zero for objects serialized with LDK versions prior to 0.0.102.
894 /// [`ChannelManager::create_channel`]: crate::ln::channelmanager::ChannelManager::create_channel
895 /// [`ChannelManager::accept_inbound_channel`]: crate::ln::channelmanager::ChannelManager::accept_inbound_channel
896 /// [`UserConfig::manually_accept_inbound_channels`]: crate::util::config::UserConfig::manually_accept_inbound_channels
897 user_channel_id: u64,
898 /// The reason the channel was closed.
899 reason: crate::lightning::util::events::ClosureReason,
901 /// Used to indicate to the user that they can abandon the funding transaction and recycle the
902 /// inputs for another purpose.
904 /// The channel_id of the channel which has been closed.
905 channel_id: crate::c_types::ThirtyTwoBytes,
906 /// The full transaction received from the user
907 transaction: crate::c_types::Transaction,
909 /// Indicates a request to open a new channel by a peer.
911 /// To accept the request, call [`ChannelManager::accept_inbound_channel`]. To reject the
912 /// request, call [`ChannelManager::force_close_without_broadcasting_txn`].
914 /// The event is only triggered when a new open channel request is received and the
915 /// [`UserConfig::manually_accept_inbound_channels`] config flag is set to true.
917 /// [`ChannelManager::accept_inbound_channel`]: crate::ln::channelmanager::ChannelManager::accept_inbound_channel
918 /// [`ChannelManager::force_close_without_broadcasting_txn`]: crate::ln::channelmanager::ChannelManager::force_close_without_broadcasting_txn
919 /// [`UserConfig::manually_accept_inbound_channels`]: crate::util::config::UserConfig::manually_accept_inbound_channels
921 /// The temporary channel ID of the channel requested to be opened.
923 /// When responding to the request, the `temporary_channel_id` should be passed
924 /// back to the ChannelManager through [`ChannelManager::accept_inbound_channel`] to accept,
925 /// or through [`ChannelManager::force_close_without_broadcasting_txn`] to reject.
927 /// [`ChannelManager::accept_inbound_channel`]: crate::ln::channelmanager::ChannelManager::accept_inbound_channel
928 /// [`ChannelManager::force_close_without_broadcasting_txn`]: crate::ln::channelmanager::ChannelManager::force_close_without_broadcasting_txn
929 temporary_channel_id: crate::c_types::ThirtyTwoBytes,
930 /// The node_id of the counterparty requesting to open the channel.
932 /// When responding to the request, the `counterparty_node_id` should be passed
933 /// back to the `ChannelManager` through [`ChannelManager::accept_inbound_channel`] to
934 /// accept the request, or through [`ChannelManager::force_close_without_broadcasting_txn`] to reject the
937 /// [`ChannelManager::accept_inbound_channel`]: crate::ln::channelmanager::ChannelManager::accept_inbound_channel
938 /// [`ChannelManager::force_close_without_broadcasting_txn`]: crate::ln::channelmanager::ChannelManager::force_close_without_broadcasting_txn
939 counterparty_node_id: crate::c_types::PublicKey,
940 /// The channel value of the requested channel.
941 funding_satoshis: u64,
942 /// Our starting balance in the channel if the request is accepted, in milli-satoshi.
944 /// The features that this channel will operate with. If you reject the channel, a
945 /// well-behaved counterparty may automatically re-attempt the channel with a new set of
948 /// Note that if [`ChannelTypeFeatures::supports_scid_privacy`] returns true on this type,
949 /// the resulting [`ChannelManager`] will not be readable by versions of LDK prior to
952 /// Furthermore, note that if [`ChannelTypeFeatures::supports_zero_conf`] returns true on this type,
953 /// the resulting [`ChannelManager`] will not be readable by versions of LDK prior to
954 /// 0.0.107. Channels setting this type also need to get manually accepted via
955 /// [`crate::ln::channelmanager::ChannelManager::accept_inbound_channel_from_trusted_peer_0conf`],
956 /// or will be rejected otherwise.
958 /// [`ChannelManager`]: crate::ln::channelmanager::ChannelManager
959 channel_type: crate::lightning::ln::features::ChannelTypeFeatures,
961 /// Indicates that the HTLC was accepted, but could not be processed when or after attempting to
964 /// Some scenarios where this event may be sent include:
965 /// * Insufficient capacity in the outbound channel
966 /// * While waiting to forward the HTLC, the channel it is meant to be forwarded through closes
967 /// * When an unknown SCID is requested for forwarding a payment.
968 /// * Claiming an amount for an MPP payment that exceeds the HTLC total
969 /// * The HTLC has timed out
971 /// This event, however, does not get generated if an HTLC fails to meet the forwarding
972 /// requirements (i.e. insufficient fees paid, or a CLTV that is too soon).
974 /// The channel over which the HTLC was received.
975 prev_channel_id: crate::c_types::ThirtyTwoBytes,
976 /// Destination of the HTLC that failed to be processed.
977 failed_next_destination: crate::lightning::util::events::HTLCDestination,
980 use lightning::util::events::Event as EventImport;
981 pub(crate) type nativeEvent = EventImport;
985 pub(crate) fn to_native(&self) -> nativeEvent {
987 Event::FundingGenerationReady {ref temporary_channel_id, ref counterparty_node_id, ref channel_value_satoshis, ref output_script, ref user_channel_id, } => {
988 let mut temporary_channel_id_nonref = (*temporary_channel_id).clone();
989 let mut counterparty_node_id_nonref = (*counterparty_node_id).clone();
990 let mut channel_value_satoshis_nonref = (*channel_value_satoshis).clone();
991 let mut output_script_nonref = (*output_script).clone();
992 let mut user_channel_id_nonref = (*user_channel_id).clone();
993 nativeEvent::FundingGenerationReady {
994 temporary_channel_id: temporary_channel_id_nonref.data,
995 counterparty_node_id: counterparty_node_id_nonref.into_rust(),
996 channel_value_satoshis: channel_value_satoshis_nonref,
997 output_script: ::bitcoin::blockdata::script::Script::from(output_script_nonref.into_rust()),
998 user_channel_id: user_channel_id_nonref,
1001 Event::PaymentReceived {ref payment_hash, ref amount_msat, ref purpose, } => {
1002 let mut payment_hash_nonref = (*payment_hash).clone();
1003 let mut amount_msat_nonref = (*amount_msat).clone();
1004 let mut purpose_nonref = (*purpose).clone();
1005 nativeEvent::PaymentReceived {
1006 payment_hash: ::lightning::ln::PaymentHash(payment_hash_nonref.data),
1007 amount_msat: amount_msat_nonref,
1008 purpose: purpose_nonref.into_native(),
1011 Event::PaymentClaimed {ref payment_hash, ref amount_msat, ref purpose, } => {
1012 let mut payment_hash_nonref = (*payment_hash).clone();
1013 let mut amount_msat_nonref = (*amount_msat).clone();
1014 let mut purpose_nonref = (*purpose).clone();
1015 nativeEvent::PaymentClaimed {
1016 payment_hash: ::lightning::ln::PaymentHash(payment_hash_nonref.data),
1017 amount_msat: amount_msat_nonref,
1018 purpose: purpose_nonref.into_native(),
1021 Event::PaymentSent {ref payment_id, ref payment_preimage, ref payment_hash, ref fee_paid_msat, } => {
1022 let mut payment_id_nonref = (*payment_id).clone();
1023 let mut local_payment_id_nonref = if payment_id_nonref.data == [0; 32] { None } else { Some( { ::lightning::ln::channelmanager::PaymentId(payment_id_nonref.data) }) };
1024 let mut payment_preimage_nonref = (*payment_preimage).clone();
1025 let mut payment_hash_nonref = (*payment_hash).clone();
1026 let mut fee_paid_msat_nonref = (*fee_paid_msat).clone();
1027 let mut local_fee_paid_msat_nonref = if fee_paid_msat_nonref.is_some() { Some( { fee_paid_msat_nonref.take() }) } else { None };
1028 nativeEvent::PaymentSent {
1029 payment_id: local_payment_id_nonref,
1030 payment_preimage: ::lightning::ln::PaymentPreimage(payment_preimage_nonref.data),
1031 payment_hash: ::lightning::ln::PaymentHash(payment_hash_nonref.data),
1032 fee_paid_msat: local_fee_paid_msat_nonref,
1035 Event::PaymentFailed {ref payment_id, ref payment_hash, } => {
1036 let mut payment_id_nonref = (*payment_id).clone();
1037 let mut payment_hash_nonref = (*payment_hash).clone();
1038 nativeEvent::PaymentFailed {
1039 payment_id: ::lightning::ln::channelmanager::PaymentId(payment_id_nonref.data),
1040 payment_hash: ::lightning::ln::PaymentHash(payment_hash_nonref.data),
1043 Event::PaymentPathSuccessful {ref payment_id, ref payment_hash, ref path, } => {
1044 let mut payment_id_nonref = (*payment_id).clone();
1045 let mut payment_hash_nonref = (*payment_hash).clone();
1046 let mut local_payment_hash_nonref = if payment_hash_nonref.data == [0; 32] { None } else { Some( { ::lightning::ln::PaymentHash(payment_hash_nonref.data) }) };
1047 let mut path_nonref = (*path).clone();
1048 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()) } }); };
1049 nativeEvent::PaymentPathSuccessful {
1050 payment_id: ::lightning::ln::channelmanager::PaymentId(payment_id_nonref.data),
1051 payment_hash: local_payment_hash_nonref,
1052 path: local_path_nonref,
1055 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, } => {
1056 let mut payment_id_nonref = (*payment_id).clone();
1057 let mut local_payment_id_nonref = if payment_id_nonref.data == [0; 32] { None } else { Some( { ::lightning::ln::channelmanager::PaymentId(payment_id_nonref.data) }) };
1058 let mut payment_hash_nonref = (*payment_hash).clone();
1059 let mut payment_failed_permanently_nonref = (*payment_failed_permanently).clone();
1060 let mut network_update_nonref = (*network_update).clone();
1061 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() }) } };
1062 let mut all_paths_failed_nonref = (*all_paths_failed).clone();
1063 let mut path_nonref = (*path).clone();
1064 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()) } }); };
1065 let mut short_channel_id_nonref = (*short_channel_id).clone();
1066 let mut local_short_channel_id_nonref = if short_channel_id_nonref.is_some() { Some( { short_channel_id_nonref.take() }) } else { None };
1067 let mut retry_nonref = (*retry).clone();
1068 let mut local_retry_nonref = if retry_nonref.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(retry_nonref.take_inner()) } }) };
1069 nativeEvent::PaymentPathFailed {
1070 payment_id: local_payment_id_nonref,
1071 payment_hash: ::lightning::ln::PaymentHash(payment_hash_nonref.data),
1072 payment_failed_permanently: payment_failed_permanently_nonref,
1073 network_update: local_network_update_nonref,
1074 all_paths_failed: all_paths_failed_nonref,
1075 path: local_path_nonref,
1076 short_channel_id: local_short_channel_id_nonref,
1077 retry: local_retry_nonref,
1080 Event::ProbeSuccessful {ref payment_id, ref payment_hash, ref path, } => {
1081 let mut payment_id_nonref = (*payment_id).clone();
1082 let mut payment_hash_nonref = (*payment_hash).clone();
1083 let mut path_nonref = (*path).clone();
1084 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()) } }); };
1085 nativeEvent::ProbeSuccessful {
1086 payment_id: ::lightning::ln::channelmanager::PaymentId(payment_id_nonref.data),
1087 payment_hash: ::lightning::ln::PaymentHash(payment_hash_nonref.data),
1088 path: local_path_nonref,
1091 Event::ProbeFailed {ref payment_id, ref payment_hash, ref path, ref short_channel_id, } => {
1092 let mut payment_id_nonref = (*payment_id).clone();
1093 let mut payment_hash_nonref = (*payment_hash).clone();
1094 let mut path_nonref = (*path).clone();
1095 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()) } }); };
1096 let mut short_channel_id_nonref = (*short_channel_id).clone();
1097 let mut local_short_channel_id_nonref = if short_channel_id_nonref.is_some() { Some( { short_channel_id_nonref.take() }) } else { None };
1098 nativeEvent::ProbeFailed {
1099 payment_id: ::lightning::ln::channelmanager::PaymentId(payment_id_nonref.data),
1100 payment_hash: ::lightning::ln::PaymentHash(payment_hash_nonref.data),
1101 path: local_path_nonref,
1102 short_channel_id: local_short_channel_id_nonref,
1105 Event::PendingHTLCsForwardable {ref time_forwardable, } => {
1106 let mut time_forwardable_nonref = (*time_forwardable).clone();
1107 nativeEvent::PendingHTLCsForwardable {
1108 time_forwardable: core::time::Duration::from_secs(time_forwardable_nonref),
1111 Event::SpendableOutputs {ref outputs, } => {
1112 let mut outputs_nonref = (*outputs).clone();
1113 let mut local_outputs_nonref = Vec::new(); for mut item in outputs_nonref.into_rust().drain(..) { local_outputs_nonref.push( { item.into_native() }); };
1114 nativeEvent::SpendableOutputs {
1115 outputs: local_outputs_nonref,
1118 Event::PaymentForwarded {ref prev_channel_id, ref next_channel_id, ref fee_earned_msat, ref claim_from_onchain_tx, } => {
1119 let mut prev_channel_id_nonref = (*prev_channel_id).clone();
1120 let mut local_prev_channel_id_nonref = if prev_channel_id_nonref.data == [0; 32] { None } else { Some( { prev_channel_id_nonref.data }) };
1121 let mut next_channel_id_nonref = (*next_channel_id).clone();
1122 let mut local_next_channel_id_nonref = if next_channel_id_nonref.data == [0; 32] { None } else { Some( { next_channel_id_nonref.data }) };
1123 let mut fee_earned_msat_nonref = (*fee_earned_msat).clone();
1124 let mut local_fee_earned_msat_nonref = if fee_earned_msat_nonref.is_some() { Some( { fee_earned_msat_nonref.take() }) } else { None };
1125 let mut claim_from_onchain_tx_nonref = (*claim_from_onchain_tx).clone();
1126 nativeEvent::PaymentForwarded {
1127 prev_channel_id: local_prev_channel_id_nonref,
1128 next_channel_id: local_next_channel_id_nonref,
1129 fee_earned_msat: local_fee_earned_msat_nonref,
1130 claim_from_onchain_tx: claim_from_onchain_tx_nonref,
1133 Event::ChannelClosed {ref channel_id, ref user_channel_id, ref reason, } => {
1134 let mut channel_id_nonref = (*channel_id).clone();
1135 let mut user_channel_id_nonref = (*user_channel_id).clone();
1136 let mut reason_nonref = (*reason).clone();
1137 nativeEvent::ChannelClosed {
1138 channel_id: channel_id_nonref.data,
1139 user_channel_id: user_channel_id_nonref,
1140 reason: reason_nonref.into_native(),
1143 Event::DiscardFunding {ref channel_id, ref transaction, } => {
1144 let mut channel_id_nonref = (*channel_id).clone();
1145 let mut transaction_nonref = (*transaction).clone();
1146 nativeEvent::DiscardFunding {
1147 channel_id: channel_id_nonref.data,
1148 transaction: transaction_nonref.into_bitcoin(),
1151 Event::OpenChannelRequest {ref temporary_channel_id, ref counterparty_node_id, ref funding_satoshis, ref push_msat, ref channel_type, } => {
1152 let mut temporary_channel_id_nonref = (*temporary_channel_id).clone();
1153 let mut counterparty_node_id_nonref = (*counterparty_node_id).clone();
1154 let mut funding_satoshis_nonref = (*funding_satoshis).clone();
1155 let mut push_msat_nonref = (*push_msat).clone();
1156 let mut channel_type_nonref = (*channel_type).clone();
1157 nativeEvent::OpenChannelRequest {
1158 temporary_channel_id: temporary_channel_id_nonref.data,
1159 counterparty_node_id: counterparty_node_id_nonref.into_rust(),
1160 funding_satoshis: funding_satoshis_nonref,
1161 push_msat: push_msat_nonref,
1162 channel_type: *unsafe { Box::from_raw(channel_type_nonref.take_inner()) },
1165 Event::HTLCHandlingFailed {ref prev_channel_id, ref failed_next_destination, } => {
1166 let mut prev_channel_id_nonref = (*prev_channel_id).clone();
1167 let mut failed_next_destination_nonref = (*failed_next_destination).clone();
1168 nativeEvent::HTLCHandlingFailed {
1169 prev_channel_id: prev_channel_id_nonref.data,
1170 failed_next_destination: failed_next_destination_nonref.into_native(),
1176 pub(crate) fn into_native(self) -> nativeEvent {
1178 Event::FundingGenerationReady {mut temporary_channel_id, mut counterparty_node_id, mut channel_value_satoshis, mut output_script, mut user_channel_id, } => {
1179 nativeEvent::FundingGenerationReady {
1180 temporary_channel_id: temporary_channel_id.data,
1181 counterparty_node_id: counterparty_node_id.into_rust(),
1182 channel_value_satoshis: channel_value_satoshis,
1183 output_script: ::bitcoin::blockdata::script::Script::from(output_script.into_rust()),
1184 user_channel_id: user_channel_id,
1187 Event::PaymentReceived {mut payment_hash, mut amount_msat, mut purpose, } => {
1188 nativeEvent::PaymentReceived {
1189 payment_hash: ::lightning::ln::PaymentHash(payment_hash.data),
1190 amount_msat: amount_msat,
1191 purpose: purpose.into_native(),
1194 Event::PaymentClaimed {mut payment_hash, mut amount_msat, mut purpose, } => {
1195 nativeEvent::PaymentClaimed {
1196 payment_hash: ::lightning::ln::PaymentHash(payment_hash.data),
1197 amount_msat: amount_msat,
1198 purpose: purpose.into_native(),
1201 Event::PaymentSent {mut payment_id, mut payment_preimage, mut payment_hash, mut fee_paid_msat, } => {
1202 let mut local_payment_id = if payment_id.data == [0; 32] { None } else { Some( { ::lightning::ln::channelmanager::PaymentId(payment_id.data) }) };
1203 let mut local_fee_paid_msat = if fee_paid_msat.is_some() { Some( { fee_paid_msat.take() }) } else { None };
1204 nativeEvent::PaymentSent {
1205 payment_id: local_payment_id,
1206 payment_preimage: ::lightning::ln::PaymentPreimage(payment_preimage.data),
1207 payment_hash: ::lightning::ln::PaymentHash(payment_hash.data),
1208 fee_paid_msat: local_fee_paid_msat,
1211 Event::PaymentFailed {mut payment_id, mut payment_hash, } => {
1212 nativeEvent::PaymentFailed {
1213 payment_id: ::lightning::ln::channelmanager::PaymentId(payment_id.data),
1214 payment_hash: ::lightning::ln::PaymentHash(payment_hash.data),
1217 Event::PaymentPathSuccessful {mut payment_id, mut payment_hash, mut path, } => {
1218 let mut local_payment_hash = if payment_hash.data == [0; 32] { None } else { Some( { ::lightning::ln::PaymentHash(payment_hash.data) }) };
1219 let mut local_path = Vec::new(); for mut item in path.into_rust().drain(..) { local_path.push( { *unsafe { Box::from_raw(item.take_inner()) } }); };
1220 nativeEvent::PaymentPathSuccessful {
1221 payment_id: ::lightning::ln::channelmanager::PaymentId(payment_id.data),
1222 payment_hash: local_payment_hash,
1226 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, } => {
1227 let mut local_payment_id = if payment_id.data == [0; 32] { None } else { Some( { ::lightning::ln::channelmanager::PaymentId(payment_id.data) }) };
1228 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() }) } };
1229 let mut local_path = Vec::new(); for mut item in path.into_rust().drain(..) { local_path.push( { *unsafe { Box::from_raw(item.take_inner()) } }); };
1230 let mut local_short_channel_id = if short_channel_id.is_some() { Some( { short_channel_id.take() }) } else { None };
1231 let mut local_retry = if retry.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(retry.take_inner()) } }) };
1232 nativeEvent::PaymentPathFailed {
1233 payment_id: local_payment_id,
1234 payment_hash: ::lightning::ln::PaymentHash(payment_hash.data),
1235 payment_failed_permanently: payment_failed_permanently,
1236 network_update: local_network_update,
1237 all_paths_failed: all_paths_failed,
1239 short_channel_id: local_short_channel_id,
1243 Event::ProbeSuccessful {mut payment_id, mut payment_hash, mut path, } => {
1244 let mut local_path = Vec::new(); for mut item in path.into_rust().drain(..) { local_path.push( { *unsafe { Box::from_raw(item.take_inner()) } }); };
1245 nativeEvent::ProbeSuccessful {
1246 payment_id: ::lightning::ln::channelmanager::PaymentId(payment_id.data),
1247 payment_hash: ::lightning::ln::PaymentHash(payment_hash.data),
1251 Event::ProbeFailed {mut payment_id, mut payment_hash, mut path, mut short_channel_id, } => {
1252 let mut local_path = Vec::new(); for mut item in path.into_rust().drain(..) { local_path.push( { *unsafe { Box::from_raw(item.take_inner()) } }); };
1253 let mut local_short_channel_id = if short_channel_id.is_some() { Some( { short_channel_id.take() }) } else { None };
1254 nativeEvent::ProbeFailed {
1255 payment_id: ::lightning::ln::channelmanager::PaymentId(payment_id.data),
1256 payment_hash: ::lightning::ln::PaymentHash(payment_hash.data),
1258 short_channel_id: local_short_channel_id,
1261 Event::PendingHTLCsForwardable {mut time_forwardable, } => {
1262 nativeEvent::PendingHTLCsForwardable {
1263 time_forwardable: core::time::Duration::from_secs(time_forwardable),
1266 Event::SpendableOutputs {mut outputs, } => {
1267 let mut local_outputs = Vec::new(); for mut item in outputs.into_rust().drain(..) { local_outputs.push( { item.into_native() }); };
1268 nativeEvent::SpendableOutputs {
1269 outputs: local_outputs,
1272 Event::PaymentForwarded {mut prev_channel_id, mut next_channel_id, mut fee_earned_msat, mut claim_from_onchain_tx, } => {
1273 let mut local_prev_channel_id = if prev_channel_id.data == [0; 32] { None } else { Some( { prev_channel_id.data }) };
1274 let mut local_next_channel_id = if next_channel_id.data == [0; 32] { None } else { Some( { next_channel_id.data }) };
1275 let mut local_fee_earned_msat = if fee_earned_msat.is_some() { Some( { fee_earned_msat.take() }) } else { None };
1276 nativeEvent::PaymentForwarded {
1277 prev_channel_id: local_prev_channel_id,
1278 next_channel_id: local_next_channel_id,
1279 fee_earned_msat: local_fee_earned_msat,
1280 claim_from_onchain_tx: claim_from_onchain_tx,
1283 Event::ChannelClosed {mut channel_id, mut user_channel_id, mut reason, } => {
1284 nativeEvent::ChannelClosed {
1285 channel_id: channel_id.data,
1286 user_channel_id: user_channel_id,
1287 reason: reason.into_native(),
1290 Event::DiscardFunding {mut channel_id, mut transaction, } => {
1291 nativeEvent::DiscardFunding {
1292 channel_id: channel_id.data,
1293 transaction: transaction.into_bitcoin(),
1296 Event::OpenChannelRequest {mut temporary_channel_id, mut counterparty_node_id, mut funding_satoshis, mut push_msat, mut channel_type, } => {
1297 nativeEvent::OpenChannelRequest {
1298 temporary_channel_id: temporary_channel_id.data,
1299 counterparty_node_id: counterparty_node_id.into_rust(),
1300 funding_satoshis: funding_satoshis,
1301 push_msat: push_msat,
1302 channel_type: *unsafe { Box::from_raw(channel_type.take_inner()) },
1305 Event::HTLCHandlingFailed {mut prev_channel_id, mut failed_next_destination, } => {
1306 nativeEvent::HTLCHandlingFailed {
1307 prev_channel_id: prev_channel_id.data,
1308 failed_next_destination: failed_next_destination.into_native(),
1314 pub(crate) fn from_native(native: &nativeEvent) -> Self {
1316 nativeEvent::FundingGenerationReady {ref temporary_channel_id, ref counterparty_node_id, ref channel_value_satoshis, ref output_script, ref user_channel_id, } => {
1317 let mut temporary_channel_id_nonref = (*temporary_channel_id).clone();
1318 let mut counterparty_node_id_nonref = (*counterparty_node_id).clone();
1319 let mut channel_value_satoshis_nonref = (*channel_value_satoshis).clone();
1320 let mut output_script_nonref = (*output_script).clone();
1321 let mut user_channel_id_nonref = (*user_channel_id).clone();
1322 Event::FundingGenerationReady {
1323 temporary_channel_id: crate::c_types::ThirtyTwoBytes { data: temporary_channel_id_nonref },
1324 counterparty_node_id: crate::c_types::PublicKey::from_rust(&counterparty_node_id_nonref),
1325 channel_value_satoshis: channel_value_satoshis_nonref,
1326 output_script: output_script_nonref.into_bytes().into(),
1327 user_channel_id: user_channel_id_nonref,
1330 nativeEvent::PaymentReceived {ref payment_hash, ref amount_msat, ref purpose, } => {
1331 let mut payment_hash_nonref = (*payment_hash).clone();
1332 let mut amount_msat_nonref = (*amount_msat).clone();
1333 let mut purpose_nonref = (*purpose).clone();
1334 Event::PaymentReceived {
1335 payment_hash: crate::c_types::ThirtyTwoBytes { data: payment_hash_nonref.0 },
1336 amount_msat: amount_msat_nonref,
1337 purpose: crate::lightning::util::events::PaymentPurpose::native_into(purpose_nonref),
1340 nativeEvent::PaymentClaimed {ref payment_hash, ref amount_msat, ref purpose, } => {
1341 let mut payment_hash_nonref = (*payment_hash).clone();
1342 let mut amount_msat_nonref = (*amount_msat).clone();
1343 let mut purpose_nonref = (*purpose).clone();
1344 Event::PaymentClaimed {
1345 payment_hash: crate::c_types::ThirtyTwoBytes { data: payment_hash_nonref.0 },
1346 amount_msat: amount_msat_nonref,
1347 purpose: crate::lightning::util::events::PaymentPurpose::native_into(purpose_nonref),
1350 nativeEvent::PaymentSent {ref payment_id, ref payment_preimage, ref payment_hash, ref fee_paid_msat, } => {
1351 let mut payment_id_nonref = (*payment_id).clone();
1352 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 } } };
1353 let mut payment_preimage_nonref = (*payment_preimage).clone();
1354 let mut payment_hash_nonref = (*payment_hash).clone();
1355 let mut fee_paid_msat_nonref = (*fee_paid_msat).clone();
1356 let mut local_fee_paid_msat_nonref = if fee_paid_msat_nonref.is_none() { crate::c_types::derived::COption_u64Z::None } else { crate::c_types::derived::COption_u64Z::Some( { fee_paid_msat_nonref.unwrap() }) };
1357 Event::PaymentSent {
1358 payment_id: local_payment_id_nonref,
1359 payment_preimage: crate::c_types::ThirtyTwoBytes { data: payment_preimage_nonref.0 },
1360 payment_hash: crate::c_types::ThirtyTwoBytes { data: payment_hash_nonref.0 },
1361 fee_paid_msat: local_fee_paid_msat_nonref,
1364 nativeEvent::PaymentFailed {ref payment_id, ref payment_hash, } => {
1365 let mut payment_id_nonref = (*payment_id).clone();
1366 let mut payment_hash_nonref = (*payment_hash).clone();
1367 Event::PaymentFailed {
1368 payment_id: crate::c_types::ThirtyTwoBytes { data: payment_id_nonref.0 },
1369 payment_hash: crate::c_types::ThirtyTwoBytes { data: payment_hash_nonref.0 },
1372 nativeEvent::PaymentPathSuccessful {ref payment_id, ref payment_hash, ref path, } => {
1373 let mut payment_id_nonref = (*payment_id).clone();
1374 let mut payment_hash_nonref = (*payment_hash).clone();
1375 let mut local_payment_hash_nonref = if payment_hash_nonref.is_none() { crate::c_types::ThirtyTwoBytes::null() } else { { crate::c_types::ThirtyTwoBytes { data: (payment_hash_nonref.unwrap()).0 } } };
1376 let mut path_nonref = (*path).clone();
1377 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 } }); };
1378 Event::PaymentPathSuccessful {
1379 payment_id: crate::c_types::ThirtyTwoBytes { data: payment_id_nonref.0 },
1380 payment_hash: local_payment_hash_nonref,
1381 path: local_path_nonref.into(),
1384 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, } => {
1385 let mut payment_id_nonref = (*payment_id).clone();
1386 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 } } };
1387 let mut payment_hash_nonref = (*payment_hash).clone();
1388 let mut payment_failed_permanently_nonref = (*payment_failed_permanently).clone();
1389 let mut network_update_nonref = (*network_update).clone();
1390 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()) }) };
1391 let mut all_paths_failed_nonref = (*all_paths_failed).clone();
1392 let mut path_nonref = (*path).clone();
1393 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 } }); };
1394 let mut short_channel_id_nonref = (*short_channel_id).clone();
1395 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() }) };
1396 let mut retry_nonref = (*retry).clone();
1397 let mut local_retry_nonref = crate::lightning::routing::router::RouteParameters { inner: if retry_nonref.is_none() { core::ptr::null_mut() } else { { ObjOps::heap_alloc((retry_nonref.unwrap())) } }, is_owned: true };
1398 Event::PaymentPathFailed {
1399 payment_id: local_payment_id_nonref,
1400 payment_hash: crate::c_types::ThirtyTwoBytes { data: payment_hash_nonref.0 },
1401 payment_failed_permanently: payment_failed_permanently_nonref,
1402 network_update: local_network_update_nonref,
1403 all_paths_failed: all_paths_failed_nonref,
1404 path: local_path_nonref.into(),
1405 short_channel_id: local_short_channel_id_nonref,
1406 retry: local_retry_nonref,
1409 nativeEvent::ProbeSuccessful {ref payment_id, ref payment_hash, ref path, } => {
1410 let mut payment_id_nonref = (*payment_id).clone();
1411 let mut payment_hash_nonref = (*payment_hash).clone();
1412 let mut path_nonref = (*path).clone();
1413 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 } }); };
1414 Event::ProbeSuccessful {
1415 payment_id: crate::c_types::ThirtyTwoBytes { data: payment_id_nonref.0 },
1416 payment_hash: crate::c_types::ThirtyTwoBytes { data: payment_hash_nonref.0 },
1417 path: local_path_nonref.into(),
1420 nativeEvent::ProbeFailed {ref payment_id, ref payment_hash, ref path, ref short_channel_id, } => {
1421 let mut payment_id_nonref = (*payment_id).clone();
1422 let mut payment_hash_nonref = (*payment_hash).clone();
1423 let mut path_nonref = (*path).clone();
1424 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 } }); };
1425 let mut short_channel_id_nonref = (*short_channel_id).clone();
1426 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() }) };
1427 Event::ProbeFailed {
1428 payment_id: crate::c_types::ThirtyTwoBytes { data: payment_id_nonref.0 },
1429 payment_hash: crate::c_types::ThirtyTwoBytes { data: payment_hash_nonref.0 },
1430 path: local_path_nonref.into(),
1431 short_channel_id: local_short_channel_id_nonref,
1434 nativeEvent::PendingHTLCsForwardable {ref time_forwardable, } => {
1435 let mut time_forwardable_nonref = (*time_forwardable).clone();
1436 Event::PendingHTLCsForwardable {
1437 time_forwardable: time_forwardable_nonref.as_secs(),
1440 nativeEvent::SpendableOutputs {ref outputs, } => {
1441 let mut outputs_nonref = (*outputs).clone();
1442 let mut local_outputs_nonref = Vec::new(); for mut item in outputs_nonref.drain(..) { local_outputs_nonref.push( { crate::lightning::chain::keysinterface::SpendableOutputDescriptor::native_into(item) }); };
1443 Event::SpendableOutputs {
1444 outputs: local_outputs_nonref.into(),
1447 nativeEvent::PaymentForwarded {ref prev_channel_id, ref next_channel_id, ref fee_earned_msat, ref claim_from_onchain_tx, } => {
1448 let mut prev_channel_id_nonref = (*prev_channel_id).clone();
1449 let mut local_prev_channel_id_nonref = if prev_channel_id_nonref.is_none() { crate::c_types::ThirtyTwoBytes { data: [0; 32] } } else { { crate::c_types::ThirtyTwoBytes { data: (prev_channel_id_nonref.unwrap()) } } };
1450 let mut next_channel_id_nonref = (*next_channel_id).clone();
1451 let mut local_next_channel_id_nonref = if next_channel_id_nonref.is_none() { crate::c_types::ThirtyTwoBytes { data: [0; 32] } } else { { crate::c_types::ThirtyTwoBytes { data: (next_channel_id_nonref.unwrap()) } } };
1452 let mut fee_earned_msat_nonref = (*fee_earned_msat).clone();
1453 let mut local_fee_earned_msat_nonref = if fee_earned_msat_nonref.is_none() { crate::c_types::derived::COption_u64Z::None } else { crate::c_types::derived::COption_u64Z::Some( { fee_earned_msat_nonref.unwrap() }) };
1454 let mut claim_from_onchain_tx_nonref = (*claim_from_onchain_tx).clone();
1455 Event::PaymentForwarded {
1456 prev_channel_id: local_prev_channel_id_nonref,
1457 next_channel_id: local_next_channel_id_nonref,
1458 fee_earned_msat: local_fee_earned_msat_nonref,
1459 claim_from_onchain_tx: claim_from_onchain_tx_nonref,
1462 nativeEvent::ChannelClosed {ref channel_id, ref user_channel_id, ref reason, } => {
1463 let mut channel_id_nonref = (*channel_id).clone();
1464 let mut user_channel_id_nonref = (*user_channel_id).clone();
1465 let mut reason_nonref = (*reason).clone();
1466 Event::ChannelClosed {
1467 channel_id: crate::c_types::ThirtyTwoBytes { data: channel_id_nonref },
1468 user_channel_id: user_channel_id_nonref,
1469 reason: crate::lightning::util::events::ClosureReason::native_into(reason_nonref),
1472 nativeEvent::DiscardFunding {ref channel_id, ref transaction, } => {
1473 let mut channel_id_nonref = (*channel_id).clone();
1474 let mut transaction_nonref = (*transaction).clone();
1475 Event::DiscardFunding {
1476 channel_id: crate::c_types::ThirtyTwoBytes { data: channel_id_nonref },
1477 transaction: crate::c_types::Transaction::from_bitcoin(&transaction_nonref),
1480 nativeEvent::OpenChannelRequest {ref temporary_channel_id, ref counterparty_node_id, ref funding_satoshis, ref push_msat, ref channel_type, } => {
1481 let mut temporary_channel_id_nonref = (*temporary_channel_id).clone();
1482 let mut counterparty_node_id_nonref = (*counterparty_node_id).clone();
1483 let mut funding_satoshis_nonref = (*funding_satoshis).clone();
1484 let mut push_msat_nonref = (*push_msat).clone();
1485 let mut channel_type_nonref = (*channel_type).clone();
1486 Event::OpenChannelRequest {
1487 temporary_channel_id: crate::c_types::ThirtyTwoBytes { data: temporary_channel_id_nonref },
1488 counterparty_node_id: crate::c_types::PublicKey::from_rust(&counterparty_node_id_nonref),
1489 funding_satoshis: funding_satoshis_nonref,
1490 push_msat: push_msat_nonref,
1491 channel_type: crate::lightning::ln::features::ChannelTypeFeatures { inner: ObjOps::heap_alloc(channel_type_nonref), is_owned: true },
1494 nativeEvent::HTLCHandlingFailed {ref prev_channel_id, ref failed_next_destination, } => {
1495 let mut prev_channel_id_nonref = (*prev_channel_id).clone();
1496 let mut failed_next_destination_nonref = (*failed_next_destination).clone();
1497 Event::HTLCHandlingFailed {
1498 prev_channel_id: crate::c_types::ThirtyTwoBytes { data: prev_channel_id_nonref },
1499 failed_next_destination: crate::lightning::util::events::HTLCDestination::native_into(failed_next_destination_nonref),
1505 pub(crate) fn native_into(native: nativeEvent) -> Self {
1507 nativeEvent::FundingGenerationReady {mut temporary_channel_id, mut counterparty_node_id, mut channel_value_satoshis, mut output_script, mut user_channel_id, } => {
1508 Event::FundingGenerationReady {
1509 temporary_channel_id: crate::c_types::ThirtyTwoBytes { data: temporary_channel_id },
1510 counterparty_node_id: crate::c_types::PublicKey::from_rust(&counterparty_node_id),
1511 channel_value_satoshis: channel_value_satoshis,
1512 output_script: output_script.into_bytes().into(),
1513 user_channel_id: user_channel_id,
1516 nativeEvent::PaymentReceived {mut payment_hash, mut amount_msat, mut purpose, } => {
1517 Event::PaymentReceived {
1518 payment_hash: crate::c_types::ThirtyTwoBytes { data: payment_hash.0 },
1519 amount_msat: amount_msat,
1520 purpose: crate::lightning::util::events::PaymentPurpose::native_into(purpose),
1523 nativeEvent::PaymentClaimed {mut payment_hash, mut amount_msat, mut purpose, } => {
1524 Event::PaymentClaimed {
1525 payment_hash: crate::c_types::ThirtyTwoBytes { data: payment_hash.0 },
1526 amount_msat: amount_msat,
1527 purpose: crate::lightning::util::events::PaymentPurpose::native_into(purpose),
1530 nativeEvent::PaymentSent {mut payment_id, mut payment_preimage, mut payment_hash, mut fee_paid_msat, } => {
1531 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 } } };
1532 let mut local_fee_paid_msat = if fee_paid_msat.is_none() { crate::c_types::derived::COption_u64Z::None } else { crate::c_types::derived::COption_u64Z::Some( { fee_paid_msat.unwrap() }) };
1533 Event::PaymentSent {
1534 payment_id: local_payment_id,
1535 payment_preimage: crate::c_types::ThirtyTwoBytes { data: payment_preimage.0 },
1536 payment_hash: crate::c_types::ThirtyTwoBytes { data: payment_hash.0 },
1537 fee_paid_msat: local_fee_paid_msat,
1540 nativeEvent::PaymentFailed {mut payment_id, mut payment_hash, } => {
1541 Event::PaymentFailed {
1542 payment_id: crate::c_types::ThirtyTwoBytes { data: payment_id.0 },
1543 payment_hash: crate::c_types::ThirtyTwoBytes { data: payment_hash.0 },
1546 nativeEvent::PaymentPathSuccessful {mut payment_id, mut payment_hash, mut path, } => {
1547 let mut local_payment_hash = if payment_hash.is_none() { crate::c_types::ThirtyTwoBytes::null() } else { { crate::c_types::ThirtyTwoBytes { data: (payment_hash.unwrap()).0 } } };
1548 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 } }); };
1549 Event::PaymentPathSuccessful {
1550 payment_id: crate::c_types::ThirtyTwoBytes { data: payment_id.0 },
1551 payment_hash: local_payment_hash,
1552 path: local_path.into(),
1555 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, } => {
1556 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 } } };
1557 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()) }) };
1558 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 } }); };
1559 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() }) };
1560 let mut local_retry = crate::lightning::routing::router::RouteParameters { inner: if retry.is_none() { core::ptr::null_mut() } else { { ObjOps::heap_alloc((retry.unwrap())) } }, is_owned: true };
1561 Event::PaymentPathFailed {
1562 payment_id: local_payment_id,
1563 payment_hash: crate::c_types::ThirtyTwoBytes { data: payment_hash.0 },
1564 payment_failed_permanently: payment_failed_permanently,
1565 network_update: local_network_update,
1566 all_paths_failed: all_paths_failed,
1567 path: local_path.into(),
1568 short_channel_id: local_short_channel_id,
1572 nativeEvent::ProbeSuccessful {mut payment_id, mut payment_hash, mut path, } => {
1573 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 } }); };
1574 Event::ProbeSuccessful {
1575 payment_id: crate::c_types::ThirtyTwoBytes { data: payment_id.0 },
1576 payment_hash: crate::c_types::ThirtyTwoBytes { data: payment_hash.0 },
1577 path: local_path.into(),
1580 nativeEvent::ProbeFailed {mut payment_id, mut payment_hash, mut path, mut short_channel_id, } => {
1581 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 } }); };
1582 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() }) };
1583 Event::ProbeFailed {
1584 payment_id: crate::c_types::ThirtyTwoBytes { data: payment_id.0 },
1585 payment_hash: crate::c_types::ThirtyTwoBytes { data: payment_hash.0 },
1586 path: local_path.into(),
1587 short_channel_id: local_short_channel_id,
1590 nativeEvent::PendingHTLCsForwardable {mut time_forwardable, } => {
1591 Event::PendingHTLCsForwardable {
1592 time_forwardable: time_forwardable.as_secs(),
1595 nativeEvent::SpendableOutputs {mut outputs, } => {
1596 let mut local_outputs = Vec::new(); for mut item in outputs.drain(..) { local_outputs.push( { crate::lightning::chain::keysinterface::SpendableOutputDescriptor::native_into(item) }); };
1597 Event::SpendableOutputs {
1598 outputs: local_outputs.into(),
1601 nativeEvent::PaymentForwarded {mut prev_channel_id, mut next_channel_id, mut fee_earned_msat, mut claim_from_onchain_tx, } => {
1602 let mut local_prev_channel_id = if prev_channel_id.is_none() { crate::c_types::ThirtyTwoBytes { data: [0; 32] } } else { { crate::c_types::ThirtyTwoBytes { data: (prev_channel_id.unwrap()) } } };
1603 let mut local_next_channel_id = if next_channel_id.is_none() { crate::c_types::ThirtyTwoBytes { data: [0; 32] } } else { { crate::c_types::ThirtyTwoBytes { data: (next_channel_id.unwrap()) } } };
1604 let mut local_fee_earned_msat = if fee_earned_msat.is_none() { crate::c_types::derived::COption_u64Z::None } else { crate::c_types::derived::COption_u64Z::Some( { fee_earned_msat.unwrap() }) };
1605 Event::PaymentForwarded {
1606 prev_channel_id: local_prev_channel_id,
1607 next_channel_id: local_next_channel_id,
1608 fee_earned_msat: local_fee_earned_msat,
1609 claim_from_onchain_tx: claim_from_onchain_tx,
1612 nativeEvent::ChannelClosed {mut channel_id, mut user_channel_id, mut reason, } => {
1613 Event::ChannelClosed {
1614 channel_id: crate::c_types::ThirtyTwoBytes { data: channel_id },
1615 user_channel_id: user_channel_id,
1616 reason: crate::lightning::util::events::ClosureReason::native_into(reason),
1619 nativeEvent::DiscardFunding {mut channel_id, mut transaction, } => {
1620 Event::DiscardFunding {
1621 channel_id: crate::c_types::ThirtyTwoBytes { data: channel_id },
1622 transaction: crate::c_types::Transaction::from_bitcoin(&transaction),
1625 nativeEvent::OpenChannelRequest {mut temporary_channel_id, mut counterparty_node_id, mut funding_satoshis, mut push_msat, mut channel_type, } => {
1626 Event::OpenChannelRequest {
1627 temporary_channel_id: crate::c_types::ThirtyTwoBytes { data: temporary_channel_id },
1628 counterparty_node_id: crate::c_types::PublicKey::from_rust(&counterparty_node_id),
1629 funding_satoshis: funding_satoshis,
1630 push_msat: push_msat,
1631 channel_type: crate::lightning::ln::features::ChannelTypeFeatures { inner: ObjOps::heap_alloc(channel_type), is_owned: true },
1634 nativeEvent::HTLCHandlingFailed {mut prev_channel_id, mut failed_next_destination, } => {
1635 Event::HTLCHandlingFailed {
1636 prev_channel_id: crate::c_types::ThirtyTwoBytes { data: prev_channel_id },
1637 failed_next_destination: crate::lightning::util::events::HTLCDestination::native_into(failed_next_destination),
1643 /// Frees any resources used by the Event
1645 pub extern "C" fn Event_free(this_ptr: Event) { }
1646 /// Creates a copy of the Event
1648 pub extern "C" fn Event_clone(orig: &Event) -> Event {
1652 /// Utility method to constructs a new FundingGenerationReady-variant Event
1653 pub extern "C" fn Event_funding_generation_ready(temporary_channel_id: crate::c_types::ThirtyTwoBytes, counterparty_node_id: crate::c_types::PublicKey, channel_value_satoshis: u64, output_script: crate::c_types::derived::CVec_u8Z, user_channel_id: u64) -> Event {
1654 Event::FundingGenerationReady {
1655 temporary_channel_id,
1656 counterparty_node_id,
1657 channel_value_satoshis,
1663 /// Utility method to constructs a new PaymentReceived-variant Event
1664 pub extern "C" fn Event_payment_received(payment_hash: crate::c_types::ThirtyTwoBytes, amount_msat: u64, purpose: crate::lightning::util::events::PaymentPurpose) -> Event {
1665 Event::PaymentReceived {
1672 /// Utility method to constructs a new PaymentClaimed-variant Event
1673 pub extern "C" fn Event_payment_claimed(payment_hash: crate::c_types::ThirtyTwoBytes, amount_msat: u64, purpose: crate::lightning::util::events::PaymentPurpose) -> Event {
1674 Event::PaymentClaimed {
1681 /// Utility method to constructs a new PaymentSent-variant Event
1682 pub extern "C" fn Event_payment_sent(payment_id: crate::c_types::ThirtyTwoBytes, payment_preimage: crate::c_types::ThirtyTwoBytes, payment_hash: crate::c_types::ThirtyTwoBytes, fee_paid_msat: crate::c_types::derived::COption_u64Z) -> Event {
1683 Event::PaymentSent {
1691 /// Utility method to constructs a new PaymentFailed-variant Event
1692 pub extern "C" fn Event_payment_failed(payment_id: crate::c_types::ThirtyTwoBytes, payment_hash: crate::c_types::ThirtyTwoBytes) -> Event {
1693 Event::PaymentFailed {
1699 /// Utility method to constructs a new PaymentPathSuccessful-variant Event
1700 pub extern "C" fn Event_payment_path_successful(payment_id: crate::c_types::ThirtyTwoBytes, payment_hash: crate::c_types::ThirtyTwoBytes, path: crate::c_types::derived::CVec_RouteHopZ) -> Event {
1701 Event::PaymentPathSuccessful {
1708 /// Utility method to constructs a new PaymentPathFailed-variant Event
1709 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 {
1710 Event::PaymentPathFailed {
1713 payment_failed_permanently,
1722 /// Utility method to constructs a new ProbeSuccessful-variant Event
1723 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 {
1724 Event::ProbeSuccessful {
1731 /// Utility method to constructs a new ProbeFailed-variant Event
1732 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 {
1733 Event::ProbeFailed {
1741 /// Utility method to constructs a new PendingHTLCsForwardable-variant Event
1742 pub extern "C" fn Event_pending_htlcs_forwardable(time_forwardable: u64) -> Event {
1743 Event::PendingHTLCsForwardable {
1748 /// Utility method to constructs a new SpendableOutputs-variant Event
1749 pub extern "C" fn Event_spendable_outputs(outputs: crate::c_types::derived::CVec_SpendableOutputDescriptorZ) -> Event {
1750 Event::SpendableOutputs {
1755 /// Utility method to constructs a new PaymentForwarded-variant Event
1756 pub extern "C" fn Event_payment_forwarded(prev_channel_id: crate::c_types::ThirtyTwoBytes, next_channel_id: crate::c_types::ThirtyTwoBytes, fee_earned_msat: crate::c_types::derived::COption_u64Z, claim_from_onchain_tx: bool) -> Event {
1757 Event::PaymentForwarded {
1761 claim_from_onchain_tx,
1765 /// Utility method to constructs a new ChannelClosed-variant Event
1766 pub extern "C" fn Event_channel_closed(channel_id: crate::c_types::ThirtyTwoBytes, user_channel_id: u64, reason: crate::lightning::util::events::ClosureReason) -> Event {
1767 Event::ChannelClosed {
1774 /// Utility method to constructs a new DiscardFunding-variant Event
1775 pub extern "C" fn Event_discard_funding(channel_id: crate::c_types::ThirtyTwoBytes, transaction: crate::c_types::Transaction) -> Event {
1776 Event::DiscardFunding {
1782 /// Utility method to constructs a new OpenChannelRequest-variant Event
1783 pub extern "C" fn Event_open_channel_request(temporary_channel_id: crate::c_types::ThirtyTwoBytes, counterparty_node_id: crate::c_types::PublicKey, funding_satoshis: u64, push_msat: u64, channel_type: crate::lightning::ln::features::ChannelTypeFeatures) -> Event {
1784 Event::OpenChannelRequest {
1785 temporary_channel_id,
1786 counterparty_node_id,
1793 /// Utility method to constructs a new HTLCHandlingFailed-variant Event
1794 pub extern "C" fn Event_htlchandling_failed(prev_channel_id: crate::c_types::ThirtyTwoBytes, failed_next_destination: crate::lightning::util::events::HTLCDestination) -> Event {
1795 Event::HTLCHandlingFailed {
1797 failed_next_destination,
1801 /// Serialize the Event object into a byte array which can be read by Event_read
1802 pub extern "C" fn Event_write(obj: &crate::lightning::util::events::Event) -> crate::c_types::derived::CVec_u8Z {
1803 crate::c_types::serialize_obj(&unsafe { &*obj }.to_native())
1806 /// Read a Event from a byte array, created by Event_write
1807 pub extern "C" fn Event_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_COption_EventZDecodeErrorZ {
1808 let res: Result<Option<lightning::util::events::Event>, lightning::ln::msgs::DecodeError> = crate::c_types::maybe_deserialize_obj(ser);
1809 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() };
1812 /// An event generated by ChannelManager which indicates a message should be sent to a peer (or
1813 /// broadcast to most peers).
1814 /// These events are handled by PeerManager::process_events if you are using a PeerManager.
1818 pub enum MessageSendEvent {
1819 /// Used to indicate that we've accepted a channel open and should send the accept_channel
1820 /// message provided to the given peer.
1822 /// The node_id of the node which should receive this message
1823 node_id: crate::c_types::PublicKey,
1824 /// The message which should be sent.
1825 msg: crate::lightning::ln::msgs::AcceptChannel,
1827 /// Used to indicate that we've initiated a channel open and should send the open_channel
1828 /// message provided to the given peer.
1830 /// The node_id of the node which should receive this message
1831 node_id: crate::c_types::PublicKey,
1832 /// The message which should be sent.
1833 msg: crate::lightning::ln::msgs::OpenChannel,
1835 /// Used to indicate that a funding_created message should be sent to the peer with the given node_id.
1836 SendFundingCreated {
1837 /// The node_id of the node which should receive this message
1838 node_id: crate::c_types::PublicKey,
1839 /// The message which should be sent.
1840 msg: crate::lightning::ln::msgs::FundingCreated,
1842 /// Used to indicate that a funding_signed message should be sent to the peer with the given node_id.
1844 /// The node_id of the node which should receive this message
1845 node_id: crate::c_types::PublicKey,
1846 /// The message which should be sent.
1847 msg: crate::lightning::ln::msgs::FundingSigned,
1849 /// Used to indicate that a channel_ready message should be sent to the peer with the given node_id.
1851 /// The node_id of the node which should receive these message(s)
1852 node_id: crate::c_types::PublicKey,
1853 /// The channel_ready message which should be sent.
1854 msg: crate::lightning::ln::msgs::ChannelReady,
1856 /// Used to indicate that an announcement_signatures message should be sent to the peer with the given node_id.
1857 SendAnnouncementSignatures {
1858 /// The node_id of the node which should receive these message(s)
1859 node_id: crate::c_types::PublicKey,
1860 /// The announcement_signatures message which should be sent.
1861 msg: crate::lightning::ln::msgs::AnnouncementSignatures,
1863 /// Used to indicate that a series of HTLC update messages, as well as a commitment_signed
1864 /// message should be sent to the peer with the given node_id.
1866 /// The node_id of the node which should receive these message(s)
1867 node_id: crate::c_types::PublicKey,
1868 /// The update messages which should be sent. ALL messages in the struct should be sent!
1869 updates: crate::lightning::ln::msgs::CommitmentUpdate,
1871 /// Used to indicate that a revoke_and_ack message should be sent to the peer with the given node_id.
1873 /// The node_id of the node which should receive this message
1874 node_id: crate::c_types::PublicKey,
1875 /// The message which should be sent.
1876 msg: crate::lightning::ln::msgs::RevokeAndACK,
1878 /// Used to indicate that a closing_signed message should be sent to the peer with the given node_id.
1880 /// The node_id of the node which should receive this message
1881 node_id: crate::c_types::PublicKey,
1882 /// The message which should be sent.
1883 msg: crate::lightning::ln::msgs::ClosingSigned,
1885 /// Used to indicate that a shutdown message should be sent to the peer with the given node_id.
1887 /// The node_id of the node which should receive this message
1888 node_id: crate::c_types::PublicKey,
1889 /// The message which should be sent.
1890 msg: crate::lightning::ln::msgs::Shutdown,
1892 /// Used to indicate that a channel_reestablish message should be sent to the peer with the given node_id.
1893 SendChannelReestablish {
1894 /// The node_id of the node which should receive this message
1895 node_id: crate::c_types::PublicKey,
1896 /// The message which should be sent.
1897 msg: crate::lightning::ln::msgs::ChannelReestablish,
1899 /// Used to send a channel_announcement and channel_update to a specific peer, likely on
1900 /// initial connection to ensure our peers know about our channels.
1901 SendChannelAnnouncement {
1902 /// The node_id of the node which should receive this message
1903 node_id: crate::c_types::PublicKey,
1904 /// The channel_announcement which should be sent.
1905 msg: crate::lightning::ln::msgs::ChannelAnnouncement,
1906 /// The followup channel_update which should be sent.
1907 update_msg: crate::lightning::ln::msgs::ChannelUpdate,
1909 /// Used to indicate that a channel_announcement and channel_update should be broadcast to all
1910 /// peers (except the peer with node_id either msg.contents.node_id_1 or msg.contents.node_id_2).
1912 /// Note that after doing so, you very likely (unless you did so very recently) want to
1913 /// broadcast a node_announcement (e.g. via [`PeerManager::broadcast_node_announcement`]). This
1914 /// ensures that any nodes which see our channel_announcement also have a relevant
1915 /// node_announcement, including relevant feature flags which may be important for routing
1916 /// through or to us.
1918 /// [`PeerManager::broadcast_node_announcement`]: crate::ln::peer_handler::PeerManager::broadcast_node_announcement
1919 BroadcastChannelAnnouncement {
1920 /// The channel_announcement which should be sent.
1921 msg: crate::lightning::ln::msgs::ChannelAnnouncement,
1922 /// The followup channel_update which should be sent.
1923 update_msg: crate::lightning::ln::msgs::ChannelUpdate,
1925 /// Used to indicate that a channel_update should be broadcast to all peers.
1926 BroadcastChannelUpdate {
1927 /// The channel_update which should be sent.
1928 msg: crate::lightning::ln::msgs::ChannelUpdate,
1930 /// Used to indicate that a channel_update should be sent to a single peer.
1931 /// In contrast to [`Self::BroadcastChannelUpdate`], this is used when the channel is a
1932 /// private channel and we shouldn't be informing all of our peers of channel parameters.
1934 /// The node_id of the node which should receive this message
1935 node_id: crate::c_types::PublicKey,
1936 /// The channel_update which should be sent.
1937 msg: crate::lightning::ln::msgs::ChannelUpdate,
1939 /// Broadcast an error downstream to be handled
1941 /// The node_id of the node which should receive this message
1942 node_id: crate::c_types::PublicKey,
1943 /// The action which should be taken.
1944 action: crate::lightning::ln::msgs::ErrorAction,
1946 /// Query a peer for channels with funding transaction UTXOs in a block range.
1947 SendChannelRangeQuery {
1948 /// The node_id of this message recipient
1949 node_id: crate::c_types::PublicKey,
1950 /// The query_channel_range which should be sent.
1951 msg: crate::lightning::ln::msgs::QueryChannelRange,
1953 /// Request routing gossip messages from a peer for a list of channels identified by
1954 /// their short_channel_ids.
1956 /// The node_id of this message recipient
1957 node_id: crate::c_types::PublicKey,
1958 /// The query_short_channel_ids which should be sent.
1959 msg: crate::lightning::ln::msgs::QueryShortChannelIds,
1961 /// Sends a reply to a channel range query. This may be one of several SendReplyChannelRange events
1962 /// emitted during processing of the query.
1963 SendReplyChannelRange {
1964 /// The node_id of this message recipient
1965 node_id: crate::c_types::PublicKey,
1966 /// The reply_channel_range which should be sent.
1967 msg: crate::lightning::ln::msgs::ReplyChannelRange,
1969 /// Sends a timestamp filter for inbound gossip. This should be sent on each new connection to
1970 /// enable receiving gossip messages from the peer.
1971 SendGossipTimestampFilter {
1972 /// The node_id of this message recipient
1973 node_id: crate::c_types::PublicKey,
1974 /// The gossip_timestamp_filter which should be sent.
1975 msg: crate::lightning::ln::msgs::GossipTimestampFilter,
1978 use lightning::util::events::MessageSendEvent as MessageSendEventImport;
1979 pub(crate) type nativeMessageSendEvent = MessageSendEventImport;
1981 impl MessageSendEvent {
1983 pub(crate) fn to_native(&self) -> nativeMessageSendEvent {
1985 MessageSendEvent::SendAcceptChannel {ref node_id, ref msg, } => {
1986 let mut node_id_nonref = (*node_id).clone();
1987 let mut msg_nonref = (*msg).clone();
1988 nativeMessageSendEvent::SendAcceptChannel {
1989 node_id: node_id_nonref.into_rust(),
1990 msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) },
1993 MessageSendEvent::SendOpenChannel {ref node_id, ref msg, } => {
1994 let mut node_id_nonref = (*node_id).clone();
1995 let mut msg_nonref = (*msg).clone();
1996 nativeMessageSendEvent::SendOpenChannel {
1997 node_id: node_id_nonref.into_rust(),
1998 msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) },
2001 MessageSendEvent::SendFundingCreated {ref node_id, ref msg, } => {
2002 let mut node_id_nonref = (*node_id).clone();
2003 let mut msg_nonref = (*msg).clone();
2004 nativeMessageSendEvent::SendFundingCreated {
2005 node_id: node_id_nonref.into_rust(),
2006 msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) },
2009 MessageSendEvent::SendFundingSigned {ref node_id, ref msg, } => {
2010 let mut node_id_nonref = (*node_id).clone();
2011 let mut msg_nonref = (*msg).clone();
2012 nativeMessageSendEvent::SendFundingSigned {
2013 node_id: node_id_nonref.into_rust(),
2014 msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) },
2017 MessageSendEvent::SendChannelReady {ref node_id, ref msg, } => {
2018 let mut node_id_nonref = (*node_id).clone();
2019 let mut msg_nonref = (*msg).clone();
2020 nativeMessageSendEvent::SendChannelReady {
2021 node_id: node_id_nonref.into_rust(),
2022 msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) },
2025 MessageSendEvent::SendAnnouncementSignatures {ref node_id, ref msg, } => {
2026 let mut node_id_nonref = (*node_id).clone();
2027 let mut msg_nonref = (*msg).clone();
2028 nativeMessageSendEvent::SendAnnouncementSignatures {
2029 node_id: node_id_nonref.into_rust(),
2030 msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) },
2033 MessageSendEvent::UpdateHTLCs {ref node_id, ref updates, } => {
2034 let mut node_id_nonref = (*node_id).clone();
2035 let mut updates_nonref = (*updates).clone();
2036 nativeMessageSendEvent::UpdateHTLCs {
2037 node_id: node_id_nonref.into_rust(),
2038 updates: *unsafe { Box::from_raw(updates_nonref.take_inner()) },
2041 MessageSendEvent::SendRevokeAndACK {ref node_id, ref msg, } => {
2042 let mut node_id_nonref = (*node_id).clone();
2043 let mut msg_nonref = (*msg).clone();
2044 nativeMessageSendEvent::SendRevokeAndACK {
2045 node_id: node_id_nonref.into_rust(),
2046 msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) },
2049 MessageSendEvent::SendClosingSigned {ref node_id, ref msg, } => {
2050 let mut node_id_nonref = (*node_id).clone();
2051 let mut msg_nonref = (*msg).clone();
2052 nativeMessageSendEvent::SendClosingSigned {
2053 node_id: node_id_nonref.into_rust(),
2054 msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) },
2057 MessageSendEvent::SendShutdown {ref node_id, ref msg, } => {
2058 let mut node_id_nonref = (*node_id).clone();
2059 let mut msg_nonref = (*msg).clone();
2060 nativeMessageSendEvent::SendShutdown {
2061 node_id: node_id_nonref.into_rust(),
2062 msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) },
2065 MessageSendEvent::SendChannelReestablish {ref node_id, ref msg, } => {
2066 let mut node_id_nonref = (*node_id).clone();
2067 let mut msg_nonref = (*msg).clone();
2068 nativeMessageSendEvent::SendChannelReestablish {
2069 node_id: node_id_nonref.into_rust(),
2070 msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) },
2073 MessageSendEvent::SendChannelAnnouncement {ref node_id, ref msg, ref update_msg, } => {
2074 let mut node_id_nonref = (*node_id).clone();
2075 let mut msg_nonref = (*msg).clone();
2076 let mut update_msg_nonref = (*update_msg).clone();
2077 nativeMessageSendEvent::SendChannelAnnouncement {
2078 node_id: node_id_nonref.into_rust(),
2079 msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) },
2080 update_msg: *unsafe { Box::from_raw(update_msg_nonref.take_inner()) },
2083 MessageSendEvent::BroadcastChannelAnnouncement {ref msg, ref update_msg, } => {
2084 let mut msg_nonref = (*msg).clone();
2085 let mut update_msg_nonref = (*update_msg).clone();
2086 nativeMessageSendEvent::BroadcastChannelAnnouncement {
2087 msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) },
2088 update_msg: *unsafe { Box::from_raw(update_msg_nonref.take_inner()) },
2091 MessageSendEvent::BroadcastChannelUpdate {ref msg, } => {
2092 let mut msg_nonref = (*msg).clone();
2093 nativeMessageSendEvent::BroadcastChannelUpdate {
2094 msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) },
2097 MessageSendEvent::SendChannelUpdate {ref node_id, ref msg, } => {
2098 let mut node_id_nonref = (*node_id).clone();
2099 let mut msg_nonref = (*msg).clone();
2100 nativeMessageSendEvent::SendChannelUpdate {
2101 node_id: node_id_nonref.into_rust(),
2102 msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) },
2105 MessageSendEvent::HandleError {ref node_id, ref action, } => {
2106 let mut node_id_nonref = (*node_id).clone();
2107 let mut action_nonref = (*action).clone();
2108 nativeMessageSendEvent::HandleError {
2109 node_id: node_id_nonref.into_rust(),
2110 action: action_nonref.into_native(),
2113 MessageSendEvent::SendChannelRangeQuery {ref node_id, ref msg, } => {
2114 let mut node_id_nonref = (*node_id).clone();
2115 let mut msg_nonref = (*msg).clone();
2116 nativeMessageSendEvent::SendChannelRangeQuery {
2117 node_id: node_id_nonref.into_rust(),
2118 msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) },
2121 MessageSendEvent::SendShortIdsQuery {ref node_id, ref msg, } => {
2122 let mut node_id_nonref = (*node_id).clone();
2123 let mut msg_nonref = (*msg).clone();
2124 nativeMessageSendEvent::SendShortIdsQuery {
2125 node_id: node_id_nonref.into_rust(),
2126 msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) },
2129 MessageSendEvent::SendReplyChannelRange {ref node_id, ref msg, } => {
2130 let mut node_id_nonref = (*node_id).clone();
2131 let mut msg_nonref = (*msg).clone();
2132 nativeMessageSendEvent::SendReplyChannelRange {
2133 node_id: node_id_nonref.into_rust(),
2134 msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) },
2137 MessageSendEvent::SendGossipTimestampFilter {ref node_id, ref msg, } => {
2138 let mut node_id_nonref = (*node_id).clone();
2139 let mut msg_nonref = (*msg).clone();
2140 nativeMessageSendEvent::SendGossipTimestampFilter {
2141 node_id: node_id_nonref.into_rust(),
2142 msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) },
2148 pub(crate) fn into_native(self) -> nativeMessageSendEvent {
2150 MessageSendEvent::SendAcceptChannel {mut node_id, mut msg, } => {
2151 nativeMessageSendEvent::SendAcceptChannel {
2152 node_id: node_id.into_rust(),
2153 msg: *unsafe { Box::from_raw(msg.take_inner()) },
2156 MessageSendEvent::SendOpenChannel {mut node_id, mut msg, } => {
2157 nativeMessageSendEvent::SendOpenChannel {
2158 node_id: node_id.into_rust(),
2159 msg: *unsafe { Box::from_raw(msg.take_inner()) },
2162 MessageSendEvent::SendFundingCreated {mut node_id, mut msg, } => {
2163 nativeMessageSendEvent::SendFundingCreated {
2164 node_id: node_id.into_rust(),
2165 msg: *unsafe { Box::from_raw(msg.take_inner()) },
2168 MessageSendEvent::SendFundingSigned {mut node_id, mut msg, } => {
2169 nativeMessageSendEvent::SendFundingSigned {
2170 node_id: node_id.into_rust(),
2171 msg: *unsafe { Box::from_raw(msg.take_inner()) },
2174 MessageSendEvent::SendChannelReady {mut node_id, mut msg, } => {
2175 nativeMessageSendEvent::SendChannelReady {
2176 node_id: node_id.into_rust(),
2177 msg: *unsafe { Box::from_raw(msg.take_inner()) },
2180 MessageSendEvent::SendAnnouncementSignatures {mut node_id, mut msg, } => {
2181 nativeMessageSendEvent::SendAnnouncementSignatures {
2182 node_id: node_id.into_rust(),
2183 msg: *unsafe { Box::from_raw(msg.take_inner()) },
2186 MessageSendEvent::UpdateHTLCs {mut node_id, mut updates, } => {
2187 nativeMessageSendEvent::UpdateHTLCs {
2188 node_id: node_id.into_rust(),
2189 updates: *unsafe { Box::from_raw(updates.take_inner()) },
2192 MessageSendEvent::SendRevokeAndACK {mut node_id, mut msg, } => {
2193 nativeMessageSendEvent::SendRevokeAndACK {
2194 node_id: node_id.into_rust(),
2195 msg: *unsafe { Box::from_raw(msg.take_inner()) },
2198 MessageSendEvent::SendClosingSigned {mut node_id, mut msg, } => {
2199 nativeMessageSendEvent::SendClosingSigned {
2200 node_id: node_id.into_rust(),
2201 msg: *unsafe { Box::from_raw(msg.take_inner()) },
2204 MessageSendEvent::SendShutdown {mut node_id, mut msg, } => {
2205 nativeMessageSendEvent::SendShutdown {
2206 node_id: node_id.into_rust(),
2207 msg: *unsafe { Box::from_raw(msg.take_inner()) },
2210 MessageSendEvent::SendChannelReestablish {mut node_id, mut msg, } => {
2211 nativeMessageSendEvent::SendChannelReestablish {
2212 node_id: node_id.into_rust(),
2213 msg: *unsafe { Box::from_raw(msg.take_inner()) },
2216 MessageSendEvent::SendChannelAnnouncement {mut node_id, mut msg, mut update_msg, } => {
2217 nativeMessageSendEvent::SendChannelAnnouncement {
2218 node_id: node_id.into_rust(),
2219 msg: *unsafe { Box::from_raw(msg.take_inner()) },
2220 update_msg: *unsafe { Box::from_raw(update_msg.take_inner()) },
2223 MessageSendEvent::BroadcastChannelAnnouncement {mut msg, mut update_msg, } => {
2224 nativeMessageSendEvent::BroadcastChannelAnnouncement {
2225 msg: *unsafe { Box::from_raw(msg.take_inner()) },
2226 update_msg: *unsafe { Box::from_raw(update_msg.take_inner()) },
2229 MessageSendEvent::BroadcastChannelUpdate {mut msg, } => {
2230 nativeMessageSendEvent::BroadcastChannelUpdate {
2231 msg: *unsafe { Box::from_raw(msg.take_inner()) },
2234 MessageSendEvent::SendChannelUpdate {mut node_id, mut msg, } => {
2235 nativeMessageSendEvent::SendChannelUpdate {
2236 node_id: node_id.into_rust(),
2237 msg: *unsafe { Box::from_raw(msg.take_inner()) },
2240 MessageSendEvent::HandleError {mut node_id, mut action, } => {
2241 nativeMessageSendEvent::HandleError {
2242 node_id: node_id.into_rust(),
2243 action: action.into_native(),
2246 MessageSendEvent::SendChannelRangeQuery {mut node_id, mut msg, } => {
2247 nativeMessageSendEvent::SendChannelRangeQuery {
2248 node_id: node_id.into_rust(),
2249 msg: *unsafe { Box::from_raw(msg.take_inner()) },
2252 MessageSendEvent::SendShortIdsQuery {mut node_id, mut msg, } => {
2253 nativeMessageSendEvent::SendShortIdsQuery {
2254 node_id: node_id.into_rust(),
2255 msg: *unsafe { Box::from_raw(msg.take_inner()) },
2258 MessageSendEvent::SendReplyChannelRange {mut node_id, mut msg, } => {
2259 nativeMessageSendEvent::SendReplyChannelRange {
2260 node_id: node_id.into_rust(),
2261 msg: *unsafe { Box::from_raw(msg.take_inner()) },
2264 MessageSendEvent::SendGossipTimestampFilter {mut node_id, mut msg, } => {
2265 nativeMessageSendEvent::SendGossipTimestampFilter {
2266 node_id: node_id.into_rust(),
2267 msg: *unsafe { Box::from_raw(msg.take_inner()) },
2273 pub(crate) fn from_native(native: &nativeMessageSendEvent) -> Self {
2275 nativeMessageSendEvent::SendAcceptChannel {ref node_id, ref msg, } => {
2276 let mut node_id_nonref = (*node_id).clone();
2277 let mut msg_nonref = (*msg).clone();
2278 MessageSendEvent::SendAcceptChannel {
2279 node_id: crate::c_types::PublicKey::from_rust(&node_id_nonref),
2280 msg: crate::lightning::ln::msgs::AcceptChannel { inner: ObjOps::heap_alloc(msg_nonref), is_owned: true },
2283 nativeMessageSendEvent::SendOpenChannel {ref node_id, ref msg, } => {
2284 let mut node_id_nonref = (*node_id).clone();
2285 let mut msg_nonref = (*msg).clone();
2286 MessageSendEvent::SendOpenChannel {
2287 node_id: crate::c_types::PublicKey::from_rust(&node_id_nonref),
2288 msg: crate::lightning::ln::msgs::OpenChannel { inner: ObjOps::heap_alloc(msg_nonref), is_owned: true },
2291 nativeMessageSendEvent::SendFundingCreated {ref node_id, ref msg, } => {
2292 let mut node_id_nonref = (*node_id).clone();
2293 let mut msg_nonref = (*msg).clone();
2294 MessageSendEvent::SendFundingCreated {
2295 node_id: crate::c_types::PublicKey::from_rust(&node_id_nonref),
2296 msg: crate::lightning::ln::msgs::FundingCreated { inner: ObjOps::heap_alloc(msg_nonref), is_owned: true },
2299 nativeMessageSendEvent::SendFundingSigned {ref node_id, ref msg, } => {
2300 let mut node_id_nonref = (*node_id).clone();
2301 let mut msg_nonref = (*msg).clone();
2302 MessageSendEvent::SendFundingSigned {
2303 node_id: crate::c_types::PublicKey::from_rust(&node_id_nonref),
2304 msg: crate::lightning::ln::msgs::FundingSigned { inner: ObjOps::heap_alloc(msg_nonref), is_owned: true },
2307 nativeMessageSendEvent::SendChannelReady {ref node_id, ref msg, } => {
2308 let mut node_id_nonref = (*node_id).clone();
2309 let mut msg_nonref = (*msg).clone();
2310 MessageSendEvent::SendChannelReady {
2311 node_id: crate::c_types::PublicKey::from_rust(&node_id_nonref),
2312 msg: crate::lightning::ln::msgs::ChannelReady { inner: ObjOps::heap_alloc(msg_nonref), is_owned: true },
2315 nativeMessageSendEvent::SendAnnouncementSignatures {ref node_id, ref msg, } => {
2316 let mut node_id_nonref = (*node_id).clone();
2317 let mut msg_nonref = (*msg).clone();
2318 MessageSendEvent::SendAnnouncementSignatures {
2319 node_id: crate::c_types::PublicKey::from_rust(&node_id_nonref),
2320 msg: crate::lightning::ln::msgs::AnnouncementSignatures { inner: ObjOps::heap_alloc(msg_nonref), is_owned: true },
2323 nativeMessageSendEvent::UpdateHTLCs {ref node_id, ref updates, } => {
2324 let mut node_id_nonref = (*node_id).clone();
2325 let mut updates_nonref = (*updates).clone();
2326 MessageSendEvent::UpdateHTLCs {
2327 node_id: crate::c_types::PublicKey::from_rust(&node_id_nonref),
2328 updates: crate::lightning::ln::msgs::CommitmentUpdate { inner: ObjOps::heap_alloc(updates_nonref), is_owned: true },
2331 nativeMessageSendEvent::SendRevokeAndACK {ref node_id, ref msg, } => {
2332 let mut node_id_nonref = (*node_id).clone();
2333 let mut msg_nonref = (*msg).clone();
2334 MessageSendEvent::SendRevokeAndACK {
2335 node_id: crate::c_types::PublicKey::from_rust(&node_id_nonref),
2336 msg: crate::lightning::ln::msgs::RevokeAndACK { inner: ObjOps::heap_alloc(msg_nonref), is_owned: true },
2339 nativeMessageSendEvent::SendClosingSigned {ref node_id, ref msg, } => {
2340 let mut node_id_nonref = (*node_id).clone();
2341 let mut msg_nonref = (*msg).clone();
2342 MessageSendEvent::SendClosingSigned {
2343 node_id: crate::c_types::PublicKey::from_rust(&node_id_nonref),
2344 msg: crate::lightning::ln::msgs::ClosingSigned { inner: ObjOps::heap_alloc(msg_nonref), is_owned: true },
2347 nativeMessageSendEvent::SendShutdown {ref node_id, ref msg, } => {
2348 let mut node_id_nonref = (*node_id).clone();
2349 let mut msg_nonref = (*msg).clone();
2350 MessageSendEvent::SendShutdown {
2351 node_id: crate::c_types::PublicKey::from_rust(&node_id_nonref),
2352 msg: crate::lightning::ln::msgs::Shutdown { inner: ObjOps::heap_alloc(msg_nonref), is_owned: true },
2355 nativeMessageSendEvent::SendChannelReestablish {ref node_id, ref msg, } => {
2356 let mut node_id_nonref = (*node_id).clone();
2357 let mut msg_nonref = (*msg).clone();
2358 MessageSendEvent::SendChannelReestablish {
2359 node_id: crate::c_types::PublicKey::from_rust(&node_id_nonref),
2360 msg: crate::lightning::ln::msgs::ChannelReestablish { inner: ObjOps::heap_alloc(msg_nonref), is_owned: true },
2363 nativeMessageSendEvent::SendChannelAnnouncement {ref node_id, ref msg, ref update_msg, } => {
2364 let mut node_id_nonref = (*node_id).clone();
2365 let mut msg_nonref = (*msg).clone();
2366 let mut update_msg_nonref = (*update_msg).clone();
2367 MessageSendEvent::SendChannelAnnouncement {
2368 node_id: crate::c_types::PublicKey::from_rust(&node_id_nonref),
2369 msg: crate::lightning::ln::msgs::ChannelAnnouncement { inner: ObjOps::heap_alloc(msg_nonref), is_owned: true },
2370 update_msg: crate::lightning::ln::msgs::ChannelUpdate { inner: ObjOps::heap_alloc(update_msg_nonref), is_owned: true },
2373 nativeMessageSendEvent::BroadcastChannelAnnouncement {ref msg, ref update_msg, } => {
2374 let mut msg_nonref = (*msg).clone();
2375 let mut update_msg_nonref = (*update_msg).clone();
2376 MessageSendEvent::BroadcastChannelAnnouncement {
2377 msg: crate::lightning::ln::msgs::ChannelAnnouncement { inner: ObjOps::heap_alloc(msg_nonref), is_owned: true },
2378 update_msg: crate::lightning::ln::msgs::ChannelUpdate { inner: ObjOps::heap_alloc(update_msg_nonref), is_owned: true },
2381 nativeMessageSendEvent::BroadcastChannelUpdate {ref msg, } => {
2382 let mut msg_nonref = (*msg).clone();
2383 MessageSendEvent::BroadcastChannelUpdate {
2384 msg: crate::lightning::ln::msgs::ChannelUpdate { inner: ObjOps::heap_alloc(msg_nonref), is_owned: true },
2387 nativeMessageSendEvent::SendChannelUpdate {ref node_id, ref msg, } => {
2388 let mut node_id_nonref = (*node_id).clone();
2389 let mut msg_nonref = (*msg).clone();
2390 MessageSendEvent::SendChannelUpdate {
2391 node_id: crate::c_types::PublicKey::from_rust(&node_id_nonref),
2392 msg: crate::lightning::ln::msgs::ChannelUpdate { inner: ObjOps::heap_alloc(msg_nonref), is_owned: true },
2395 nativeMessageSendEvent::HandleError {ref node_id, ref action, } => {
2396 let mut node_id_nonref = (*node_id).clone();
2397 let mut action_nonref = (*action).clone();
2398 MessageSendEvent::HandleError {
2399 node_id: crate::c_types::PublicKey::from_rust(&node_id_nonref),
2400 action: crate::lightning::ln::msgs::ErrorAction::native_into(action_nonref),
2403 nativeMessageSendEvent::SendChannelRangeQuery {ref node_id, ref msg, } => {
2404 let mut node_id_nonref = (*node_id).clone();
2405 let mut msg_nonref = (*msg).clone();
2406 MessageSendEvent::SendChannelRangeQuery {
2407 node_id: crate::c_types::PublicKey::from_rust(&node_id_nonref),
2408 msg: crate::lightning::ln::msgs::QueryChannelRange { inner: ObjOps::heap_alloc(msg_nonref), is_owned: true },
2411 nativeMessageSendEvent::SendShortIdsQuery {ref node_id, ref msg, } => {
2412 let mut node_id_nonref = (*node_id).clone();
2413 let mut msg_nonref = (*msg).clone();
2414 MessageSendEvent::SendShortIdsQuery {
2415 node_id: crate::c_types::PublicKey::from_rust(&node_id_nonref),
2416 msg: crate::lightning::ln::msgs::QueryShortChannelIds { inner: ObjOps::heap_alloc(msg_nonref), is_owned: true },
2419 nativeMessageSendEvent::SendReplyChannelRange {ref node_id, ref msg, } => {
2420 let mut node_id_nonref = (*node_id).clone();
2421 let mut msg_nonref = (*msg).clone();
2422 MessageSendEvent::SendReplyChannelRange {
2423 node_id: crate::c_types::PublicKey::from_rust(&node_id_nonref),
2424 msg: crate::lightning::ln::msgs::ReplyChannelRange { inner: ObjOps::heap_alloc(msg_nonref), is_owned: true },
2427 nativeMessageSendEvent::SendGossipTimestampFilter {ref node_id, ref msg, } => {
2428 let mut node_id_nonref = (*node_id).clone();
2429 let mut msg_nonref = (*msg).clone();
2430 MessageSendEvent::SendGossipTimestampFilter {
2431 node_id: crate::c_types::PublicKey::from_rust(&node_id_nonref),
2432 msg: crate::lightning::ln::msgs::GossipTimestampFilter { inner: ObjOps::heap_alloc(msg_nonref), is_owned: true },
2438 pub(crate) fn native_into(native: nativeMessageSendEvent) -> Self {
2440 nativeMessageSendEvent::SendAcceptChannel {mut node_id, mut msg, } => {
2441 MessageSendEvent::SendAcceptChannel {
2442 node_id: crate::c_types::PublicKey::from_rust(&node_id),
2443 msg: crate::lightning::ln::msgs::AcceptChannel { inner: ObjOps::heap_alloc(msg), is_owned: true },
2446 nativeMessageSendEvent::SendOpenChannel {mut node_id, mut msg, } => {
2447 MessageSendEvent::SendOpenChannel {
2448 node_id: crate::c_types::PublicKey::from_rust(&node_id),
2449 msg: crate::lightning::ln::msgs::OpenChannel { inner: ObjOps::heap_alloc(msg), is_owned: true },
2452 nativeMessageSendEvent::SendFundingCreated {mut node_id, mut msg, } => {
2453 MessageSendEvent::SendFundingCreated {
2454 node_id: crate::c_types::PublicKey::from_rust(&node_id),
2455 msg: crate::lightning::ln::msgs::FundingCreated { inner: ObjOps::heap_alloc(msg), is_owned: true },
2458 nativeMessageSendEvent::SendFundingSigned {mut node_id, mut msg, } => {
2459 MessageSendEvent::SendFundingSigned {
2460 node_id: crate::c_types::PublicKey::from_rust(&node_id),
2461 msg: crate::lightning::ln::msgs::FundingSigned { inner: ObjOps::heap_alloc(msg), is_owned: true },
2464 nativeMessageSendEvent::SendChannelReady {mut node_id, mut msg, } => {
2465 MessageSendEvent::SendChannelReady {
2466 node_id: crate::c_types::PublicKey::from_rust(&node_id),
2467 msg: crate::lightning::ln::msgs::ChannelReady { inner: ObjOps::heap_alloc(msg), is_owned: true },
2470 nativeMessageSendEvent::SendAnnouncementSignatures {mut node_id, mut msg, } => {
2471 MessageSendEvent::SendAnnouncementSignatures {
2472 node_id: crate::c_types::PublicKey::from_rust(&node_id),
2473 msg: crate::lightning::ln::msgs::AnnouncementSignatures { inner: ObjOps::heap_alloc(msg), is_owned: true },
2476 nativeMessageSendEvent::UpdateHTLCs {mut node_id, mut updates, } => {
2477 MessageSendEvent::UpdateHTLCs {
2478 node_id: crate::c_types::PublicKey::from_rust(&node_id),
2479 updates: crate::lightning::ln::msgs::CommitmentUpdate { inner: ObjOps::heap_alloc(updates), is_owned: true },
2482 nativeMessageSendEvent::SendRevokeAndACK {mut node_id, mut msg, } => {
2483 MessageSendEvent::SendRevokeAndACK {
2484 node_id: crate::c_types::PublicKey::from_rust(&node_id),
2485 msg: crate::lightning::ln::msgs::RevokeAndACK { inner: ObjOps::heap_alloc(msg), is_owned: true },
2488 nativeMessageSendEvent::SendClosingSigned {mut node_id, mut msg, } => {
2489 MessageSendEvent::SendClosingSigned {
2490 node_id: crate::c_types::PublicKey::from_rust(&node_id),
2491 msg: crate::lightning::ln::msgs::ClosingSigned { inner: ObjOps::heap_alloc(msg), is_owned: true },
2494 nativeMessageSendEvent::SendShutdown {mut node_id, mut msg, } => {
2495 MessageSendEvent::SendShutdown {
2496 node_id: crate::c_types::PublicKey::from_rust(&node_id),
2497 msg: crate::lightning::ln::msgs::Shutdown { inner: ObjOps::heap_alloc(msg), is_owned: true },
2500 nativeMessageSendEvent::SendChannelReestablish {mut node_id, mut msg, } => {
2501 MessageSendEvent::SendChannelReestablish {
2502 node_id: crate::c_types::PublicKey::from_rust(&node_id),
2503 msg: crate::lightning::ln::msgs::ChannelReestablish { inner: ObjOps::heap_alloc(msg), is_owned: true },
2506 nativeMessageSendEvent::SendChannelAnnouncement {mut node_id, mut msg, mut update_msg, } => {
2507 MessageSendEvent::SendChannelAnnouncement {
2508 node_id: crate::c_types::PublicKey::from_rust(&node_id),
2509 msg: crate::lightning::ln::msgs::ChannelAnnouncement { inner: ObjOps::heap_alloc(msg), is_owned: true },
2510 update_msg: crate::lightning::ln::msgs::ChannelUpdate { inner: ObjOps::heap_alloc(update_msg), is_owned: true },
2513 nativeMessageSendEvent::BroadcastChannelAnnouncement {mut msg, mut update_msg, } => {
2514 MessageSendEvent::BroadcastChannelAnnouncement {
2515 msg: crate::lightning::ln::msgs::ChannelAnnouncement { inner: ObjOps::heap_alloc(msg), is_owned: true },
2516 update_msg: crate::lightning::ln::msgs::ChannelUpdate { inner: ObjOps::heap_alloc(update_msg), is_owned: true },
2519 nativeMessageSendEvent::BroadcastChannelUpdate {mut msg, } => {
2520 MessageSendEvent::BroadcastChannelUpdate {
2521 msg: crate::lightning::ln::msgs::ChannelUpdate { inner: ObjOps::heap_alloc(msg), is_owned: true },
2524 nativeMessageSendEvent::SendChannelUpdate {mut node_id, mut msg, } => {
2525 MessageSendEvent::SendChannelUpdate {
2526 node_id: crate::c_types::PublicKey::from_rust(&node_id),
2527 msg: crate::lightning::ln::msgs::ChannelUpdate { inner: ObjOps::heap_alloc(msg), is_owned: true },
2530 nativeMessageSendEvent::HandleError {mut node_id, mut action, } => {
2531 MessageSendEvent::HandleError {
2532 node_id: crate::c_types::PublicKey::from_rust(&node_id),
2533 action: crate::lightning::ln::msgs::ErrorAction::native_into(action),
2536 nativeMessageSendEvent::SendChannelRangeQuery {mut node_id, mut msg, } => {
2537 MessageSendEvent::SendChannelRangeQuery {
2538 node_id: crate::c_types::PublicKey::from_rust(&node_id),
2539 msg: crate::lightning::ln::msgs::QueryChannelRange { inner: ObjOps::heap_alloc(msg), is_owned: true },
2542 nativeMessageSendEvent::SendShortIdsQuery {mut node_id, mut msg, } => {
2543 MessageSendEvent::SendShortIdsQuery {
2544 node_id: crate::c_types::PublicKey::from_rust(&node_id),
2545 msg: crate::lightning::ln::msgs::QueryShortChannelIds { inner: ObjOps::heap_alloc(msg), is_owned: true },
2548 nativeMessageSendEvent::SendReplyChannelRange {mut node_id, mut msg, } => {
2549 MessageSendEvent::SendReplyChannelRange {
2550 node_id: crate::c_types::PublicKey::from_rust(&node_id),
2551 msg: crate::lightning::ln::msgs::ReplyChannelRange { inner: ObjOps::heap_alloc(msg), is_owned: true },
2554 nativeMessageSendEvent::SendGossipTimestampFilter {mut node_id, mut msg, } => {
2555 MessageSendEvent::SendGossipTimestampFilter {
2556 node_id: crate::c_types::PublicKey::from_rust(&node_id),
2557 msg: crate::lightning::ln::msgs::GossipTimestampFilter { inner: ObjOps::heap_alloc(msg), is_owned: true },
2563 /// Frees any resources used by the MessageSendEvent
2565 pub extern "C" fn MessageSendEvent_free(this_ptr: MessageSendEvent) { }
2566 /// Creates a copy of the MessageSendEvent
2568 pub extern "C" fn MessageSendEvent_clone(orig: &MessageSendEvent) -> MessageSendEvent {
2572 /// Utility method to constructs a new SendAcceptChannel-variant MessageSendEvent
2573 pub extern "C" fn MessageSendEvent_send_accept_channel(node_id: crate::c_types::PublicKey, msg: crate::lightning::ln::msgs::AcceptChannel) -> MessageSendEvent {
2574 MessageSendEvent::SendAcceptChannel {
2580 /// Utility method to constructs a new SendOpenChannel-variant MessageSendEvent
2581 pub extern "C" fn MessageSendEvent_send_open_channel(node_id: crate::c_types::PublicKey, msg: crate::lightning::ln::msgs::OpenChannel) -> MessageSendEvent {
2582 MessageSendEvent::SendOpenChannel {
2588 /// Utility method to constructs a new SendFundingCreated-variant MessageSendEvent
2589 pub extern "C" fn MessageSendEvent_send_funding_created(node_id: crate::c_types::PublicKey, msg: crate::lightning::ln::msgs::FundingCreated) -> MessageSendEvent {
2590 MessageSendEvent::SendFundingCreated {
2596 /// Utility method to constructs a new SendFundingSigned-variant MessageSendEvent
2597 pub extern "C" fn MessageSendEvent_send_funding_signed(node_id: crate::c_types::PublicKey, msg: crate::lightning::ln::msgs::FundingSigned) -> MessageSendEvent {
2598 MessageSendEvent::SendFundingSigned {
2604 /// Utility method to constructs a new SendChannelReady-variant MessageSendEvent
2605 pub extern "C" fn MessageSendEvent_send_channel_ready(node_id: crate::c_types::PublicKey, msg: crate::lightning::ln::msgs::ChannelReady) -> MessageSendEvent {
2606 MessageSendEvent::SendChannelReady {
2612 /// Utility method to constructs a new SendAnnouncementSignatures-variant MessageSendEvent
2613 pub extern "C" fn MessageSendEvent_send_announcement_signatures(node_id: crate::c_types::PublicKey, msg: crate::lightning::ln::msgs::AnnouncementSignatures) -> MessageSendEvent {
2614 MessageSendEvent::SendAnnouncementSignatures {
2620 /// Utility method to constructs a new UpdateHTLCs-variant MessageSendEvent
2621 pub extern "C" fn MessageSendEvent_update_htlcs(node_id: crate::c_types::PublicKey, updates: crate::lightning::ln::msgs::CommitmentUpdate) -> MessageSendEvent {
2622 MessageSendEvent::UpdateHTLCs {
2628 /// Utility method to constructs a new SendRevokeAndACK-variant MessageSendEvent
2629 pub extern "C" fn MessageSendEvent_send_revoke_and_ack(node_id: crate::c_types::PublicKey, msg: crate::lightning::ln::msgs::RevokeAndACK) -> MessageSendEvent {
2630 MessageSendEvent::SendRevokeAndACK {
2636 /// Utility method to constructs a new SendClosingSigned-variant MessageSendEvent
2637 pub extern "C" fn MessageSendEvent_send_closing_signed(node_id: crate::c_types::PublicKey, msg: crate::lightning::ln::msgs::ClosingSigned) -> MessageSendEvent {
2638 MessageSendEvent::SendClosingSigned {
2644 /// Utility method to constructs a new SendShutdown-variant MessageSendEvent
2645 pub extern "C" fn MessageSendEvent_send_shutdown(node_id: crate::c_types::PublicKey, msg: crate::lightning::ln::msgs::Shutdown) -> MessageSendEvent {
2646 MessageSendEvent::SendShutdown {
2652 /// Utility method to constructs a new SendChannelReestablish-variant MessageSendEvent
2653 pub extern "C" fn MessageSendEvent_send_channel_reestablish(node_id: crate::c_types::PublicKey, msg: crate::lightning::ln::msgs::ChannelReestablish) -> MessageSendEvent {
2654 MessageSendEvent::SendChannelReestablish {
2660 /// Utility method to constructs a new SendChannelAnnouncement-variant MessageSendEvent
2661 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 {
2662 MessageSendEvent::SendChannelAnnouncement {
2669 /// Utility method to constructs a new BroadcastChannelAnnouncement-variant MessageSendEvent
2670 pub extern "C" fn MessageSendEvent_broadcast_channel_announcement(msg: crate::lightning::ln::msgs::ChannelAnnouncement, update_msg: crate::lightning::ln::msgs::ChannelUpdate) -> MessageSendEvent {
2671 MessageSendEvent::BroadcastChannelAnnouncement {
2677 /// Utility method to constructs a new BroadcastChannelUpdate-variant MessageSendEvent
2678 pub extern "C" fn MessageSendEvent_broadcast_channel_update(msg: crate::lightning::ln::msgs::ChannelUpdate) -> MessageSendEvent {
2679 MessageSendEvent::BroadcastChannelUpdate {
2684 /// Utility method to constructs a new SendChannelUpdate-variant MessageSendEvent
2685 pub extern "C" fn MessageSendEvent_send_channel_update(node_id: crate::c_types::PublicKey, msg: crate::lightning::ln::msgs::ChannelUpdate) -> MessageSendEvent {
2686 MessageSendEvent::SendChannelUpdate {
2692 /// Utility method to constructs a new HandleError-variant MessageSendEvent
2693 pub extern "C" fn MessageSendEvent_handle_error(node_id: crate::c_types::PublicKey, action: crate::lightning::ln::msgs::ErrorAction) -> MessageSendEvent {
2694 MessageSendEvent::HandleError {
2700 /// Utility method to constructs a new SendChannelRangeQuery-variant MessageSendEvent
2701 pub extern "C" fn MessageSendEvent_send_channel_range_query(node_id: crate::c_types::PublicKey, msg: crate::lightning::ln::msgs::QueryChannelRange) -> MessageSendEvent {
2702 MessageSendEvent::SendChannelRangeQuery {
2708 /// Utility method to constructs a new SendShortIdsQuery-variant MessageSendEvent
2709 pub extern "C" fn MessageSendEvent_send_short_ids_query(node_id: crate::c_types::PublicKey, msg: crate::lightning::ln::msgs::QueryShortChannelIds) -> MessageSendEvent {
2710 MessageSendEvent::SendShortIdsQuery {
2716 /// Utility method to constructs a new SendReplyChannelRange-variant MessageSendEvent
2717 pub extern "C" fn MessageSendEvent_send_reply_channel_range(node_id: crate::c_types::PublicKey, msg: crate::lightning::ln::msgs::ReplyChannelRange) -> MessageSendEvent {
2718 MessageSendEvent::SendReplyChannelRange {
2724 /// Utility method to constructs a new SendGossipTimestampFilter-variant MessageSendEvent
2725 pub extern "C" fn MessageSendEvent_send_gossip_timestamp_filter(node_id: crate::c_types::PublicKey, msg: crate::lightning::ln::msgs::GossipTimestampFilter) -> MessageSendEvent {
2726 MessageSendEvent::SendGossipTimestampFilter {
2731 /// A trait indicating an object may generate message send events
2733 pub struct MessageSendEventsProvider {
2734 /// An opaque pointer which is passed to your function implementations as an argument.
2735 /// This has no meaning in the LDK, and can be NULL or any other value.
2736 pub this_arg: *mut c_void,
2737 /// Gets the list of pending events which were generated by previous actions, clearing the list
2740 pub get_and_clear_pending_msg_events: extern "C" fn (this_arg: *const c_void) -> crate::c_types::derived::CVec_MessageSendEventZ,
2741 /// Frees any resources associated with this object given its this_arg pointer.
2742 /// Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed.
2743 pub free: Option<extern "C" fn(this_arg: *mut c_void)>,
2745 unsafe impl Send for MessageSendEventsProvider {}
2746 unsafe impl Sync for MessageSendEventsProvider {}
2748 pub(crate) extern "C" fn MessageSendEventsProvider_clone_fields(orig: &MessageSendEventsProvider) -> MessageSendEventsProvider {
2749 MessageSendEventsProvider {
2750 this_arg: orig.this_arg,
2751 get_and_clear_pending_msg_events: Clone::clone(&orig.get_and_clear_pending_msg_events),
2752 free: Clone::clone(&orig.free),
2756 use lightning::util::events::MessageSendEventsProvider as rustMessageSendEventsProvider;
2757 impl rustMessageSendEventsProvider for MessageSendEventsProvider {
2758 fn get_and_clear_pending_msg_events(&self) -> Vec<lightning::util::events::MessageSendEvent> {
2759 let mut ret = (self.get_and_clear_pending_msg_events)(self.this_arg);
2760 let mut local_ret = Vec::new(); for mut item in ret.into_rust().drain(..) { local_ret.push( { item.into_native() }); };
2765 // We're essentially a pointer already, or at least a set of pointers, so allow us to be used
2766 // directly as a Deref trait in higher-level structs:
2767 impl core::ops::Deref for MessageSendEventsProvider {
2769 fn deref(&self) -> &Self {
2773 /// Calls the free function if one is set
2775 pub extern "C" fn MessageSendEventsProvider_free(this_ptr: MessageSendEventsProvider) { }
2776 impl Drop for MessageSendEventsProvider {
2777 fn drop(&mut self) {
2778 if let Some(f) = self.free {
2783 /// A trait indicating an object may generate onion messages to send
2785 pub struct OnionMessageProvider {
2786 /// An opaque pointer which is passed to your function implementations as an argument.
2787 /// This has no meaning in the LDK, and can be NULL or any other value.
2788 pub this_arg: *mut c_void,
2789 /// Gets the next pending onion message for the peer with the given node id.
2791 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
2793 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,
2794 /// Frees any resources associated with this object given its this_arg pointer.
2795 /// Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed.
2796 pub free: Option<extern "C" fn(this_arg: *mut c_void)>,
2798 unsafe impl Send for OnionMessageProvider {}
2799 unsafe impl Sync for OnionMessageProvider {}
2801 pub(crate) extern "C" fn OnionMessageProvider_clone_fields(orig: &OnionMessageProvider) -> OnionMessageProvider {
2802 OnionMessageProvider {
2803 this_arg: orig.this_arg,
2804 next_onion_message_for_peer: Clone::clone(&orig.next_onion_message_for_peer),
2805 free: Clone::clone(&orig.free),
2809 use lightning::util::events::OnionMessageProvider as rustOnionMessageProvider;
2810 impl rustOnionMessageProvider for OnionMessageProvider {
2811 fn next_onion_message_for_peer(&self, mut peer_node_id: bitcoin::secp256k1::PublicKey) -> Option<lightning::ln::msgs::OnionMessage> {
2812 let mut ret = (self.next_onion_message_for_peer)(self.this_arg, crate::c_types::PublicKey::from_rust(&peer_node_id));
2813 let mut local_ret = if ret.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(ret.take_inner()) } }) };
2818 // We're essentially a pointer already, or at least a set of pointers, so allow us to be used
2819 // directly as a Deref trait in higher-level structs:
2820 impl core::ops::Deref for OnionMessageProvider {
2822 fn deref(&self) -> &Self {
2826 /// Calls the free function if one is set
2828 pub extern "C" fn OnionMessageProvider_free(this_ptr: OnionMessageProvider) { }
2829 impl Drop for OnionMessageProvider {
2830 fn drop(&mut self) {
2831 if let Some(f) = self.free {
2836 /// A trait indicating an object may generate events.
2838 /// Events are processed by passing an [`EventHandler`] to [`process_pending_events`].
2842 /// When using this trait, [`process_pending_events`] will call [`handle_event`] for each pending
2843 /// event since the last invocation.
2845 /// In order to ensure no [`Event`]s are lost, implementors of this trait will persist [`Event`]s
2846 /// and replay any unhandled events on startup. An [`Event`] is considered handled when
2847 /// [`process_pending_events`] returns, thus handlers MUST fully handle [`Event`]s and persist any
2848 /// relevant changes to disk *before* returning.
2850 /// Further, because an application may crash between an [`Event`] being handled and the
2851 /// implementor of this trait being re-serialized, [`Event`] handling must be idempotent - in
2852 /// effect, [`Event`]s may be replayed.
2854 /// Note, handlers may call back into the provider and thus deadlocking must be avoided. Be sure to
2855 /// consult the provider's documentation on the implication of processing events and how a handler
2856 /// may safely use the provider (e.g., see [`ChannelManager::process_pending_events`] and
2857 /// [`ChainMonitor::process_pending_events`]).
2859 /// (C-not implementable) As there is likely no reason for a user to implement this trait on their
2862 /// [`process_pending_events`]: Self::process_pending_events
2863 /// [`handle_event`]: EventHandler::handle_event
2864 /// [`ChannelManager::process_pending_events`]: crate::ln::channelmanager::ChannelManager#method.process_pending_events
2865 /// [`ChainMonitor::process_pending_events`]: crate::chain::chainmonitor::ChainMonitor#method.process_pending_events
2867 pub struct EventsProvider {
2868 /// An opaque pointer which is passed to your function implementations as an argument.
2869 /// This has no meaning in the LDK, and can be NULL or any other value.
2870 pub this_arg: *mut c_void,
2871 /// Processes any events generated since the last call using the given event handler.
2873 /// See the trait-level documentation for requirements.
2874 pub process_pending_events: extern "C" fn (this_arg: *const c_void, handler: crate::lightning::util::events::EventHandler),
2875 /// Frees any resources associated with this object given its this_arg pointer.
2876 /// Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed.
2877 pub free: Option<extern "C" fn(this_arg: *mut c_void)>,
2879 unsafe impl Send for EventsProvider {}
2880 unsafe impl Sync for EventsProvider {}
2882 pub(crate) extern "C" fn EventsProvider_clone_fields(orig: &EventsProvider) -> EventsProvider {
2884 this_arg: orig.this_arg,
2885 process_pending_events: Clone::clone(&orig.process_pending_events),
2886 free: Clone::clone(&orig.free),
2890 use lightning::util::events::EventsProvider as rustEventsProvider;
2891 /// Calls the free function if one is set
2893 pub extern "C" fn EventsProvider_free(this_ptr: EventsProvider) { }
2894 impl Drop for EventsProvider {
2895 fn drop(&mut self) {
2896 if let Some(f) = self.free {
2901 /// A trait implemented for objects handling events from [`EventsProvider`].
2903 pub struct EventHandler {
2904 /// An opaque pointer which is passed to your function implementations as an argument.
2905 /// This has no meaning in the LDK, and can be NULL or any other value.
2906 pub this_arg: *mut c_void,
2907 /// Handles the given [`Event`].
2909 /// See [`EventsProvider`] for details that must be considered when implementing this method.
2910 pub handle_event: extern "C" fn (this_arg: *const c_void, event: &crate::lightning::util::events::Event),
2911 /// Frees any resources associated with this object given its this_arg pointer.
2912 /// Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed.
2913 pub free: Option<extern "C" fn(this_arg: *mut c_void)>,
2915 unsafe impl Send for EventHandler {}
2916 unsafe impl Sync for EventHandler {}
2918 pub(crate) extern "C" fn EventHandler_clone_fields(orig: &EventHandler) -> EventHandler {
2920 this_arg: orig.this_arg,
2921 handle_event: Clone::clone(&orig.handle_event),
2922 free: Clone::clone(&orig.free),
2926 use lightning::util::events::EventHandler as rustEventHandler;
2927 impl rustEventHandler for EventHandler {
2928 fn handle_event(&self, mut event: &lightning::util::events::Event) {
2929 (self.handle_event)(self.this_arg, &crate::lightning::util::events::Event::from_native(event))
2933 // We're essentially a pointer already, or at least a set of pointers, so allow us to be used
2934 // directly as a Deref trait in higher-level structs:
2935 impl core::ops::Deref for EventHandler {
2937 fn deref(&self) -> &Self {
2941 /// Calls the free function if one is set
2943 pub extern "C" fn EventHandler_free(this_ptr: EventHandler) { }
2944 impl Drop for EventHandler {
2945 fn drop(&mut self) {
2946 if let Some(f) = self.free {