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 { inner: ObjOps::heap_alloc(e), is_owned: true } }).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 /// In LDK versions prior to 0.0.107 this could also occur if we were unable to connect to the
209 /// peer because of mutual incompatibility between us and our channel counterparty.
211 /// Closure generated from `ChannelManager::read` if the ChannelMonitor is newer than
212 /// the ChannelManager deserialized.
213 OutdatedChannelManager,
215 use lightning::util::events::ClosureReason as ClosureReasonImport;
216 pub(crate) type nativeClosureReason = ClosureReasonImport;
220 pub(crate) fn to_native(&self) -> nativeClosureReason {
222 ClosureReason::CounterpartyForceClosed {ref peer_msg, } => {
223 let mut peer_msg_nonref = (*peer_msg).clone();
224 nativeClosureReason::CounterpartyForceClosed {
225 peer_msg: peer_msg_nonref.into_string(),
228 ClosureReason::HolderForceClosed => nativeClosureReason::HolderForceClosed,
229 ClosureReason::CooperativeClosure => nativeClosureReason::CooperativeClosure,
230 ClosureReason::CommitmentTxConfirmed => nativeClosureReason::CommitmentTxConfirmed,
231 ClosureReason::FundingTimedOut => nativeClosureReason::FundingTimedOut,
232 ClosureReason::ProcessingError {ref err, } => {
233 let mut err_nonref = (*err).clone();
234 nativeClosureReason::ProcessingError {
235 err: err_nonref.into_string(),
238 ClosureReason::DisconnectedPeer => nativeClosureReason::DisconnectedPeer,
239 ClosureReason::OutdatedChannelManager => nativeClosureReason::OutdatedChannelManager,
243 pub(crate) fn into_native(self) -> nativeClosureReason {
245 ClosureReason::CounterpartyForceClosed {mut peer_msg, } => {
246 nativeClosureReason::CounterpartyForceClosed {
247 peer_msg: peer_msg.into_string(),
250 ClosureReason::HolderForceClosed => nativeClosureReason::HolderForceClosed,
251 ClosureReason::CooperativeClosure => nativeClosureReason::CooperativeClosure,
252 ClosureReason::CommitmentTxConfirmed => nativeClosureReason::CommitmentTxConfirmed,
253 ClosureReason::FundingTimedOut => nativeClosureReason::FundingTimedOut,
254 ClosureReason::ProcessingError {mut err, } => {
255 nativeClosureReason::ProcessingError {
256 err: err.into_string(),
259 ClosureReason::DisconnectedPeer => nativeClosureReason::DisconnectedPeer,
260 ClosureReason::OutdatedChannelManager => nativeClosureReason::OutdatedChannelManager,
264 pub(crate) fn from_native(native: &nativeClosureReason) -> Self {
266 nativeClosureReason::CounterpartyForceClosed {ref peer_msg, } => {
267 let mut peer_msg_nonref = (*peer_msg).clone();
268 ClosureReason::CounterpartyForceClosed {
269 peer_msg: peer_msg_nonref.into(),
272 nativeClosureReason::HolderForceClosed => ClosureReason::HolderForceClosed,
273 nativeClosureReason::CooperativeClosure => ClosureReason::CooperativeClosure,
274 nativeClosureReason::CommitmentTxConfirmed => ClosureReason::CommitmentTxConfirmed,
275 nativeClosureReason::FundingTimedOut => ClosureReason::FundingTimedOut,
276 nativeClosureReason::ProcessingError {ref err, } => {
277 let mut err_nonref = (*err).clone();
278 ClosureReason::ProcessingError {
279 err: err_nonref.into(),
282 nativeClosureReason::DisconnectedPeer => ClosureReason::DisconnectedPeer,
283 nativeClosureReason::OutdatedChannelManager => ClosureReason::OutdatedChannelManager,
287 pub(crate) fn native_into(native: nativeClosureReason) -> Self {
289 nativeClosureReason::CounterpartyForceClosed {mut peer_msg, } => {
290 ClosureReason::CounterpartyForceClosed {
291 peer_msg: peer_msg.into(),
294 nativeClosureReason::HolderForceClosed => ClosureReason::HolderForceClosed,
295 nativeClosureReason::CooperativeClosure => ClosureReason::CooperativeClosure,
296 nativeClosureReason::CommitmentTxConfirmed => ClosureReason::CommitmentTxConfirmed,
297 nativeClosureReason::FundingTimedOut => ClosureReason::FundingTimedOut,
298 nativeClosureReason::ProcessingError {mut err, } => {
299 ClosureReason::ProcessingError {
303 nativeClosureReason::DisconnectedPeer => ClosureReason::DisconnectedPeer,
304 nativeClosureReason::OutdatedChannelManager => ClosureReason::OutdatedChannelManager,
308 /// Frees any resources used by the ClosureReason
310 pub extern "C" fn ClosureReason_free(this_ptr: ClosureReason) { }
311 /// Creates a copy of the ClosureReason
313 pub extern "C" fn ClosureReason_clone(orig: &ClosureReason) -> ClosureReason {
317 /// Utility method to constructs a new CounterpartyForceClosed-variant ClosureReason
318 pub extern "C" fn ClosureReason_counterparty_force_closed(peer_msg: crate::c_types::Str) -> ClosureReason {
319 ClosureReason::CounterpartyForceClosed {
324 /// Utility method to constructs a new HolderForceClosed-variant ClosureReason
325 pub extern "C" fn ClosureReason_holder_force_closed() -> ClosureReason {
326 ClosureReason::HolderForceClosed}
328 /// Utility method to constructs a new CooperativeClosure-variant ClosureReason
329 pub extern "C" fn ClosureReason_cooperative_closure() -> ClosureReason {
330 ClosureReason::CooperativeClosure}
332 /// Utility method to constructs a new CommitmentTxConfirmed-variant ClosureReason
333 pub extern "C" fn ClosureReason_commitment_tx_confirmed() -> ClosureReason {
334 ClosureReason::CommitmentTxConfirmed}
336 /// Utility method to constructs a new FundingTimedOut-variant ClosureReason
337 pub extern "C" fn ClosureReason_funding_timed_out() -> ClosureReason {
338 ClosureReason::FundingTimedOut}
340 /// Utility method to constructs a new ProcessingError-variant ClosureReason
341 pub extern "C" fn ClosureReason_processing_error(err: crate::c_types::Str) -> ClosureReason {
342 ClosureReason::ProcessingError {
347 /// Utility method to constructs a new DisconnectedPeer-variant ClosureReason
348 pub extern "C" fn ClosureReason_disconnected_peer() -> ClosureReason {
349 ClosureReason::DisconnectedPeer}
351 /// Utility method to constructs a new OutdatedChannelManager-variant ClosureReason
352 pub extern "C" fn ClosureReason_outdated_channel_manager() -> ClosureReason {
353 ClosureReason::OutdatedChannelManager}
355 /// Serialize the ClosureReason object into a byte array which can be read by ClosureReason_read
356 pub extern "C" fn ClosureReason_write(obj: &crate::lightning::util::events::ClosureReason) -> crate::c_types::derived::CVec_u8Z {
357 crate::c_types::serialize_obj(&unsafe { &*obj }.to_native())
360 /// Read a ClosureReason from a byte array, created by ClosureReason_write
361 pub extern "C" fn ClosureReason_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_COption_ClosureReasonZDecodeErrorZ {
362 let res: Result<Option<lightning::util::events::ClosureReason>, lightning::ln::msgs::DecodeError> = crate::c_types::maybe_deserialize_obj(ser);
363 let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { let mut local_res_0 = if o.is_none() { crate::c_types::derived::COption_ClosureReasonZ::None } else { crate::c_types::derived::COption_ClosureReasonZ::Some( { crate::lightning::util::events::ClosureReason::native_into(o.unwrap()) }) }; local_res_0 }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError { inner: ObjOps::heap_alloc(e), is_owned: true } }).into() };
366 /// An Event which you should probably take some action in response to.
368 /// Note that while Writeable and Readable are implemented for Event, you probably shouldn't use
369 /// them directly as they don't round-trip exactly (for example FundingGenerationReady is never
370 /// written as it makes no sense to respond to it after reconnecting to peers).
375 /// Used to indicate that the client should generate a funding transaction with the given
376 /// parameters and then call [`ChannelManager::funding_transaction_generated`].
377 /// Generated in [`ChannelManager`] message handling.
378 /// Note that *all inputs* in the funding transaction must spend SegWit outputs or your
379 /// counterparty can steal your funds!
381 /// [`ChannelManager`]: crate::ln::channelmanager::ChannelManager
382 /// [`ChannelManager::funding_transaction_generated`]: crate::ln::channelmanager::ChannelManager::funding_transaction_generated
383 FundingGenerationReady {
384 /// The random channel_id we picked which you'll need to pass into
385 /// [`ChannelManager::funding_transaction_generated`].
387 /// [`ChannelManager::funding_transaction_generated`]: crate::ln::channelmanager::ChannelManager::funding_transaction_generated
388 temporary_channel_id: crate::c_types::ThirtyTwoBytes,
389 /// The counterparty's node_id, which you'll need to pass back into
390 /// [`ChannelManager::funding_transaction_generated`].
392 /// [`ChannelManager::funding_transaction_generated`]: crate::ln::channelmanager::ChannelManager::funding_transaction_generated
393 counterparty_node_id: crate::c_types::PublicKey,
394 /// The value, in satoshis, that the output should have.
395 channel_value_satoshis: u64,
396 /// The script which should be used in the transaction output.
397 output_script: crate::c_types::derived::CVec_u8Z,
398 /// The `user_channel_id` value passed in to [`ChannelManager::create_channel`], or 0 for
399 /// an inbound channel.
401 /// [`ChannelManager::create_channel`]: crate::ln::channelmanager::ChannelManager::create_channel
402 user_channel_id: u64,
404 /// Indicates we've received (an offer of) money! Just gotta dig out that payment preimage and
405 /// feed it to [`ChannelManager::claim_funds`] to get it....
407 /// Note that if the preimage is not known, you should call
408 /// [`ChannelManager::fail_htlc_backwards`] to free up resources for this HTLC and avoid
409 /// network congestion.
410 /// If you fail to call either [`ChannelManager::claim_funds`] or
411 /// [`ChannelManager::fail_htlc_backwards`] within the HTLC's timeout, the HTLC will be
412 /// automatically failed.
415 /// LDK will not stop an inbound payment from being paid multiple times, so multiple
416 /// `PaymentReceived` events may be generated for the same payment.
418 /// [`ChannelManager::claim_funds`]: crate::ln::channelmanager::ChannelManager::claim_funds
419 /// [`ChannelManager::fail_htlc_backwards`]: crate::ln::channelmanager::ChannelManager::fail_htlc_backwards
421 /// The hash for which the preimage should be handed to the ChannelManager. Note that LDK will
422 /// not stop you from registering duplicate payment hashes for inbound payments.
423 payment_hash: crate::c_types::ThirtyTwoBytes,
424 /// The value, in thousandths of a satoshi, that this payment is for.
426 /// Information for claiming this received payment, based on whether the purpose of the
427 /// payment is to pay an invoice or to send a spontaneous payment.
428 purpose: crate::lightning::util::events::PaymentPurpose,
430 /// Indicates a payment has been claimed and we've received money!
432 /// This most likely occurs when [`ChannelManager::claim_funds`] has been called in response
433 /// to an [`Event::PaymentReceived`]. However, if we previously crashed during a
434 /// [`ChannelManager::claim_funds`] call you may see this event without a corresponding
435 /// [`Event::PaymentReceived`] event.
438 /// LDK will not stop an inbound payment from being paid multiple times, so multiple
439 /// `PaymentReceived` events may be generated for the same payment. If you then call
440 /// [`ChannelManager::claim_funds`] twice for the same [`Event::PaymentReceived`] you may get
441 /// multiple `PaymentClaimed` events.
443 /// [`ChannelManager::claim_funds`]: crate::ln::channelmanager::ChannelManager::claim_funds
445 /// The payment hash of the claimed payment. Note that LDK will not stop you from
446 /// registering duplicate payment hashes for inbound payments.
447 payment_hash: crate::c_types::ThirtyTwoBytes,
448 /// The value, in thousandths of a satoshi, that this payment is for.
450 /// The purpose of this claimed payment, i.e. whether the payment was for an invoice or a
451 /// spontaneous payment.
452 purpose: crate::lightning::util::events::PaymentPurpose,
454 /// Indicates an outbound payment we made succeeded (i.e. it made it all the way to its target
455 /// and we got back the payment preimage for it).
457 /// Note for MPP payments: in rare cases, this event may be preceded by a `PaymentPathFailed`
458 /// event. In this situation, you SHOULD treat this payment as having succeeded.
460 /// The id returned by [`ChannelManager::send_payment`] and used with
461 /// [`ChannelManager::retry_payment`].
463 /// [`ChannelManager::send_payment`]: crate::ln::channelmanager::ChannelManager::send_payment
464 /// [`ChannelManager::retry_payment`]: crate::ln::channelmanager::ChannelManager::retry_payment
466 /// Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None
467 payment_id: crate::c_types::ThirtyTwoBytes,
468 /// The preimage to the hash given to ChannelManager::send_payment.
469 /// Note that this serves as a payment receipt, if you wish to have such a thing, you must
470 /// store it somehow!
471 payment_preimage: crate::c_types::ThirtyTwoBytes,
472 /// The hash that was given to [`ChannelManager::send_payment`].
474 /// [`ChannelManager::send_payment`]: crate::ln::channelmanager::ChannelManager::send_payment
475 payment_hash: crate::c_types::ThirtyTwoBytes,
476 /// The total fee which was spent at intermediate hops in this payment, across all paths.
478 /// Note that, like [`Route::get_total_fees`] this does *not* include any potential
479 /// overpayment to the recipient node.
481 /// If the recipient or an intermediate node misbehaves and gives us free money, this may
482 /// overstate the amount paid, though this is unlikely.
484 /// [`Route::get_total_fees`]: crate::routing::router::Route::get_total_fees
485 fee_paid_msat: crate::c_types::derived::COption_u64Z,
487 /// Indicates an outbound payment failed. Individual [`Event::PaymentPathFailed`] events
488 /// provide failure information for each MPP part in the payment.
490 /// This event is provided once there are no further pending HTLCs for the payment and the
491 /// payment is no longer retryable, either due to a several-block timeout or because
492 /// [`ChannelManager::abandon_payment`] was previously called for the corresponding payment.
494 /// [`ChannelManager::abandon_payment`]: crate::ln::channelmanager::ChannelManager::abandon_payment
496 /// The id returned by [`ChannelManager::send_payment`] and used with
497 /// [`ChannelManager::retry_payment`] and [`ChannelManager::abandon_payment`].
499 /// [`ChannelManager::send_payment`]: crate::ln::channelmanager::ChannelManager::send_payment
500 /// [`ChannelManager::retry_payment`]: crate::ln::channelmanager::ChannelManager::retry_payment
501 /// [`ChannelManager::abandon_payment`]: crate::ln::channelmanager::ChannelManager::abandon_payment
502 payment_id: crate::c_types::ThirtyTwoBytes,
503 /// The hash that was given to [`ChannelManager::send_payment`].
505 /// [`ChannelManager::send_payment`]: crate::ln::channelmanager::ChannelManager::send_payment
506 payment_hash: crate::c_types::ThirtyTwoBytes,
508 /// Indicates that a path for an outbound payment was successful.
510 /// Always generated after [`Event::PaymentSent`] and thus useful for scoring channels. See
511 /// [`Event::PaymentSent`] for obtaining the payment preimage.
512 PaymentPathSuccessful {
513 /// The id returned by [`ChannelManager::send_payment`] and used with
514 /// [`ChannelManager::retry_payment`].
516 /// [`ChannelManager::send_payment`]: crate::ln::channelmanager::ChannelManager::send_payment
517 /// [`ChannelManager::retry_payment`]: crate::ln::channelmanager::ChannelManager::retry_payment
518 payment_id: crate::c_types::ThirtyTwoBytes,
519 /// The hash that was given to [`ChannelManager::send_payment`].
521 /// [`ChannelManager::send_payment`]: crate::ln::channelmanager::ChannelManager::send_payment
523 /// Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None
524 payment_hash: crate::c_types::ThirtyTwoBytes,
525 /// The payment path that was successful.
527 /// May contain a closed channel if the HTLC sent along the path was fulfilled on chain.
528 path: crate::c_types::derived::CVec_RouteHopZ,
530 /// Indicates an outbound HTLC we sent failed. Probably some intermediary node dropped
531 /// something. You may wish to retry with a different route.
533 /// Note that this does *not* indicate that all paths for an MPP payment have failed, see
534 /// [`Event::PaymentFailed`] and [`all_paths_failed`].
536 /// [`all_paths_failed`]: Self::PaymentPathFailed::all_paths_failed
538 /// The id returned by [`ChannelManager::send_payment`] and used with
539 /// [`ChannelManager::retry_payment`] and [`ChannelManager::abandon_payment`].
541 /// [`ChannelManager::send_payment`]: crate::ln::channelmanager::ChannelManager::send_payment
542 /// [`ChannelManager::retry_payment`]: crate::ln::channelmanager::ChannelManager::retry_payment
543 /// [`ChannelManager::abandon_payment`]: crate::ln::channelmanager::ChannelManager::abandon_payment
545 /// Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None
546 payment_id: crate::c_types::ThirtyTwoBytes,
547 /// The hash that was given to [`ChannelManager::send_payment`].
549 /// [`ChannelManager::send_payment`]: crate::ln::channelmanager::ChannelManager::send_payment
550 payment_hash: crate::c_types::ThirtyTwoBytes,
551 /// Indicates the payment was rejected for some reason by the recipient. This implies that
552 /// the payment has failed, not just the route in question. If this is not set, you may
553 /// retry the payment via a different route.
554 rejected_by_dest: bool,
555 /// Any failure information conveyed via the Onion return packet by a node along the failed
558 /// Should be applied to the [`NetworkGraph`] so that routing decisions can take into
559 /// account the update.
561 /// [`NetworkGraph`]: crate::routing::gossip::NetworkGraph
562 network_update: crate::c_types::derived::COption_NetworkUpdateZ,
563 /// For both single-path and multi-path payments, this is set if all paths of the payment have
564 /// failed. This will be set to false if (1) this is an MPP payment and (2) other parts of the
565 /// larger MPP payment were still in flight when this event was generated.
567 /// Note that if you are retrying individual MPP parts, using this value to determine if a
568 /// payment has fully failed is race-y. Because multiple failures can happen prior to events
569 /// being processed, you may retry in response to a first failure, with a second failure
570 /// (with `all_paths_failed` set) still pending. Then, when the second failure is processed
571 /// you will see `all_paths_failed` set even though the retry of the first failure still
572 /// has an associated in-flight HTLC. See (1) for an example of such a failure.
574 /// If you wish to retry individual MPP parts and learn when a payment has failed, you must
575 /// call [`ChannelManager::abandon_payment`] and wait for a [`Event::PaymentFailed`] event.
577 /// (1) <https://github.com/lightningdevkit/rust-lightning/issues/1164>
579 /// [`ChannelManager::abandon_payment`]: crate::ln::channelmanager::ChannelManager::abandon_payment
580 all_paths_failed: bool,
581 /// The payment path that failed.
582 path: crate::c_types::derived::CVec_RouteHopZ,
583 /// The channel responsible for the failed payment path.
585 /// Note that for route hints or for the first hop in a path this may be an SCID alias and
586 /// may not refer to a channel in the public network graph. These aliases may also collide
587 /// with channels in the public network graph.
589 /// If this is `Some`, then the corresponding channel should be avoided when the payment is
590 /// retried. May be `None` for older [`Event`] serializations.
591 short_channel_id: crate::c_types::derived::COption_u64Z,
592 /// Parameters needed to compute a new [`Route`] when retrying the failed payment path.
594 /// See [`find_route`] for details.
596 /// [`Route`]: crate::routing::router::Route
597 /// [`find_route`]: crate::routing::router::find_route
599 /// Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None
600 retry: crate::lightning::routing::router::RouteParameters,
602 /// Used to indicate that [`ChannelManager::process_pending_htlc_forwards`] should be called at
603 /// a time in the future.
605 /// [`ChannelManager::process_pending_htlc_forwards`]: crate::ln::channelmanager::ChannelManager::process_pending_htlc_forwards
606 PendingHTLCsForwardable {
607 /// The minimum amount of time that should be waited prior to calling
608 /// process_pending_htlc_forwards. To increase the effort required to correlate payments,
609 /// you should wait a random amount of time in roughly the range (now + time_forwardable,
610 /// now + 5*time_forwardable).
611 time_forwardable: u64,
613 /// Used to indicate that an output which you should know how to spend was confirmed on chain
614 /// and is now spendable.
615 /// Such an output will *not* ever be spent by rust-lightning, and are not at risk of your
616 /// counterparty spending them due to some kind of timeout. Thus, you need to store them
617 /// somewhere and spend them when you create on-chain transactions.
619 /// The outputs which you should store as spendable by you.
620 outputs: crate::c_types::derived::CVec_SpendableOutputDescriptorZ,
622 /// This event is generated when a payment has been successfully forwarded through us and a
623 /// forwarding fee earned.
625 /// The incoming channel between the previous node and us. This is only `None` for events
626 /// generated or serialized by versions prior to 0.0.107.
628 /// Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None
629 prev_channel_id: crate::c_types::ThirtyTwoBytes,
630 /// The outgoing channel between the next node and us. This is only `None` for events
631 /// generated or serialized by versions prior to 0.0.107.
633 /// Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None
634 next_channel_id: crate::c_types::ThirtyTwoBytes,
635 /// The fee, in milli-satoshis, which was earned as a result of the payment.
637 /// Note that if we force-closed the channel over which we forwarded an HTLC while the HTLC
638 /// was pending, the amount the next hop claimed will have been rounded down to the nearest
639 /// whole satoshi. Thus, the fee calculated here may be higher than expected as we still
640 /// claimed the full value in millisatoshis from the source. In this case,
641 /// `claim_from_onchain_tx` will be set.
643 /// If the channel which sent us the payment has been force-closed, we will claim the funds
644 /// via an on-chain transaction. In that case we do not yet know the on-chain transaction
645 /// fees which we will spend and will instead set this to `None`. It is possible duplicate
646 /// `PaymentForwarded` events are generated for the same payment iff `fee_earned_msat` is
648 fee_earned_msat: crate::c_types::derived::COption_u64Z,
649 /// If this is `true`, the forwarded HTLC was claimed by our counterparty via an on-chain
651 claim_from_onchain_tx: bool,
653 /// Used to indicate that a previously opened channel with the given `channel_id` is in the
654 /// process of closure.
656 /// The channel_id of the channel which has been closed. Note that on-chain transactions
657 /// resolving the channel are likely still awaiting confirmation.
658 channel_id: crate::c_types::ThirtyTwoBytes,
659 /// The `user_channel_id` value passed in to [`ChannelManager::create_channel`] for outbound
660 /// channels, or to [`ChannelManager::accept_inbound_channel`] for inbound channels if
661 /// [`UserConfig::manually_accept_inbound_channels`] config flag is set to true. Otherwise
662 /// `user_channel_id` will be 0 for an inbound channel.
663 /// This will always be zero for objects serialized with LDK versions prior to 0.0.102.
665 /// [`ChannelManager::create_channel`]: crate::ln::channelmanager::ChannelManager::create_channel
666 /// [`ChannelManager::accept_inbound_channel`]: crate::ln::channelmanager::ChannelManager::accept_inbound_channel
667 /// [`UserConfig::manually_accept_inbound_channels`]: crate::util::config::UserConfig::manually_accept_inbound_channels
668 user_channel_id: u64,
669 /// The reason the channel was closed.
670 reason: crate::lightning::util::events::ClosureReason,
672 /// Used to indicate to the user that they can abandon the funding transaction and recycle the
673 /// inputs for another purpose.
675 /// The channel_id of the channel which has been closed.
676 channel_id: crate::c_types::ThirtyTwoBytes,
677 /// The full transaction received from the user
678 transaction: crate::c_types::Transaction,
680 /// Indicates a request to open a new channel by a peer.
682 /// To accept the request, call [`ChannelManager::accept_inbound_channel`]. To reject the
683 /// request, call [`ChannelManager::force_close_without_broadcasting_txn`].
685 /// The event is only triggered when a new open channel request is received and the
686 /// [`UserConfig::manually_accept_inbound_channels`] config flag is set to true.
688 /// [`ChannelManager::accept_inbound_channel`]: crate::ln::channelmanager::ChannelManager::accept_inbound_channel
689 /// [`ChannelManager::force_close_without_broadcasting_txn`]: crate::ln::channelmanager::ChannelManager::force_close_without_broadcasting_txn
690 /// [`UserConfig::manually_accept_inbound_channels`]: crate::util::config::UserConfig::manually_accept_inbound_channels
692 /// The temporary channel ID of the channel requested to be opened.
694 /// When responding to the request, the `temporary_channel_id` should be passed
695 /// back to the ChannelManager through [`ChannelManager::accept_inbound_channel`] to accept,
696 /// or through [`ChannelManager::force_close_without_broadcasting_txn`] to reject.
698 /// [`ChannelManager::accept_inbound_channel`]: crate::ln::channelmanager::ChannelManager::accept_inbound_channel
699 /// [`ChannelManager::force_close_without_broadcasting_txn`]: crate::ln::channelmanager::ChannelManager::force_close_without_broadcasting_txn
700 temporary_channel_id: crate::c_types::ThirtyTwoBytes,
701 /// The node_id of the counterparty requesting to open the channel.
703 /// When responding to the request, the `counterparty_node_id` should be passed
704 /// back to the `ChannelManager` through [`ChannelManager::accept_inbound_channel`] to
705 /// accept the request, or through [`ChannelManager::force_close_without_broadcasting_txn`] to reject the
708 /// [`ChannelManager::accept_inbound_channel`]: crate::ln::channelmanager::ChannelManager::accept_inbound_channel
709 /// [`ChannelManager::force_close_without_broadcasting_txn`]: crate::ln::channelmanager::ChannelManager::force_close_without_broadcasting_txn
710 counterparty_node_id: crate::c_types::PublicKey,
711 /// The channel value of the requested channel.
712 funding_satoshis: u64,
713 /// Our starting balance in the channel if the request is accepted, in milli-satoshi.
715 /// The features that this channel will operate with. If you reject the channel, a
716 /// well-behaved counterparty may automatically re-attempt the channel with a new set of
719 /// Note that if [`ChannelTypeFeatures::supports_scid_privacy`] returns true on this type,
720 /// the resulting [`ChannelManager`] will not be readable by versions of LDK prior to
723 /// Furthermore, note that if [`ChannelTypeFeatures::supports_zero_conf`] returns true on this type,
724 /// the resulting [`ChannelManager`] will not be readable by versions of LDK prior to
725 /// 0.0.107. Channels setting this type also need to get manually accepted via
726 /// [`crate::ln::channelmanager::ChannelManager::accept_inbound_channel_from_trusted_peer_0conf`],
727 /// or will be rejected otherwise.
729 /// [`ChannelManager`]: crate::ln::channelmanager::ChannelManager
730 channel_type: crate::lightning::ln::features::ChannelTypeFeatures,
733 use lightning::util::events::Event as EventImport;
734 pub(crate) type nativeEvent = EventImport;
738 pub(crate) fn to_native(&self) -> nativeEvent {
740 Event::FundingGenerationReady {ref temporary_channel_id, ref counterparty_node_id, ref channel_value_satoshis, ref output_script, ref user_channel_id, } => {
741 let mut temporary_channel_id_nonref = (*temporary_channel_id).clone();
742 let mut counterparty_node_id_nonref = (*counterparty_node_id).clone();
743 let mut channel_value_satoshis_nonref = (*channel_value_satoshis).clone();
744 let mut output_script_nonref = (*output_script).clone();
745 let mut user_channel_id_nonref = (*user_channel_id).clone();
746 nativeEvent::FundingGenerationReady {
747 temporary_channel_id: temporary_channel_id_nonref.data,
748 counterparty_node_id: counterparty_node_id_nonref.into_rust(),
749 channel_value_satoshis: channel_value_satoshis_nonref,
750 output_script: ::bitcoin::blockdata::script::Script::from(output_script_nonref.into_rust()),
751 user_channel_id: user_channel_id_nonref,
754 Event::PaymentReceived {ref payment_hash, ref amount_msat, ref purpose, } => {
755 let mut payment_hash_nonref = (*payment_hash).clone();
756 let mut amount_msat_nonref = (*amount_msat).clone();
757 let mut purpose_nonref = (*purpose).clone();
758 nativeEvent::PaymentReceived {
759 payment_hash: ::lightning::ln::PaymentHash(payment_hash_nonref.data),
760 amount_msat: amount_msat_nonref,
761 purpose: purpose_nonref.into_native(),
764 Event::PaymentClaimed {ref payment_hash, ref amount_msat, ref purpose, } => {
765 let mut payment_hash_nonref = (*payment_hash).clone();
766 let mut amount_msat_nonref = (*amount_msat).clone();
767 let mut purpose_nonref = (*purpose).clone();
768 nativeEvent::PaymentClaimed {
769 payment_hash: ::lightning::ln::PaymentHash(payment_hash_nonref.data),
770 amount_msat: amount_msat_nonref,
771 purpose: purpose_nonref.into_native(),
774 Event::PaymentSent {ref payment_id, ref payment_preimage, ref payment_hash, ref fee_paid_msat, } => {
775 let mut payment_id_nonref = (*payment_id).clone();
776 let mut local_payment_id_nonref = if payment_id_nonref.data == [0; 32] { None } else { Some( { ::lightning::ln::channelmanager::PaymentId(payment_id_nonref.data) }) };
777 let mut payment_preimage_nonref = (*payment_preimage).clone();
778 let mut payment_hash_nonref = (*payment_hash).clone();
779 let mut fee_paid_msat_nonref = (*fee_paid_msat).clone();
780 let mut local_fee_paid_msat_nonref = if fee_paid_msat_nonref.is_some() { Some( { fee_paid_msat_nonref.take() }) } else { None };
781 nativeEvent::PaymentSent {
782 payment_id: local_payment_id_nonref,
783 payment_preimage: ::lightning::ln::PaymentPreimage(payment_preimage_nonref.data),
784 payment_hash: ::lightning::ln::PaymentHash(payment_hash_nonref.data),
785 fee_paid_msat: local_fee_paid_msat_nonref,
788 Event::PaymentFailed {ref payment_id, ref payment_hash, } => {
789 let mut payment_id_nonref = (*payment_id).clone();
790 let mut payment_hash_nonref = (*payment_hash).clone();
791 nativeEvent::PaymentFailed {
792 payment_id: ::lightning::ln::channelmanager::PaymentId(payment_id_nonref.data),
793 payment_hash: ::lightning::ln::PaymentHash(payment_hash_nonref.data),
796 Event::PaymentPathSuccessful {ref payment_id, ref payment_hash, ref path, } => {
797 let mut payment_id_nonref = (*payment_id).clone();
798 let mut payment_hash_nonref = (*payment_hash).clone();
799 let mut local_payment_hash_nonref = if payment_hash_nonref.data == [0; 32] { None } else { Some( { ::lightning::ln::PaymentHash(payment_hash_nonref.data) }) };
800 let mut path_nonref = (*path).clone();
801 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()) } }); };
802 nativeEvent::PaymentPathSuccessful {
803 payment_id: ::lightning::ln::channelmanager::PaymentId(payment_id_nonref.data),
804 payment_hash: local_payment_hash_nonref,
805 path: local_path_nonref,
808 Event::PaymentPathFailed {ref payment_id, ref payment_hash, ref rejected_by_dest, ref network_update, ref all_paths_failed, ref path, ref short_channel_id, ref retry, } => {
809 let mut payment_id_nonref = (*payment_id).clone();
810 let mut local_payment_id_nonref = if payment_id_nonref.data == [0; 32] { None } else { Some( { ::lightning::ln::channelmanager::PaymentId(payment_id_nonref.data) }) };
811 let mut payment_hash_nonref = (*payment_hash).clone();
812 let mut rejected_by_dest_nonref = (*rejected_by_dest).clone();
813 let mut network_update_nonref = (*network_update).clone();
814 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() }) } };
815 let mut all_paths_failed_nonref = (*all_paths_failed).clone();
816 let mut path_nonref = (*path).clone();
817 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()) } }); };
818 let mut short_channel_id_nonref = (*short_channel_id).clone();
819 let mut local_short_channel_id_nonref = if short_channel_id_nonref.is_some() { Some( { short_channel_id_nonref.take() }) } else { None };
820 let mut retry_nonref = (*retry).clone();
821 let mut local_retry_nonref = if retry_nonref.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(retry_nonref.take_inner()) } }) };
822 nativeEvent::PaymentPathFailed {
823 payment_id: local_payment_id_nonref,
824 payment_hash: ::lightning::ln::PaymentHash(payment_hash_nonref.data),
825 rejected_by_dest: rejected_by_dest_nonref,
826 network_update: local_network_update_nonref,
827 all_paths_failed: all_paths_failed_nonref,
828 path: local_path_nonref,
829 short_channel_id: local_short_channel_id_nonref,
830 retry: local_retry_nonref,
833 Event::PendingHTLCsForwardable {ref time_forwardable, } => {
834 let mut time_forwardable_nonref = (*time_forwardable).clone();
835 nativeEvent::PendingHTLCsForwardable {
836 time_forwardable: core::time::Duration::from_secs(time_forwardable_nonref),
839 Event::SpendableOutputs {ref outputs, } => {
840 let mut outputs_nonref = (*outputs).clone();
841 let mut local_outputs_nonref = Vec::new(); for mut item in outputs_nonref.into_rust().drain(..) { local_outputs_nonref.push( { item.into_native() }); };
842 nativeEvent::SpendableOutputs {
843 outputs: local_outputs_nonref,
846 Event::PaymentForwarded {ref prev_channel_id, ref next_channel_id, ref fee_earned_msat, ref claim_from_onchain_tx, } => {
847 let mut prev_channel_id_nonref = (*prev_channel_id).clone();
848 let mut local_prev_channel_id_nonref = if prev_channel_id_nonref.data == [0; 32] { None } else { Some( { prev_channel_id_nonref.data }) };
849 let mut next_channel_id_nonref = (*next_channel_id).clone();
850 let mut local_next_channel_id_nonref = if next_channel_id_nonref.data == [0; 32] { None } else { Some( { next_channel_id_nonref.data }) };
851 let mut fee_earned_msat_nonref = (*fee_earned_msat).clone();
852 let mut local_fee_earned_msat_nonref = if fee_earned_msat_nonref.is_some() { Some( { fee_earned_msat_nonref.take() }) } else { None };
853 let mut claim_from_onchain_tx_nonref = (*claim_from_onchain_tx).clone();
854 nativeEvent::PaymentForwarded {
855 prev_channel_id: local_prev_channel_id_nonref,
856 next_channel_id: local_next_channel_id_nonref,
857 fee_earned_msat: local_fee_earned_msat_nonref,
858 claim_from_onchain_tx: claim_from_onchain_tx_nonref,
861 Event::ChannelClosed {ref channel_id, ref user_channel_id, ref reason, } => {
862 let mut channel_id_nonref = (*channel_id).clone();
863 let mut user_channel_id_nonref = (*user_channel_id).clone();
864 let mut reason_nonref = (*reason).clone();
865 nativeEvent::ChannelClosed {
866 channel_id: channel_id_nonref.data,
867 user_channel_id: user_channel_id_nonref,
868 reason: reason_nonref.into_native(),
871 Event::DiscardFunding {ref channel_id, ref transaction, } => {
872 let mut channel_id_nonref = (*channel_id).clone();
873 let mut transaction_nonref = (*transaction).clone();
874 nativeEvent::DiscardFunding {
875 channel_id: channel_id_nonref.data,
876 transaction: transaction_nonref.into_bitcoin(),
879 Event::OpenChannelRequest {ref temporary_channel_id, ref counterparty_node_id, ref funding_satoshis, ref push_msat, ref channel_type, } => {
880 let mut temporary_channel_id_nonref = (*temporary_channel_id).clone();
881 let mut counterparty_node_id_nonref = (*counterparty_node_id).clone();
882 let mut funding_satoshis_nonref = (*funding_satoshis).clone();
883 let mut push_msat_nonref = (*push_msat).clone();
884 let mut channel_type_nonref = (*channel_type).clone();
885 nativeEvent::OpenChannelRequest {
886 temporary_channel_id: temporary_channel_id_nonref.data,
887 counterparty_node_id: counterparty_node_id_nonref.into_rust(),
888 funding_satoshis: funding_satoshis_nonref,
889 push_msat: push_msat_nonref,
890 channel_type: *unsafe { Box::from_raw(channel_type_nonref.take_inner()) },
896 pub(crate) fn into_native(self) -> nativeEvent {
898 Event::FundingGenerationReady {mut temporary_channel_id, mut counterparty_node_id, mut channel_value_satoshis, mut output_script, mut user_channel_id, } => {
899 nativeEvent::FundingGenerationReady {
900 temporary_channel_id: temporary_channel_id.data,
901 counterparty_node_id: counterparty_node_id.into_rust(),
902 channel_value_satoshis: channel_value_satoshis,
903 output_script: ::bitcoin::blockdata::script::Script::from(output_script.into_rust()),
904 user_channel_id: user_channel_id,
907 Event::PaymentReceived {mut payment_hash, mut amount_msat, mut purpose, } => {
908 nativeEvent::PaymentReceived {
909 payment_hash: ::lightning::ln::PaymentHash(payment_hash.data),
910 amount_msat: amount_msat,
911 purpose: purpose.into_native(),
914 Event::PaymentClaimed {mut payment_hash, mut amount_msat, mut purpose, } => {
915 nativeEvent::PaymentClaimed {
916 payment_hash: ::lightning::ln::PaymentHash(payment_hash.data),
917 amount_msat: amount_msat,
918 purpose: purpose.into_native(),
921 Event::PaymentSent {mut payment_id, mut payment_preimage, mut payment_hash, mut fee_paid_msat, } => {
922 let mut local_payment_id = if payment_id.data == [0; 32] { None } else { Some( { ::lightning::ln::channelmanager::PaymentId(payment_id.data) }) };
923 let mut local_fee_paid_msat = if fee_paid_msat.is_some() { Some( { fee_paid_msat.take() }) } else { None };
924 nativeEvent::PaymentSent {
925 payment_id: local_payment_id,
926 payment_preimage: ::lightning::ln::PaymentPreimage(payment_preimage.data),
927 payment_hash: ::lightning::ln::PaymentHash(payment_hash.data),
928 fee_paid_msat: local_fee_paid_msat,
931 Event::PaymentFailed {mut payment_id, mut payment_hash, } => {
932 nativeEvent::PaymentFailed {
933 payment_id: ::lightning::ln::channelmanager::PaymentId(payment_id.data),
934 payment_hash: ::lightning::ln::PaymentHash(payment_hash.data),
937 Event::PaymentPathSuccessful {mut payment_id, mut payment_hash, mut path, } => {
938 let mut local_payment_hash = if payment_hash.data == [0; 32] { None } else { Some( { ::lightning::ln::PaymentHash(payment_hash.data) }) };
939 let mut local_path = Vec::new(); for mut item in path.into_rust().drain(..) { local_path.push( { *unsafe { Box::from_raw(item.take_inner()) } }); };
940 nativeEvent::PaymentPathSuccessful {
941 payment_id: ::lightning::ln::channelmanager::PaymentId(payment_id.data),
942 payment_hash: local_payment_hash,
946 Event::PaymentPathFailed {mut payment_id, mut payment_hash, mut rejected_by_dest, mut network_update, mut all_paths_failed, mut path, mut short_channel_id, mut retry, } => {
947 let mut local_payment_id = if payment_id.data == [0; 32] { None } else { Some( { ::lightning::ln::channelmanager::PaymentId(payment_id.data) }) };
948 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() }) } };
949 let mut local_path = Vec::new(); for mut item in path.into_rust().drain(..) { local_path.push( { *unsafe { Box::from_raw(item.take_inner()) } }); };
950 let mut local_short_channel_id = if short_channel_id.is_some() { Some( { short_channel_id.take() }) } else { None };
951 let mut local_retry = if retry.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(retry.take_inner()) } }) };
952 nativeEvent::PaymentPathFailed {
953 payment_id: local_payment_id,
954 payment_hash: ::lightning::ln::PaymentHash(payment_hash.data),
955 rejected_by_dest: rejected_by_dest,
956 network_update: local_network_update,
957 all_paths_failed: all_paths_failed,
959 short_channel_id: local_short_channel_id,
963 Event::PendingHTLCsForwardable {mut time_forwardable, } => {
964 nativeEvent::PendingHTLCsForwardable {
965 time_forwardable: core::time::Duration::from_secs(time_forwardable),
968 Event::SpendableOutputs {mut outputs, } => {
969 let mut local_outputs = Vec::new(); for mut item in outputs.into_rust().drain(..) { local_outputs.push( { item.into_native() }); };
970 nativeEvent::SpendableOutputs {
971 outputs: local_outputs,
974 Event::PaymentForwarded {mut prev_channel_id, mut next_channel_id, mut fee_earned_msat, mut claim_from_onchain_tx, } => {
975 let mut local_prev_channel_id = if prev_channel_id.data == [0; 32] { None } else { Some( { prev_channel_id.data }) };
976 let mut local_next_channel_id = if next_channel_id.data == [0; 32] { None } else { Some( { next_channel_id.data }) };
977 let mut local_fee_earned_msat = if fee_earned_msat.is_some() { Some( { fee_earned_msat.take() }) } else { None };
978 nativeEvent::PaymentForwarded {
979 prev_channel_id: local_prev_channel_id,
980 next_channel_id: local_next_channel_id,
981 fee_earned_msat: local_fee_earned_msat,
982 claim_from_onchain_tx: claim_from_onchain_tx,
985 Event::ChannelClosed {mut channel_id, mut user_channel_id, mut reason, } => {
986 nativeEvent::ChannelClosed {
987 channel_id: channel_id.data,
988 user_channel_id: user_channel_id,
989 reason: reason.into_native(),
992 Event::DiscardFunding {mut channel_id, mut transaction, } => {
993 nativeEvent::DiscardFunding {
994 channel_id: channel_id.data,
995 transaction: transaction.into_bitcoin(),
998 Event::OpenChannelRequest {mut temporary_channel_id, mut counterparty_node_id, mut funding_satoshis, mut push_msat, mut channel_type, } => {
999 nativeEvent::OpenChannelRequest {
1000 temporary_channel_id: temporary_channel_id.data,
1001 counterparty_node_id: counterparty_node_id.into_rust(),
1002 funding_satoshis: funding_satoshis,
1003 push_msat: push_msat,
1004 channel_type: *unsafe { Box::from_raw(channel_type.take_inner()) },
1010 pub(crate) fn from_native(native: &nativeEvent) -> Self {
1012 nativeEvent::FundingGenerationReady {ref temporary_channel_id, ref counterparty_node_id, ref channel_value_satoshis, ref output_script, ref user_channel_id, } => {
1013 let mut temporary_channel_id_nonref = (*temporary_channel_id).clone();
1014 let mut counterparty_node_id_nonref = (*counterparty_node_id).clone();
1015 let mut channel_value_satoshis_nonref = (*channel_value_satoshis).clone();
1016 let mut output_script_nonref = (*output_script).clone();
1017 let mut user_channel_id_nonref = (*user_channel_id).clone();
1018 Event::FundingGenerationReady {
1019 temporary_channel_id: crate::c_types::ThirtyTwoBytes { data: temporary_channel_id_nonref },
1020 counterparty_node_id: crate::c_types::PublicKey::from_rust(&counterparty_node_id_nonref),
1021 channel_value_satoshis: channel_value_satoshis_nonref,
1022 output_script: output_script_nonref.into_bytes().into(),
1023 user_channel_id: user_channel_id_nonref,
1026 nativeEvent::PaymentReceived {ref payment_hash, ref amount_msat, ref purpose, } => {
1027 let mut payment_hash_nonref = (*payment_hash).clone();
1028 let mut amount_msat_nonref = (*amount_msat).clone();
1029 let mut purpose_nonref = (*purpose).clone();
1030 Event::PaymentReceived {
1031 payment_hash: crate::c_types::ThirtyTwoBytes { data: payment_hash_nonref.0 },
1032 amount_msat: amount_msat_nonref,
1033 purpose: crate::lightning::util::events::PaymentPurpose::native_into(purpose_nonref),
1036 nativeEvent::PaymentClaimed {ref payment_hash, ref amount_msat, ref purpose, } => {
1037 let mut payment_hash_nonref = (*payment_hash).clone();
1038 let mut amount_msat_nonref = (*amount_msat).clone();
1039 let mut purpose_nonref = (*purpose).clone();
1040 Event::PaymentClaimed {
1041 payment_hash: crate::c_types::ThirtyTwoBytes { data: payment_hash_nonref.0 },
1042 amount_msat: amount_msat_nonref,
1043 purpose: crate::lightning::util::events::PaymentPurpose::native_into(purpose_nonref),
1046 nativeEvent::PaymentSent {ref payment_id, ref payment_preimage, ref payment_hash, ref fee_paid_msat, } => {
1047 let mut payment_id_nonref = (*payment_id).clone();
1048 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 } } };
1049 let mut payment_preimage_nonref = (*payment_preimage).clone();
1050 let mut payment_hash_nonref = (*payment_hash).clone();
1051 let mut fee_paid_msat_nonref = (*fee_paid_msat).clone();
1052 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() }) };
1053 Event::PaymentSent {
1054 payment_id: local_payment_id_nonref,
1055 payment_preimage: crate::c_types::ThirtyTwoBytes { data: payment_preimage_nonref.0 },
1056 payment_hash: crate::c_types::ThirtyTwoBytes { data: payment_hash_nonref.0 },
1057 fee_paid_msat: local_fee_paid_msat_nonref,
1060 nativeEvent::PaymentFailed {ref payment_id, ref payment_hash, } => {
1061 let mut payment_id_nonref = (*payment_id).clone();
1062 let mut payment_hash_nonref = (*payment_hash).clone();
1063 Event::PaymentFailed {
1064 payment_id: crate::c_types::ThirtyTwoBytes { data: payment_id_nonref.0 },
1065 payment_hash: crate::c_types::ThirtyTwoBytes { data: payment_hash_nonref.0 },
1068 nativeEvent::PaymentPathSuccessful {ref payment_id, ref payment_hash, ref path, } => {
1069 let mut payment_id_nonref = (*payment_id).clone();
1070 let mut payment_hash_nonref = (*payment_hash).clone();
1071 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 } } };
1072 let mut path_nonref = (*path).clone();
1073 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 } }); };
1074 Event::PaymentPathSuccessful {
1075 payment_id: crate::c_types::ThirtyTwoBytes { data: payment_id_nonref.0 },
1076 payment_hash: local_payment_hash_nonref,
1077 path: local_path_nonref.into(),
1080 nativeEvent::PaymentPathFailed {ref payment_id, ref payment_hash, ref rejected_by_dest, ref network_update, ref all_paths_failed, ref path, ref short_channel_id, ref retry, } => {
1081 let mut payment_id_nonref = (*payment_id).clone();
1082 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 } } };
1083 let mut payment_hash_nonref = (*payment_hash).clone();
1084 let mut rejected_by_dest_nonref = (*rejected_by_dest).clone();
1085 let mut network_update_nonref = (*network_update).clone();
1086 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()) }) };
1087 let mut all_paths_failed_nonref = (*all_paths_failed).clone();
1088 let mut path_nonref = (*path).clone();
1089 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 } }); };
1090 let mut short_channel_id_nonref = (*short_channel_id).clone();
1091 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() }) };
1092 let mut retry_nonref = (*retry).clone();
1093 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 };
1094 Event::PaymentPathFailed {
1095 payment_id: local_payment_id_nonref,
1096 payment_hash: crate::c_types::ThirtyTwoBytes { data: payment_hash_nonref.0 },
1097 rejected_by_dest: rejected_by_dest_nonref,
1098 network_update: local_network_update_nonref,
1099 all_paths_failed: all_paths_failed_nonref,
1100 path: local_path_nonref.into(),
1101 short_channel_id: local_short_channel_id_nonref,
1102 retry: local_retry_nonref,
1105 nativeEvent::PendingHTLCsForwardable {ref time_forwardable, } => {
1106 let mut time_forwardable_nonref = (*time_forwardable).clone();
1107 Event::PendingHTLCsForwardable {
1108 time_forwardable: time_forwardable_nonref.as_secs(),
1111 nativeEvent::SpendableOutputs {ref outputs, } => {
1112 let mut outputs_nonref = (*outputs).clone();
1113 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) }); };
1114 Event::SpendableOutputs {
1115 outputs: local_outputs_nonref.into(),
1118 nativeEvent::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.is_none() { crate::c_types::ThirtyTwoBytes { data: [0; 32] } } else { { crate::c_types::ThirtyTwoBytes { data: (prev_channel_id_nonref.unwrap()) } } };
1121 let mut next_channel_id_nonref = (*next_channel_id).clone();
1122 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()) } } };
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_none() { crate::c_types::derived::COption_u64Z::None } else { crate::c_types::derived::COption_u64Z::Some( { fee_earned_msat_nonref.unwrap() }) };
1125 let mut claim_from_onchain_tx_nonref = (*claim_from_onchain_tx).clone();
1126 Event::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 nativeEvent::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 Event::ChannelClosed {
1138 channel_id: crate::c_types::ThirtyTwoBytes { data: channel_id_nonref },
1139 user_channel_id: user_channel_id_nonref,
1140 reason: crate::lightning::util::events::ClosureReason::native_into(reason_nonref),
1143 nativeEvent::DiscardFunding {ref channel_id, ref transaction, } => {
1144 let mut channel_id_nonref = (*channel_id).clone();
1145 let mut transaction_nonref = (*transaction).clone();
1146 Event::DiscardFunding {
1147 channel_id: crate::c_types::ThirtyTwoBytes { data: channel_id_nonref },
1148 transaction: crate::c_types::Transaction::from_bitcoin(&transaction_nonref),
1151 nativeEvent::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 Event::OpenChannelRequest {
1158 temporary_channel_id: crate::c_types::ThirtyTwoBytes { data: temporary_channel_id_nonref },
1159 counterparty_node_id: crate::c_types::PublicKey::from_rust(&counterparty_node_id_nonref),
1160 funding_satoshis: funding_satoshis_nonref,
1161 push_msat: push_msat_nonref,
1162 channel_type: crate::lightning::ln::features::ChannelTypeFeatures { inner: ObjOps::heap_alloc(channel_type_nonref), is_owned: true },
1168 pub(crate) fn native_into(native: nativeEvent) -> Self {
1170 nativeEvent::FundingGenerationReady {mut temporary_channel_id, mut counterparty_node_id, mut channel_value_satoshis, mut output_script, mut user_channel_id, } => {
1171 Event::FundingGenerationReady {
1172 temporary_channel_id: crate::c_types::ThirtyTwoBytes { data: temporary_channel_id },
1173 counterparty_node_id: crate::c_types::PublicKey::from_rust(&counterparty_node_id),
1174 channel_value_satoshis: channel_value_satoshis,
1175 output_script: output_script.into_bytes().into(),
1176 user_channel_id: user_channel_id,
1179 nativeEvent::PaymentReceived {mut payment_hash, mut amount_msat, mut purpose, } => {
1180 Event::PaymentReceived {
1181 payment_hash: crate::c_types::ThirtyTwoBytes { data: payment_hash.0 },
1182 amount_msat: amount_msat,
1183 purpose: crate::lightning::util::events::PaymentPurpose::native_into(purpose),
1186 nativeEvent::PaymentClaimed {mut payment_hash, mut amount_msat, mut purpose, } => {
1187 Event::PaymentClaimed {
1188 payment_hash: crate::c_types::ThirtyTwoBytes { data: payment_hash.0 },
1189 amount_msat: amount_msat,
1190 purpose: crate::lightning::util::events::PaymentPurpose::native_into(purpose),
1193 nativeEvent::PaymentSent {mut payment_id, mut payment_preimage, mut payment_hash, mut fee_paid_msat, } => {
1194 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 } } };
1195 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() }) };
1196 Event::PaymentSent {
1197 payment_id: local_payment_id,
1198 payment_preimage: crate::c_types::ThirtyTwoBytes { data: payment_preimage.0 },
1199 payment_hash: crate::c_types::ThirtyTwoBytes { data: payment_hash.0 },
1200 fee_paid_msat: local_fee_paid_msat,
1203 nativeEvent::PaymentFailed {mut payment_id, mut payment_hash, } => {
1204 Event::PaymentFailed {
1205 payment_id: crate::c_types::ThirtyTwoBytes { data: payment_id.0 },
1206 payment_hash: crate::c_types::ThirtyTwoBytes { data: payment_hash.0 },
1209 nativeEvent::PaymentPathSuccessful {mut payment_id, mut payment_hash, mut path, } => {
1210 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 } } };
1211 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 } }); };
1212 Event::PaymentPathSuccessful {
1213 payment_id: crate::c_types::ThirtyTwoBytes { data: payment_id.0 },
1214 payment_hash: local_payment_hash,
1215 path: local_path.into(),
1218 nativeEvent::PaymentPathFailed {mut payment_id, mut payment_hash, mut rejected_by_dest, mut network_update, mut all_paths_failed, mut path, mut short_channel_id, mut retry, } => {
1219 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 } } };
1220 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()) }) };
1221 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 } }); };
1222 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() }) };
1223 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 };
1224 Event::PaymentPathFailed {
1225 payment_id: local_payment_id,
1226 payment_hash: crate::c_types::ThirtyTwoBytes { data: payment_hash.0 },
1227 rejected_by_dest: rejected_by_dest,
1228 network_update: local_network_update,
1229 all_paths_failed: all_paths_failed,
1230 path: local_path.into(),
1231 short_channel_id: local_short_channel_id,
1235 nativeEvent::PendingHTLCsForwardable {mut time_forwardable, } => {
1236 Event::PendingHTLCsForwardable {
1237 time_forwardable: time_forwardable.as_secs(),
1240 nativeEvent::SpendableOutputs {mut outputs, } => {
1241 let mut local_outputs = Vec::new(); for mut item in outputs.drain(..) { local_outputs.push( { crate::lightning::chain::keysinterface::SpendableOutputDescriptor::native_into(item) }); };
1242 Event::SpendableOutputs {
1243 outputs: local_outputs.into(),
1246 nativeEvent::PaymentForwarded {mut prev_channel_id, mut next_channel_id, mut fee_earned_msat, mut claim_from_onchain_tx, } => {
1247 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()) } } };
1248 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()) } } };
1249 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() }) };
1250 Event::PaymentForwarded {
1251 prev_channel_id: local_prev_channel_id,
1252 next_channel_id: local_next_channel_id,
1253 fee_earned_msat: local_fee_earned_msat,
1254 claim_from_onchain_tx: claim_from_onchain_tx,
1257 nativeEvent::ChannelClosed {mut channel_id, mut user_channel_id, mut reason, } => {
1258 Event::ChannelClosed {
1259 channel_id: crate::c_types::ThirtyTwoBytes { data: channel_id },
1260 user_channel_id: user_channel_id,
1261 reason: crate::lightning::util::events::ClosureReason::native_into(reason),
1264 nativeEvent::DiscardFunding {mut channel_id, mut transaction, } => {
1265 Event::DiscardFunding {
1266 channel_id: crate::c_types::ThirtyTwoBytes { data: channel_id },
1267 transaction: crate::c_types::Transaction::from_bitcoin(&transaction),
1270 nativeEvent::OpenChannelRequest {mut temporary_channel_id, mut counterparty_node_id, mut funding_satoshis, mut push_msat, mut channel_type, } => {
1271 Event::OpenChannelRequest {
1272 temporary_channel_id: crate::c_types::ThirtyTwoBytes { data: temporary_channel_id },
1273 counterparty_node_id: crate::c_types::PublicKey::from_rust(&counterparty_node_id),
1274 funding_satoshis: funding_satoshis,
1275 push_msat: push_msat,
1276 channel_type: crate::lightning::ln::features::ChannelTypeFeatures { inner: ObjOps::heap_alloc(channel_type), is_owned: true },
1282 /// Frees any resources used by the Event
1284 pub extern "C" fn Event_free(this_ptr: Event) { }
1285 /// Creates a copy of the Event
1287 pub extern "C" fn Event_clone(orig: &Event) -> Event {
1291 /// Utility method to constructs a new FundingGenerationReady-variant Event
1292 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 {
1293 Event::FundingGenerationReady {
1294 temporary_channel_id,
1295 counterparty_node_id,
1296 channel_value_satoshis,
1302 /// Utility method to constructs a new PaymentReceived-variant Event
1303 pub extern "C" fn Event_payment_received(payment_hash: crate::c_types::ThirtyTwoBytes, amount_msat: u64, purpose: crate::lightning::util::events::PaymentPurpose) -> Event {
1304 Event::PaymentReceived {
1311 /// Utility method to constructs a new PaymentClaimed-variant Event
1312 pub extern "C" fn Event_payment_claimed(payment_hash: crate::c_types::ThirtyTwoBytes, amount_msat: u64, purpose: crate::lightning::util::events::PaymentPurpose) -> Event {
1313 Event::PaymentClaimed {
1320 /// Utility method to constructs a new PaymentSent-variant Event
1321 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 {
1322 Event::PaymentSent {
1330 /// Utility method to constructs a new PaymentFailed-variant Event
1331 pub extern "C" fn Event_payment_failed(payment_id: crate::c_types::ThirtyTwoBytes, payment_hash: crate::c_types::ThirtyTwoBytes) -> Event {
1332 Event::PaymentFailed {
1338 /// Utility method to constructs a new PaymentPathSuccessful-variant Event
1339 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 {
1340 Event::PaymentPathSuccessful {
1347 /// Utility method to constructs a new PaymentPathFailed-variant Event
1348 pub extern "C" fn Event_payment_path_failed(payment_id: crate::c_types::ThirtyTwoBytes, payment_hash: crate::c_types::ThirtyTwoBytes, rejected_by_dest: bool, network_update: crate::c_types::derived::COption_NetworkUpdateZ, all_paths_failed: bool, path: crate::c_types::derived::CVec_RouteHopZ, short_channel_id: crate::c_types::derived::COption_u64Z, retry: crate::lightning::routing::router::RouteParameters) -> Event {
1349 Event::PaymentPathFailed {
1361 /// Utility method to constructs a new PendingHTLCsForwardable-variant Event
1362 pub extern "C" fn Event_pending_htlcs_forwardable(time_forwardable: u64) -> Event {
1363 Event::PendingHTLCsForwardable {
1368 /// Utility method to constructs a new SpendableOutputs-variant Event
1369 pub extern "C" fn Event_spendable_outputs(outputs: crate::c_types::derived::CVec_SpendableOutputDescriptorZ) -> Event {
1370 Event::SpendableOutputs {
1375 /// Utility method to constructs a new PaymentForwarded-variant Event
1376 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 {
1377 Event::PaymentForwarded {
1381 claim_from_onchain_tx,
1385 /// Utility method to constructs a new ChannelClosed-variant Event
1386 pub extern "C" fn Event_channel_closed(channel_id: crate::c_types::ThirtyTwoBytes, user_channel_id: u64, reason: crate::lightning::util::events::ClosureReason) -> Event {
1387 Event::ChannelClosed {
1394 /// Utility method to constructs a new DiscardFunding-variant Event
1395 pub extern "C" fn Event_discard_funding(channel_id: crate::c_types::ThirtyTwoBytes, transaction: crate::c_types::Transaction) -> Event {
1396 Event::DiscardFunding {
1402 /// Utility method to constructs a new OpenChannelRequest-variant Event
1403 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 {
1404 Event::OpenChannelRequest {
1405 temporary_channel_id,
1406 counterparty_node_id,
1413 /// Serialize the Event object into a byte array which can be read by Event_read
1414 pub extern "C" fn Event_write(obj: &crate::lightning::util::events::Event) -> crate::c_types::derived::CVec_u8Z {
1415 crate::c_types::serialize_obj(&unsafe { &*obj }.to_native())
1418 /// Read a Event from a byte array, created by Event_write
1419 pub extern "C" fn Event_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_COption_EventZDecodeErrorZ {
1420 let res: Result<Option<lightning::util::events::Event>, lightning::ln::msgs::DecodeError> = crate::c_types::maybe_deserialize_obj(ser);
1421 let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { let mut local_res_0 = if o.is_none() { crate::c_types::derived::COption_EventZ::None } else { crate::c_types::derived::COption_EventZ::Some( { crate::lightning::util::events::Event::native_into(o.unwrap()) }) }; local_res_0 }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError { inner: ObjOps::heap_alloc(e), is_owned: true } }).into() };
1424 /// An event generated by ChannelManager which indicates a message should be sent to a peer (or
1425 /// broadcast to most peers).
1426 /// These events are handled by PeerManager::process_events if you are using a PeerManager.
1430 pub enum MessageSendEvent {
1431 /// Used to indicate that we've accepted a channel open and should send the accept_channel
1432 /// message provided to the given peer.
1434 /// The node_id of the node which should receive this message
1435 node_id: crate::c_types::PublicKey,
1436 /// The message which should be sent.
1437 msg: crate::lightning::ln::msgs::AcceptChannel,
1439 /// Used to indicate that we've initiated a channel open and should send the open_channel
1440 /// message provided to the given peer.
1442 /// The node_id of the node which should receive this message
1443 node_id: crate::c_types::PublicKey,
1444 /// The message which should be sent.
1445 msg: crate::lightning::ln::msgs::OpenChannel,
1447 /// Used to indicate that a funding_created message should be sent to the peer with the given node_id.
1448 SendFundingCreated {
1449 /// The node_id of the node which should receive this message
1450 node_id: crate::c_types::PublicKey,
1451 /// The message which should be sent.
1452 msg: crate::lightning::ln::msgs::FundingCreated,
1454 /// Used to indicate that a funding_signed message should be sent to the peer with the given node_id.
1456 /// The node_id of the node which should receive this message
1457 node_id: crate::c_types::PublicKey,
1458 /// The message which should be sent.
1459 msg: crate::lightning::ln::msgs::FundingSigned,
1461 /// Used to indicate that a channel_ready message should be sent to the peer with the given node_id.
1463 /// The node_id of the node which should receive these message(s)
1464 node_id: crate::c_types::PublicKey,
1465 /// The channel_ready message which should be sent.
1466 msg: crate::lightning::ln::msgs::ChannelReady,
1468 /// Used to indicate that an announcement_signatures message should be sent to the peer with the given node_id.
1469 SendAnnouncementSignatures {
1470 /// The node_id of the node which should receive these message(s)
1471 node_id: crate::c_types::PublicKey,
1472 /// The announcement_signatures message which should be sent.
1473 msg: crate::lightning::ln::msgs::AnnouncementSignatures,
1475 /// Used to indicate that a series of HTLC update messages, as well as a commitment_signed
1476 /// message should be sent to the peer with the given node_id.
1478 /// The node_id of the node which should receive these message(s)
1479 node_id: crate::c_types::PublicKey,
1480 /// The update messages which should be sent. ALL messages in the struct should be sent!
1481 updates: crate::lightning::ln::msgs::CommitmentUpdate,
1483 /// Used to indicate that a revoke_and_ack message should be sent to the peer with the given node_id.
1485 /// The node_id of the node which should receive this message
1486 node_id: crate::c_types::PublicKey,
1487 /// The message which should be sent.
1488 msg: crate::lightning::ln::msgs::RevokeAndACK,
1490 /// Used to indicate that a closing_signed message should be sent to the peer with the given node_id.
1492 /// The node_id of the node which should receive this message
1493 node_id: crate::c_types::PublicKey,
1494 /// The message which should be sent.
1495 msg: crate::lightning::ln::msgs::ClosingSigned,
1497 /// Used to indicate that a shutdown message should be sent to the peer with the given node_id.
1499 /// The node_id of the node which should receive this message
1500 node_id: crate::c_types::PublicKey,
1501 /// The message which should be sent.
1502 msg: crate::lightning::ln::msgs::Shutdown,
1504 /// Used to indicate that a channel_reestablish message should be sent to the peer with the given node_id.
1505 SendChannelReestablish {
1506 /// The node_id of the node which should receive this message
1507 node_id: crate::c_types::PublicKey,
1508 /// The message which should be sent.
1509 msg: crate::lightning::ln::msgs::ChannelReestablish,
1511 /// Used to indicate that a channel_announcement and channel_update should be broadcast to all
1512 /// peers (except the peer with node_id either msg.contents.node_id_1 or msg.contents.node_id_2).
1514 /// Note that after doing so, you very likely (unless you did so very recently) want to call
1515 /// ChannelManager::broadcast_node_announcement to trigger a BroadcastNodeAnnouncement event.
1516 /// This ensures that any nodes which see our channel_announcement also have a relevant
1517 /// node_announcement, including relevant feature flags which may be important for routing
1518 /// through or to us.
1519 BroadcastChannelAnnouncement {
1520 /// The channel_announcement which should be sent.
1521 msg: crate::lightning::ln::msgs::ChannelAnnouncement,
1522 /// The followup channel_update which should be sent.
1523 update_msg: crate::lightning::ln::msgs::ChannelUpdate,
1525 /// Used to indicate that a node_announcement should be broadcast to all peers.
1526 BroadcastNodeAnnouncement {
1527 /// The node_announcement which should be sent.
1528 msg: crate::lightning::ln::msgs::NodeAnnouncement,
1530 /// Used to indicate that a channel_update should be broadcast to all peers.
1531 BroadcastChannelUpdate {
1532 /// The channel_update which should be sent.
1533 msg: crate::lightning::ln::msgs::ChannelUpdate,
1535 /// Used to indicate that a channel_update should be sent to a single peer.
1536 /// In contrast to [`Self::BroadcastChannelUpdate`], this is used when the channel is a
1537 /// private channel and we shouldn't be informing all of our peers of channel parameters.
1539 /// The node_id of the node which should receive this message
1540 node_id: crate::c_types::PublicKey,
1541 /// The channel_update which should be sent.
1542 msg: crate::lightning::ln::msgs::ChannelUpdate,
1544 /// Broadcast an error downstream to be handled
1546 /// The node_id of the node which should receive this message
1547 node_id: crate::c_types::PublicKey,
1548 /// The action which should be taken.
1549 action: crate::lightning::ln::msgs::ErrorAction,
1551 /// Query a peer for channels with funding transaction UTXOs in a block range.
1552 SendChannelRangeQuery {
1553 /// The node_id of this message recipient
1554 node_id: crate::c_types::PublicKey,
1555 /// The query_channel_range which should be sent.
1556 msg: crate::lightning::ln::msgs::QueryChannelRange,
1558 /// Request routing gossip messages from a peer for a list of channels identified by
1559 /// their short_channel_ids.
1561 /// The node_id of this message recipient
1562 node_id: crate::c_types::PublicKey,
1563 /// The query_short_channel_ids which should be sent.
1564 msg: crate::lightning::ln::msgs::QueryShortChannelIds,
1566 /// Sends a reply to a channel range query. This may be one of several SendReplyChannelRange events
1567 /// emitted during processing of the query.
1568 SendReplyChannelRange {
1569 /// The node_id of this message recipient
1570 node_id: crate::c_types::PublicKey,
1571 /// The reply_channel_range which should be sent.
1572 msg: crate::lightning::ln::msgs::ReplyChannelRange,
1574 /// Sends a timestamp filter for inbound gossip. This should be sent on each new connection to
1575 /// enable receiving gossip messages from the peer.
1576 SendGossipTimestampFilter {
1577 /// The node_id of this message recipient
1578 node_id: crate::c_types::PublicKey,
1579 /// The gossip_timestamp_filter which should be sent.
1580 msg: crate::lightning::ln::msgs::GossipTimestampFilter,
1583 use lightning::util::events::MessageSendEvent as MessageSendEventImport;
1584 pub(crate) type nativeMessageSendEvent = MessageSendEventImport;
1586 impl MessageSendEvent {
1588 pub(crate) fn to_native(&self) -> nativeMessageSendEvent {
1590 MessageSendEvent::SendAcceptChannel {ref node_id, ref msg, } => {
1591 let mut node_id_nonref = (*node_id).clone();
1592 let mut msg_nonref = (*msg).clone();
1593 nativeMessageSendEvent::SendAcceptChannel {
1594 node_id: node_id_nonref.into_rust(),
1595 msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) },
1598 MessageSendEvent::SendOpenChannel {ref node_id, ref msg, } => {
1599 let mut node_id_nonref = (*node_id).clone();
1600 let mut msg_nonref = (*msg).clone();
1601 nativeMessageSendEvent::SendOpenChannel {
1602 node_id: node_id_nonref.into_rust(),
1603 msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) },
1606 MessageSendEvent::SendFundingCreated {ref node_id, ref msg, } => {
1607 let mut node_id_nonref = (*node_id).clone();
1608 let mut msg_nonref = (*msg).clone();
1609 nativeMessageSendEvent::SendFundingCreated {
1610 node_id: node_id_nonref.into_rust(),
1611 msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) },
1614 MessageSendEvent::SendFundingSigned {ref node_id, ref msg, } => {
1615 let mut node_id_nonref = (*node_id).clone();
1616 let mut msg_nonref = (*msg).clone();
1617 nativeMessageSendEvent::SendFundingSigned {
1618 node_id: node_id_nonref.into_rust(),
1619 msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) },
1622 MessageSendEvent::SendChannelReady {ref node_id, ref msg, } => {
1623 let mut node_id_nonref = (*node_id).clone();
1624 let mut msg_nonref = (*msg).clone();
1625 nativeMessageSendEvent::SendChannelReady {
1626 node_id: node_id_nonref.into_rust(),
1627 msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) },
1630 MessageSendEvent::SendAnnouncementSignatures {ref node_id, ref msg, } => {
1631 let mut node_id_nonref = (*node_id).clone();
1632 let mut msg_nonref = (*msg).clone();
1633 nativeMessageSendEvent::SendAnnouncementSignatures {
1634 node_id: node_id_nonref.into_rust(),
1635 msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) },
1638 MessageSendEvent::UpdateHTLCs {ref node_id, ref updates, } => {
1639 let mut node_id_nonref = (*node_id).clone();
1640 let mut updates_nonref = (*updates).clone();
1641 nativeMessageSendEvent::UpdateHTLCs {
1642 node_id: node_id_nonref.into_rust(),
1643 updates: *unsafe { Box::from_raw(updates_nonref.take_inner()) },
1646 MessageSendEvent::SendRevokeAndACK {ref node_id, ref msg, } => {
1647 let mut node_id_nonref = (*node_id).clone();
1648 let mut msg_nonref = (*msg).clone();
1649 nativeMessageSendEvent::SendRevokeAndACK {
1650 node_id: node_id_nonref.into_rust(),
1651 msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) },
1654 MessageSendEvent::SendClosingSigned {ref node_id, ref msg, } => {
1655 let mut node_id_nonref = (*node_id).clone();
1656 let mut msg_nonref = (*msg).clone();
1657 nativeMessageSendEvent::SendClosingSigned {
1658 node_id: node_id_nonref.into_rust(),
1659 msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) },
1662 MessageSendEvent::SendShutdown {ref node_id, ref msg, } => {
1663 let mut node_id_nonref = (*node_id).clone();
1664 let mut msg_nonref = (*msg).clone();
1665 nativeMessageSendEvent::SendShutdown {
1666 node_id: node_id_nonref.into_rust(),
1667 msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) },
1670 MessageSendEvent::SendChannelReestablish {ref node_id, ref msg, } => {
1671 let mut node_id_nonref = (*node_id).clone();
1672 let mut msg_nonref = (*msg).clone();
1673 nativeMessageSendEvent::SendChannelReestablish {
1674 node_id: node_id_nonref.into_rust(),
1675 msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) },
1678 MessageSendEvent::BroadcastChannelAnnouncement {ref msg, ref update_msg, } => {
1679 let mut msg_nonref = (*msg).clone();
1680 let mut update_msg_nonref = (*update_msg).clone();
1681 nativeMessageSendEvent::BroadcastChannelAnnouncement {
1682 msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) },
1683 update_msg: *unsafe { Box::from_raw(update_msg_nonref.take_inner()) },
1686 MessageSendEvent::BroadcastNodeAnnouncement {ref msg, } => {
1687 let mut msg_nonref = (*msg).clone();
1688 nativeMessageSendEvent::BroadcastNodeAnnouncement {
1689 msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) },
1692 MessageSendEvent::BroadcastChannelUpdate {ref msg, } => {
1693 let mut msg_nonref = (*msg).clone();
1694 nativeMessageSendEvent::BroadcastChannelUpdate {
1695 msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) },
1698 MessageSendEvent::SendChannelUpdate {ref node_id, ref msg, } => {
1699 let mut node_id_nonref = (*node_id).clone();
1700 let mut msg_nonref = (*msg).clone();
1701 nativeMessageSendEvent::SendChannelUpdate {
1702 node_id: node_id_nonref.into_rust(),
1703 msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) },
1706 MessageSendEvent::HandleError {ref node_id, ref action, } => {
1707 let mut node_id_nonref = (*node_id).clone();
1708 let mut action_nonref = (*action).clone();
1709 nativeMessageSendEvent::HandleError {
1710 node_id: node_id_nonref.into_rust(),
1711 action: action_nonref.into_native(),
1714 MessageSendEvent::SendChannelRangeQuery {ref node_id, ref msg, } => {
1715 let mut node_id_nonref = (*node_id).clone();
1716 let mut msg_nonref = (*msg).clone();
1717 nativeMessageSendEvent::SendChannelRangeQuery {
1718 node_id: node_id_nonref.into_rust(),
1719 msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) },
1722 MessageSendEvent::SendShortIdsQuery {ref node_id, ref msg, } => {
1723 let mut node_id_nonref = (*node_id).clone();
1724 let mut msg_nonref = (*msg).clone();
1725 nativeMessageSendEvent::SendShortIdsQuery {
1726 node_id: node_id_nonref.into_rust(),
1727 msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) },
1730 MessageSendEvent::SendReplyChannelRange {ref node_id, ref msg, } => {
1731 let mut node_id_nonref = (*node_id).clone();
1732 let mut msg_nonref = (*msg).clone();
1733 nativeMessageSendEvent::SendReplyChannelRange {
1734 node_id: node_id_nonref.into_rust(),
1735 msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) },
1738 MessageSendEvent::SendGossipTimestampFilter {ref node_id, ref msg, } => {
1739 let mut node_id_nonref = (*node_id).clone();
1740 let mut msg_nonref = (*msg).clone();
1741 nativeMessageSendEvent::SendGossipTimestampFilter {
1742 node_id: node_id_nonref.into_rust(),
1743 msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) },
1749 pub(crate) fn into_native(self) -> nativeMessageSendEvent {
1751 MessageSendEvent::SendAcceptChannel {mut node_id, mut msg, } => {
1752 nativeMessageSendEvent::SendAcceptChannel {
1753 node_id: node_id.into_rust(),
1754 msg: *unsafe { Box::from_raw(msg.take_inner()) },
1757 MessageSendEvent::SendOpenChannel {mut node_id, mut msg, } => {
1758 nativeMessageSendEvent::SendOpenChannel {
1759 node_id: node_id.into_rust(),
1760 msg: *unsafe { Box::from_raw(msg.take_inner()) },
1763 MessageSendEvent::SendFundingCreated {mut node_id, mut msg, } => {
1764 nativeMessageSendEvent::SendFundingCreated {
1765 node_id: node_id.into_rust(),
1766 msg: *unsafe { Box::from_raw(msg.take_inner()) },
1769 MessageSendEvent::SendFundingSigned {mut node_id, mut msg, } => {
1770 nativeMessageSendEvent::SendFundingSigned {
1771 node_id: node_id.into_rust(),
1772 msg: *unsafe { Box::from_raw(msg.take_inner()) },
1775 MessageSendEvent::SendChannelReady {mut node_id, mut msg, } => {
1776 nativeMessageSendEvent::SendChannelReady {
1777 node_id: node_id.into_rust(),
1778 msg: *unsafe { Box::from_raw(msg.take_inner()) },
1781 MessageSendEvent::SendAnnouncementSignatures {mut node_id, mut msg, } => {
1782 nativeMessageSendEvent::SendAnnouncementSignatures {
1783 node_id: node_id.into_rust(),
1784 msg: *unsafe { Box::from_raw(msg.take_inner()) },
1787 MessageSendEvent::UpdateHTLCs {mut node_id, mut updates, } => {
1788 nativeMessageSendEvent::UpdateHTLCs {
1789 node_id: node_id.into_rust(),
1790 updates: *unsafe { Box::from_raw(updates.take_inner()) },
1793 MessageSendEvent::SendRevokeAndACK {mut node_id, mut msg, } => {
1794 nativeMessageSendEvent::SendRevokeAndACK {
1795 node_id: node_id.into_rust(),
1796 msg: *unsafe { Box::from_raw(msg.take_inner()) },
1799 MessageSendEvent::SendClosingSigned {mut node_id, mut msg, } => {
1800 nativeMessageSendEvent::SendClosingSigned {
1801 node_id: node_id.into_rust(),
1802 msg: *unsafe { Box::from_raw(msg.take_inner()) },
1805 MessageSendEvent::SendShutdown {mut node_id, mut msg, } => {
1806 nativeMessageSendEvent::SendShutdown {
1807 node_id: node_id.into_rust(),
1808 msg: *unsafe { Box::from_raw(msg.take_inner()) },
1811 MessageSendEvent::SendChannelReestablish {mut node_id, mut msg, } => {
1812 nativeMessageSendEvent::SendChannelReestablish {
1813 node_id: node_id.into_rust(),
1814 msg: *unsafe { Box::from_raw(msg.take_inner()) },
1817 MessageSendEvent::BroadcastChannelAnnouncement {mut msg, mut update_msg, } => {
1818 nativeMessageSendEvent::BroadcastChannelAnnouncement {
1819 msg: *unsafe { Box::from_raw(msg.take_inner()) },
1820 update_msg: *unsafe { Box::from_raw(update_msg.take_inner()) },
1823 MessageSendEvent::BroadcastNodeAnnouncement {mut msg, } => {
1824 nativeMessageSendEvent::BroadcastNodeAnnouncement {
1825 msg: *unsafe { Box::from_raw(msg.take_inner()) },
1828 MessageSendEvent::BroadcastChannelUpdate {mut msg, } => {
1829 nativeMessageSendEvent::BroadcastChannelUpdate {
1830 msg: *unsafe { Box::from_raw(msg.take_inner()) },
1833 MessageSendEvent::SendChannelUpdate {mut node_id, mut msg, } => {
1834 nativeMessageSendEvent::SendChannelUpdate {
1835 node_id: node_id.into_rust(),
1836 msg: *unsafe { Box::from_raw(msg.take_inner()) },
1839 MessageSendEvent::HandleError {mut node_id, mut action, } => {
1840 nativeMessageSendEvent::HandleError {
1841 node_id: node_id.into_rust(),
1842 action: action.into_native(),
1845 MessageSendEvent::SendChannelRangeQuery {mut node_id, mut msg, } => {
1846 nativeMessageSendEvent::SendChannelRangeQuery {
1847 node_id: node_id.into_rust(),
1848 msg: *unsafe { Box::from_raw(msg.take_inner()) },
1851 MessageSendEvent::SendShortIdsQuery {mut node_id, mut msg, } => {
1852 nativeMessageSendEvent::SendShortIdsQuery {
1853 node_id: node_id.into_rust(),
1854 msg: *unsafe { Box::from_raw(msg.take_inner()) },
1857 MessageSendEvent::SendReplyChannelRange {mut node_id, mut msg, } => {
1858 nativeMessageSendEvent::SendReplyChannelRange {
1859 node_id: node_id.into_rust(),
1860 msg: *unsafe { Box::from_raw(msg.take_inner()) },
1863 MessageSendEvent::SendGossipTimestampFilter {mut node_id, mut msg, } => {
1864 nativeMessageSendEvent::SendGossipTimestampFilter {
1865 node_id: node_id.into_rust(),
1866 msg: *unsafe { Box::from_raw(msg.take_inner()) },
1872 pub(crate) fn from_native(native: &nativeMessageSendEvent) -> Self {
1874 nativeMessageSendEvent::SendAcceptChannel {ref node_id, ref msg, } => {
1875 let mut node_id_nonref = (*node_id).clone();
1876 let mut msg_nonref = (*msg).clone();
1877 MessageSendEvent::SendAcceptChannel {
1878 node_id: crate::c_types::PublicKey::from_rust(&node_id_nonref),
1879 msg: crate::lightning::ln::msgs::AcceptChannel { inner: ObjOps::heap_alloc(msg_nonref), is_owned: true },
1882 nativeMessageSendEvent::SendOpenChannel {ref node_id, ref msg, } => {
1883 let mut node_id_nonref = (*node_id).clone();
1884 let mut msg_nonref = (*msg).clone();
1885 MessageSendEvent::SendOpenChannel {
1886 node_id: crate::c_types::PublicKey::from_rust(&node_id_nonref),
1887 msg: crate::lightning::ln::msgs::OpenChannel { inner: ObjOps::heap_alloc(msg_nonref), is_owned: true },
1890 nativeMessageSendEvent::SendFundingCreated {ref node_id, ref msg, } => {
1891 let mut node_id_nonref = (*node_id).clone();
1892 let mut msg_nonref = (*msg).clone();
1893 MessageSendEvent::SendFundingCreated {
1894 node_id: crate::c_types::PublicKey::from_rust(&node_id_nonref),
1895 msg: crate::lightning::ln::msgs::FundingCreated { inner: ObjOps::heap_alloc(msg_nonref), is_owned: true },
1898 nativeMessageSendEvent::SendFundingSigned {ref node_id, ref msg, } => {
1899 let mut node_id_nonref = (*node_id).clone();
1900 let mut msg_nonref = (*msg).clone();
1901 MessageSendEvent::SendFundingSigned {
1902 node_id: crate::c_types::PublicKey::from_rust(&node_id_nonref),
1903 msg: crate::lightning::ln::msgs::FundingSigned { inner: ObjOps::heap_alloc(msg_nonref), is_owned: true },
1906 nativeMessageSendEvent::SendChannelReady {ref node_id, ref msg, } => {
1907 let mut node_id_nonref = (*node_id).clone();
1908 let mut msg_nonref = (*msg).clone();
1909 MessageSendEvent::SendChannelReady {
1910 node_id: crate::c_types::PublicKey::from_rust(&node_id_nonref),
1911 msg: crate::lightning::ln::msgs::ChannelReady { inner: ObjOps::heap_alloc(msg_nonref), is_owned: true },
1914 nativeMessageSendEvent::SendAnnouncementSignatures {ref node_id, ref msg, } => {
1915 let mut node_id_nonref = (*node_id).clone();
1916 let mut msg_nonref = (*msg).clone();
1917 MessageSendEvent::SendAnnouncementSignatures {
1918 node_id: crate::c_types::PublicKey::from_rust(&node_id_nonref),
1919 msg: crate::lightning::ln::msgs::AnnouncementSignatures { inner: ObjOps::heap_alloc(msg_nonref), is_owned: true },
1922 nativeMessageSendEvent::UpdateHTLCs {ref node_id, ref updates, } => {
1923 let mut node_id_nonref = (*node_id).clone();
1924 let mut updates_nonref = (*updates).clone();
1925 MessageSendEvent::UpdateHTLCs {
1926 node_id: crate::c_types::PublicKey::from_rust(&node_id_nonref),
1927 updates: crate::lightning::ln::msgs::CommitmentUpdate { inner: ObjOps::heap_alloc(updates_nonref), is_owned: true },
1930 nativeMessageSendEvent::SendRevokeAndACK {ref node_id, ref msg, } => {
1931 let mut node_id_nonref = (*node_id).clone();
1932 let mut msg_nonref = (*msg).clone();
1933 MessageSendEvent::SendRevokeAndACK {
1934 node_id: crate::c_types::PublicKey::from_rust(&node_id_nonref),
1935 msg: crate::lightning::ln::msgs::RevokeAndACK { inner: ObjOps::heap_alloc(msg_nonref), is_owned: true },
1938 nativeMessageSendEvent::SendClosingSigned {ref node_id, ref msg, } => {
1939 let mut node_id_nonref = (*node_id).clone();
1940 let mut msg_nonref = (*msg).clone();
1941 MessageSendEvent::SendClosingSigned {
1942 node_id: crate::c_types::PublicKey::from_rust(&node_id_nonref),
1943 msg: crate::lightning::ln::msgs::ClosingSigned { inner: ObjOps::heap_alloc(msg_nonref), is_owned: true },
1946 nativeMessageSendEvent::SendShutdown {ref node_id, ref msg, } => {
1947 let mut node_id_nonref = (*node_id).clone();
1948 let mut msg_nonref = (*msg).clone();
1949 MessageSendEvent::SendShutdown {
1950 node_id: crate::c_types::PublicKey::from_rust(&node_id_nonref),
1951 msg: crate::lightning::ln::msgs::Shutdown { inner: ObjOps::heap_alloc(msg_nonref), is_owned: true },
1954 nativeMessageSendEvent::SendChannelReestablish {ref node_id, ref msg, } => {
1955 let mut node_id_nonref = (*node_id).clone();
1956 let mut msg_nonref = (*msg).clone();
1957 MessageSendEvent::SendChannelReestablish {
1958 node_id: crate::c_types::PublicKey::from_rust(&node_id_nonref),
1959 msg: crate::lightning::ln::msgs::ChannelReestablish { inner: ObjOps::heap_alloc(msg_nonref), is_owned: true },
1962 nativeMessageSendEvent::BroadcastChannelAnnouncement {ref msg, ref update_msg, } => {
1963 let mut msg_nonref = (*msg).clone();
1964 let mut update_msg_nonref = (*update_msg).clone();
1965 MessageSendEvent::BroadcastChannelAnnouncement {
1966 msg: crate::lightning::ln::msgs::ChannelAnnouncement { inner: ObjOps::heap_alloc(msg_nonref), is_owned: true },
1967 update_msg: crate::lightning::ln::msgs::ChannelUpdate { inner: ObjOps::heap_alloc(update_msg_nonref), is_owned: true },
1970 nativeMessageSendEvent::BroadcastNodeAnnouncement {ref msg, } => {
1971 let mut msg_nonref = (*msg).clone();
1972 MessageSendEvent::BroadcastNodeAnnouncement {
1973 msg: crate::lightning::ln::msgs::NodeAnnouncement { inner: ObjOps::heap_alloc(msg_nonref), is_owned: true },
1976 nativeMessageSendEvent::BroadcastChannelUpdate {ref msg, } => {
1977 let mut msg_nonref = (*msg).clone();
1978 MessageSendEvent::BroadcastChannelUpdate {
1979 msg: crate::lightning::ln::msgs::ChannelUpdate { inner: ObjOps::heap_alloc(msg_nonref), is_owned: true },
1982 nativeMessageSendEvent::SendChannelUpdate {ref node_id, ref msg, } => {
1983 let mut node_id_nonref = (*node_id).clone();
1984 let mut msg_nonref = (*msg).clone();
1985 MessageSendEvent::SendChannelUpdate {
1986 node_id: crate::c_types::PublicKey::from_rust(&node_id_nonref),
1987 msg: crate::lightning::ln::msgs::ChannelUpdate { inner: ObjOps::heap_alloc(msg_nonref), is_owned: true },
1990 nativeMessageSendEvent::HandleError {ref node_id, ref action, } => {
1991 let mut node_id_nonref = (*node_id).clone();
1992 let mut action_nonref = (*action).clone();
1993 MessageSendEvent::HandleError {
1994 node_id: crate::c_types::PublicKey::from_rust(&node_id_nonref),
1995 action: crate::lightning::ln::msgs::ErrorAction::native_into(action_nonref),
1998 nativeMessageSendEvent::SendChannelRangeQuery {ref node_id, ref msg, } => {
1999 let mut node_id_nonref = (*node_id).clone();
2000 let mut msg_nonref = (*msg).clone();
2001 MessageSendEvent::SendChannelRangeQuery {
2002 node_id: crate::c_types::PublicKey::from_rust(&node_id_nonref),
2003 msg: crate::lightning::ln::msgs::QueryChannelRange { inner: ObjOps::heap_alloc(msg_nonref), is_owned: true },
2006 nativeMessageSendEvent::SendShortIdsQuery {ref node_id, ref msg, } => {
2007 let mut node_id_nonref = (*node_id).clone();
2008 let mut msg_nonref = (*msg).clone();
2009 MessageSendEvent::SendShortIdsQuery {
2010 node_id: crate::c_types::PublicKey::from_rust(&node_id_nonref),
2011 msg: crate::lightning::ln::msgs::QueryShortChannelIds { inner: ObjOps::heap_alloc(msg_nonref), is_owned: true },
2014 nativeMessageSendEvent::SendReplyChannelRange {ref node_id, ref msg, } => {
2015 let mut node_id_nonref = (*node_id).clone();
2016 let mut msg_nonref = (*msg).clone();
2017 MessageSendEvent::SendReplyChannelRange {
2018 node_id: crate::c_types::PublicKey::from_rust(&node_id_nonref),
2019 msg: crate::lightning::ln::msgs::ReplyChannelRange { inner: ObjOps::heap_alloc(msg_nonref), is_owned: true },
2022 nativeMessageSendEvent::SendGossipTimestampFilter {ref node_id, ref msg, } => {
2023 let mut node_id_nonref = (*node_id).clone();
2024 let mut msg_nonref = (*msg).clone();
2025 MessageSendEvent::SendGossipTimestampFilter {
2026 node_id: crate::c_types::PublicKey::from_rust(&node_id_nonref),
2027 msg: crate::lightning::ln::msgs::GossipTimestampFilter { inner: ObjOps::heap_alloc(msg_nonref), is_owned: true },
2033 pub(crate) fn native_into(native: nativeMessageSendEvent) -> Self {
2035 nativeMessageSendEvent::SendAcceptChannel {mut node_id, mut msg, } => {
2036 MessageSendEvent::SendAcceptChannel {
2037 node_id: crate::c_types::PublicKey::from_rust(&node_id),
2038 msg: crate::lightning::ln::msgs::AcceptChannel { inner: ObjOps::heap_alloc(msg), is_owned: true },
2041 nativeMessageSendEvent::SendOpenChannel {mut node_id, mut msg, } => {
2042 MessageSendEvent::SendOpenChannel {
2043 node_id: crate::c_types::PublicKey::from_rust(&node_id),
2044 msg: crate::lightning::ln::msgs::OpenChannel { inner: ObjOps::heap_alloc(msg), is_owned: true },
2047 nativeMessageSendEvent::SendFundingCreated {mut node_id, mut msg, } => {
2048 MessageSendEvent::SendFundingCreated {
2049 node_id: crate::c_types::PublicKey::from_rust(&node_id),
2050 msg: crate::lightning::ln::msgs::FundingCreated { inner: ObjOps::heap_alloc(msg), is_owned: true },
2053 nativeMessageSendEvent::SendFundingSigned {mut node_id, mut msg, } => {
2054 MessageSendEvent::SendFundingSigned {
2055 node_id: crate::c_types::PublicKey::from_rust(&node_id),
2056 msg: crate::lightning::ln::msgs::FundingSigned { inner: ObjOps::heap_alloc(msg), is_owned: true },
2059 nativeMessageSendEvent::SendChannelReady {mut node_id, mut msg, } => {
2060 MessageSendEvent::SendChannelReady {
2061 node_id: crate::c_types::PublicKey::from_rust(&node_id),
2062 msg: crate::lightning::ln::msgs::ChannelReady { inner: ObjOps::heap_alloc(msg), is_owned: true },
2065 nativeMessageSendEvent::SendAnnouncementSignatures {mut node_id, mut msg, } => {
2066 MessageSendEvent::SendAnnouncementSignatures {
2067 node_id: crate::c_types::PublicKey::from_rust(&node_id),
2068 msg: crate::lightning::ln::msgs::AnnouncementSignatures { inner: ObjOps::heap_alloc(msg), is_owned: true },
2071 nativeMessageSendEvent::UpdateHTLCs {mut node_id, mut updates, } => {
2072 MessageSendEvent::UpdateHTLCs {
2073 node_id: crate::c_types::PublicKey::from_rust(&node_id),
2074 updates: crate::lightning::ln::msgs::CommitmentUpdate { inner: ObjOps::heap_alloc(updates), is_owned: true },
2077 nativeMessageSendEvent::SendRevokeAndACK {mut node_id, mut msg, } => {
2078 MessageSendEvent::SendRevokeAndACK {
2079 node_id: crate::c_types::PublicKey::from_rust(&node_id),
2080 msg: crate::lightning::ln::msgs::RevokeAndACK { inner: ObjOps::heap_alloc(msg), is_owned: true },
2083 nativeMessageSendEvent::SendClosingSigned {mut node_id, mut msg, } => {
2084 MessageSendEvent::SendClosingSigned {
2085 node_id: crate::c_types::PublicKey::from_rust(&node_id),
2086 msg: crate::lightning::ln::msgs::ClosingSigned { inner: ObjOps::heap_alloc(msg), is_owned: true },
2089 nativeMessageSendEvent::SendShutdown {mut node_id, mut msg, } => {
2090 MessageSendEvent::SendShutdown {
2091 node_id: crate::c_types::PublicKey::from_rust(&node_id),
2092 msg: crate::lightning::ln::msgs::Shutdown { inner: ObjOps::heap_alloc(msg), is_owned: true },
2095 nativeMessageSendEvent::SendChannelReestablish {mut node_id, mut msg, } => {
2096 MessageSendEvent::SendChannelReestablish {
2097 node_id: crate::c_types::PublicKey::from_rust(&node_id),
2098 msg: crate::lightning::ln::msgs::ChannelReestablish { inner: ObjOps::heap_alloc(msg), is_owned: true },
2101 nativeMessageSendEvent::BroadcastChannelAnnouncement {mut msg, mut update_msg, } => {
2102 MessageSendEvent::BroadcastChannelAnnouncement {
2103 msg: crate::lightning::ln::msgs::ChannelAnnouncement { inner: ObjOps::heap_alloc(msg), is_owned: true },
2104 update_msg: crate::lightning::ln::msgs::ChannelUpdate { inner: ObjOps::heap_alloc(update_msg), is_owned: true },
2107 nativeMessageSendEvent::BroadcastNodeAnnouncement {mut msg, } => {
2108 MessageSendEvent::BroadcastNodeAnnouncement {
2109 msg: crate::lightning::ln::msgs::NodeAnnouncement { inner: ObjOps::heap_alloc(msg), is_owned: true },
2112 nativeMessageSendEvent::BroadcastChannelUpdate {mut msg, } => {
2113 MessageSendEvent::BroadcastChannelUpdate {
2114 msg: crate::lightning::ln::msgs::ChannelUpdate { inner: ObjOps::heap_alloc(msg), is_owned: true },
2117 nativeMessageSendEvent::SendChannelUpdate {mut node_id, mut msg, } => {
2118 MessageSendEvent::SendChannelUpdate {
2119 node_id: crate::c_types::PublicKey::from_rust(&node_id),
2120 msg: crate::lightning::ln::msgs::ChannelUpdate { inner: ObjOps::heap_alloc(msg), is_owned: true },
2123 nativeMessageSendEvent::HandleError {mut node_id, mut action, } => {
2124 MessageSendEvent::HandleError {
2125 node_id: crate::c_types::PublicKey::from_rust(&node_id),
2126 action: crate::lightning::ln::msgs::ErrorAction::native_into(action),
2129 nativeMessageSendEvent::SendChannelRangeQuery {mut node_id, mut msg, } => {
2130 MessageSendEvent::SendChannelRangeQuery {
2131 node_id: crate::c_types::PublicKey::from_rust(&node_id),
2132 msg: crate::lightning::ln::msgs::QueryChannelRange { inner: ObjOps::heap_alloc(msg), is_owned: true },
2135 nativeMessageSendEvent::SendShortIdsQuery {mut node_id, mut msg, } => {
2136 MessageSendEvent::SendShortIdsQuery {
2137 node_id: crate::c_types::PublicKey::from_rust(&node_id),
2138 msg: crate::lightning::ln::msgs::QueryShortChannelIds { inner: ObjOps::heap_alloc(msg), is_owned: true },
2141 nativeMessageSendEvent::SendReplyChannelRange {mut node_id, mut msg, } => {
2142 MessageSendEvent::SendReplyChannelRange {
2143 node_id: crate::c_types::PublicKey::from_rust(&node_id),
2144 msg: crate::lightning::ln::msgs::ReplyChannelRange { inner: ObjOps::heap_alloc(msg), is_owned: true },
2147 nativeMessageSendEvent::SendGossipTimestampFilter {mut node_id, mut msg, } => {
2148 MessageSendEvent::SendGossipTimestampFilter {
2149 node_id: crate::c_types::PublicKey::from_rust(&node_id),
2150 msg: crate::lightning::ln::msgs::GossipTimestampFilter { inner: ObjOps::heap_alloc(msg), is_owned: true },
2156 /// Frees any resources used by the MessageSendEvent
2158 pub extern "C" fn MessageSendEvent_free(this_ptr: MessageSendEvent) { }
2159 /// Creates a copy of the MessageSendEvent
2161 pub extern "C" fn MessageSendEvent_clone(orig: &MessageSendEvent) -> MessageSendEvent {
2165 /// Utility method to constructs a new SendAcceptChannel-variant MessageSendEvent
2166 pub extern "C" fn MessageSendEvent_send_accept_channel(node_id: crate::c_types::PublicKey, msg: crate::lightning::ln::msgs::AcceptChannel) -> MessageSendEvent {
2167 MessageSendEvent::SendAcceptChannel {
2173 /// Utility method to constructs a new SendOpenChannel-variant MessageSendEvent
2174 pub extern "C" fn MessageSendEvent_send_open_channel(node_id: crate::c_types::PublicKey, msg: crate::lightning::ln::msgs::OpenChannel) -> MessageSendEvent {
2175 MessageSendEvent::SendOpenChannel {
2181 /// Utility method to constructs a new SendFundingCreated-variant MessageSendEvent
2182 pub extern "C" fn MessageSendEvent_send_funding_created(node_id: crate::c_types::PublicKey, msg: crate::lightning::ln::msgs::FundingCreated) -> MessageSendEvent {
2183 MessageSendEvent::SendFundingCreated {
2189 /// Utility method to constructs a new SendFundingSigned-variant MessageSendEvent
2190 pub extern "C" fn MessageSendEvent_send_funding_signed(node_id: crate::c_types::PublicKey, msg: crate::lightning::ln::msgs::FundingSigned) -> MessageSendEvent {
2191 MessageSendEvent::SendFundingSigned {
2197 /// Utility method to constructs a new SendChannelReady-variant MessageSendEvent
2198 pub extern "C" fn MessageSendEvent_send_channel_ready(node_id: crate::c_types::PublicKey, msg: crate::lightning::ln::msgs::ChannelReady) -> MessageSendEvent {
2199 MessageSendEvent::SendChannelReady {
2205 /// Utility method to constructs a new SendAnnouncementSignatures-variant MessageSendEvent
2206 pub extern "C" fn MessageSendEvent_send_announcement_signatures(node_id: crate::c_types::PublicKey, msg: crate::lightning::ln::msgs::AnnouncementSignatures) -> MessageSendEvent {
2207 MessageSendEvent::SendAnnouncementSignatures {
2213 /// Utility method to constructs a new UpdateHTLCs-variant MessageSendEvent
2214 pub extern "C" fn MessageSendEvent_update_htlcs(node_id: crate::c_types::PublicKey, updates: crate::lightning::ln::msgs::CommitmentUpdate) -> MessageSendEvent {
2215 MessageSendEvent::UpdateHTLCs {
2221 /// Utility method to constructs a new SendRevokeAndACK-variant MessageSendEvent
2222 pub extern "C" fn MessageSendEvent_send_revoke_and_ack(node_id: crate::c_types::PublicKey, msg: crate::lightning::ln::msgs::RevokeAndACK) -> MessageSendEvent {
2223 MessageSendEvent::SendRevokeAndACK {
2229 /// Utility method to constructs a new SendClosingSigned-variant MessageSendEvent
2230 pub extern "C" fn MessageSendEvent_send_closing_signed(node_id: crate::c_types::PublicKey, msg: crate::lightning::ln::msgs::ClosingSigned) -> MessageSendEvent {
2231 MessageSendEvent::SendClosingSigned {
2237 /// Utility method to constructs a new SendShutdown-variant MessageSendEvent
2238 pub extern "C" fn MessageSendEvent_send_shutdown(node_id: crate::c_types::PublicKey, msg: crate::lightning::ln::msgs::Shutdown) -> MessageSendEvent {
2239 MessageSendEvent::SendShutdown {
2245 /// Utility method to constructs a new SendChannelReestablish-variant MessageSendEvent
2246 pub extern "C" fn MessageSendEvent_send_channel_reestablish(node_id: crate::c_types::PublicKey, msg: crate::lightning::ln::msgs::ChannelReestablish) -> MessageSendEvent {
2247 MessageSendEvent::SendChannelReestablish {
2253 /// Utility method to constructs a new BroadcastChannelAnnouncement-variant MessageSendEvent
2254 pub extern "C" fn MessageSendEvent_broadcast_channel_announcement(msg: crate::lightning::ln::msgs::ChannelAnnouncement, update_msg: crate::lightning::ln::msgs::ChannelUpdate) -> MessageSendEvent {
2255 MessageSendEvent::BroadcastChannelAnnouncement {
2261 /// Utility method to constructs a new BroadcastNodeAnnouncement-variant MessageSendEvent
2262 pub extern "C" fn MessageSendEvent_broadcast_node_announcement(msg: crate::lightning::ln::msgs::NodeAnnouncement) -> MessageSendEvent {
2263 MessageSendEvent::BroadcastNodeAnnouncement {
2268 /// Utility method to constructs a new BroadcastChannelUpdate-variant MessageSendEvent
2269 pub extern "C" fn MessageSendEvent_broadcast_channel_update(msg: crate::lightning::ln::msgs::ChannelUpdate) -> MessageSendEvent {
2270 MessageSendEvent::BroadcastChannelUpdate {
2275 /// Utility method to constructs a new SendChannelUpdate-variant MessageSendEvent
2276 pub extern "C" fn MessageSendEvent_send_channel_update(node_id: crate::c_types::PublicKey, msg: crate::lightning::ln::msgs::ChannelUpdate) -> MessageSendEvent {
2277 MessageSendEvent::SendChannelUpdate {
2283 /// Utility method to constructs a new HandleError-variant MessageSendEvent
2284 pub extern "C" fn MessageSendEvent_handle_error(node_id: crate::c_types::PublicKey, action: crate::lightning::ln::msgs::ErrorAction) -> MessageSendEvent {
2285 MessageSendEvent::HandleError {
2291 /// Utility method to constructs a new SendChannelRangeQuery-variant MessageSendEvent
2292 pub extern "C" fn MessageSendEvent_send_channel_range_query(node_id: crate::c_types::PublicKey, msg: crate::lightning::ln::msgs::QueryChannelRange) -> MessageSendEvent {
2293 MessageSendEvent::SendChannelRangeQuery {
2299 /// Utility method to constructs a new SendShortIdsQuery-variant MessageSendEvent
2300 pub extern "C" fn MessageSendEvent_send_short_ids_query(node_id: crate::c_types::PublicKey, msg: crate::lightning::ln::msgs::QueryShortChannelIds) -> MessageSendEvent {
2301 MessageSendEvent::SendShortIdsQuery {
2307 /// Utility method to constructs a new SendReplyChannelRange-variant MessageSendEvent
2308 pub extern "C" fn MessageSendEvent_send_reply_channel_range(node_id: crate::c_types::PublicKey, msg: crate::lightning::ln::msgs::ReplyChannelRange) -> MessageSendEvent {
2309 MessageSendEvent::SendReplyChannelRange {
2315 /// Utility method to constructs a new SendGossipTimestampFilter-variant MessageSendEvent
2316 pub extern "C" fn MessageSendEvent_send_gossip_timestamp_filter(node_id: crate::c_types::PublicKey, msg: crate::lightning::ln::msgs::GossipTimestampFilter) -> MessageSendEvent {
2317 MessageSendEvent::SendGossipTimestampFilter {
2322 /// A trait indicating an object may generate message send events
2324 pub struct MessageSendEventsProvider {
2325 /// An opaque pointer which is passed to your function implementations as an argument.
2326 /// This has no meaning in the LDK, and can be NULL or any other value.
2327 pub this_arg: *mut c_void,
2328 /// Gets the list of pending events which were generated by previous actions, clearing the list
2331 pub get_and_clear_pending_msg_events: extern "C" fn (this_arg: *const c_void) -> crate::c_types::derived::CVec_MessageSendEventZ,
2332 /// Frees any resources associated with this object given its this_arg pointer.
2333 /// Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed.
2334 pub free: Option<extern "C" fn(this_arg: *mut c_void)>,
2336 unsafe impl Send for MessageSendEventsProvider {}
2337 unsafe impl Sync for MessageSendEventsProvider {}
2339 pub(crate) extern "C" fn MessageSendEventsProvider_clone_fields(orig: &MessageSendEventsProvider) -> MessageSendEventsProvider {
2340 MessageSendEventsProvider {
2341 this_arg: orig.this_arg,
2342 get_and_clear_pending_msg_events: Clone::clone(&orig.get_and_clear_pending_msg_events),
2343 free: Clone::clone(&orig.free),
2347 use lightning::util::events::MessageSendEventsProvider as rustMessageSendEventsProvider;
2348 impl rustMessageSendEventsProvider for MessageSendEventsProvider {
2349 fn get_and_clear_pending_msg_events(&self) -> Vec<lightning::util::events::MessageSendEvent> {
2350 let mut ret = (self.get_and_clear_pending_msg_events)(self.this_arg);
2351 let mut local_ret = Vec::new(); for mut item in ret.into_rust().drain(..) { local_ret.push( { item.into_native() }); };
2356 // We're essentially a pointer already, or at least a set of pointers, so allow us to be used
2357 // directly as a Deref trait in higher-level structs:
2358 impl core::ops::Deref for MessageSendEventsProvider {
2360 fn deref(&self) -> &Self {
2364 /// Calls the free function if one is set
2366 pub extern "C" fn MessageSendEventsProvider_free(this_ptr: MessageSendEventsProvider) { }
2367 impl Drop for MessageSendEventsProvider {
2368 fn drop(&mut self) {
2369 if let Some(f) = self.free {
2374 /// A trait indicating an object may generate events.
2376 /// Events are processed by passing an [`EventHandler`] to [`process_pending_events`].
2380 /// See [`process_pending_events`] for requirements around event processing.
2382 /// When using this trait, [`process_pending_events`] will call [`handle_event`] for each pending
2383 /// event since the last invocation. The handler must either act upon the event immediately
2384 /// or preserve it for later handling.
2386 /// Note, handlers may call back into the provider and thus deadlocking must be avoided. Be sure to
2387 /// consult the provider's documentation on the implication of processing events and how a handler
2388 /// may safely use the provider (e.g., see [`ChannelManager::process_pending_events`] and
2389 /// [`ChainMonitor::process_pending_events`]).
2391 /// (C-not implementable) As there is likely no reason for a user to implement this trait on their
2394 /// [`process_pending_events`]: Self::process_pending_events
2395 /// [`handle_event`]: EventHandler::handle_event
2396 /// [`ChannelManager::process_pending_events`]: crate::ln::channelmanager::ChannelManager#method.process_pending_events
2397 /// [`ChainMonitor::process_pending_events`]: crate::chain::chainmonitor::ChainMonitor#method.process_pending_events
2399 pub struct EventsProvider {
2400 /// An opaque pointer which is passed to your function implementations as an argument.
2401 /// This has no meaning in the LDK, and can be NULL or any other value.
2402 pub this_arg: *mut c_void,
2403 /// Processes any events generated since the last call using the given event handler.
2405 /// Subsequent calls must only process new events. However, handlers must be capable of handling
2406 /// duplicate events across process restarts. This may occur if the provider was recovered from
2407 /// an old state (i.e., it hadn't been successfully persisted after processing pending events).
2408 pub process_pending_events: extern "C" fn (this_arg: *const c_void, handler: crate::lightning::util::events::EventHandler),
2409 /// Frees any resources associated with this object given its this_arg pointer.
2410 /// Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed.
2411 pub free: Option<extern "C" fn(this_arg: *mut c_void)>,
2413 unsafe impl Send for EventsProvider {}
2414 unsafe impl Sync for EventsProvider {}
2416 pub(crate) extern "C" fn EventsProvider_clone_fields(orig: &EventsProvider) -> EventsProvider {
2418 this_arg: orig.this_arg,
2419 process_pending_events: Clone::clone(&orig.process_pending_events),
2420 free: Clone::clone(&orig.free),
2424 use lightning::util::events::EventsProvider as rustEventsProvider;
2425 /// Calls the free function if one is set
2427 pub extern "C" fn EventsProvider_free(this_ptr: EventsProvider) { }
2428 impl Drop for EventsProvider {
2429 fn drop(&mut self) {
2430 if let Some(f) = self.free {
2435 /// A trait implemented for objects handling events from [`EventsProvider`].
2437 pub struct EventHandler {
2438 /// An opaque pointer which is passed to your function implementations as an argument.
2439 /// This has no meaning in the LDK, and can be NULL or any other value.
2440 pub this_arg: *mut c_void,
2441 /// Handles the given [`Event`].
2443 /// See [`EventsProvider`] for details that must be considered when implementing this method.
2444 pub handle_event: extern "C" fn (this_arg: *const c_void, event: &crate::lightning::util::events::Event),
2445 /// Frees any resources associated with this object given its this_arg pointer.
2446 /// Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed.
2447 pub free: Option<extern "C" fn(this_arg: *mut c_void)>,
2449 unsafe impl Send for EventHandler {}
2450 unsafe impl Sync for EventHandler {}
2452 pub(crate) extern "C" fn EventHandler_clone_fields(orig: &EventHandler) -> EventHandler {
2454 this_arg: orig.this_arg,
2455 handle_event: Clone::clone(&orig.handle_event),
2456 free: Clone::clone(&orig.free),
2460 use lightning::util::events::EventHandler as rustEventHandler;
2461 impl rustEventHandler for EventHandler {
2462 fn handle_event(&self, mut event: &lightning::util::events::Event) {
2463 (self.handle_event)(self.this_arg, &crate::lightning::util::events::Event::from_native(event))
2467 // We're essentially a pointer already, or at least a set of pointers, so allow us to be used
2468 // directly as a Deref trait in higher-level structs:
2469 impl core::ops::Deref for EventHandler {
2471 fn deref(&self) -> &Self {
2475 /// Calls the free function if one is set
2477 pub extern "C" fn EventHandler_free(this_ptr: EventHandler) { }
2478 impl Drop for EventHandler {
2479 fn drop(&mut self) {
2480 if let Some(f) = self.free {