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 alloc::string::String;
18 use core::ffi::c_void;
19 use core::convert::Infallible;
20 use bitcoin::hashes::Hash;
21 use crate::c_types::*;
22 #[cfg(feature="no-std")]
23 use alloc::{vec::Vec, boxed::Box};
25 pub mod bump_transaction;
26 /// Some information provided on receipt of payment depends on whether the payment received is a
27 /// spontaneous payment or a \"conventional\" lightning payment that's paying an invoice.
31 pub enum PaymentPurpose {
32 /// Information for receiving a payment that we generated an invoice for.
34 /// The preimage to the payment_hash, if the payment hash (and secret) were fetched via
35 /// [`ChannelManager::create_inbound_payment`]. If provided, this can be handed directly to
36 /// [`ChannelManager::claim_funds`].
38 /// [`ChannelManager::create_inbound_payment`]: crate::ln::channelmanager::ChannelManager::create_inbound_payment
39 /// [`ChannelManager::claim_funds`]: crate::ln::channelmanager::ChannelManager::claim_funds
40 payment_preimage: crate::c_types::derived::COption_ThirtyTwoBytesZ,
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::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 = Clone::clone(payment_preimage);
67 let mut local_payment_preimage_nonref = { /*payment_preimage_nonref*/ let payment_preimage_nonref_opt = payment_preimage_nonref; if payment_preimage_nonref_opt.is_none() { None } else { Some({ { ::lightning::ln::PaymentPreimage({ payment_preimage_nonref_opt.take() }.data) }})} };
68 let mut payment_secret_nonref = Clone::clone(payment_secret);
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 = Clone::clone(a);
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 = { /*payment_preimage*/ let payment_preimage_opt = payment_preimage; if payment_preimage_opt.is_none() { None } else { Some({ { ::lightning::ln::PaymentPreimage({ payment_preimage_opt.take() }.data) }})} };
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 = Clone::clone(payment_preimage);
104 let mut local_payment_preimage_nonref = if payment_preimage_nonref.is_none() { crate::c_types::derived::COption_ThirtyTwoBytesZ::None } else { crate::c_types::derived::COption_ThirtyTwoBytesZ::Some( { crate::c_types::ThirtyTwoBytes { data: payment_preimage_nonref.unwrap().0 } }) };
105 let mut payment_secret_nonref = Clone::clone(payment_secret);
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 = Clone::clone(a);
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::derived::COption_ThirtyTwoBytesZ::None } else { crate::c_types::derived::COption_ThirtyTwoBytesZ::Some( { 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 /// Used only if an object of this type is returned as a trait impl by a method
147 pub(crate) extern "C" fn PaymentPurpose_clone_void(this_ptr: *const c_void) -> *mut c_void {
148 Box::into_raw(Box::new(unsafe { (*(this_ptr as *const PaymentPurpose)).clone() })) as *mut c_void
151 /// Used only if an object of this type is returned as a trait impl by a method
152 pub(crate) extern "C" fn PaymentPurpose_free_void(this_ptr: *mut c_void) {
153 let _ = unsafe { Box::from_raw(this_ptr as *mut PaymentPurpose) };
156 /// Utility method to constructs a new InvoicePayment-variant PaymentPurpose
157 pub extern "C" fn PaymentPurpose_invoice_payment(payment_preimage: crate::c_types::derived::COption_ThirtyTwoBytesZ, payment_secret: crate::c_types::ThirtyTwoBytes) -> PaymentPurpose {
158 PaymentPurpose::InvoicePayment {
164 /// Utility method to constructs a new SpontaneousPayment-variant PaymentPurpose
165 pub extern "C" fn PaymentPurpose_spontaneous_payment(a: crate::c_types::ThirtyTwoBytes) -> PaymentPurpose {
166 PaymentPurpose::SpontaneousPayment(a, )
168 /// Checks if two PaymentPurposes contain equal inner contents.
169 /// This ignores pointers and is_owned flags and looks at the values in fields.
171 pub extern "C" fn PaymentPurpose_eq(a: &PaymentPurpose, b: &PaymentPurpose) -> bool {
172 if &a.to_native() == &b.to_native() { true } else { false }
175 /// Serialize the PaymentPurpose object into a byte array which can be read by PaymentPurpose_read
176 pub extern "C" fn PaymentPurpose_write(obj: &crate::lightning::events::PaymentPurpose) -> crate::c_types::derived::CVec_u8Z {
177 crate::c_types::serialize_obj(&unsafe { &*obj }.to_native())
180 pub(crate) extern "C" fn PaymentPurpose_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
181 PaymentPurpose_write(unsafe { &*(obj as *const PaymentPurpose) })
184 /// Read a PaymentPurpose from a byte array, created by PaymentPurpose_write
185 pub extern "C" fn PaymentPurpose_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_PaymentPurposeDecodeErrorZ {
186 let res: Result<lightning::events::PaymentPurpose, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
187 let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::events::PaymentPurpose::native_into(o) }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() };
191 use lightning::events::ClaimedHTLC as nativeClaimedHTLCImport;
192 pub(crate) type nativeClaimedHTLC = nativeClaimedHTLCImport;
194 /// Information about an HTLC that is part of a payment that can be claimed.
197 pub struct ClaimedHTLC {
198 /// A pointer to the opaque Rust object.
200 /// Nearly everywhere, inner must be non-null, however in places where
201 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
202 pub inner: *mut nativeClaimedHTLC,
203 /// Indicates that this is the only struct which contains the same pointer.
205 /// Rust functions which take ownership of an object provided via an argument require
206 /// this to be true and invalidate the object pointed to by inner.
210 impl Drop for ClaimedHTLC {
212 if self.is_owned && !<*mut nativeClaimedHTLC>::is_null(self.inner) {
213 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
217 /// Frees any resources used by the ClaimedHTLC, if is_owned is set and inner is non-NULL.
219 pub extern "C" fn ClaimedHTLC_free(this_obj: ClaimedHTLC) { }
221 /// Used only if an object of this type is returned as a trait impl by a method
222 pub(crate) extern "C" fn ClaimedHTLC_free_void(this_ptr: *mut c_void) {
223 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeClaimedHTLC) };
227 pub(crate) fn get_native_ref(&self) -> &'static nativeClaimedHTLC {
228 unsafe { &*ObjOps::untweak_ptr(self.inner) }
230 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeClaimedHTLC {
231 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
233 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
234 pub(crate) fn take_inner(mut self) -> *mut nativeClaimedHTLC {
235 assert!(self.is_owned);
236 let ret = ObjOps::untweak_ptr(self.inner);
237 self.inner = core::ptr::null_mut();
241 /// The `channel_id` of the channel over which the HTLC was received.
243 pub extern "C" fn ClaimedHTLC_get_channel_id(this_ptr: &ClaimedHTLC) -> *const [u8; 32] {
244 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
247 /// The `channel_id` of the channel over which the HTLC was received.
249 pub extern "C" fn ClaimedHTLC_set_channel_id(this_ptr: &mut ClaimedHTLC, mut val: crate::c_types::ThirtyTwoBytes) {
250 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = ::lightning::ln::ChannelId(val.data);
252 /// The `user_channel_id` of the channel over which the HTLC was received. This is the value
253 /// passed in to [`ChannelManager::create_channel`] for outbound channels, or to
254 /// [`ChannelManager::accept_inbound_channel`] for inbound channels if
255 /// [`UserConfig::manually_accept_inbound_channels`] config flag is set to true. Otherwise
256 /// `user_channel_id` will be randomized for an inbound channel.
258 /// This field will be zero for a payment that was serialized prior to LDK version 0.0.117. (This
259 /// should only happen in the case that a payment was claimable prior to LDK version 0.0.117, but
260 /// was not actually claimed until after upgrading.)
262 /// [`ChannelManager::create_channel`]: crate::ln::channelmanager::ChannelManager::create_channel
263 /// [`ChannelManager::accept_inbound_channel`]: crate::ln::channelmanager::ChannelManager::accept_inbound_channel
264 /// [`UserConfig::manually_accept_inbound_channels`]: crate::util::config::UserConfig::manually_accept_inbound_channels
266 pub extern "C" fn ClaimedHTLC_get_user_channel_id(this_ptr: &ClaimedHTLC) -> crate::c_types::U128 {
267 let mut inner_val = &mut this_ptr.get_native_mut_ref().user_channel_id;
270 /// The `user_channel_id` of the channel over which the HTLC was received. This is the value
271 /// passed in to [`ChannelManager::create_channel`] for outbound channels, or to
272 /// [`ChannelManager::accept_inbound_channel`] for inbound channels if
273 /// [`UserConfig::manually_accept_inbound_channels`] config flag is set to true. Otherwise
274 /// `user_channel_id` will be randomized for an inbound channel.
276 /// This field will be zero for a payment that was serialized prior to LDK version 0.0.117. (This
277 /// should only happen in the case that a payment was claimable prior to LDK version 0.0.117, but
278 /// was not actually claimed until after upgrading.)
280 /// [`ChannelManager::create_channel`]: crate::ln::channelmanager::ChannelManager::create_channel
281 /// [`ChannelManager::accept_inbound_channel`]: crate::ln::channelmanager::ChannelManager::accept_inbound_channel
282 /// [`UserConfig::manually_accept_inbound_channels`]: crate::util::config::UserConfig::manually_accept_inbound_channels
284 pub extern "C" fn ClaimedHTLC_set_user_channel_id(this_ptr: &mut ClaimedHTLC, mut val: crate::c_types::U128) {
285 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.user_channel_id = val.into();
287 /// The block height at which this HTLC expires.
289 pub extern "C" fn ClaimedHTLC_get_cltv_expiry(this_ptr: &ClaimedHTLC) -> u32 {
290 let mut inner_val = &mut this_ptr.get_native_mut_ref().cltv_expiry;
293 /// The block height at which this HTLC expires.
295 pub extern "C" fn ClaimedHTLC_set_cltv_expiry(this_ptr: &mut ClaimedHTLC, mut val: u32) {
296 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.cltv_expiry = val;
298 /// The amount (in msats) of this part of an MPP.
300 pub extern "C" fn ClaimedHTLC_get_value_msat(this_ptr: &ClaimedHTLC) -> u64 {
301 let mut inner_val = &mut this_ptr.get_native_mut_ref().value_msat;
304 /// The amount (in msats) of this part of an MPP.
306 pub extern "C" fn ClaimedHTLC_set_value_msat(this_ptr: &mut ClaimedHTLC, mut val: u64) {
307 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.value_msat = val;
309 /// Constructs a new ClaimedHTLC given each field
312 pub extern "C" fn ClaimedHTLC_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut user_channel_id_arg: crate::c_types::U128, mut cltv_expiry_arg: u32, mut value_msat_arg: u64) -> ClaimedHTLC {
313 ClaimedHTLC { inner: ObjOps::heap_alloc(nativeClaimedHTLC {
314 channel_id: ::lightning::ln::ChannelId(channel_id_arg.data),
315 user_channel_id: user_channel_id_arg.into(),
316 cltv_expiry: cltv_expiry_arg,
317 value_msat: value_msat_arg,
320 impl Clone for ClaimedHTLC {
321 fn clone(&self) -> Self {
323 inner: if <*mut nativeClaimedHTLC>::is_null(self.inner) { core::ptr::null_mut() } else {
324 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
330 /// Used only if an object of this type is returned as a trait impl by a method
331 pub(crate) extern "C" fn ClaimedHTLC_clone_void(this_ptr: *const c_void) -> *mut c_void {
332 Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeClaimedHTLC)).clone() })) as *mut c_void
335 /// Creates a copy of the ClaimedHTLC
336 pub extern "C" fn ClaimedHTLC_clone(orig: &ClaimedHTLC) -> ClaimedHTLC {
339 /// Checks if two ClaimedHTLCs contain equal inner contents.
340 /// This ignores pointers and is_owned flags and looks at the values in fields.
341 /// Two objects with NULL inner values will be considered "equal" here.
343 pub extern "C" fn ClaimedHTLC_eq(a: &ClaimedHTLC, b: &ClaimedHTLC) -> bool {
344 if a.inner == b.inner { return true; }
345 if a.inner.is_null() || b.inner.is_null() { return false; }
346 if a.get_native_ref() == b.get_native_ref() { true } else { false }
349 /// Serialize the ClaimedHTLC object into a byte array which can be read by ClaimedHTLC_read
350 pub extern "C" fn ClaimedHTLC_write(obj: &crate::lightning::events::ClaimedHTLC) -> crate::c_types::derived::CVec_u8Z {
351 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
354 pub(crate) extern "C" fn ClaimedHTLC_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
355 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeClaimedHTLC) })
358 /// Read a ClaimedHTLC from a byte array, created by ClaimedHTLC_write
359 pub extern "C" fn ClaimedHTLC_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ClaimedHTLCDecodeErrorZ {
360 let res: Result<lightning::events::ClaimedHTLC, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
361 let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::events::ClaimedHTLC { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() };
364 /// When the payment path failure took place and extra details about it. [`PathFailure::OnPath`] may
365 /// contain a [`NetworkUpdate`] that needs to be applied to the [`NetworkGraph`].
367 /// [`NetworkUpdate`]: crate::routing::gossip::NetworkUpdate
368 /// [`NetworkGraph`]: crate::routing::gossip::NetworkGraph
372 pub enum PathFailure {
373 /// We failed to initially send the payment and no HTLC was committed to. Contains the relevant
376 /// The error surfaced from initial send.
377 err: crate::lightning::util::errors::APIError,
379 /// A hop on the path failed to forward our payment.
381 /// If present, this [`NetworkUpdate`] should be applied to the [`NetworkGraph`] so that routing
382 /// decisions can take into account the update.
384 /// [`NetworkUpdate`]: crate::routing::gossip::NetworkUpdate
385 /// [`NetworkGraph`]: crate::routing::gossip::NetworkGraph
386 network_update: crate::c_types::derived::COption_NetworkUpdateZ,
389 use lightning::events::PathFailure as PathFailureImport;
390 pub(crate) type nativePathFailure = PathFailureImport;
394 pub(crate) fn to_native(&self) -> nativePathFailure {
396 PathFailure::InitialSend {ref err, } => {
397 let mut err_nonref = Clone::clone(err);
398 nativePathFailure::InitialSend {
399 err: err_nonref.into_native(),
402 PathFailure::OnPath {ref network_update, } => {
403 let mut network_update_nonref = Clone::clone(network_update);
404 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() }})} };
405 nativePathFailure::OnPath {
406 network_update: local_network_update_nonref,
412 pub(crate) fn into_native(self) -> nativePathFailure {
414 PathFailure::InitialSend {mut err, } => {
415 nativePathFailure::InitialSend {
416 err: err.into_native(),
419 PathFailure::OnPath {mut network_update, } => {
420 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() }})} };
421 nativePathFailure::OnPath {
422 network_update: local_network_update,
428 pub(crate) fn from_native(native: &nativePathFailure) -> Self {
430 nativePathFailure::InitialSend {ref err, } => {
431 let mut err_nonref = Clone::clone(err);
432 PathFailure::InitialSend {
433 err: crate::lightning::util::errors::APIError::native_into(err_nonref),
436 nativePathFailure::OnPath {ref network_update, } => {
437 let mut network_update_nonref = Clone::clone(network_update);
438 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()) }) };
439 PathFailure::OnPath {
440 network_update: local_network_update_nonref,
446 pub(crate) fn native_into(native: nativePathFailure) -> Self {
448 nativePathFailure::InitialSend {mut err, } => {
449 PathFailure::InitialSend {
450 err: crate::lightning::util::errors::APIError::native_into(err),
453 nativePathFailure::OnPath {mut network_update, } => {
454 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()) }) };
455 PathFailure::OnPath {
456 network_update: local_network_update,
462 /// Frees any resources used by the PathFailure
464 pub extern "C" fn PathFailure_free(this_ptr: PathFailure) { }
465 /// Creates a copy of the PathFailure
467 pub extern "C" fn PathFailure_clone(orig: &PathFailure) -> PathFailure {
471 /// Used only if an object of this type is returned as a trait impl by a method
472 pub(crate) extern "C" fn PathFailure_clone_void(this_ptr: *const c_void) -> *mut c_void {
473 Box::into_raw(Box::new(unsafe { (*(this_ptr as *const PathFailure)).clone() })) as *mut c_void
476 /// Used only if an object of this type is returned as a trait impl by a method
477 pub(crate) extern "C" fn PathFailure_free_void(this_ptr: *mut c_void) {
478 let _ = unsafe { Box::from_raw(this_ptr as *mut PathFailure) };
481 /// Utility method to constructs a new InitialSend-variant PathFailure
482 pub extern "C" fn PathFailure_initial_send(err: crate::lightning::util::errors::APIError) -> PathFailure {
483 PathFailure::InitialSend {
488 /// Utility method to constructs a new OnPath-variant PathFailure
489 pub extern "C" fn PathFailure_on_path(network_update: crate::c_types::derived::COption_NetworkUpdateZ) -> PathFailure {
490 PathFailure::OnPath {
494 /// Checks if two PathFailures contain equal inner contents.
495 /// This ignores pointers and is_owned flags and looks at the values in fields.
497 pub extern "C" fn PathFailure_eq(a: &PathFailure, b: &PathFailure) -> bool {
498 if &a.to_native() == &b.to_native() { true } else { false }
501 /// Serialize the PathFailure object into a byte array which can be read by PathFailure_read
502 pub extern "C" fn PathFailure_write(obj: &crate::lightning::events::PathFailure) -> crate::c_types::derived::CVec_u8Z {
503 crate::c_types::serialize_obj(&unsafe { &*obj }.to_native())
506 pub(crate) extern "C" fn PathFailure_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
507 PathFailure_write(unsafe { &*(obj as *const PathFailure) })
510 /// Read a PathFailure from a byte array, created by PathFailure_write
511 pub extern "C" fn PathFailure_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_COption_PathFailureZDecodeErrorZ {
512 let res: Result<Option<lightning::events::PathFailure>, lightning::ln::msgs::DecodeError> = crate::c_types::maybe_deserialize_obj(ser);
513 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_PathFailureZ::None } else { crate::c_types::derived::COption_PathFailureZ::Some( { crate::lightning::events::PathFailure::native_into(o.unwrap()) }) }; local_res_0 }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() };
516 /// The reason the channel was closed. See individual variants for more details.
520 pub enum ClosureReason {
521 /// Closure generated from receiving a peer error message.
523 /// Our counterparty may have broadcasted their latest commitment state, and we have
525 CounterpartyForceClosed {
526 /// The error which the peer sent us.
528 /// Be careful about printing the peer_msg, a well-crafted message could exploit
529 /// a security vulnerability in the terminal emulator or the logging subsystem.
530 /// To be safe, use `Display` on `UntrustedString`
532 /// [`UntrustedString`]: crate::util::string::UntrustedString
533 peer_msg: crate::lightning::util::string::UntrustedString,
535 /// Closure generated from [`ChannelManager::force_close_channel`], called by the user.
537 /// [`ChannelManager::force_close_channel`]: crate::ln::channelmanager::ChannelManager::force_close_channel.
539 /// The channel was closed after negotiating a cooperative close and we've now broadcasted
540 /// the cooperative close transaction. Note the shutdown may have been initiated by us.
542 /// A commitment transaction was confirmed on chain, closing the channel. Most likely this
543 /// commitment transaction came from our counterparty, but it may also have come from
544 /// a copy of our own `ChannelMonitor`.
545 CommitmentTxConfirmed,
546 /// The funding transaction failed to confirm in a timely manner on an inbound channel.
548 /// Closure generated from processing an event, likely a HTLC forward/relay/reception.
550 /// A developer-readable error message which we generated.
551 err: crate::c_types::Str,
553 /// The peer disconnected prior to funding completing. In this case the spec mandates that we
554 /// forget the channel entirely - we can attempt again if the peer reconnects.
556 /// This includes cases where we restarted prior to funding completion, including prior to the
557 /// initial [`ChannelMonitor`] persistence completing.
559 /// In LDK versions prior to 0.0.107 this could also occur if we were unable to connect to the
560 /// peer because of mutual incompatibility between us and our channel counterparty.
562 /// [`ChannelMonitor`]: crate::chain::channelmonitor::ChannelMonitor
564 /// Closure generated from `ChannelManager::read` if the [`ChannelMonitor`] is newer than
565 /// the [`ChannelManager`] deserialized.
567 /// [`ChannelMonitor`]: crate::chain::channelmonitor::ChannelMonitor
568 /// [`ChannelManager`]: crate::ln::channelmanager::ChannelManager
569 OutdatedChannelManager,
570 /// The counterparty requested a cooperative close of a channel that had not been funded yet.
571 /// The channel has been immediately closed.
572 CounterpartyCoopClosedUnfundedChannel,
573 /// Another channel in the same funding batch closed before the funding transaction
574 /// was ready to be broadcast.
577 use lightning::events::ClosureReason as ClosureReasonImport;
578 pub(crate) type nativeClosureReason = ClosureReasonImport;
582 pub(crate) fn to_native(&self) -> nativeClosureReason {
584 ClosureReason::CounterpartyForceClosed {ref peer_msg, } => {
585 let mut peer_msg_nonref = Clone::clone(peer_msg);
586 nativeClosureReason::CounterpartyForceClosed {
587 peer_msg: *unsafe { Box::from_raw(peer_msg_nonref.take_inner()) },
590 ClosureReason::HolderForceClosed => nativeClosureReason::HolderForceClosed,
591 ClosureReason::CooperativeClosure => nativeClosureReason::CooperativeClosure,
592 ClosureReason::CommitmentTxConfirmed => nativeClosureReason::CommitmentTxConfirmed,
593 ClosureReason::FundingTimedOut => nativeClosureReason::FundingTimedOut,
594 ClosureReason::ProcessingError {ref err, } => {
595 let mut err_nonref = Clone::clone(err);
596 nativeClosureReason::ProcessingError {
597 err: err_nonref.into_string(),
600 ClosureReason::DisconnectedPeer => nativeClosureReason::DisconnectedPeer,
601 ClosureReason::OutdatedChannelManager => nativeClosureReason::OutdatedChannelManager,
602 ClosureReason::CounterpartyCoopClosedUnfundedChannel => nativeClosureReason::CounterpartyCoopClosedUnfundedChannel,
603 ClosureReason::FundingBatchClosure => nativeClosureReason::FundingBatchClosure,
607 pub(crate) fn into_native(self) -> nativeClosureReason {
609 ClosureReason::CounterpartyForceClosed {mut peer_msg, } => {
610 nativeClosureReason::CounterpartyForceClosed {
611 peer_msg: *unsafe { Box::from_raw(peer_msg.take_inner()) },
614 ClosureReason::HolderForceClosed => nativeClosureReason::HolderForceClosed,
615 ClosureReason::CooperativeClosure => nativeClosureReason::CooperativeClosure,
616 ClosureReason::CommitmentTxConfirmed => nativeClosureReason::CommitmentTxConfirmed,
617 ClosureReason::FundingTimedOut => nativeClosureReason::FundingTimedOut,
618 ClosureReason::ProcessingError {mut err, } => {
619 nativeClosureReason::ProcessingError {
620 err: err.into_string(),
623 ClosureReason::DisconnectedPeer => nativeClosureReason::DisconnectedPeer,
624 ClosureReason::OutdatedChannelManager => nativeClosureReason::OutdatedChannelManager,
625 ClosureReason::CounterpartyCoopClosedUnfundedChannel => nativeClosureReason::CounterpartyCoopClosedUnfundedChannel,
626 ClosureReason::FundingBatchClosure => nativeClosureReason::FundingBatchClosure,
630 pub(crate) fn from_native(native: &nativeClosureReason) -> Self {
632 nativeClosureReason::CounterpartyForceClosed {ref peer_msg, } => {
633 let mut peer_msg_nonref = Clone::clone(peer_msg);
634 ClosureReason::CounterpartyForceClosed {
635 peer_msg: crate::lightning::util::string::UntrustedString { inner: ObjOps::heap_alloc(peer_msg_nonref), is_owned: true },
638 nativeClosureReason::HolderForceClosed => ClosureReason::HolderForceClosed,
639 nativeClosureReason::CooperativeClosure => ClosureReason::CooperativeClosure,
640 nativeClosureReason::CommitmentTxConfirmed => ClosureReason::CommitmentTxConfirmed,
641 nativeClosureReason::FundingTimedOut => ClosureReason::FundingTimedOut,
642 nativeClosureReason::ProcessingError {ref err, } => {
643 let mut err_nonref = Clone::clone(err);
644 ClosureReason::ProcessingError {
645 err: err_nonref.into(),
648 nativeClosureReason::DisconnectedPeer => ClosureReason::DisconnectedPeer,
649 nativeClosureReason::OutdatedChannelManager => ClosureReason::OutdatedChannelManager,
650 nativeClosureReason::CounterpartyCoopClosedUnfundedChannel => ClosureReason::CounterpartyCoopClosedUnfundedChannel,
651 nativeClosureReason::FundingBatchClosure => ClosureReason::FundingBatchClosure,
655 pub(crate) fn native_into(native: nativeClosureReason) -> Self {
657 nativeClosureReason::CounterpartyForceClosed {mut peer_msg, } => {
658 ClosureReason::CounterpartyForceClosed {
659 peer_msg: crate::lightning::util::string::UntrustedString { inner: ObjOps::heap_alloc(peer_msg), is_owned: true },
662 nativeClosureReason::HolderForceClosed => ClosureReason::HolderForceClosed,
663 nativeClosureReason::CooperativeClosure => ClosureReason::CooperativeClosure,
664 nativeClosureReason::CommitmentTxConfirmed => ClosureReason::CommitmentTxConfirmed,
665 nativeClosureReason::FundingTimedOut => ClosureReason::FundingTimedOut,
666 nativeClosureReason::ProcessingError {mut err, } => {
667 ClosureReason::ProcessingError {
671 nativeClosureReason::DisconnectedPeer => ClosureReason::DisconnectedPeer,
672 nativeClosureReason::OutdatedChannelManager => ClosureReason::OutdatedChannelManager,
673 nativeClosureReason::CounterpartyCoopClosedUnfundedChannel => ClosureReason::CounterpartyCoopClosedUnfundedChannel,
674 nativeClosureReason::FundingBatchClosure => ClosureReason::FundingBatchClosure,
678 /// Frees any resources used by the ClosureReason
680 pub extern "C" fn ClosureReason_free(this_ptr: ClosureReason) { }
681 /// Creates a copy of the ClosureReason
683 pub extern "C" fn ClosureReason_clone(orig: &ClosureReason) -> ClosureReason {
687 /// Used only if an object of this type is returned as a trait impl by a method
688 pub(crate) extern "C" fn ClosureReason_clone_void(this_ptr: *const c_void) -> *mut c_void {
689 Box::into_raw(Box::new(unsafe { (*(this_ptr as *const ClosureReason)).clone() })) as *mut c_void
692 /// Used only if an object of this type is returned as a trait impl by a method
693 pub(crate) extern "C" fn ClosureReason_free_void(this_ptr: *mut c_void) {
694 let _ = unsafe { Box::from_raw(this_ptr as *mut ClosureReason) };
697 /// Utility method to constructs a new CounterpartyForceClosed-variant ClosureReason
698 pub extern "C" fn ClosureReason_counterparty_force_closed(peer_msg: crate::lightning::util::string::UntrustedString) -> ClosureReason {
699 ClosureReason::CounterpartyForceClosed {
704 /// Utility method to constructs a new HolderForceClosed-variant ClosureReason
705 pub extern "C" fn ClosureReason_holder_force_closed() -> ClosureReason {
706 ClosureReason::HolderForceClosed}
708 /// Utility method to constructs a new CooperativeClosure-variant ClosureReason
709 pub extern "C" fn ClosureReason_cooperative_closure() -> ClosureReason {
710 ClosureReason::CooperativeClosure}
712 /// Utility method to constructs a new CommitmentTxConfirmed-variant ClosureReason
713 pub extern "C" fn ClosureReason_commitment_tx_confirmed() -> ClosureReason {
714 ClosureReason::CommitmentTxConfirmed}
716 /// Utility method to constructs a new FundingTimedOut-variant ClosureReason
717 pub extern "C" fn ClosureReason_funding_timed_out() -> ClosureReason {
718 ClosureReason::FundingTimedOut}
720 /// Utility method to constructs a new ProcessingError-variant ClosureReason
721 pub extern "C" fn ClosureReason_processing_error(err: crate::c_types::Str) -> ClosureReason {
722 ClosureReason::ProcessingError {
727 /// Utility method to constructs a new DisconnectedPeer-variant ClosureReason
728 pub extern "C" fn ClosureReason_disconnected_peer() -> ClosureReason {
729 ClosureReason::DisconnectedPeer}
731 /// Utility method to constructs a new OutdatedChannelManager-variant ClosureReason
732 pub extern "C" fn ClosureReason_outdated_channel_manager() -> ClosureReason {
733 ClosureReason::OutdatedChannelManager}
735 /// Utility method to constructs a new CounterpartyCoopClosedUnfundedChannel-variant ClosureReason
736 pub extern "C" fn ClosureReason_counterparty_coop_closed_unfunded_channel() -> ClosureReason {
737 ClosureReason::CounterpartyCoopClosedUnfundedChannel}
739 /// Utility method to constructs a new FundingBatchClosure-variant ClosureReason
740 pub extern "C" fn ClosureReason_funding_batch_closure() -> ClosureReason {
741 ClosureReason::FundingBatchClosure}
742 /// Checks if two ClosureReasons contain equal inner contents.
743 /// This ignores pointers and is_owned flags and looks at the values in fields.
745 pub extern "C" fn ClosureReason_eq(a: &ClosureReason, b: &ClosureReason) -> bool {
746 if &a.to_native() == &b.to_native() { true } else { false }
749 /// Serialize the ClosureReason object into a byte array which can be read by ClosureReason_read
750 pub extern "C" fn ClosureReason_write(obj: &crate::lightning::events::ClosureReason) -> crate::c_types::derived::CVec_u8Z {
751 crate::c_types::serialize_obj(&unsafe { &*obj }.to_native())
754 pub(crate) extern "C" fn ClosureReason_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
755 ClosureReason_write(unsafe { &*(obj as *const ClosureReason) })
758 /// Read a ClosureReason from a byte array, created by ClosureReason_write
759 pub extern "C" fn ClosureReason_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_COption_ClosureReasonZDecodeErrorZ {
760 let res: Result<Option<lightning::events::ClosureReason>, lightning::ln::msgs::DecodeError> = crate::c_types::maybe_deserialize_obj(ser);
761 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::events::ClosureReason::native_into(o.unwrap()) }) }; local_res_0 }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() };
764 /// Intended destination of a failed HTLC as indicated in [`Event::HTLCHandlingFailed`].
768 pub enum HTLCDestination {
769 /// We tried forwarding to a channel but failed to do so. An example of such an instance is when
770 /// there is insufficient capacity in our outbound channel.
772 /// The `node_id` of the next node. For backwards compatibility, this field is
773 /// marked as optional, versions prior to 0.0.110 may not always be able to provide
774 /// counterparty node information.
776 /// Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None
777 node_id: crate::c_types::PublicKey,
778 /// The outgoing `channel_id` between us and the next node.
779 channel_id: crate::c_types::ThirtyTwoBytes,
781 /// Scenario where we are unsure of the next node to forward the HTLC to.
783 /// Short channel id we are requesting to forward an HTLC to.
784 requested_forward_scid: u64,
786 /// We couldn't forward to the outgoing scid. An example would be attempting to send a duplicate
789 /// Short channel id we are requesting to forward an HTLC to.
790 requested_forward_scid: u64,
792 /// Failure scenario where an HTLC may have been forwarded to be intended for us,
793 /// but is invalid for some reason, so we reject it.
795 /// Some of the reasons may include:
797 /// * Excess HTLCs for a payment that we have already fully received, over-paying for the
799 /// * The counterparty node modified the HTLC in transit,
800 /// * A probing attack where an intermediary node is trying to detect if we are the ultimate
801 /// recipient for a payment.
803 /// The payment hash of the payment we attempted to process.
804 payment_hash: crate::c_types::ThirtyTwoBytes,
807 use lightning::events::HTLCDestination as HTLCDestinationImport;
808 pub(crate) type nativeHTLCDestination = HTLCDestinationImport;
810 impl HTLCDestination {
812 pub(crate) fn to_native(&self) -> nativeHTLCDestination {
814 HTLCDestination::NextHopChannel {ref node_id, ref channel_id, } => {
815 let mut node_id_nonref = Clone::clone(node_id);
816 let mut local_node_id_nonref = if node_id_nonref.is_null() { None } else { Some( { node_id_nonref.into_rust() }) };
817 let mut channel_id_nonref = Clone::clone(channel_id);
818 nativeHTLCDestination::NextHopChannel {
819 node_id: local_node_id_nonref,
820 channel_id: ::lightning::ln::ChannelId(channel_id_nonref.data),
823 HTLCDestination::UnknownNextHop {ref requested_forward_scid, } => {
824 let mut requested_forward_scid_nonref = Clone::clone(requested_forward_scid);
825 nativeHTLCDestination::UnknownNextHop {
826 requested_forward_scid: requested_forward_scid_nonref,
829 HTLCDestination::InvalidForward {ref requested_forward_scid, } => {
830 let mut requested_forward_scid_nonref = Clone::clone(requested_forward_scid);
831 nativeHTLCDestination::InvalidForward {
832 requested_forward_scid: requested_forward_scid_nonref,
835 HTLCDestination::FailedPayment {ref payment_hash, } => {
836 let mut payment_hash_nonref = Clone::clone(payment_hash);
837 nativeHTLCDestination::FailedPayment {
838 payment_hash: ::lightning::ln::PaymentHash(payment_hash_nonref.data),
844 pub(crate) fn into_native(self) -> nativeHTLCDestination {
846 HTLCDestination::NextHopChannel {mut node_id, mut channel_id, } => {
847 let mut local_node_id = if node_id.is_null() { None } else { Some( { node_id.into_rust() }) };
848 nativeHTLCDestination::NextHopChannel {
849 node_id: local_node_id,
850 channel_id: ::lightning::ln::ChannelId(channel_id.data),
853 HTLCDestination::UnknownNextHop {mut requested_forward_scid, } => {
854 nativeHTLCDestination::UnknownNextHop {
855 requested_forward_scid: requested_forward_scid,
858 HTLCDestination::InvalidForward {mut requested_forward_scid, } => {
859 nativeHTLCDestination::InvalidForward {
860 requested_forward_scid: requested_forward_scid,
863 HTLCDestination::FailedPayment {mut payment_hash, } => {
864 nativeHTLCDestination::FailedPayment {
865 payment_hash: ::lightning::ln::PaymentHash(payment_hash.data),
871 pub(crate) fn from_native(native: &nativeHTLCDestination) -> Self {
873 nativeHTLCDestination::NextHopChannel {ref node_id, ref channel_id, } => {
874 let mut node_id_nonref = Clone::clone(node_id);
875 let mut local_node_id_nonref = if node_id_nonref.is_none() { crate::c_types::PublicKey::null() } else { { crate::c_types::PublicKey::from_rust(&(node_id_nonref.unwrap())) } };
876 let mut channel_id_nonref = Clone::clone(channel_id);
877 HTLCDestination::NextHopChannel {
878 node_id: local_node_id_nonref,
879 channel_id: crate::c_types::ThirtyTwoBytes { data: channel_id_nonref.0 },
882 nativeHTLCDestination::UnknownNextHop {ref requested_forward_scid, } => {
883 let mut requested_forward_scid_nonref = Clone::clone(requested_forward_scid);
884 HTLCDestination::UnknownNextHop {
885 requested_forward_scid: requested_forward_scid_nonref,
888 nativeHTLCDestination::InvalidForward {ref requested_forward_scid, } => {
889 let mut requested_forward_scid_nonref = Clone::clone(requested_forward_scid);
890 HTLCDestination::InvalidForward {
891 requested_forward_scid: requested_forward_scid_nonref,
894 nativeHTLCDestination::FailedPayment {ref payment_hash, } => {
895 let mut payment_hash_nonref = Clone::clone(payment_hash);
896 HTLCDestination::FailedPayment {
897 payment_hash: crate::c_types::ThirtyTwoBytes { data: payment_hash_nonref.0 },
903 pub(crate) fn native_into(native: nativeHTLCDestination) -> Self {
905 nativeHTLCDestination::NextHopChannel {mut node_id, mut channel_id, } => {
906 let mut local_node_id = if node_id.is_none() { crate::c_types::PublicKey::null() } else { { crate::c_types::PublicKey::from_rust(&(node_id.unwrap())) } };
907 HTLCDestination::NextHopChannel {
908 node_id: local_node_id,
909 channel_id: crate::c_types::ThirtyTwoBytes { data: channel_id.0 },
912 nativeHTLCDestination::UnknownNextHop {mut requested_forward_scid, } => {
913 HTLCDestination::UnknownNextHop {
914 requested_forward_scid: requested_forward_scid,
917 nativeHTLCDestination::InvalidForward {mut requested_forward_scid, } => {
918 HTLCDestination::InvalidForward {
919 requested_forward_scid: requested_forward_scid,
922 nativeHTLCDestination::FailedPayment {mut payment_hash, } => {
923 HTLCDestination::FailedPayment {
924 payment_hash: crate::c_types::ThirtyTwoBytes { data: payment_hash.0 },
930 /// Frees any resources used by the HTLCDestination
932 pub extern "C" fn HTLCDestination_free(this_ptr: HTLCDestination) { }
933 /// Creates a copy of the HTLCDestination
935 pub extern "C" fn HTLCDestination_clone(orig: &HTLCDestination) -> HTLCDestination {
939 /// Used only if an object of this type is returned as a trait impl by a method
940 pub(crate) extern "C" fn HTLCDestination_clone_void(this_ptr: *const c_void) -> *mut c_void {
941 Box::into_raw(Box::new(unsafe { (*(this_ptr as *const HTLCDestination)).clone() })) as *mut c_void
944 /// Used only if an object of this type is returned as a trait impl by a method
945 pub(crate) extern "C" fn HTLCDestination_free_void(this_ptr: *mut c_void) {
946 let _ = unsafe { Box::from_raw(this_ptr as *mut HTLCDestination) };
949 /// Utility method to constructs a new NextHopChannel-variant HTLCDestination
950 pub extern "C" fn HTLCDestination_next_hop_channel(node_id: crate::c_types::PublicKey, channel_id: crate::c_types::ThirtyTwoBytes) -> HTLCDestination {
951 HTLCDestination::NextHopChannel {
957 /// Utility method to constructs a new UnknownNextHop-variant HTLCDestination
958 pub extern "C" fn HTLCDestination_unknown_next_hop(requested_forward_scid: u64) -> HTLCDestination {
959 HTLCDestination::UnknownNextHop {
960 requested_forward_scid,
964 /// Utility method to constructs a new InvalidForward-variant HTLCDestination
965 pub extern "C" fn HTLCDestination_invalid_forward(requested_forward_scid: u64) -> HTLCDestination {
966 HTLCDestination::InvalidForward {
967 requested_forward_scid,
971 /// Utility method to constructs a new FailedPayment-variant HTLCDestination
972 pub extern "C" fn HTLCDestination_failed_payment(payment_hash: crate::c_types::ThirtyTwoBytes) -> HTLCDestination {
973 HTLCDestination::FailedPayment {
977 /// Checks if two HTLCDestinations contain equal inner contents.
978 /// This ignores pointers and is_owned flags and looks at the values in fields.
980 pub extern "C" fn HTLCDestination_eq(a: &HTLCDestination, b: &HTLCDestination) -> bool {
981 if &a.to_native() == &b.to_native() { true } else { false }
984 /// Serialize the HTLCDestination object into a byte array which can be read by HTLCDestination_read
985 pub extern "C" fn HTLCDestination_write(obj: &crate::lightning::events::HTLCDestination) -> crate::c_types::derived::CVec_u8Z {
986 crate::c_types::serialize_obj(&unsafe { &*obj }.to_native())
989 pub(crate) extern "C" fn HTLCDestination_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
990 HTLCDestination_write(unsafe { &*(obj as *const HTLCDestination) })
993 /// Read a HTLCDestination from a byte array, created by HTLCDestination_write
994 pub extern "C" fn HTLCDestination_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_COption_HTLCDestinationZDecodeErrorZ {
995 let res: Result<Option<lightning::events::HTLCDestination>, lightning::ln::msgs::DecodeError> = crate::c_types::maybe_deserialize_obj(ser);
996 let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { let mut local_res_0 = if o.is_none() { crate::c_types::derived::COption_HTLCDestinationZ::None } else { crate::c_types::derived::COption_HTLCDestinationZ::Some( { crate::lightning::events::HTLCDestination::native_into(o.unwrap()) }) }; local_res_0 }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() };
999 /// The reason the payment failed. Used in [`Event::PaymentFailed`].
1003 pub enum PaymentFailureReason {
1004 /// The intended recipient rejected our payment.
1006 /// The user chose to abandon this payment by calling [`ChannelManager::abandon_payment`].
1008 /// [`ChannelManager::abandon_payment`]: crate::ln::channelmanager::ChannelManager::abandon_payment
1010 /// We exhausted all of our retry attempts while trying to send the payment, or we
1011 /// exhausted the [`Retry::Timeout`] if the user set one. If at any point a retry
1012 /// attempt failed while being forwarded along the path, an [`Event::PaymentPathFailed`] will
1013 /// have come before this.
1015 /// [`Retry::Timeout`]: crate::ln::channelmanager::Retry::Timeout
1017 /// The payment expired while retrying, based on the provided
1018 /// [`PaymentParameters::expiry_time`].
1020 /// [`PaymentParameters::expiry_time`]: crate::routing::router::PaymentParameters::expiry_time
1022 /// We failed to find a route while retrying the payment.
1024 /// This error should generally never happen. This likely means that there is a problem with
1028 use lightning::events::PaymentFailureReason as PaymentFailureReasonImport;
1029 pub(crate) type nativePaymentFailureReason = PaymentFailureReasonImport;
1031 impl PaymentFailureReason {
1033 pub(crate) fn to_native(&self) -> nativePaymentFailureReason {
1035 PaymentFailureReason::RecipientRejected => nativePaymentFailureReason::RecipientRejected,
1036 PaymentFailureReason::UserAbandoned => nativePaymentFailureReason::UserAbandoned,
1037 PaymentFailureReason::RetriesExhausted => nativePaymentFailureReason::RetriesExhausted,
1038 PaymentFailureReason::PaymentExpired => nativePaymentFailureReason::PaymentExpired,
1039 PaymentFailureReason::RouteNotFound => nativePaymentFailureReason::RouteNotFound,
1040 PaymentFailureReason::UnexpectedError => nativePaymentFailureReason::UnexpectedError,
1044 pub(crate) fn into_native(self) -> nativePaymentFailureReason {
1046 PaymentFailureReason::RecipientRejected => nativePaymentFailureReason::RecipientRejected,
1047 PaymentFailureReason::UserAbandoned => nativePaymentFailureReason::UserAbandoned,
1048 PaymentFailureReason::RetriesExhausted => nativePaymentFailureReason::RetriesExhausted,
1049 PaymentFailureReason::PaymentExpired => nativePaymentFailureReason::PaymentExpired,
1050 PaymentFailureReason::RouteNotFound => nativePaymentFailureReason::RouteNotFound,
1051 PaymentFailureReason::UnexpectedError => nativePaymentFailureReason::UnexpectedError,
1055 pub(crate) fn from_native(native: &nativePaymentFailureReason) -> Self {
1057 nativePaymentFailureReason::RecipientRejected => PaymentFailureReason::RecipientRejected,
1058 nativePaymentFailureReason::UserAbandoned => PaymentFailureReason::UserAbandoned,
1059 nativePaymentFailureReason::RetriesExhausted => PaymentFailureReason::RetriesExhausted,
1060 nativePaymentFailureReason::PaymentExpired => PaymentFailureReason::PaymentExpired,
1061 nativePaymentFailureReason::RouteNotFound => PaymentFailureReason::RouteNotFound,
1062 nativePaymentFailureReason::UnexpectedError => PaymentFailureReason::UnexpectedError,
1066 pub(crate) fn native_into(native: nativePaymentFailureReason) -> Self {
1068 nativePaymentFailureReason::RecipientRejected => PaymentFailureReason::RecipientRejected,
1069 nativePaymentFailureReason::UserAbandoned => PaymentFailureReason::UserAbandoned,
1070 nativePaymentFailureReason::RetriesExhausted => PaymentFailureReason::RetriesExhausted,
1071 nativePaymentFailureReason::PaymentExpired => PaymentFailureReason::PaymentExpired,
1072 nativePaymentFailureReason::RouteNotFound => PaymentFailureReason::RouteNotFound,
1073 nativePaymentFailureReason::UnexpectedError => PaymentFailureReason::UnexpectedError,
1077 /// Creates a copy of the PaymentFailureReason
1079 pub extern "C" fn PaymentFailureReason_clone(orig: &PaymentFailureReason) -> PaymentFailureReason {
1083 /// Used only if an object of this type is returned as a trait impl by a method
1084 pub(crate) extern "C" fn PaymentFailureReason_clone_void(this_ptr: *const c_void) -> *mut c_void {
1085 Box::into_raw(Box::new(unsafe { (*(this_ptr as *const PaymentFailureReason)).clone() })) as *mut c_void
1088 /// Used only if an object of this type is returned as a trait impl by a method
1089 pub(crate) extern "C" fn PaymentFailureReason_free_void(this_ptr: *mut c_void) {
1090 let _ = unsafe { Box::from_raw(this_ptr as *mut PaymentFailureReason) };
1093 /// Utility method to constructs a new RecipientRejected-variant PaymentFailureReason
1094 pub extern "C" fn PaymentFailureReason_recipient_rejected() -> PaymentFailureReason {
1095 PaymentFailureReason::RecipientRejected}
1097 /// Utility method to constructs a new UserAbandoned-variant PaymentFailureReason
1098 pub extern "C" fn PaymentFailureReason_user_abandoned() -> PaymentFailureReason {
1099 PaymentFailureReason::UserAbandoned}
1101 /// Utility method to constructs a new RetriesExhausted-variant PaymentFailureReason
1102 pub extern "C" fn PaymentFailureReason_retries_exhausted() -> PaymentFailureReason {
1103 PaymentFailureReason::RetriesExhausted}
1105 /// Utility method to constructs a new PaymentExpired-variant PaymentFailureReason
1106 pub extern "C" fn PaymentFailureReason_payment_expired() -> PaymentFailureReason {
1107 PaymentFailureReason::PaymentExpired}
1109 /// Utility method to constructs a new RouteNotFound-variant PaymentFailureReason
1110 pub extern "C" fn PaymentFailureReason_route_not_found() -> PaymentFailureReason {
1111 PaymentFailureReason::RouteNotFound}
1113 /// Utility method to constructs a new UnexpectedError-variant PaymentFailureReason
1114 pub extern "C" fn PaymentFailureReason_unexpected_error() -> PaymentFailureReason {
1115 PaymentFailureReason::UnexpectedError}
1116 /// Checks if two PaymentFailureReasons contain equal inner contents.
1117 /// This ignores pointers and is_owned flags and looks at the values in fields.
1119 pub extern "C" fn PaymentFailureReason_eq(a: &PaymentFailureReason, b: &PaymentFailureReason) -> bool {
1120 if &a.to_native() == &b.to_native() { true } else { false }
1123 /// Serialize the PaymentFailureReason object into a byte array which can be read by PaymentFailureReason_read
1124 pub extern "C" fn PaymentFailureReason_write(obj: &crate::lightning::events::PaymentFailureReason) -> crate::c_types::derived::CVec_u8Z {
1125 crate::c_types::serialize_obj(&unsafe { &*obj }.to_native())
1128 pub(crate) extern "C" fn PaymentFailureReason_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
1129 PaymentFailureReason_write(unsafe { &*(obj as *const PaymentFailureReason) })
1132 /// Read a PaymentFailureReason from a byte array, created by PaymentFailureReason_write
1133 pub extern "C" fn PaymentFailureReason_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_PaymentFailureReasonDecodeErrorZ {
1134 let res: Result<lightning::events::PaymentFailureReason, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
1135 let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::events::PaymentFailureReason::native_into(o) }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() };
1138 /// An Event which you should probably take some action in response to.
1140 /// Note that while Writeable and Readable are implemented for Event, you probably shouldn't use
1141 /// them directly as they don't round-trip exactly (for example FundingGenerationReady is never
1142 /// written as it makes no sense to respond to it after reconnecting to peers).
1147 /// Used to indicate that the client should generate a funding transaction with the given
1148 /// parameters and then call [`ChannelManager::funding_transaction_generated`].
1149 /// Generated in [`ChannelManager`] message handling.
1150 /// Note that *all inputs* in the funding transaction must spend SegWit outputs or your
1151 /// counterparty can steal your funds!
1153 /// [`ChannelManager`]: crate::ln::channelmanager::ChannelManager
1154 /// [`ChannelManager::funding_transaction_generated`]: crate::ln::channelmanager::ChannelManager::funding_transaction_generated
1155 FundingGenerationReady {
1156 /// The random channel_id we picked which you'll need to pass into
1157 /// [`ChannelManager::funding_transaction_generated`].
1159 /// [`ChannelManager::funding_transaction_generated`]: crate::ln::channelmanager::ChannelManager::funding_transaction_generated
1160 temporary_channel_id: crate::c_types::ThirtyTwoBytes,
1161 /// The counterparty's node_id, which you'll need to pass back into
1162 /// [`ChannelManager::funding_transaction_generated`].
1164 /// [`ChannelManager::funding_transaction_generated`]: crate::ln::channelmanager::ChannelManager::funding_transaction_generated
1165 counterparty_node_id: crate::c_types::PublicKey,
1166 /// The value, in satoshis, that the output should have.
1167 channel_value_satoshis: u64,
1168 /// The script which should be used in the transaction output.
1169 output_script: crate::c_types::derived::CVec_u8Z,
1170 /// The `user_channel_id` value passed in to [`ChannelManager::create_channel`] for outbound
1171 /// channels, or to [`ChannelManager::accept_inbound_channel`] for inbound channels if
1172 /// [`UserConfig::manually_accept_inbound_channels`] config flag is set to true. Otherwise
1173 /// `user_channel_id` will be randomized for an inbound channel. This may be zero for objects
1174 /// serialized with LDK versions prior to 0.0.113.
1176 /// [`ChannelManager::create_channel`]: crate::ln::channelmanager::ChannelManager::create_channel
1177 /// [`ChannelManager::accept_inbound_channel`]: crate::ln::channelmanager::ChannelManager::accept_inbound_channel
1178 /// [`UserConfig::manually_accept_inbound_channels`]: crate::util::config::UserConfig::manually_accept_inbound_channels
1179 user_channel_id: crate::c_types::U128,
1181 /// Indicates that we've been offered a payment and it needs to be claimed via calling
1182 /// [`ChannelManager::claim_funds`] with the preimage given in [`PaymentPurpose`].
1184 /// Note that if the preimage is not known, you should call
1185 /// [`ChannelManager::fail_htlc_backwards`] or [`ChannelManager::fail_htlc_backwards_with_reason`]
1186 /// to free up resources for this HTLC and avoid network congestion.
1188 /// If [`Event::PaymentClaimable::onion_fields`] is `Some`, and includes custom TLVs with even type
1189 /// numbers, you should use [`ChannelManager::fail_htlc_backwards_with_reason`] with
1190 /// [`FailureCode::InvalidOnionPayload`] if you fail to understand and handle the contents, or
1191 /// [`ChannelManager::claim_funds_with_known_custom_tlvs`] upon successful handling.
1192 /// If you don't intend to check for custom TLVs, you can simply use
1193 /// [`ChannelManager::claim_funds`], which will automatically fail back even custom TLVs.
1195 /// If you fail to call [`ChannelManager::claim_funds`],
1196 /// [`ChannelManager::claim_funds_with_known_custom_tlvs`],
1197 /// [`ChannelManager::fail_htlc_backwards`], or
1198 /// [`ChannelManager::fail_htlc_backwards_with_reason`] within the HTLC's timeout, the HTLC will
1199 /// be automatically failed.
1202 /// LDK will not stop an inbound payment from being paid multiple times, so multiple
1203 /// `PaymentClaimable` events may be generated for the same payment. In such a case it is
1204 /// polite (and required in the lightning specification) to fail the payment the second time
1205 /// and give the sender their money back rather than accepting double payment.
1208 /// This event used to be called `PaymentReceived` in LDK versions 0.0.112 and earlier.
1210 /// [`ChannelManager::claim_funds`]: crate::ln::channelmanager::ChannelManager::claim_funds
1211 /// [`ChannelManager::claim_funds_with_known_custom_tlvs`]: crate::ln::channelmanager::ChannelManager::claim_funds_with_known_custom_tlvs
1212 /// [`FailureCode::InvalidOnionPayload`]: crate::ln::channelmanager::FailureCode::InvalidOnionPayload
1213 /// [`ChannelManager::fail_htlc_backwards`]: crate::ln::channelmanager::ChannelManager::fail_htlc_backwards
1214 /// [`ChannelManager::fail_htlc_backwards_with_reason`]: crate::ln::channelmanager::ChannelManager::fail_htlc_backwards_with_reason
1216 /// The node that will receive the payment after it has been claimed.
1217 /// This is useful to identify payments received via [phantom nodes].
1218 /// This field will always be filled in when the event was generated by LDK versions
1219 /// 0.0.113 and above.
1221 /// [phantom nodes]: crate::sign::PhantomKeysManager
1223 /// Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None
1224 receiver_node_id: crate::c_types::PublicKey,
1225 /// The hash for which the preimage should be handed to the ChannelManager. Note that LDK will
1226 /// not stop you from registering duplicate payment hashes for inbound payments.
1227 payment_hash: crate::c_types::ThirtyTwoBytes,
1228 /// The fields in the onion which were received with each HTLC. Only fields which were
1229 /// identical in each HTLC involved in the payment will be included here.
1231 /// Payments received on LDK versions prior to 0.0.115 will have this field unset.
1233 /// Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None
1234 onion_fields: crate::lightning::ln::outbound_payment::RecipientOnionFields,
1235 /// The value, in thousandths of a satoshi, that this payment is claimable for. May be greater
1236 /// than the invoice amount.
1238 /// May be less than the invoice amount if [`ChannelConfig::accept_underpaying_htlcs`] is set
1239 /// and the previous hop took an extra fee.
1242 /// If [`ChannelConfig::accept_underpaying_htlcs`] is set and you claim without verifying this
1243 /// field, you may lose money!
1245 /// [`ChannelConfig::accept_underpaying_htlcs`]: crate::util::config::ChannelConfig::accept_underpaying_htlcs
1247 /// The value, in thousands of a satoshi, that was skimmed off of this payment as an extra fee
1248 /// taken by our channel counterparty.
1250 /// Will always be 0 unless [`ChannelConfig::accept_underpaying_htlcs`] is set.
1252 /// [`ChannelConfig::accept_underpaying_htlcs`]: crate::util::config::ChannelConfig::accept_underpaying_htlcs
1253 counterparty_skimmed_fee_msat: u64,
1254 /// Information for claiming this received payment, based on whether the purpose of the
1255 /// payment is to pay an invoice or to send a spontaneous payment.
1256 purpose: crate::lightning::events::PaymentPurpose,
1257 /// The `channel_id` indicating over which channel we received the payment.
1258 via_channel_id: crate::c_types::derived::COption_ThirtyTwoBytesZ,
1259 /// The `user_channel_id` indicating over which channel we received the payment.
1260 via_user_channel_id: crate::c_types::derived::COption_U128Z,
1261 /// The block height at which this payment will be failed back and will no longer be
1262 /// eligible for claiming.
1264 /// Prior to this height, a call to [`ChannelManager::claim_funds`] is guaranteed to
1265 /// succeed, however you should wait for [`Event::PaymentClaimed`] to be sure.
1267 /// [`ChannelManager::claim_funds`]: crate::ln::channelmanager::ChannelManager::claim_funds
1268 claim_deadline: crate::c_types::derived::COption_u32Z,
1270 /// Indicates a payment has been claimed and we've received money!
1272 /// This most likely occurs when [`ChannelManager::claim_funds`] has been called in response
1273 /// to an [`Event::PaymentClaimable`]. However, if we previously crashed during a
1274 /// [`ChannelManager::claim_funds`] call you may see this event without a corresponding
1275 /// [`Event::PaymentClaimable`] event.
1278 /// LDK will not stop an inbound payment from being paid multiple times, so multiple
1279 /// `PaymentClaimable` events may be generated for the same payment. If you then call
1280 /// [`ChannelManager::claim_funds`] twice for the same [`Event::PaymentClaimable`] you may get
1281 /// multiple `PaymentClaimed` events.
1283 /// [`ChannelManager::claim_funds`]: crate::ln::channelmanager::ChannelManager::claim_funds
1285 /// The node that received the payment.
1286 /// This is useful to identify payments which were received via [phantom nodes].
1287 /// This field will always be filled in when the event was generated by LDK versions
1288 /// 0.0.113 and above.
1290 /// [phantom nodes]: crate::sign::PhantomKeysManager
1292 /// Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None
1293 receiver_node_id: crate::c_types::PublicKey,
1294 /// The payment hash of the claimed payment. Note that LDK will not stop you from
1295 /// registering duplicate payment hashes for inbound payments.
1296 payment_hash: crate::c_types::ThirtyTwoBytes,
1297 /// The value, in thousandths of a satoshi, that this payment is for. May be greater than the
1300 /// The purpose of the claimed payment, i.e. whether the payment was for an invoice or a
1301 /// spontaneous payment.
1302 purpose: crate::lightning::events::PaymentPurpose,
1303 /// The HTLCs that comprise the claimed payment. This will be empty for events serialized prior
1304 /// to LDK version 0.0.117.
1305 htlcs: crate::c_types::derived::CVec_ClaimedHTLCZ,
1306 /// The sender-intended sum total of all the MPP parts. This will be `None` for events
1307 /// serialized prior to LDK version 0.0.117.
1308 sender_intended_total_msat: crate::c_types::derived::COption_u64Z,
1310 /// Indicates a request for an invoice failed to yield a response in a reasonable amount of time
1311 /// or was explicitly abandoned by [`ChannelManager::abandon_payment`]. This may be for an
1312 /// [`InvoiceRequest`] sent for an [`Offer`] or for a [`Refund`] that hasn't been redeemed.
1314 /// [`ChannelManager::abandon_payment`]: crate::ln::channelmanager::ChannelManager::abandon_payment
1315 /// [`InvoiceRequest`]: crate::offers::invoice_request::InvoiceRequest
1316 /// [`Offer`]: crate::offers::offer::Offer
1317 /// [`Refund`]: crate::offers::refund::Refund
1318 InvoiceRequestFailed {
1319 /// The `payment_id` to have been associated with payment for the requested invoice.
1320 payment_id: crate::c_types::ThirtyTwoBytes,
1322 /// Indicates an outbound payment we made succeeded (i.e. it made it all the way to its target
1323 /// and we got back the payment preimage for it).
1325 /// Note for MPP payments: in rare cases, this event may be preceded by a `PaymentPathFailed`
1326 /// event. In this situation, you SHOULD treat this payment as having succeeded.
1328 /// The `payment_id` passed to [`ChannelManager::send_payment`].
1330 /// [`ChannelManager::send_payment`]: crate::ln::channelmanager::ChannelManager::send_payment
1331 payment_id: crate::c_types::derived::COption_ThirtyTwoBytesZ,
1332 /// The preimage to the hash given to ChannelManager::send_payment.
1333 /// Note that this serves as a payment receipt, if you wish to have such a thing, you must
1334 /// store it somehow!
1335 payment_preimage: crate::c_types::ThirtyTwoBytes,
1336 /// The hash that was given to [`ChannelManager::send_payment`].
1338 /// [`ChannelManager::send_payment`]: crate::ln::channelmanager::ChannelManager::send_payment
1339 payment_hash: crate::c_types::ThirtyTwoBytes,
1340 /// The total fee which was spent at intermediate hops in this payment, across all paths.
1342 /// Note that, like [`Route::get_total_fees`] this does *not* include any potential
1343 /// overpayment to the recipient node.
1345 /// If the recipient or an intermediate node misbehaves and gives us free money, this may
1346 /// overstate the amount paid, though this is unlikely.
1348 /// [`Route::get_total_fees`]: crate::routing::router::Route::get_total_fees
1349 fee_paid_msat: crate::c_types::derived::COption_u64Z,
1351 /// Indicates an outbound payment failed. Individual [`Event::PaymentPathFailed`] events
1352 /// provide failure information for each path attempt in the payment, including retries.
1354 /// This event is provided once there are no further pending HTLCs for the payment and the
1355 /// payment is no longer retryable, due either to the [`Retry`] provided or
1356 /// [`ChannelManager::abandon_payment`] having been called for the corresponding payment.
1358 /// In exceedingly rare cases, it is possible that an [`Event::PaymentFailed`] is generated for
1359 /// a payment after an [`Event::PaymentSent`] event for this same payment has already been
1360 /// received and processed. In this case, the [`Event::PaymentFailed`] event MUST be ignored,
1361 /// and the payment MUST be treated as having succeeded.
1363 /// [`Retry`]: crate::ln::channelmanager::Retry
1364 /// [`ChannelManager::abandon_payment`]: crate::ln::channelmanager::ChannelManager::abandon_payment
1366 /// The `payment_id` passed to [`ChannelManager::send_payment`].
1368 /// [`ChannelManager::send_payment`]: crate::ln::channelmanager::ChannelManager::send_payment
1369 payment_id: crate::c_types::ThirtyTwoBytes,
1370 /// The hash that was given to [`ChannelManager::send_payment`].
1372 /// [`ChannelManager::send_payment`]: crate::ln::channelmanager::ChannelManager::send_payment
1373 payment_hash: crate::c_types::ThirtyTwoBytes,
1374 /// The reason the payment failed. This is only `None` for events generated or serialized
1375 /// by versions prior to 0.0.115.
1376 reason: crate::c_types::derived::COption_PaymentFailureReasonZ,
1378 /// Indicates that a path for an outbound payment was successful.
1380 /// Always generated after [`Event::PaymentSent`] and thus useful for scoring channels. See
1381 /// [`Event::PaymentSent`] for obtaining the payment preimage.
1382 PaymentPathSuccessful {
1383 /// The `payment_id` passed to [`ChannelManager::send_payment`].
1385 /// [`ChannelManager::send_payment`]: crate::ln::channelmanager::ChannelManager::send_payment
1386 payment_id: crate::c_types::ThirtyTwoBytes,
1387 /// The hash that was given to [`ChannelManager::send_payment`].
1389 /// This will be `Some` for all payments which completed on LDK 0.0.104 or later.
1391 /// [`ChannelManager::send_payment`]: crate::ln::channelmanager::ChannelManager::send_payment
1392 payment_hash: crate::c_types::derived::COption_ThirtyTwoBytesZ,
1393 /// The payment path that was successful.
1395 /// May contain a closed channel if the HTLC sent along the path was fulfilled on chain.
1396 path: crate::lightning::routing::router::Path,
1398 /// Indicates an outbound HTLC we sent failed, likely due to an intermediary node being unable to
1399 /// handle the HTLC.
1401 /// Note that this does *not* indicate that all paths for an MPP payment have failed, see
1402 /// [`Event::PaymentFailed`].
1404 /// See [`ChannelManager::abandon_payment`] for giving up on this payment before its retries have
1407 /// [`ChannelManager::abandon_payment`]: crate::ln::channelmanager::ChannelManager::abandon_payment
1409 /// The `payment_id` passed to [`ChannelManager::send_payment`].
1411 /// This will be `Some` for all payment paths which failed on LDK 0.0.103 or later.
1413 /// [`ChannelManager::send_payment`]: crate::ln::channelmanager::ChannelManager::send_payment
1414 /// [`ChannelManager::abandon_payment`]: crate::ln::channelmanager::ChannelManager::abandon_payment
1415 payment_id: crate::c_types::derived::COption_ThirtyTwoBytesZ,
1416 /// The hash that was given to [`ChannelManager::send_payment`].
1418 /// [`ChannelManager::send_payment`]: crate::ln::channelmanager::ChannelManager::send_payment
1419 payment_hash: crate::c_types::ThirtyTwoBytes,
1420 /// Indicates the payment was rejected for some reason by the recipient. This implies that
1421 /// the payment has failed, not just the route in question. If this is not set, the payment may
1422 /// be retried via a different route.
1423 payment_failed_permanently: bool,
1424 /// Extra error details based on the failure type. May contain an update that needs to be
1425 /// applied to the [`NetworkGraph`].
1427 /// [`NetworkGraph`]: crate::routing::gossip::NetworkGraph
1428 failure: crate::lightning::events::PathFailure,
1429 /// The payment path that failed.
1430 path: crate::lightning::routing::router::Path,
1431 /// The channel responsible for the failed payment path.
1433 /// Note that for route hints or for the first hop in a path this may be an SCID alias and
1434 /// may not refer to a channel in the public network graph. These aliases may also collide
1435 /// with channels in the public network graph.
1437 /// If this is `Some`, then the corresponding channel should be avoided when the payment is
1438 /// retried. May be `None` for older [`Event`] serializations.
1439 short_channel_id: crate::c_types::derived::COption_u64Z,
1441 /// Indicates that a probe payment we sent returned successful, i.e., only failed at the destination.
1443 /// The id returned by [`ChannelManager::send_probe`].
1445 /// [`ChannelManager::send_probe`]: crate::ln::channelmanager::ChannelManager::send_probe
1446 payment_id: crate::c_types::ThirtyTwoBytes,
1447 /// The hash generated by [`ChannelManager::send_probe`].
1449 /// [`ChannelManager::send_probe`]: crate::ln::channelmanager::ChannelManager::send_probe
1450 payment_hash: crate::c_types::ThirtyTwoBytes,
1451 /// The payment path that was successful.
1452 path: crate::lightning::routing::router::Path,
1454 /// Indicates that a probe payment we sent failed at an intermediary node on the path.
1456 /// The id returned by [`ChannelManager::send_probe`].
1458 /// [`ChannelManager::send_probe`]: crate::ln::channelmanager::ChannelManager::send_probe
1459 payment_id: crate::c_types::ThirtyTwoBytes,
1460 /// The hash generated by [`ChannelManager::send_probe`].
1462 /// [`ChannelManager::send_probe`]: crate::ln::channelmanager::ChannelManager::send_probe
1463 payment_hash: crate::c_types::ThirtyTwoBytes,
1464 /// The payment path that failed.
1465 path: crate::lightning::routing::router::Path,
1466 /// The channel responsible for the failed probe.
1468 /// Note that for route hints or for the first hop in a path this may be an SCID alias and
1469 /// may not refer to a channel in the public network graph. These aliases may also collide
1470 /// with channels in the public network graph.
1471 short_channel_id: crate::c_types::derived::COption_u64Z,
1473 /// Used to indicate that [`ChannelManager::process_pending_htlc_forwards`] should be called at
1474 /// a time in the future.
1476 /// [`ChannelManager::process_pending_htlc_forwards`]: crate::ln::channelmanager::ChannelManager::process_pending_htlc_forwards
1477 PendingHTLCsForwardable {
1478 /// The minimum amount of time that should be waited prior to calling
1479 /// process_pending_htlc_forwards. To increase the effort required to correlate payments,
1480 /// you should wait a random amount of time in roughly the range (now + time_forwardable,
1481 /// now + 5*time_forwardable).
1482 time_forwardable: u64,
1484 /// Used to indicate that we've intercepted an HTLC forward. This event will only be generated if
1485 /// you've encoded an intercept scid in the receiver's invoice route hints using
1486 /// [`ChannelManager::get_intercept_scid`] and have set [`UserConfig::accept_intercept_htlcs`].
1488 /// [`ChannelManager::forward_intercepted_htlc`] or
1489 /// [`ChannelManager::fail_intercepted_htlc`] MUST be called in response to this event. See
1490 /// their docs for more information.
1492 /// [`ChannelManager::get_intercept_scid`]: crate::ln::channelmanager::ChannelManager::get_intercept_scid
1493 /// [`UserConfig::accept_intercept_htlcs`]: crate::util::config::UserConfig::accept_intercept_htlcs
1494 /// [`ChannelManager::forward_intercepted_htlc`]: crate::ln::channelmanager::ChannelManager::forward_intercepted_htlc
1495 /// [`ChannelManager::fail_intercepted_htlc`]: crate::ln::channelmanager::ChannelManager::fail_intercepted_htlc
1497 /// An id to help LDK identify which HTLC is being forwarded or failed.
1498 intercept_id: crate::c_types::ThirtyTwoBytes,
1499 /// The fake scid that was programmed as the next hop's scid, generated using
1500 /// [`ChannelManager::get_intercept_scid`].
1502 /// [`ChannelManager::get_intercept_scid`]: crate::ln::channelmanager::ChannelManager::get_intercept_scid
1503 requested_next_hop_scid: u64,
1504 /// The payment hash used for this HTLC.
1505 payment_hash: crate::c_types::ThirtyTwoBytes,
1506 /// How many msats were received on the inbound edge of this HTLC.
1507 inbound_amount_msat: u64,
1508 /// How many msats the payer intended to route to the next node. Depending on the reason you are
1509 /// intercepting this payment, you might take a fee by forwarding less than this amount.
1510 /// Forwarding less than this amount may break compatibility with LDK versions prior to 0.0.116.
1512 /// Note that LDK will NOT check that expected fees were factored into this value. You MUST
1513 /// check that whatever fee you want has been included here or subtract it as required. Further,
1514 /// LDK will not stop you from forwarding more than you received.
1515 expected_outbound_amount_msat: u64,
1517 /// Used to indicate that an output which you should know how to spend was confirmed on chain
1518 /// and is now spendable.
1519 /// Such an output will *not* ever be spent by rust-lightning, and are not at risk of your
1520 /// counterparty spending them due to some kind of timeout. Thus, you need to store them
1521 /// somewhere and spend them when you create on-chain transactions.
1523 /// The outputs which you should store as spendable by you.
1524 outputs: crate::c_types::derived::CVec_SpendableOutputDescriptorZ,
1525 /// The `channel_id` indicating which channel the spendable outputs belong to.
1527 /// This will always be `Some` for events generated by LDK versions 0.0.117 and above.
1528 channel_id: crate::c_types::derived::COption_ThirtyTwoBytesZ,
1530 /// This event is generated when a payment has been successfully forwarded through us and a
1531 /// forwarding fee earned.
1533 /// The incoming channel between the previous node and us. This is only `None` for events
1534 /// generated or serialized by versions prior to 0.0.107.
1535 prev_channel_id: crate::c_types::derived::COption_ThirtyTwoBytesZ,
1536 /// The outgoing channel between the next node and us. This is only `None` for events
1537 /// generated or serialized by versions prior to 0.0.107.
1538 next_channel_id: crate::c_types::derived::COption_ThirtyTwoBytesZ,
1539 /// The fee, in milli-satoshis, which was earned as a result of the payment.
1541 /// Note that if we force-closed the channel over which we forwarded an HTLC while the HTLC
1542 /// was pending, the amount the next hop claimed will have been rounded down to the nearest
1543 /// whole satoshi. Thus, the fee calculated here may be higher than expected as we still
1544 /// claimed the full value in millisatoshis from the source. In this case,
1545 /// `claim_from_onchain_tx` will be set.
1547 /// If the channel which sent us the payment has been force-closed, we will claim the funds
1548 /// via an on-chain transaction. In that case we do not yet know the on-chain transaction
1549 /// fees which we will spend and will instead set this to `None`. It is possible duplicate
1550 /// `PaymentForwarded` events are generated for the same payment iff `fee_earned_msat` is
1552 fee_earned_msat: crate::c_types::derived::COption_u64Z,
1553 /// If this is `true`, the forwarded HTLC was claimed by our counterparty via an on-chain
1555 claim_from_onchain_tx: bool,
1556 /// The final amount forwarded, in milli-satoshis, after the fee is deducted.
1558 /// The caveat described above the `fee_earned_msat` field applies here as well.
1559 outbound_amount_forwarded_msat: crate::c_types::derived::COption_u64Z,
1561 /// Used to indicate that a channel with the given `channel_id` is being opened and pending
1562 /// confirmation on-chain.
1564 /// This event is emitted when the funding transaction has been signed and is broadcast to the
1565 /// network. For 0conf channels it will be immediately followed by the corresponding
1566 /// [`Event::ChannelReady`] event.
1568 /// The `channel_id` of the channel that is pending confirmation.
1569 channel_id: crate::c_types::ThirtyTwoBytes,
1570 /// The `user_channel_id` value passed in to [`ChannelManager::create_channel`] for outbound
1571 /// channels, or to [`ChannelManager::accept_inbound_channel`] for inbound channels if
1572 /// [`UserConfig::manually_accept_inbound_channels`] config flag is set to true. Otherwise
1573 /// `user_channel_id` will be randomized for an inbound channel.
1575 /// [`ChannelManager::create_channel`]: crate::ln::channelmanager::ChannelManager::create_channel
1576 /// [`ChannelManager::accept_inbound_channel`]: crate::ln::channelmanager::ChannelManager::accept_inbound_channel
1577 /// [`UserConfig::manually_accept_inbound_channels`]: crate::util::config::UserConfig::manually_accept_inbound_channels
1578 user_channel_id: crate::c_types::U128,
1579 /// The `temporary_channel_id` this channel used to be known by during channel establishment.
1581 /// Will be `None` for channels created prior to LDK version 0.0.115.
1582 former_temporary_channel_id: crate::c_types::derived::COption_ThirtyTwoBytesZ,
1583 /// The `node_id` of the channel counterparty.
1584 counterparty_node_id: crate::c_types::PublicKey,
1585 /// The outpoint of the channel's funding transaction.
1586 funding_txo: crate::lightning::chain::transaction::OutPoint,
1588 /// Used to indicate that a channel with the given `channel_id` is ready to
1589 /// be used. This event is emitted either when the funding transaction has been confirmed
1590 /// on-chain, or, in case of a 0conf channel, when both parties have confirmed the channel
1593 /// The `channel_id` of the channel that is ready.
1594 channel_id: crate::c_types::ThirtyTwoBytes,
1595 /// The `user_channel_id` value passed in to [`ChannelManager::create_channel`] for outbound
1596 /// channels, or to [`ChannelManager::accept_inbound_channel`] for inbound channels if
1597 /// [`UserConfig::manually_accept_inbound_channels`] config flag is set to true. Otherwise
1598 /// `user_channel_id` will be randomized for an inbound channel.
1600 /// [`ChannelManager::create_channel`]: crate::ln::channelmanager::ChannelManager::create_channel
1601 /// [`ChannelManager::accept_inbound_channel`]: crate::ln::channelmanager::ChannelManager::accept_inbound_channel
1602 /// [`UserConfig::manually_accept_inbound_channels`]: crate::util::config::UserConfig::manually_accept_inbound_channels
1603 user_channel_id: crate::c_types::U128,
1604 /// The `node_id` of the channel counterparty.
1605 counterparty_node_id: crate::c_types::PublicKey,
1606 /// The features that this channel will operate with.
1607 channel_type: crate::lightning::ln::features::ChannelTypeFeatures,
1609 /// Used to indicate that a previously opened channel with the given `channel_id` is in the
1610 /// process of closure.
1612 /// Note that this event is only triggered for accepted channels: if the
1613 /// [`UserConfig::manually_accept_inbound_channels`] config flag is set to true and the channel is
1614 /// rejected, no `ChannelClosed` event will be sent.
1616 /// [`ChannelManager::accept_inbound_channel`]: crate::ln::channelmanager::ChannelManager::accept_inbound_channel
1617 /// [`UserConfig::manually_accept_inbound_channels`]: crate::util::config::UserConfig::manually_accept_inbound_channels
1619 /// The `channel_id` of the channel which has been closed. Note that on-chain transactions
1620 /// resolving the channel are likely still awaiting confirmation.
1621 channel_id: crate::c_types::ThirtyTwoBytes,
1622 /// The `user_channel_id` value passed in to [`ChannelManager::create_channel`] for outbound
1623 /// channels, or to [`ChannelManager::accept_inbound_channel`] for inbound channels if
1624 /// [`UserConfig::manually_accept_inbound_channels`] config flag is set to true. Otherwise
1625 /// `user_channel_id` will be randomized for inbound channels.
1626 /// This may be zero for inbound channels serialized prior to 0.0.113 and will always be
1627 /// zero for objects serialized with LDK versions prior to 0.0.102.
1629 /// [`ChannelManager::create_channel`]: crate::ln::channelmanager::ChannelManager::create_channel
1630 /// [`ChannelManager::accept_inbound_channel`]: crate::ln::channelmanager::ChannelManager::accept_inbound_channel
1631 /// [`UserConfig::manually_accept_inbound_channels`]: crate::util::config::UserConfig::manually_accept_inbound_channels
1632 user_channel_id: crate::c_types::U128,
1633 /// The reason the channel was closed.
1634 reason: crate::lightning::events::ClosureReason,
1635 /// Counterparty in the closed channel.
1637 /// This field will be `None` for objects serialized prior to LDK 0.0.117.
1639 /// Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None
1640 counterparty_node_id: crate::c_types::PublicKey,
1641 /// Channel capacity of the closing channel (sats).
1643 /// This field will be `None` for objects serialized prior to LDK 0.0.117.
1644 channel_capacity_sats: crate::c_types::derived::COption_u64Z,
1646 /// Used to indicate to the user that they can abandon the funding transaction and recycle the
1647 /// inputs for another purpose.
1649 /// This event is not guaranteed to be generated for channels that are closed due to a restart.
1651 /// The channel_id of the channel which has been closed.
1652 channel_id: crate::c_types::ThirtyTwoBytes,
1653 /// The full transaction received from the user
1654 transaction: crate::c_types::Transaction,
1656 /// Indicates a request to open a new channel by a peer.
1658 /// To accept the request, call [`ChannelManager::accept_inbound_channel`]. To reject the request,
1659 /// call [`ChannelManager::force_close_without_broadcasting_txn`]. Note that a ['ChannelClosed`]
1660 /// event will _not_ be triggered if the channel is rejected.
1662 /// The event is only triggered when a new open channel request is received and the
1663 /// [`UserConfig::manually_accept_inbound_channels`] config flag is set to true.
1665 /// [`ChannelManager::accept_inbound_channel`]: crate::ln::channelmanager::ChannelManager::accept_inbound_channel
1666 /// [`ChannelManager::force_close_without_broadcasting_txn`]: crate::ln::channelmanager::ChannelManager::force_close_without_broadcasting_txn
1667 /// [`UserConfig::manually_accept_inbound_channels`]: crate::util::config::UserConfig::manually_accept_inbound_channels
1668 OpenChannelRequest {
1669 /// The temporary channel ID of the channel requested to be opened.
1671 /// When responding to the request, the `temporary_channel_id` should be passed
1672 /// back to the ChannelManager through [`ChannelManager::accept_inbound_channel`] to accept,
1673 /// or through [`ChannelManager::force_close_without_broadcasting_txn`] to reject.
1675 /// [`ChannelManager::accept_inbound_channel`]: crate::ln::channelmanager::ChannelManager::accept_inbound_channel
1676 /// [`ChannelManager::force_close_without_broadcasting_txn`]: crate::ln::channelmanager::ChannelManager::force_close_without_broadcasting_txn
1677 temporary_channel_id: crate::c_types::ThirtyTwoBytes,
1678 /// The node_id of the counterparty requesting to open the channel.
1680 /// When responding to the request, the `counterparty_node_id` should be passed
1681 /// back to the `ChannelManager` through [`ChannelManager::accept_inbound_channel`] to
1682 /// accept the request, or through [`ChannelManager::force_close_without_broadcasting_txn`] to reject the
1685 /// [`ChannelManager::accept_inbound_channel`]: crate::ln::channelmanager::ChannelManager::accept_inbound_channel
1686 /// [`ChannelManager::force_close_without_broadcasting_txn`]: crate::ln::channelmanager::ChannelManager::force_close_without_broadcasting_txn
1687 counterparty_node_id: crate::c_types::PublicKey,
1688 /// The channel value of the requested channel.
1689 funding_satoshis: u64,
1690 /// Our starting balance in the channel if the request is accepted, in milli-satoshi.
1692 /// The features that this channel will operate with. If you reject the channel, a
1693 /// well-behaved counterparty may automatically re-attempt the channel with a new set of
1696 /// Note that if [`ChannelTypeFeatures::supports_scid_privacy`] returns true on this type,
1697 /// the resulting [`ChannelManager`] will not be readable by versions of LDK prior to
1700 /// Furthermore, note that if [`ChannelTypeFeatures::supports_zero_conf`] returns true on this type,
1701 /// the resulting [`ChannelManager`] will not be readable by versions of LDK prior to
1702 /// 0.0.107. Channels setting this type also need to get manually accepted via
1703 /// [`crate::ln::channelmanager::ChannelManager::accept_inbound_channel_from_trusted_peer_0conf`],
1704 /// or will be rejected otherwise.
1706 /// [`ChannelManager`]: crate::ln::channelmanager::ChannelManager
1707 channel_type: crate::lightning::ln::features::ChannelTypeFeatures,
1709 /// Indicates that the HTLC was accepted, but could not be processed when or after attempting to
1712 /// Some scenarios where this event may be sent include:
1713 /// * Insufficient capacity in the outbound channel
1714 /// * While waiting to forward the HTLC, the channel it is meant to be forwarded through closes
1715 /// * When an unknown SCID is requested for forwarding a payment.
1716 /// * Expected MPP amount has already been reached
1717 /// * The HTLC has timed out
1719 /// This event, however, does not get generated if an HTLC fails to meet the forwarding
1720 /// requirements (i.e. insufficient fees paid, or a CLTV that is too soon).
1721 HTLCHandlingFailed {
1722 /// The channel over which the HTLC was received.
1723 prev_channel_id: crate::c_types::ThirtyTwoBytes,
1724 /// Destination of the HTLC that failed to be processed.
1725 failed_next_destination: crate::lightning::events::HTLCDestination,
1727 /// Indicates that a transaction originating from LDK needs to have its fee bumped. This event
1728 /// requires confirmed external funds to be readily available to spend.
1730 /// LDK does not currently generate this event unless the
1731 /// [`ChannelHandshakeConfig::negotiate_anchors_zero_fee_htlc_tx`] config flag is set to true.
1732 /// It is limited to the scope of channels with anchor outputs.
1734 /// [`ChannelHandshakeConfig::negotiate_anchors_zero_fee_htlc_tx`]: crate::util::config::ChannelHandshakeConfig::negotiate_anchors_zero_fee_htlc_tx
1736 crate::lightning::events::bump_transaction::BumpTransactionEvent),
1738 use lightning::events::Event as EventImport;
1739 pub(crate) type nativeEvent = EventImport;
1743 pub(crate) fn to_native(&self) -> nativeEvent {
1745 Event::FundingGenerationReady {ref temporary_channel_id, ref counterparty_node_id, ref channel_value_satoshis, ref output_script, ref user_channel_id, } => {
1746 let mut temporary_channel_id_nonref = Clone::clone(temporary_channel_id);
1747 let mut counterparty_node_id_nonref = Clone::clone(counterparty_node_id);
1748 let mut channel_value_satoshis_nonref = Clone::clone(channel_value_satoshis);
1749 let mut output_script_nonref = Clone::clone(output_script);
1750 let mut user_channel_id_nonref = Clone::clone(user_channel_id);
1751 nativeEvent::FundingGenerationReady {
1752 temporary_channel_id: ::lightning::ln::ChannelId(temporary_channel_id_nonref.data),
1753 counterparty_node_id: counterparty_node_id_nonref.into_rust(),
1754 channel_value_satoshis: channel_value_satoshis_nonref,
1755 output_script: ::bitcoin::blockdata::script::Script::from(output_script_nonref.into_rust()),
1756 user_channel_id: user_channel_id_nonref.into(),
1759 Event::PaymentClaimable {ref receiver_node_id, ref payment_hash, ref onion_fields, ref amount_msat, ref counterparty_skimmed_fee_msat, ref purpose, ref via_channel_id, ref via_user_channel_id, ref claim_deadline, } => {
1760 let mut receiver_node_id_nonref = Clone::clone(receiver_node_id);
1761 let mut local_receiver_node_id_nonref = if receiver_node_id_nonref.is_null() { None } else { Some( { receiver_node_id_nonref.into_rust() }) };
1762 let mut payment_hash_nonref = Clone::clone(payment_hash);
1763 let mut onion_fields_nonref = Clone::clone(onion_fields);
1764 let mut local_onion_fields_nonref = if onion_fields_nonref.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(onion_fields_nonref.take_inner()) } }) };
1765 let mut amount_msat_nonref = Clone::clone(amount_msat);
1766 let mut counterparty_skimmed_fee_msat_nonref = Clone::clone(counterparty_skimmed_fee_msat);
1767 let mut purpose_nonref = Clone::clone(purpose);
1768 let mut via_channel_id_nonref = Clone::clone(via_channel_id);
1769 let mut local_via_channel_id_nonref = { /*via_channel_id_nonref*/ let via_channel_id_nonref_opt = via_channel_id_nonref; if via_channel_id_nonref_opt.is_none() { None } else { Some({ { ::lightning::ln::ChannelId({ via_channel_id_nonref_opt.take() }.data) }})} };
1770 let mut via_user_channel_id_nonref = Clone::clone(via_user_channel_id);
1771 let mut local_via_user_channel_id_nonref = { /*via_user_channel_id_nonref*/ let via_user_channel_id_nonref_opt = via_user_channel_id_nonref; if via_user_channel_id_nonref_opt.is_none() { None } else { Some({ { { via_user_channel_id_nonref_opt.take() }.into() }})} };
1772 let mut claim_deadline_nonref = Clone::clone(claim_deadline);
1773 let mut local_claim_deadline_nonref = if claim_deadline_nonref.is_some() { Some( { claim_deadline_nonref.take() }) } else { None };
1774 nativeEvent::PaymentClaimable {
1775 receiver_node_id: local_receiver_node_id_nonref,
1776 payment_hash: ::lightning::ln::PaymentHash(payment_hash_nonref.data),
1777 onion_fields: local_onion_fields_nonref,
1778 amount_msat: amount_msat_nonref,
1779 counterparty_skimmed_fee_msat: counterparty_skimmed_fee_msat_nonref,
1780 purpose: purpose_nonref.into_native(),
1781 via_channel_id: local_via_channel_id_nonref,
1782 via_user_channel_id: local_via_user_channel_id_nonref,
1783 claim_deadline: local_claim_deadline_nonref,
1786 Event::PaymentClaimed {ref receiver_node_id, ref payment_hash, ref amount_msat, ref purpose, ref htlcs, ref sender_intended_total_msat, } => {
1787 let mut receiver_node_id_nonref = Clone::clone(receiver_node_id);
1788 let mut local_receiver_node_id_nonref = if receiver_node_id_nonref.is_null() { None } else { Some( { receiver_node_id_nonref.into_rust() }) };
1789 let mut payment_hash_nonref = Clone::clone(payment_hash);
1790 let mut amount_msat_nonref = Clone::clone(amount_msat);
1791 let mut purpose_nonref = Clone::clone(purpose);
1792 let mut htlcs_nonref = Clone::clone(htlcs);
1793 let mut local_htlcs_nonref = Vec::new(); for mut item in htlcs_nonref.into_rust().drain(..) { local_htlcs_nonref.push( { *unsafe { Box::from_raw(item.take_inner()) } }); };
1794 let mut sender_intended_total_msat_nonref = Clone::clone(sender_intended_total_msat);
1795 let mut local_sender_intended_total_msat_nonref = if sender_intended_total_msat_nonref.is_some() { Some( { sender_intended_total_msat_nonref.take() }) } else { None };
1796 nativeEvent::PaymentClaimed {
1797 receiver_node_id: local_receiver_node_id_nonref,
1798 payment_hash: ::lightning::ln::PaymentHash(payment_hash_nonref.data),
1799 amount_msat: amount_msat_nonref,
1800 purpose: purpose_nonref.into_native(),
1801 htlcs: local_htlcs_nonref,
1802 sender_intended_total_msat: local_sender_intended_total_msat_nonref,
1805 Event::InvoiceRequestFailed {ref payment_id, } => {
1806 let mut payment_id_nonref = Clone::clone(payment_id);
1807 nativeEvent::InvoiceRequestFailed {
1808 payment_id: ::lightning::ln::channelmanager::PaymentId(payment_id_nonref.data),
1811 Event::PaymentSent {ref payment_id, ref payment_preimage, ref payment_hash, ref fee_paid_msat, } => {
1812 let mut payment_id_nonref = Clone::clone(payment_id);
1813 let mut local_payment_id_nonref = { /*payment_id_nonref*/ let payment_id_nonref_opt = payment_id_nonref; if payment_id_nonref_opt.is_none() { None } else { Some({ { ::lightning::ln::channelmanager::PaymentId({ payment_id_nonref_opt.take() }.data) }})} };
1814 let mut payment_preimage_nonref = Clone::clone(payment_preimage);
1815 let mut payment_hash_nonref = Clone::clone(payment_hash);
1816 let mut fee_paid_msat_nonref = Clone::clone(fee_paid_msat);
1817 let mut local_fee_paid_msat_nonref = if fee_paid_msat_nonref.is_some() { Some( { fee_paid_msat_nonref.take() }) } else { None };
1818 nativeEvent::PaymentSent {
1819 payment_id: local_payment_id_nonref,
1820 payment_preimage: ::lightning::ln::PaymentPreimage(payment_preimage_nonref.data),
1821 payment_hash: ::lightning::ln::PaymentHash(payment_hash_nonref.data),
1822 fee_paid_msat: local_fee_paid_msat_nonref,
1825 Event::PaymentFailed {ref payment_id, ref payment_hash, ref reason, } => {
1826 let mut payment_id_nonref = Clone::clone(payment_id);
1827 let mut payment_hash_nonref = Clone::clone(payment_hash);
1828 let mut reason_nonref = Clone::clone(reason);
1829 let mut local_reason_nonref = { /*reason_nonref*/ let reason_nonref_opt = reason_nonref; if reason_nonref_opt.is_none() { None } else { Some({ { { reason_nonref_opt.take() }.into_native() }})} };
1830 nativeEvent::PaymentFailed {
1831 payment_id: ::lightning::ln::channelmanager::PaymentId(payment_id_nonref.data),
1832 payment_hash: ::lightning::ln::PaymentHash(payment_hash_nonref.data),
1833 reason: local_reason_nonref,
1836 Event::PaymentPathSuccessful {ref payment_id, ref payment_hash, ref path, } => {
1837 let mut payment_id_nonref = Clone::clone(payment_id);
1838 let mut payment_hash_nonref = Clone::clone(payment_hash);
1839 let mut local_payment_hash_nonref = { /*payment_hash_nonref*/ let payment_hash_nonref_opt = payment_hash_nonref; if payment_hash_nonref_opt.is_none() { None } else { Some({ { ::lightning::ln::PaymentHash({ payment_hash_nonref_opt.take() }.data) }})} };
1840 let mut path_nonref = Clone::clone(path);
1841 nativeEvent::PaymentPathSuccessful {
1842 payment_id: ::lightning::ln::channelmanager::PaymentId(payment_id_nonref.data),
1843 payment_hash: local_payment_hash_nonref,
1844 path: *unsafe { Box::from_raw(path_nonref.take_inner()) },
1847 Event::PaymentPathFailed {ref payment_id, ref payment_hash, ref payment_failed_permanently, ref failure, ref path, ref short_channel_id, } => {
1848 let mut payment_id_nonref = Clone::clone(payment_id);
1849 let mut local_payment_id_nonref = { /*payment_id_nonref*/ let payment_id_nonref_opt = payment_id_nonref; if payment_id_nonref_opt.is_none() { None } else { Some({ { ::lightning::ln::channelmanager::PaymentId({ payment_id_nonref_opt.take() }.data) }})} };
1850 let mut payment_hash_nonref = Clone::clone(payment_hash);
1851 let mut payment_failed_permanently_nonref = Clone::clone(payment_failed_permanently);
1852 let mut failure_nonref = Clone::clone(failure);
1853 let mut path_nonref = Clone::clone(path);
1854 let mut short_channel_id_nonref = Clone::clone(short_channel_id);
1855 let mut local_short_channel_id_nonref = if short_channel_id_nonref.is_some() { Some( { short_channel_id_nonref.take() }) } else { None };
1856 nativeEvent::PaymentPathFailed {
1857 payment_id: local_payment_id_nonref,
1858 payment_hash: ::lightning::ln::PaymentHash(payment_hash_nonref.data),
1859 payment_failed_permanently: payment_failed_permanently_nonref,
1860 failure: failure_nonref.into_native(),
1861 path: *unsafe { Box::from_raw(path_nonref.take_inner()) },
1862 short_channel_id: local_short_channel_id_nonref,
1865 Event::ProbeSuccessful {ref payment_id, ref payment_hash, ref path, } => {
1866 let mut payment_id_nonref = Clone::clone(payment_id);
1867 let mut payment_hash_nonref = Clone::clone(payment_hash);
1868 let mut path_nonref = Clone::clone(path);
1869 nativeEvent::ProbeSuccessful {
1870 payment_id: ::lightning::ln::channelmanager::PaymentId(payment_id_nonref.data),
1871 payment_hash: ::lightning::ln::PaymentHash(payment_hash_nonref.data),
1872 path: *unsafe { Box::from_raw(path_nonref.take_inner()) },
1875 Event::ProbeFailed {ref payment_id, ref payment_hash, ref path, ref short_channel_id, } => {
1876 let mut payment_id_nonref = Clone::clone(payment_id);
1877 let mut payment_hash_nonref = Clone::clone(payment_hash);
1878 let mut path_nonref = Clone::clone(path);
1879 let mut short_channel_id_nonref = Clone::clone(short_channel_id);
1880 let mut local_short_channel_id_nonref = if short_channel_id_nonref.is_some() { Some( { short_channel_id_nonref.take() }) } else { None };
1881 nativeEvent::ProbeFailed {
1882 payment_id: ::lightning::ln::channelmanager::PaymentId(payment_id_nonref.data),
1883 payment_hash: ::lightning::ln::PaymentHash(payment_hash_nonref.data),
1884 path: *unsafe { Box::from_raw(path_nonref.take_inner()) },
1885 short_channel_id: local_short_channel_id_nonref,
1888 Event::PendingHTLCsForwardable {ref time_forwardable, } => {
1889 let mut time_forwardable_nonref = Clone::clone(time_forwardable);
1890 nativeEvent::PendingHTLCsForwardable {
1891 time_forwardable: core::time::Duration::from_secs(time_forwardable_nonref),
1894 Event::HTLCIntercepted {ref intercept_id, ref requested_next_hop_scid, ref payment_hash, ref inbound_amount_msat, ref expected_outbound_amount_msat, } => {
1895 let mut intercept_id_nonref = Clone::clone(intercept_id);
1896 let mut requested_next_hop_scid_nonref = Clone::clone(requested_next_hop_scid);
1897 let mut payment_hash_nonref = Clone::clone(payment_hash);
1898 let mut inbound_amount_msat_nonref = Clone::clone(inbound_amount_msat);
1899 let mut expected_outbound_amount_msat_nonref = Clone::clone(expected_outbound_amount_msat);
1900 nativeEvent::HTLCIntercepted {
1901 intercept_id: ::lightning::ln::channelmanager::InterceptId(intercept_id_nonref.data),
1902 requested_next_hop_scid: requested_next_hop_scid_nonref,
1903 payment_hash: ::lightning::ln::PaymentHash(payment_hash_nonref.data),
1904 inbound_amount_msat: inbound_amount_msat_nonref,
1905 expected_outbound_amount_msat: expected_outbound_amount_msat_nonref,
1908 Event::SpendableOutputs {ref outputs, ref channel_id, } => {
1909 let mut outputs_nonref = Clone::clone(outputs);
1910 let mut local_outputs_nonref = Vec::new(); for mut item in outputs_nonref.into_rust().drain(..) { local_outputs_nonref.push( { item.into_native() }); };
1911 let mut channel_id_nonref = Clone::clone(channel_id);
1912 let mut local_channel_id_nonref = { /*channel_id_nonref*/ let channel_id_nonref_opt = channel_id_nonref; if channel_id_nonref_opt.is_none() { None } else { Some({ { ::lightning::ln::ChannelId({ channel_id_nonref_opt.take() }.data) }})} };
1913 nativeEvent::SpendableOutputs {
1914 outputs: local_outputs_nonref,
1915 channel_id: local_channel_id_nonref,
1918 Event::PaymentForwarded {ref prev_channel_id, ref next_channel_id, ref fee_earned_msat, ref claim_from_onchain_tx, ref outbound_amount_forwarded_msat, } => {
1919 let mut prev_channel_id_nonref = Clone::clone(prev_channel_id);
1920 let mut local_prev_channel_id_nonref = { /*prev_channel_id_nonref*/ let prev_channel_id_nonref_opt = prev_channel_id_nonref; if prev_channel_id_nonref_opt.is_none() { None } else { Some({ { ::lightning::ln::ChannelId({ prev_channel_id_nonref_opt.take() }.data) }})} };
1921 let mut next_channel_id_nonref = Clone::clone(next_channel_id);
1922 let mut local_next_channel_id_nonref = { /*next_channel_id_nonref*/ let next_channel_id_nonref_opt = next_channel_id_nonref; if next_channel_id_nonref_opt.is_none() { None } else { Some({ { ::lightning::ln::ChannelId({ next_channel_id_nonref_opt.take() }.data) }})} };
1923 let mut fee_earned_msat_nonref = Clone::clone(fee_earned_msat);
1924 let mut local_fee_earned_msat_nonref = if fee_earned_msat_nonref.is_some() { Some( { fee_earned_msat_nonref.take() }) } else { None };
1925 let mut claim_from_onchain_tx_nonref = Clone::clone(claim_from_onchain_tx);
1926 let mut outbound_amount_forwarded_msat_nonref = Clone::clone(outbound_amount_forwarded_msat);
1927 let mut local_outbound_amount_forwarded_msat_nonref = if outbound_amount_forwarded_msat_nonref.is_some() { Some( { outbound_amount_forwarded_msat_nonref.take() }) } else { None };
1928 nativeEvent::PaymentForwarded {
1929 prev_channel_id: local_prev_channel_id_nonref,
1930 next_channel_id: local_next_channel_id_nonref,
1931 fee_earned_msat: local_fee_earned_msat_nonref,
1932 claim_from_onchain_tx: claim_from_onchain_tx_nonref,
1933 outbound_amount_forwarded_msat: local_outbound_amount_forwarded_msat_nonref,
1936 Event::ChannelPending {ref channel_id, ref user_channel_id, ref former_temporary_channel_id, ref counterparty_node_id, ref funding_txo, } => {
1937 let mut channel_id_nonref = Clone::clone(channel_id);
1938 let mut user_channel_id_nonref = Clone::clone(user_channel_id);
1939 let mut former_temporary_channel_id_nonref = Clone::clone(former_temporary_channel_id);
1940 let mut local_former_temporary_channel_id_nonref = { /*former_temporary_channel_id_nonref*/ let former_temporary_channel_id_nonref_opt = former_temporary_channel_id_nonref; if former_temporary_channel_id_nonref_opt.is_none() { None } else { Some({ { ::lightning::ln::ChannelId({ former_temporary_channel_id_nonref_opt.take() }.data) }})} };
1941 let mut counterparty_node_id_nonref = Clone::clone(counterparty_node_id);
1942 let mut funding_txo_nonref = Clone::clone(funding_txo);
1943 nativeEvent::ChannelPending {
1944 channel_id: ::lightning::ln::ChannelId(channel_id_nonref.data),
1945 user_channel_id: user_channel_id_nonref.into(),
1946 former_temporary_channel_id: local_former_temporary_channel_id_nonref,
1947 counterparty_node_id: counterparty_node_id_nonref.into_rust(),
1948 funding_txo: crate::c_types::C_to_bitcoin_outpoint(funding_txo_nonref),
1951 Event::ChannelReady {ref channel_id, ref user_channel_id, ref counterparty_node_id, ref channel_type, } => {
1952 let mut channel_id_nonref = Clone::clone(channel_id);
1953 let mut user_channel_id_nonref = Clone::clone(user_channel_id);
1954 let mut counterparty_node_id_nonref = Clone::clone(counterparty_node_id);
1955 let mut channel_type_nonref = Clone::clone(channel_type);
1956 nativeEvent::ChannelReady {
1957 channel_id: ::lightning::ln::ChannelId(channel_id_nonref.data),
1958 user_channel_id: user_channel_id_nonref.into(),
1959 counterparty_node_id: counterparty_node_id_nonref.into_rust(),
1960 channel_type: *unsafe { Box::from_raw(channel_type_nonref.take_inner()) },
1963 Event::ChannelClosed {ref channel_id, ref user_channel_id, ref reason, ref counterparty_node_id, ref channel_capacity_sats, } => {
1964 let mut channel_id_nonref = Clone::clone(channel_id);
1965 let mut user_channel_id_nonref = Clone::clone(user_channel_id);
1966 let mut reason_nonref = Clone::clone(reason);
1967 let mut counterparty_node_id_nonref = Clone::clone(counterparty_node_id);
1968 let mut local_counterparty_node_id_nonref = if counterparty_node_id_nonref.is_null() { None } else { Some( { counterparty_node_id_nonref.into_rust() }) };
1969 let mut channel_capacity_sats_nonref = Clone::clone(channel_capacity_sats);
1970 let mut local_channel_capacity_sats_nonref = if channel_capacity_sats_nonref.is_some() { Some( { channel_capacity_sats_nonref.take() }) } else { None };
1971 nativeEvent::ChannelClosed {
1972 channel_id: ::lightning::ln::ChannelId(channel_id_nonref.data),
1973 user_channel_id: user_channel_id_nonref.into(),
1974 reason: reason_nonref.into_native(),
1975 counterparty_node_id: local_counterparty_node_id_nonref,
1976 channel_capacity_sats: local_channel_capacity_sats_nonref,
1979 Event::DiscardFunding {ref channel_id, ref transaction, } => {
1980 let mut channel_id_nonref = Clone::clone(channel_id);
1981 let mut transaction_nonref = Clone::clone(transaction);
1982 nativeEvent::DiscardFunding {
1983 channel_id: ::lightning::ln::ChannelId(channel_id_nonref.data),
1984 transaction: transaction_nonref.into_bitcoin(),
1987 Event::OpenChannelRequest {ref temporary_channel_id, ref counterparty_node_id, ref funding_satoshis, ref push_msat, ref channel_type, } => {
1988 let mut temporary_channel_id_nonref = Clone::clone(temporary_channel_id);
1989 let mut counterparty_node_id_nonref = Clone::clone(counterparty_node_id);
1990 let mut funding_satoshis_nonref = Clone::clone(funding_satoshis);
1991 let mut push_msat_nonref = Clone::clone(push_msat);
1992 let mut channel_type_nonref = Clone::clone(channel_type);
1993 nativeEvent::OpenChannelRequest {
1994 temporary_channel_id: ::lightning::ln::ChannelId(temporary_channel_id_nonref.data),
1995 counterparty_node_id: counterparty_node_id_nonref.into_rust(),
1996 funding_satoshis: funding_satoshis_nonref,
1997 push_msat: push_msat_nonref,
1998 channel_type: *unsafe { Box::from_raw(channel_type_nonref.take_inner()) },
2001 Event::HTLCHandlingFailed {ref prev_channel_id, ref failed_next_destination, } => {
2002 let mut prev_channel_id_nonref = Clone::clone(prev_channel_id);
2003 let mut failed_next_destination_nonref = Clone::clone(failed_next_destination);
2004 nativeEvent::HTLCHandlingFailed {
2005 prev_channel_id: ::lightning::ln::ChannelId(prev_channel_id_nonref.data),
2006 failed_next_destination: failed_next_destination_nonref.into_native(),
2009 Event::BumpTransaction (ref a, ) => {
2010 let mut a_nonref = Clone::clone(a);
2011 nativeEvent::BumpTransaction (
2012 a_nonref.into_native(),
2018 pub(crate) fn into_native(self) -> nativeEvent {
2020 Event::FundingGenerationReady {mut temporary_channel_id, mut counterparty_node_id, mut channel_value_satoshis, mut output_script, mut user_channel_id, } => {
2021 nativeEvent::FundingGenerationReady {
2022 temporary_channel_id: ::lightning::ln::ChannelId(temporary_channel_id.data),
2023 counterparty_node_id: counterparty_node_id.into_rust(),
2024 channel_value_satoshis: channel_value_satoshis,
2025 output_script: ::bitcoin::blockdata::script::Script::from(output_script.into_rust()),
2026 user_channel_id: user_channel_id.into(),
2029 Event::PaymentClaimable {mut receiver_node_id, mut payment_hash, mut onion_fields, mut amount_msat, mut counterparty_skimmed_fee_msat, mut purpose, mut via_channel_id, mut via_user_channel_id, mut claim_deadline, } => {
2030 let mut local_receiver_node_id = if receiver_node_id.is_null() { None } else { Some( { receiver_node_id.into_rust() }) };
2031 let mut local_onion_fields = if onion_fields.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(onion_fields.take_inner()) } }) };
2032 let mut local_via_channel_id = { /*via_channel_id*/ let via_channel_id_opt = via_channel_id; if via_channel_id_opt.is_none() { None } else { Some({ { ::lightning::ln::ChannelId({ via_channel_id_opt.take() }.data) }})} };
2033 let mut local_via_user_channel_id = { /*via_user_channel_id*/ let via_user_channel_id_opt = via_user_channel_id; if via_user_channel_id_opt.is_none() { None } else { Some({ { { via_user_channel_id_opt.take() }.into() }})} };
2034 let mut local_claim_deadline = if claim_deadline.is_some() { Some( { claim_deadline.take() }) } else { None };
2035 nativeEvent::PaymentClaimable {
2036 receiver_node_id: local_receiver_node_id,
2037 payment_hash: ::lightning::ln::PaymentHash(payment_hash.data),
2038 onion_fields: local_onion_fields,
2039 amount_msat: amount_msat,
2040 counterparty_skimmed_fee_msat: counterparty_skimmed_fee_msat,
2041 purpose: purpose.into_native(),
2042 via_channel_id: local_via_channel_id,
2043 via_user_channel_id: local_via_user_channel_id,
2044 claim_deadline: local_claim_deadline,
2047 Event::PaymentClaimed {mut receiver_node_id, mut payment_hash, mut amount_msat, mut purpose, mut htlcs, mut sender_intended_total_msat, } => {
2048 let mut local_receiver_node_id = if receiver_node_id.is_null() { None } else { Some( { receiver_node_id.into_rust() }) };
2049 let mut local_htlcs = Vec::new(); for mut item in htlcs.into_rust().drain(..) { local_htlcs.push( { *unsafe { Box::from_raw(item.take_inner()) } }); };
2050 let mut local_sender_intended_total_msat = if sender_intended_total_msat.is_some() { Some( { sender_intended_total_msat.take() }) } else { None };
2051 nativeEvent::PaymentClaimed {
2052 receiver_node_id: local_receiver_node_id,
2053 payment_hash: ::lightning::ln::PaymentHash(payment_hash.data),
2054 amount_msat: amount_msat,
2055 purpose: purpose.into_native(),
2057 sender_intended_total_msat: local_sender_intended_total_msat,
2060 Event::InvoiceRequestFailed {mut payment_id, } => {
2061 nativeEvent::InvoiceRequestFailed {
2062 payment_id: ::lightning::ln::channelmanager::PaymentId(payment_id.data),
2065 Event::PaymentSent {mut payment_id, mut payment_preimage, mut payment_hash, mut fee_paid_msat, } => {
2066 let mut local_payment_id = { /*payment_id*/ let payment_id_opt = payment_id; if payment_id_opt.is_none() { None } else { Some({ { ::lightning::ln::channelmanager::PaymentId({ payment_id_opt.take() }.data) }})} };
2067 let mut local_fee_paid_msat = if fee_paid_msat.is_some() { Some( { fee_paid_msat.take() }) } else { None };
2068 nativeEvent::PaymentSent {
2069 payment_id: local_payment_id,
2070 payment_preimage: ::lightning::ln::PaymentPreimage(payment_preimage.data),
2071 payment_hash: ::lightning::ln::PaymentHash(payment_hash.data),
2072 fee_paid_msat: local_fee_paid_msat,
2075 Event::PaymentFailed {mut payment_id, mut payment_hash, mut reason, } => {
2076 let mut local_reason = { /*reason*/ let reason_opt = reason; if reason_opt.is_none() { None } else { Some({ { { reason_opt.take() }.into_native() }})} };
2077 nativeEvent::PaymentFailed {
2078 payment_id: ::lightning::ln::channelmanager::PaymentId(payment_id.data),
2079 payment_hash: ::lightning::ln::PaymentHash(payment_hash.data),
2080 reason: local_reason,
2083 Event::PaymentPathSuccessful {mut payment_id, mut payment_hash, mut path, } => {
2084 let mut local_payment_hash = { /*payment_hash*/ let payment_hash_opt = payment_hash; if payment_hash_opt.is_none() { None } else { Some({ { ::lightning::ln::PaymentHash({ payment_hash_opt.take() }.data) }})} };
2085 nativeEvent::PaymentPathSuccessful {
2086 payment_id: ::lightning::ln::channelmanager::PaymentId(payment_id.data),
2087 payment_hash: local_payment_hash,
2088 path: *unsafe { Box::from_raw(path.take_inner()) },
2091 Event::PaymentPathFailed {mut payment_id, mut payment_hash, mut payment_failed_permanently, mut failure, mut path, mut short_channel_id, } => {
2092 let mut local_payment_id = { /*payment_id*/ let payment_id_opt = payment_id; if payment_id_opt.is_none() { None } else { Some({ { ::lightning::ln::channelmanager::PaymentId({ payment_id_opt.take() }.data) }})} };
2093 let mut local_short_channel_id = if short_channel_id.is_some() { Some( { short_channel_id.take() }) } else { None };
2094 nativeEvent::PaymentPathFailed {
2095 payment_id: local_payment_id,
2096 payment_hash: ::lightning::ln::PaymentHash(payment_hash.data),
2097 payment_failed_permanently: payment_failed_permanently,
2098 failure: failure.into_native(),
2099 path: *unsafe { Box::from_raw(path.take_inner()) },
2100 short_channel_id: local_short_channel_id,
2103 Event::ProbeSuccessful {mut payment_id, mut payment_hash, mut path, } => {
2104 nativeEvent::ProbeSuccessful {
2105 payment_id: ::lightning::ln::channelmanager::PaymentId(payment_id.data),
2106 payment_hash: ::lightning::ln::PaymentHash(payment_hash.data),
2107 path: *unsafe { Box::from_raw(path.take_inner()) },
2110 Event::ProbeFailed {mut payment_id, mut payment_hash, mut path, mut short_channel_id, } => {
2111 let mut local_short_channel_id = if short_channel_id.is_some() { Some( { short_channel_id.take() }) } else { None };
2112 nativeEvent::ProbeFailed {
2113 payment_id: ::lightning::ln::channelmanager::PaymentId(payment_id.data),
2114 payment_hash: ::lightning::ln::PaymentHash(payment_hash.data),
2115 path: *unsafe { Box::from_raw(path.take_inner()) },
2116 short_channel_id: local_short_channel_id,
2119 Event::PendingHTLCsForwardable {mut time_forwardable, } => {
2120 nativeEvent::PendingHTLCsForwardable {
2121 time_forwardable: core::time::Duration::from_secs(time_forwardable),
2124 Event::HTLCIntercepted {mut intercept_id, mut requested_next_hop_scid, mut payment_hash, mut inbound_amount_msat, mut expected_outbound_amount_msat, } => {
2125 nativeEvent::HTLCIntercepted {
2126 intercept_id: ::lightning::ln::channelmanager::InterceptId(intercept_id.data),
2127 requested_next_hop_scid: requested_next_hop_scid,
2128 payment_hash: ::lightning::ln::PaymentHash(payment_hash.data),
2129 inbound_amount_msat: inbound_amount_msat,
2130 expected_outbound_amount_msat: expected_outbound_amount_msat,
2133 Event::SpendableOutputs {mut outputs, mut channel_id, } => {
2134 let mut local_outputs = Vec::new(); for mut item in outputs.into_rust().drain(..) { local_outputs.push( { item.into_native() }); };
2135 let mut local_channel_id = { /*channel_id*/ let channel_id_opt = channel_id; if channel_id_opt.is_none() { None } else { Some({ { ::lightning::ln::ChannelId({ channel_id_opt.take() }.data) }})} };
2136 nativeEvent::SpendableOutputs {
2137 outputs: local_outputs,
2138 channel_id: local_channel_id,
2141 Event::PaymentForwarded {mut prev_channel_id, mut next_channel_id, mut fee_earned_msat, mut claim_from_onchain_tx, mut outbound_amount_forwarded_msat, } => {
2142 let mut local_prev_channel_id = { /*prev_channel_id*/ let prev_channel_id_opt = prev_channel_id; if prev_channel_id_opt.is_none() { None } else { Some({ { ::lightning::ln::ChannelId({ prev_channel_id_opt.take() }.data) }})} };
2143 let mut local_next_channel_id = { /*next_channel_id*/ let next_channel_id_opt = next_channel_id; if next_channel_id_opt.is_none() { None } else { Some({ { ::lightning::ln::ChannelId({ next_channel_id_opt.take() }.data) }})} };
2144 let mut local_fee_earned_msat = if fee_earned_msat.is_some() { Some( { fee_earned_msat.take() }) } else { None };
2145 let mut local_outbound_amount_forwarded_msat = if outbound_amount_forwarded_msat.is_some() { Some( { outbound_amount_forwarded_msat.take() }) } else { None };
2146 nativeEvent::PaymentForwarded {
2147 prev_channel_id: local_prev_channel_id,
2148 next_channel_id: local_next_channel_id,
2149 fee_earned_msat: local_fee_earned_msat,
2150 claim_from_onchain_tx: claim_from_onchain_tx,
2151 outbound_amount_forwarded_msat: local_outbound_amount_forwarded_msat,
2154 Event::ChannelPending {mut channel_id, mut user_channel_id, mut former_temporary_channel_id, mut counterparty_node_id, mut funding_txo, } => {
2155 let mut local_former_temporary_channel_id = { /*former_temporary_channel_id*/ let former_temporary_channel_id_opt = former_temporary_channel_id; if former_temporary_channel_id_opt.is_none() { None } else { Some({ { ::lightning::ln::ChannelId({ former_temporary_channel_id_opt.take() }.data) }})} };
2156 nativeEvent::ChannelPending {
2157 channel_id: ::lightning::ln::ChannelId(channel_id.data),
2158 user_channel_id: user_channel_id.into(),
2159 former_temporary_channel_id: local_former_temporary_channel_id,
2160 counterparty_node_id: counterparty_node_id.into_rust(),
2161 funding_txo: crate::c_types::C_to_bitcoin_outpoint(funding_txo),
2164 Event::ChannelReady {mut channel_id, mut user_channel_id, mut counterparty_node_id, mut channel_type, } => {
2165 nativeEvent::ChannelReady {
2166 channel_id: ::lightning::ln::ChannelId(channel_id.data),
2167 user_channel_id: user_channel_id.into(),
2168 counterparty_node_id: counterparty_node_id.into_rust(),
2169 channel_type: *unsafe { Box::from_raw(channel_type.take_inner()) },
2172 Event::ChannelClosed {mut channel_id, mut user_channel_id, mut reason, mut counterparty_node_id, mut channel_capacity_sats, } => {
2173 let mut local_counterparty_node_id = if counterparty_node_id.is_null() { None } else { Some( { counterparty_node_id.into_rust() }) };
2174 let mut local_channel_capacity_sats = if channel_capacity_sats.is_some() { Some( { channel_capacity_sats.take() }) } else { None };
2175 nativeEvent::ChannelClosed {
2176 channel_id: ::lightning::ln::ChannelId(channel_id.data),
2177 user_channel_id: user_channel_id.into(),
2178 reason: reason.into_native(),
2179 counterparty_node_id: local_counterparty_node_id,
2180 channel_capacity_sats: local_channel_capacity_sats,
2183 Event::DiscardFunding {mut channel_id, mut transaction, } => {
2184 nativeEvent::DiscardFunding {
2185 channel_id: ::lightning::ln::ChannelId(channel_id.data),
2186 transaction: transaction.into_bitcoin(),
2189 Event::OpenChannelRequest {mut temporary_channel_id, mut counterparty_node_id, mut funding_satoshis, mut push_msat, mut channel_type, } => {
2190 nativeEvent::OpenChannelRequest {
2191 temporary_channel_id: ::lightning::ln::ChannelId(temporary_channel_id.data),
2192 counterparty_node_id: counterparty_node_id.into_rust(),
2193 funding_satoshis: funding_satoshis,
2194 push_msat: push_msat,
2195 channel_type: *unsafe { Box::from_raw(channel_type.take_inner()) },
2198 Event::HTLCHandlingFailed {mut prev_channel_id, mut failed_next_destination, } => {
2199 nativeEvent::HTLCHandlingFailed {
2200 prev_channel_id: ::lightning::ln::ChannelId(prev_channel_id.data),
2201 failed_next_destination: failed_next_destination.into_native(),
2204 Event::BumpTransaction (mut a, ) => {
2205 nativeEvent::BumpTransaction (
2212 pub(crate) fn from_native(native: &nativeEvent) -> Self {
2214 nativeEvent::FundingGenerationReady {ref temporary_channel_id, ref counterparty_node_id, ref channel_value_satoshis, ref output_script, ref user_channel_id, } => {
2215 let mut temporary_channel_id_nonref = Clone::clone(temporary_channel_id);
2216 let mut counterparty_node_id_nonref = Clone::clone(counterparty_node_id);
2217 let mut channel_value_satoshis_nonref = Clone::clone(channel_value_satoshis);
2218 let mut output_script_nonref = Clone::clone(output_script);
2219 let mut user_channel_id_nonref = Clone::clone(user_channel_id);
2220 Event::FundingGenerationReady {
2221 temporary_channel_id: crate::c_types::ThirtyTwoBytes { data: temporary_channel_id_nonref.0 },
2222 counterparty_node_id: crate::c_types::PublicKey::from_rust(&counterparty_node_id_nonref),
2223 channel_value_satoshis: channel_value_satoshis_nonref,
2224 output_script: output_script_nonref.into_bytes().into(),
2225 user_channel_id: user_channel_id_nonref.into(),
2228 nativeEvent::PaymentClaimable {ref receiver_node_id, ref payment_hash, ref onion_fields, ref amount_msat, ref counterparty_skimmed_fee_msat, ref purpose, ref via_channel_id, ref via_user_channel_id, ref claim_deadline, } => {
2229 let mut receiver_node_id_nonref = Clone::clone(receiver_node_id);
2230 let mut local_receiver_node_id_nonref = if receiver_node_id_nonref.is_none() { crate::c_types::PublicKey::null() } else { { crate::c_types::PublicKey::from_rust(&(receiver_node_id_nonref.unwrap())) } };
2231 let mut payment_hash_nonref = Clone::clone(payment_hash);
2232 let mut onion_fields_nonref = Clone::clone(onion_fields);
2233 let mut local_onion_fields_nonref = crate::lightning::ln::outbound_payment::RecipientOnionFields { inner: if onion_fields_nonref.is_none() { core::ptr::null_mut() } else { { ObjOps::heap_alloc((onion_fields_nonref.unwrap())) } }, is_owned: true };
2234 let mut amount_msat_nonref = Clone::clone(amount_msat);
2235 let mut counterparty_skimmed_fee_msat_nonref = Clone::clone(counterparty_skimmed_fee_msat);
2236 let mut purpose_nonref = Clone::clone(purpose);
2237 let mut via_channel_id_nonref = Clone::clone(via_channel_id);
2238 let mut local_via_channel_id_nonref = if via_channel_id_nonref.is_none() { crate::c_types::derived::COption_ThirtyTwoBytesZ::None } else { crate::c_types::derived::COption_ThirtyTwoBytesZ::Some( { crate::c_types::ThirtyTwoBytes { data: via_channel_id_nonref.unwrap().0 } }) };
2239 let mut via_user_channel_id_nonref = Clone::clone(via_user_channel_id);
2240 let mut local_via_user_channel_id_nonref = if via_user_channel_id_nonref.is_none() { crate::c_types::derived::COption_U128Z::None } else { crate::c_types::derived::COption_U128Z::Some( { via_user_channel_id_nonref.unwrap().into() }) };
2241 let mut claim_deadline_nonref = Clone::clone(claim_deadline);
2242 let mut local_claim_deadline_nonref = if claim_deadline_nonref.is_none() { crate::c_types::derived::COption_u32Z::None } else { crate::c_types::derived::COption_u32Z::Some( { claim_deadline_nonref.unwrap() }) };
2243 Event::PaymentClaimable {
2244 receiver_node_id: local_receiver_node_id_nonref,
2245 payment_hash: crate::c_types::ThirtyTwoBytes { data: payment_hash_nonref.0 },
2246 onion_fields: local_onion_fields_nonref,
2247 amount_msat: amount_msat_nonref,
2248 counterparty_skimmed_fee_msat: counterparty_skimmed_fee_msat_nonref,
2249 purpose: crate::lightning::events::PaymentPurpose::native_into(purpose_nonref),
2250 via_channel_id: local_via_channel_id_nonref,
2251 via_user_channel_id: local_via_user_channel_id_nonref,
2252 claim_deadline: local_claim_deadline_nonref,
2255 nativeEvent::PaymentClaimed {ref receiver_node_id, ref payment_hash, ref amount_msat, ref purpose, ref htlcs, ref sender_intended_total_msat, } => {
2256 let mut receiver_node_id_nonref = Clone::clone(receiver_node_id);
2257 let mut local_receiver_node_id_nonref = if receiver_node_id_nonref.is_none() { crate::c_types::PublicKey::null() } else { { crate::c_types::PublicKey::from_rust(&(receiver_node_id_nonref.unwrap())) } };
2258 let mut payment_hash_nonref = Clone::clone(payment_hash);
2259 let mut amount_msat_nonref = Clone::clone(amount_msat);
2260 let mut purpose_nonref = Clone::clone(purpose);
2261 let mut htlcs_nonref = Clone::clone(htlcs);
2262 let mut local_htlcs_nonref = Vec::new(); for mut item in htlcs_nonref.drain(..) { local_htlcs_nonref.push( { crate::lightning::events::ClaimedHTLC { inner: ObjOps::heap_alloc(item), is_owned: true } }); };
2263 let mut sender_intended_total_msat_nonref = Clone::clone(sender_intended_total_msat);
2264 let mut local_sender_intended_total_msat_nonref = if sender_intended_total_msat_nonref.is_none() { crate::c_types::derived::COption_u64Z::None } else { crate::c_types::derived::COption_u64Z::Some( { sender_intended_total_msat_nonref.unwrap() }) };
2265 Event::PaymentClaimed {
2266 receiver_node_id: local_receiver_node_id_nonref,
2267 payment_hash: crate::c_types::ThirtyTwoBytes { data: payment_hash_nonref.0 },
2268 amount_msat: amount_msat_nonref,
2269 purpose: crate::lightning::events::PaymentPurpose::native_into(purpose_nonref),
2270 htlcs: local_htlcs_nonref.into(),
2271 sender_intended_total_msat: local_sender_intended_total_msat_nonref,
2274 nativeEvent::InvoiceRequestFailed {ref payment_id, } => {
2275 let mut payment_id_nonref = Clone::clone(payment_id);
2276 Event::InvoiceRequestFailed {
2277 payment_id: crate::c_types::ThirtyTwoBytes { data: payment_id_nonref.0 },
2280 nativeEvent::PaymentSent {ref payment_id, ref payment_preimage, ref payment_hash, ref fee_paid_msat, } => {
2281 let mut payment_id_nonref = Clone::clone(payment_id);
2282 let mut local_payment_id_nonref = if payment_id_nonref.is_none() { crate::c_types::derived::COption_ThirtyTwoBytesZ::None } else { crate::c_types::derived::COption_ThirtyTwoBytesZ::Some( { crate::c_types::ThirtyTwoBytes { data: payment_id_nonref.unwrap().0 } }) };
2283 let mut payment_preimage_nonref = Clone::clone(payment_preimage);
2284 let mut payment_hash_nonref = Clone::clone(payment_hash);
2285 let mut fee_paid_msat_nonref = Clone::clone(fee_paid_msat);
2286 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() }) };
2287 Event::PaymentSent {
2288 payment_id: local_payment_id_nonref,
2289 payment_preimage: crate::c_types::ThirtyTwoBytes { data: payment_preimage_nonref.0 },
2290 payment_hash: crate::c_types::ThirtyTwoBytes { data: payment_hash_nonref.0 },
2291 fee_paid_msat: local_fee_paid_msat_nonref,
2294 nativeEvent::PaymentFailed {ref payment_id, ref payment_hash, ref reason, } => {
2295 let mut payment_id_nonref = Clone::clone(payment_id);
2296 let mut payment_hash_nonref = Clone::clone(payment_hash);
2297 let mut reason_nonref = Clone::clone(reason);
2298 let mut local_reason_nonref = if reason_nonref.is_none() { crate::c_types::derived::COption_PaymentFailureReasonZ::None } else { crate::c_types::derived::COption_PaymentFailureReasonZ::Some( { crate::lightning::events::PaymentFailureReason::native_into(reason_nonref.unwrap()) }) };
2299 Event::PaymentFailed {
2300 payment_id: crate::c_types::ThirtyTwoBytes { data: payment_id_nonref.0 },
2301 payment_hash: crate::c_types::ThirtyTwoBytes { data: payment_hash_nonref.0 },
2302 reason: local_reason_nonref,
2305 nativeEvent::PaymentPathSuccessful {ref payment_id, ref payment_hash, ref path, } => {
2306 let mut payment_id_nonref = Clone::clone(payment_id);
2307 let mut payment_hash_nonref = Clone::clone(payment_hash);
2308 let mut local_payment_hash_nonref = if payment_hash_nonref.is_none() { crate::c_types::derived::COption_ThirtyTwoBytesZ::None } else { crate::c_types::derived::COption_ThirtyTwoBytesZ::Some( { crate::c_types::ThirtyTwoBytes { data: payment_hash_nonref.unwrap().0 } }) };
2309 let mut path_nonref = Clone::clone(path);
2310 Event::PaymentPathSuccessful {
2311 payment_id: crate::c_types::ThirtyTwoBytes { data: payment_id_nonref.0 },
2312 payment_hash: local_payment_hash_nonref,
2313 path: crate::lightning::routing::router::Path { inner: ObjOps::heap_alloc(path_nonref), is_owned: true },
2316 nativeEvent::PaymentPathFailed {ref payment_id, ref payment_hash, ref payment_failed_permanently, ref failure, ref path, ref short_channel_id, } => {
2317 let mut payment_id_nonref = Clone::clone(payment_id);
2318 let mut local_payment_id_nonref = if payment_id_nonref.is_none() { crate::c_types::derived::COption_ThirtyTwoBytesZ::None } else { crate::c_types::derived::COption_ThirtyTwoBytesZ::Some( { crate::c_types::ThirtyTwoBytes { data: payment_id_nonref.unwrap().0 } }) };
2319 let mut payment_hash_nonref = Clone::clone(payment_hash);
2320 let mut payment_failed_permanently_nonref = Clone::clone(payment_failed_permanently);
2321 let mut failure_nonref = Clone::clone(failure);
2322 let mut path_nonref = Clone::clone(path);
2323 let mut short_channel_id_nonref = Clone::clone(short_channel_id);
2324 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() }) };
2325 Event::PaymentPathFailed {
2326 payment_id: local_payment_id_nonref,
2327 payment_hash: crate::c_types::ThirtyTwoBytes { data: payment_hash_nonref.0 },
2328 payment_failed_permanently: payment_failed_permanently_nonref,
2329 failure: crate::lightning::events::PathFailure::native_into(failure_nonref),
2330 path: crate::lightning::routing::router::Path { inner: ObjOps::heap_alloc(path_nonref), is_owned: true },
2331 short_channel_id: local_short_channel_id_nonref,
2334 nativeEvent::ProbeSuccessful {ref payment_id, ref payment_hash, ref path, } => {
2335 let mut payment_id_nonref = Clone::clone(payment_id);
2336 let mut payment_hash_nonref = Clone::clone(payment_hash);
2337 let mut path_nonref = Clone::clone(path);
2338 Event::ProbeSuccessful {
2339 payment_id: crate::c_types::ThirtyTwoBytes { data: payment_id_nonref.0 },
2340 payment_hash: crate::c_types::ThirtyTwoBytes { data: payment_hash_nonref.0 },
2341 path: crate::lightning::routing::router::Path { inner: ObjOps::heap_alloc(path_nonref), is_owned: true },
2344 nativeEvent::ProbeFailed {ref payment_id, ref payment_hash, ref path, ref short_channel_id, } => {
2345 let mut payment_id_nonref = Clone::clone(payment_id);
2346 let mut payment_hash_nonref = Clone::clone(payment_hash);
2347 let mut path_nonref = Clone::clone(path);
2348 let mut short_channel_id_nonref = Clone::clone(short_channel_id);
2349 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() }) };
2350 Event::ProbeFailed {
2351 payment_id: crate::c_types::ThirtyTwoBytes { data: payment_id_nonref.0 },
2352 payment_hash: crate::c_types::ThirtyTwoBytes { data: payment_hash_nonref.0 },
2353 path: crate::lightning::routing::router::Path { inner: ObjOps::heap_alloc(path_nonref), is_owned: true },
2354 short_channel_id: local_short_channel_id_nonref,
2357 nativeEvent::PendingHTLCsForwardable {ref time_forwardable, } => {
2358 let mut time_forwardable_nonref = Clone::clone(time_forwardable);
2359 Event::PendingHTLCsForwardable {
2360 time_forwardable: time_forwardable_nonref.as_secs(),
2363 nativeEvent::HTLCIntercepted {ref intercept_id, ref requested_next_hop_scid, ref payment_hash, ref inbound_amount_msat, ref expected_outbound_amount_msat, } => {
2364 let mut intercept_id_nonref = Clone::clone(intercept_id);
2365 let mut requested_next_hop_scid_nonref = Clone::clone(requested_next_hop_scid);
2366 let mut payment_hash_nonref = Clone::clone(payment_hash);
2367 let mut inbound_amount_msat_nonref = Clone::clone(inbound_amount_msat);
2368 let mut expected_outbound_amount_msat_nonref = Clone::clone(expected_outbound_amount_msat);
2369 Event::HTLCIntercepted {
2370 intercept_id: crate::c_types::ThirtyTwoBytes { data: intercept_id_nonref.0 },
2371 requested_next_hop_scid: requested_next_hop_scid_nonref,
2372 payment_hash: crate::c_types::ThirtyTwoBytes { data: payment_hash_nonref.0 },
2373 inbound_amount_msat: inbound_amount_msat_nonref,
2374 expected_outbound_amount_msat: expected_outbound_amount_msat_nonref,
2377 nativeEvent::SpendableOutputs {ref outputs, ref channel_id, } => {
2378 let mut outputs_nonref = Clone::clone(outputs);
2379 let mut local_outputs_nonref = Vec::new(); for mut item in outputs_nonref.drain(..) { local_outputs_nonref.push( { crate::lightning::sign::SpendableOutputDescriptor::native_into(item) }); };
2380 let mut channel_id_nonref = Clone::clone(channel_id);
2381 let mut local_channel_id_nonref = if channel_id_nonref.is_none() { crate::c_types::derived::COption_ThirtyTwoBytesZ::None } else { crate::c_types::derived::COption_ThirtyTwoBytesZ::Some( { crate::c_types::ThirtyTwoBytes { data: channel_id_nonref.unwrap().0 } }) };
2382 Event::SpendableOutputs {
2383 outputs: local_outputs_nonref.into(),
2384 channel_id: local_channel_id_nonref,
2387 nativeEvent::PaymentForwarded {ref prev_channel_id, ref next_channel_id, ref fee_earned_msat, ref claim_from_onchain_tx, ref outbound_amount_forwarded_msat, } => {
2388 let mut prev_channel_id_nonref = Clone::clone(prev_channel_id);
2389 let mut local_prev_channel_id_nonref = if prev_channel_id_nonref.is_none() { crate::c_types::derived::COption_ThirtyTwoBytesZ::None } else { crate::c_types::derived::COption_ThirtyTwoBytesZ::Some( { crate::c_types::ThirtyTwoBytes { data: prev_channel_id_nonref.unwrap().0 } }) };
2390 let mut next_channel_id_nonref = Clone::clone(next_channel_id);
2391 let mut local_next_channel_id_nonref = if next_channel_id_nonref.is_none() { crate::c_types::derived::COption_ThirtyTwoBytesZ::None } else { crate::c_types::derived::COption_ThirtyTwoBytesZ::Some( { crate::c_types::ThirtyTwoBytes { data: next_channel_id_nonref.unwrap().0 } }) };
2392 let mut fee_earned_msat_nonref = Clone::clone(fee_earned_msat);
2393 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() }) };
2394 let mut claim_from_onchain_tx_nonref = Clone::clone(claim_from_onchain_tx);
2395 let mut outbound_amount_forwarded_msat_nonref = Clone::clone(outbound_amount_forwarded_msat);
2396 let mut local_outbound_amount_forwarded_msat_nonref = if outbound_amount_forwarded_msat_nonref.is_none() { crate::c_types::derived::COption_u64Z::None } else { crate::c_types::derived::COption_u64Z::Some( { outbound_amount_forwarded_msat_nonref.unwrap() }) };
2397 Event::PaymentForwarded {
2398 prev_channel_id: local_prev_channel_id_nonref,
2399 next_channel_id: local_next_channel_id_nonref,
2400 fee_earned_msat: local_fee_earned_msat_nonref,
2401 claim_from_onchain_tx: claim_from_onchain_tx_nonref,
2402 outbound_amount_forwarded_msat: local_outbound_amount_forwarded_msat_nonref,
2405 nativeEvent::ChannelPending {ref channel_id, ref user_channel_id, ref former_temporary_channel_id, ref counterparty_node_id, ref funding_txo, } => {
2406 let mut channel_id_nonref = Clone::clone(channel_id);
2407 let mut user_channel_id_nonref = Clone::clone(user_channel_id);
2408 let mut former_temporary_channel_id_nonref = Clone::clone(former_temporary_channel_id);
2409 let mut local_former_temporary_channel_id_nonref = if former_temporary_channel_id_nonref.is_none() { crate::c_types::derived::COption_ThirtyTwoBytesZ::None } else { crate::c_types::derived::COption_ThirtyTwoBytesZ::Some( { crate::c_types::ThirtyTwoBytes { data: former_temporary_channel_id_nonref.unwrap().0 } }) };
2410 let mut counterparty_node_id_nonref = Clone::clone(counterparty_node_id);
2411 let mut funding_txo_nonref = Clone::clone(funding_txo);
2412 Event::ChannelPending {
2413 channel_id: crate::c_types::ThirtyTwoBytes { data: channel_id_nonref.0 },
2414 user_channel_id: user_channel_id_nonref.into(),
2415 former_temporary_channel_id: local_former_temporary_channel_id_nonref,
2416 counterparty_node_id: crate::c_types::PublicKey::from_rust(&counterparty_node_id_nonref),
2417 funding_txo: crate::c_types::bitcoin_to_C_outpoint(&funding_txo_nonref),
2420 nativeEvent::ChannelReady {ref channel_id, ref user_channel_id, ref counterparty_node_id, ref channel_type, } => {
2421 let mut channel_id_nonref = Clone::clone(channel_id);
2422 let mut user_channel_id_nonref = Clone::clone(user_channel_id);
2423 let mut counterparty_node_id_nonref = Clone::clone(counterparty_node_id);
2424 let mut channel_type_nonref = Clone::clone(channel_type);
2425 Event::ChannelReady {
2426 channel_id: crate::c_types::ThirtyTwoBytes { data: channel_id_nonref.0 },
2427 user_channel_id: user_channel_id_nonref.into(),
2428 counterparty_node_id: crate::c_types::PublicKey::from_rust(&counterparty_node_id_nonref),
2429 channel_type: crate::lightning::ln::features::ChannelTypeFeatures { inner: ObjOps::heap_alloc(channel_type_nonref), is_owned: true },
2432 nativeEvent::ChannelClosed {ref channel_id, ref user_channel_id, ref reason, ref counterparty_node_id, ref channel_capacity_sats, } => {
2433 let mut channel_id_nonref = Clone::clone(channel_id);
2434 let mut user_channel_id_nonref = Clone::clone(user_channel_id);
2435 let mut reason_nonref = Clone::clone(reason);
2436 let mut counterparty_node_id_nonref = Clone::clone(counterparty_node_id);
2437 let mut local_counterparty_node_id_nonref = if counterparty_node_id_nonref.is_none() { crate::c_types::PublicKey::null() } else { { crate::c_types::PublicKey::from_rust(&(counterparty_node_id_nonref.unwrap())) } };
2438 let mut channel_capacity_sats_nonref = Clone::clone(channel_capacity_sats);
2439 let mut local_channel_capacity_sats_nonref = if channel_capacity_sats_nonref.is_none() { crate::c_types::derived::COption_u64Z::None } else { crate::c_types::derived::COption_u64Z::Some( { channel_capacity_sats_nonref.unwrap() }) };
2440 Event::ChannelClosed {
2441 channel_id: crate::c_types::ThirtyTwoBytes { data: channel_id_nonref.0 },
2442 user_channel_id: user_channel_id_nonref.into(),
2443 reason: crate::lightning::events::ClosureReason::native_into(reason_nonref),
2444 counterparty_node_id: local_counterparty_node_id_nonref,
2445 channel_capacity_sats: local_channel_capacity_sats_nonref,
2448 nativeEvent::DiscardFunding {ref channel_id, ref transaction, } => {
2449 let mut channel_id_nonref = Clone::clone(channel_id);
2450 let mut transaction_nonref = Clone::clone(transaction);
2451 Event::DiscardFunding {
2452 channel_id: crate::c_types::ThirtyTwoBytes { data: channel_id_nonref.0 },
2453 transaction: crate::c_types::Transaction::from_bitcoin(&transaction_nonref),
2456 nativeEvent::OpenChannelRequest {ref temporary_channel_id, ref counterparty_node_id, ref funding_satoshis, ref push_msat, ref channel_type, } => {
2457 let mut temporary_channel_id_nonref = Clone::clone(temporary_channel_id);
2458 let mut counterparty_node_id_nonref = Clone::clone(counterparty_node_id);
2459 let mut funding_satoshis_nonref = Clone::clone(funding_satoshis);
2460 let mut push_msat_nonref = Clone::clone(push_msat);
2461 let mut channel_type_nonref = Clone::clone(channel_type);
2462 Event::OpenChannelRequest {
2463 temporary_channel_id: crate::c_types::ThirtyTwoBytes { data: temporary_channel_id_nonref.0 },
2464 counterparty_node_id: crate::c_types::PublicKey::from_rust(&counterparty_node_id_nonref),
2465 funding_satoshis: funding_satoshis_nonref,
2466 push_msat: push_msat_nonref,
2467 channel_type: crate::lightning::ln::features::ChannelTypeFeatures { inner: ObjOps::heap_alloc(channel_type_nonref), is_owned: true },
2470 nativeEvent::HTLCHandlingFailed {ref prev_channel_id, ref failed_next_destination, } => {
2471 let mut prev_channel_id_nonref = Clone::clone(prev_channel_id);
2472 let mut failed_next_destination_nonref = Clone::clone(failed_next_destination);
2473 Event::HTLCHandlingFailed {
2474 prev_channel_id: crate::c_types::ThirtyTwoBytes { data: prev_channel_id_nonref.0 },
2475 failed_next_destination: crate::lightning::events::HTLCDestination::native_into(failed_next_destination_nonref),
2478 nativeEvent::BumpTransaction (ref a, ) => {
2479 let mut a_nonref = Clone::clone(a);
2480 Event::BumpTransaction (
2481 crate::lightning::events::bump_transaction::BumpTransactionEvent::native_into(a_nonref),
2487 pub(crate) fn native_into(native: nativeEvent) -> Self {
2489 nativeEvent::FundingGenerationReady {mut temporary_channel_id, mut counterparty_node_id, mut channel_value_satoshis, mut output_script, mut user_channel_id, } => {
2490 Event::FundingGenerationReady {
2491 temporary_channel_id: crate::c_types::ThirtyTwoBytes { data: temporary_channel_id.0 },
2492 counterparty_node_id: crate::c_types::PublicKey::from_rust(&counterparty_node_id),
2493 channel_value_satoshis: channel_value_satoshis,
2494 output_script: output_script.into_bytes().into(),
2495 user_channel_id: user_channel_id.into(),
2498 nativeEvent::PaymentClaimable {mut receiver_node_id, mut payment_hash, mut onion_fields, mut amount_msat, mut counterparty_skimmed_fee_msat, mut purpose, mut via_channel_id, mut via_user_channel_id, mut claim_deadline, } => {
2499 let mut local_receiver_node_id = if receiver_node_id.is_none() { crate::c_types::PublicKey::null() } else { { crate::c_types::PublicKey::from_rust(&(receiver_node_id.unwrap())) } };
2500 let mut local_onion_fields = crate::lightning::ln::outbound_payment::RecipientOnionFields { inner: if onion_fields.is_none() { core::ptr::null_mut() } else { { ObjOps::heap_alloc((onion_fields.unwrap())) } }, is_owned: true };
2501 let mut local_via_channel_id = if via_channel_id.is_none() { crate::c_types::derived::COption_ThirtyTwoBytesZ::None } else { crate::c_types::derived::COption_ThirtyTwoBytesZ::Some( { crate::c_types::ThirtyTwoBytes { data: via_channel_id.unwrap().0 } }) };
2502 let mut local_via_user_channel_id = if via_user_channel_id.is_none() { crate::c_types::derived::COption_U128Z::None } else { crate::c_types::derived::COption_U128Z::Some( { via_user_channel_id.unwrap().into() }) };
2503 let mut local_claim_deadline = if claim_deadline.is_none() { crate::c_types::derived::COption_u32Z::None } else { crate::c_types::derived::COption_u32Z::Some( { claim_deadline.unwrap() }) };
2504 Event::PaymentClaimable {
2505 receiver_node_id: local_receiver_node_id,
2506 payment_hash: crate::c_types::ThirtyTwoBytes { data: payment_hash.0 },
2507 onion_fields: local_onion_fields,
2508 amount_msat: amount_msat,
2509 counterparty_skimmed_fee_msat: counterparty_skimmed_fee_msat,
2510 purpose: crate::lightning::events::PaymentPurpose::native_into(purpose),
2511 via_channel_id: local_via_channel_id,
2512 via_user_channel_id: local_via_user_channel_id,
2513 claim_deadline: local_claim_deadline,
2516 nativeEvent::PaymentClaimed {mut receiver_node_id, mut payment_hash, mut amount_msat, mut purpose, mut htlcs, mut sender_intended_total_msat, } => {
2517 let mut local_receiver_node_id = if receiver_node_id.is_none() { crate::c_types::PublicKey::null() } else { { crate::c_types::PublicKey::from_rust(&(receiver_node_id.unwrap())) } };
2518 let mut local_htlcs = Vec::new(); for mut item in htlcs.drain(..) { local_htlcs.push( { crate::lightning::events::ClaimedHTLC { inner: ObjOps::heap_alloc(item), is_owned: true } }); };
2519 let mut local_sender_intended_total_msat = if sender_intended_total_msat.is_none() { crate::c_types::derived::COption_u64Z::None } else { crate::c_types::derived::COption_u64Z::Some( { sender_intended_total_msat.unwrap() }) };
2520 Event::PaymentClaimed {
2521 receiver_node_id: local_receiver_node_id,
2522 payment_hash: crate::c_types::ThirtyTwoBytes { data: payment_hash.0 },
2523 amount_msat: amount_msat,
2524 purpose: crate::lightning::events::PaymentPurpose::native_into(purpose),
2525 htlcs: local_htlcs.into(),
2526 sender_intended_total_msat: local_sender_intended_total_msat,
2529 nativeEvent::InvoiceRequestFailed {mut payment_id, } => {
2530 Event::InvoiceRequestFailed {
2531 payment_id: crate::c_types::ThirtyTwoBytes { data: payment_id.0 },
2534 nativeEvent::PaymentSent {mut payment_id, mut payment_preimage, mut payment_hash, mut fee_paid_msat, } => {
2535 let mut local_payment_id = if payment_id.is_none() { crate::c_types::derived::COption_ThirtyTwoBytesZ::None } else { crate::c_types::derived::COption_ThirtyTwoBytesZ::Some( { crate::c_types::ThirtyTwoBytes { data: payment_id.unwrap().0 } }) };
2536 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() }) };
2537 Event::PaymentSent {
2538 payment_id: local_payment_id,
2539 payment_preimage: crate::c_types::ThirtyTwoBytes { data: payment_preimage.0 },
2540 payment_hash: crate::c_types::ThirtyTwoBytes { data: payment_hash.0 },
2541 fee_paid_msat: local_fee_paid_msat,
2544 nativeEvent::PaymentFailed {mut payment_id, mut payment_hash, mut reason, } => {
2545 let mut local_reason = if reason.is_none() { crate::c_types::derived::COption_PaymentFailureReasonZ::None } else { crate::c_types::derived::COption_PaymentFailureReasonZ::Some( { crate::lightning::events::PaymentFailureReason::native_into(reason.unwrap()) }) };
2546 Event::PaymentFailed {
2547 payment_id: crate::c_types::ThirtyTwoBytes { data: payment_id.0 },
2548 payment_hash: crate::c_types::ThirtyTwoBytes { data: payment_hash.0 },
2549 reason: local_reason,
2552 nativeEvent::PaymentPathSuccessful {mut payment_id, mut payment_hash, mut path, } => {
2553 let mut local_payment_hash = if payment_hash.is_none() { crate::c_types::derived::COption_ThirtyTwoBytesZ::None } else { crate::c_types::derived::COption_ThirtyTwoBytesZ::Some( { crate::c_types::ThirtyTwoBytes { data: payment_hash.unwrap().0 } }) };
2554 Event::PaymentPathSuccessful {
2555 payment_id: crate::c_types::ThirtyTwoBytes { data: payment_id.0 },
2556 payment_hash: local_payment_hash,
2557 path: crate::lightning::routing::router::Path { inner: ObjOps::heap_alloc(path), is_owned: true },
2560 nativeEvent::PaymentPathFailed {mut payment_id, mut payment_hash, mut payment_failed_permanently, mut failure, mut path, mut short_channel_id, } => {
2561 let mut local_payment_id = if payment_id.is_none() { crate::c_types::derived::COption_ThirtyTwoBytesZ::None } else { crate::c_types::derived::COption_ThirtyTwoBytesZ::Some( { crate::c_types::ThirtyTwoBytes { data: payment_id.unwrap().0 } }) };
2562 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() }) };
2563 Event::PaymentPathFailed {
2564 payment_id: local_payment_id,
2565 payment_hash: crate::c_types::ThirtyTwoBytes { data: payment_hash.0 },
2566 payment_failed_permanently: payment_failed_permanently,
2567 failure: crate::lightning::events::PathFailure::native_into(failure),
2568 path: crate::lightning::routing::router::Path { inner: ObjOps::heap_alloc(path), is_owned: true },
2569 short_channel_id: local_short_channel_id,
2572 nativeEvent::ProbeSuccessful {mut payment_id, mut payment_hash, mut path, } => {
2573 Event::ProbeSuccessful {
2574 payment_id: crate::c_types::ThirtyTwoBytes { data: payment_id.0 },
2575 payment_hash: crate::c_types::ThirtyTwoBytes { data: payment_hash.0 },
2576 path: crate::lightning::routing::router::Path { inner: ObjOps::heap_alloc(path), is_owned: true },
2579 nativeEvent::ProbeFailed {mut payment_id, mut payment_hash, mut path, mut short_channel_id, } => {
2580 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() }) };
2581 Event::ProbeFailed {
2582 payment_id: crate::c_types::ThirtyTwoBytes { data: payment_id.0 },
2583 payment_hash: crate::c_types::ThirtyTwoBytes { data: payment_hash.0 },
2584 path: crate::lightning::routing::router::Path { inner: ObjOps::heap_alloc(path), is_owned: true },
2585 short_channel_id: local_short_channel_id,
2588 nativeEvent::PendingHTLCsForwardable {mut time_forwardable, } => {
2589 Event::PendingHTLCsForwardable {
2590 time_forwardable: time_forwardable.as_secs(),
2593 nativeEvent::HTLCIntercepted {mut intercept_id, mut requested_next_hop_scid, mut payment_hash, mut inbound_amount_msat, mut expected_outbound_amount_msat, } => {
2594 Event::HTLCIntercepted {
2595 intercept_id: crate::c_types::ThirtyTwoBytes { data: intercept_id.0 },
2596 requested_next_hop_scid: requested_next_hop_scid,
2597 payment_hash: crate::c_types::ThirtyTwoBytes { data: payment_hash.0 },
2598 inbound_amount_msat: inbound_amount_msat,
2599 expected_outbound_amount_msat: expected_outbound_amount_msat,
2602 nativeEvent::SpendableOutputs {mut outputs, mut channel_id, } => {
2603 let mut local_outputs = Vec::new(); for mut item in outputs.drain(..) { local_outputs.push( { crate::lightning::sign::SpendableOutputDescriptor::native_into(item) }); };
2604 let mut local_channel_id = if channel_id.is_none() { crate::c_types::derived::COption_ThirtyTwoBytesZ::None } else { crate::c_types::derived::COption_ThirtyTwoBytesZ::Some( { crate::c_types::ThirtyTwoBytes { data: channel_id.unwrap().0 } }) };
2605 Event::SpendableOutputs {
2606 outputs: local_outputs.into(),
2607 channel_id: local_channel_id,
2610 nativeEvent::PaymentForwarded {mut prev_channel_id, mut next_channel_id, mut fee_earned_msat, mut claim_from_onchain_tx, mut outbound_amount_forwarded_msat, } => {
2611 let mut local_prev_channel_id = if prev_channel_id.is_none() { crate::c_types::derived::COption_ThirtyTwoBytesZ::None } else { crate::c_types::derived::COption_ThirtyTwoBytesZ::Some( { crate::c_types::ThirtyTwoBytes { data: prev_channel_id.unwrap().0 } }) };
2612 let mut local_next_channel_id = if next_channel_id.is_none() { crate::c_types::derived::COption_ThirtyTwoBytesZ::None } else { crate::c_types::derived::COption_ThirtyTwoBytesZ::Some( { crate::c_types::ThirtyTwoBytes { data: next_channel_id.unwrap().0 } }) };
2613 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() }) };
2614 let mut local_outbound_amount_forwarded_msat = if outbound_amount_forwarded_msat.is_none() { crate::c_types::derived::COption_u64Z::None } else { crate::c_types::derived::COption_u64Z::Some( { outbound_amount_forwarded_msat.unwrap() }) };
2615 Event::PaymentForwarded {
2616 prev_channel_id: local_prev_channel_id,
2617 next_channel_id: local_next_channel_id,
2618 fee_earned_msat: local_fee_earned_msat,
2619 claim_from_onchain_tx: claim_from_onchain_tx,
2620 outbound_amount_forwarded_msat: local_outbound_amount_forwarded_msat,
2623 nativeEvent::ChannelPending {mut channel_id, mut user_channel_id, mut former_temporary_channel_id, mut counterparty_node_id, mut funding_txo, } => {
2624 let mut local_former_temporary_channel_id = if former_temporary_channel_id.is_none() { crate::c_types::derived::COption_ThirtyTwoBytesZ::None } else { crate::c_types::derived::COption_ThirtyTwoBytesZ::Some( { crate::c_types::ThirtyTwoBytes { data: former_temporary_channel_id.unwrap().0 } }) };
2625 Event::ChannelPending {
2626 channel_id: crate::c_types::ThirtyTwoBytes { data: channel_id.0 },
2627 user_channel_id: user_channel_id.into(),
2628 former_temporary_channel_id: local_former_temporary_channel_id,
2629 counterparty_node_id: crate::c_types::PublicKey::from_rust(&counterparty_node_id),
2630 funding_txo: crate::c_types::bitcoin_to_C_outpoint(&funding_txo),
2633 nativeEvent::ChannelReady {mut channel_id, mut user_channel_id, mut counterparty_node_id, mut channel_type, } => {
2634 Event::ChannelReady {
2635 channel_id: crate::c_types::ThirtyTwoBytes { data: channel_id.0 },
2636 user_channel_id: user_channel_id.into(),
2637 counterparty_node_id: crate::c_types::PublicKey::from_rust(&counterparty_node_id),
2638 channel_type: crate::lightning::ln::features::ChannelTypeFeatures { inner: ObjOps::heap_alloc(channel_type), is_owned: true },
2641 nativeEvent::ChannelClosed {mut channel_id, mut user_channel_id, mut reason, mut counterparty_node_id, mut channel_capacity_sats, } => {
2642 let mut local_counterparty_node_id = if counterparty_node_id.is_none() { crate::c_types::PublicKey::null() } else { { crate::c_types::PublicKey::from_rust(&(counterparty_node_id.unwrap())) } };
2643 let mut local_channel_capacity_sats = if channel_capacity_sats.is_none() { crate::c_types::derived::COption_u64Z::None } else { crate::c_types::derived::COption_u64Z::Some( { channel_capacity_sats.unwrap() }) };
2644 Event::ChannelClosed {
2645 channel_id: crate::c_types::ThirtyTwoBytes { data: channel_id.0 },
2646 user_channel_id: user_channel_id.into(),
2647 reason: crate::lightning::events::ClosureReason::native_into(reason),
2648 counterparty_node_id: local_counterparty_node_id,
2649 channel_capacity_sats: local_channel_capacity_sats,
2652 nativeEvent::DiscardFunding {mut channel_id, mut transaction, } => {
2653 Event::DiscardFunding {
2654 channel_id: crate::c_types::ThirtyTwoBytes { data: channel_id.0 },
2655 transaction: crate::c_types::Transaction::from_bitcoin(&transaction),
2658 nativeEvent::OpenChannelRequest {mut temporary_channel_id, mut counterparty_node_id, mut funding_satoshis, mut push_msat, mut channel_type, } => {
2659 Event::OpenChannelRequest {
2660 temporary_channel_id: crate::c_types::ThirtyTwoBytes { data: temporary_channel_id.0 },
2661 counterparty_node_id: crate::c_types::PublicKey::from_rust(&counterparty_node_id),
2662 funding_satoshis: funding_satoshis,
2663 push_msat: push_msat,
2664 channel_type: crate::lightning::ln::features::ChannelTypeFeatures { inner: ObjOps::heap_alloc(channel_type), is_owned: true },
2667 nativeEvent::HTLCHandlingFailed {mut prev_channel_id, mut failed_next_destination, } => {
2668 Event::HTLCHandlingFailed {
2669 prev_channel_id: crate::c_types::ThirtyTwoBytes { data: prev_channel_id.0 },
2670 failed_next_destination: crate::lightning::events::HTLCDestination::native_into(failed_next_destination),
2673 nativeEvent::BumpTransaction (mut a, ) => {
2674 Event::BumpTransaction (
2675 crate::lightning::events::bump_transaction::BumpTransactionEvent::native_into(a),
2681 /// Frees any resources used by the Event
2683 pub extern "C" fn Event_free(this_ptr: Event) { }
2684 /// Creates a copy of the Event
2686 pub extern "C" fn Event_clone(orig: &Event) -> Event {
2690 /// Used only if an object of this type is returned as a trait impl by a method
2691 pub(crate) extern "C" fn Event_clone_void(this_ptr: *const c_void) -> *mut c_void {
2692 Box::into_raw(Box::new(unsafe { (*(this_ptr as *const Event)).clone() })) as *mut c_void
2695 /// Used only if an object of this type is returned as a trait impl by a method
2696 pub(crate) extern "C" fn Event_free_void(this_ptr: *mut c_void) {
2697 let _ = unsafe { Box::from_raw(this_ptr as *mut Event) };
2700 /// Utility method to constructs a new FundingGenerationReady-variant Event
2701 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: crate::c_types::U128) -> Event {
2702 Event::FundingGenerationReady {
2703 temporary_channel_id,
2704 counterparty_node_id,
2705 channel_value_satoshis,
2711 /// Utility method to constructs a new PaymentClaimable-variant Event
2712 pub extern "C" fn Event_payment_claimable(receiver_node_id: crate::c_types::PublicKey, payment_hash: crate::c_types::ThirtyTwoBytes, onion_fields: crate::lightning::ln::outbound_payment::RecipientOnionFields, amount_msat: u64, counterparty_skimmed_fee_msat: u64, purpose: crate::lightning::events::PaymentPurpose, via_channel_id: crate::c_types::derived::COption_ThirtyTwoBytesZ, via_user_channel_id: crate::c_types::derived::COption_U128Z, claim_deadline: crate::c_types::derived::COption_u32Z) -> Event {
2713 Event::PaymentClaimable {
2718 counterparty_skimmed_fee_msat,
2721 via_user_channel_id,
2726 /// Utility method to constructs a new PaymentClaimed-variant Event
2727 pub extern "C" fn Event_payment_claimed(receiver_node_id: crate::c_types::PublicKey, payment_hash: crate::c_types::ThirtyTwoBytes, amount_msat: u64, purpose: crate::lightning::events::PaymentPurpose, htlcs: crate::c_types::derived::CVec_ClaimedHTLCZ, sender_intended_total_msat: crate::c_types::derived::COption_u64Z) -> Event {
2728 Event::PaymentClaimed {
2734 sender_intended_total_msat,
2738 /// Utility method to constructs a new InvoiceRequestFailed-variant Event
2739 pub extern "C" fn Event_invoice_request_failed(payment_id: crate::c_types::ThirtyTwoBytes) -> Event {
2740 Event::InvoiceRequestFailed {
2745 /// Utility method to constructs a new PaymentSent-variant Event
2746 pub extern "C" fn Event_payment_sent(payment_id: crate::c_types::derived::COption_ThirtyTwoBytesZ, payment_preimage: crate::c_types::ThirtyTwoBytes, payment_hash: crate::c_types::ThirtyTwoBytes, fee_paid_msat: crate::c_types::derived::COption_u64Z) -> Event {
2747 Event::PaymentSent {
2755 /// Utility method to constructs a new PaymentFailed-variant Event
2756 pub extern "C" fn Event_payment_failed(payment_id: crate::c_types::ThirtyTwoBytes, payment_hash: crate::c_types::ThirtyTwoBytes, reason: crate::c_types::derived::COption_PaymentFailureReasonZ) -> Event {
2757 Event::PaymentFailed {
2764 /// Utility method to constructs a new PaymentPathSuccessful-variant Event
2765 pub extern "C" fn Event_payment_path_successful(payment_id: crate::c_types::ThirtyTwoBytes, payment_hash: crate::c_types::derived::COption_ThirtyTwoBytesZ, path: crate::lightning::routing::router::Path) -> Event {
2766 Event::PaymentPathSuccessful {
2773 /// Utility method to constructs a new PaymentPathFailed-variant Event
2774 pub extern "C" fn Event_payment_path_failed(payment_id: crate::c_types::derived::COption_ThirtyTwoBytesZ, payment_hash: crate::c_types::ThirtyTwoBytes, payment_failed_permanently: bool, failure: crate::lightning::events::PathFailure, path: crate::lightning::routing::router::Path, short_channel_id: crate::c_types::derived::COption_u64Z) -> Event {
2775 Event::PaymentPathFailed {
2778 payment_failed_permanently,
2785 /// Utility method to constructs a new ProbeSuccessful-variant Event
2786 pub extern "C" fn Event_probe_successful(payment_id: crate::c_types::ThirtyTwoBytes, payment_hash: crate::c_types::ThirtyTwoBytes, path: crate::lightning::routing::router::Path) -> Event {
2787 Event::ProbeSuccessful {
2794 /// Utility method to constructs a new ProbeFailed-variant Event
2795 pub extern "C" fn Event_probe_failed(payment_id: crate::c_types::ThirtyTwoBytes, payment_hash: crate::c_types::ThirtyTwoBytes, path: crate::lightning::routing::router::Path, short_channel_id: crate::c_types::derived::COption_u64Z) -> Event {
2796 Event::ProbeFailed {
2804 /// Utility method to constructs a new PendingHTLCsForwardable-variant Event
2805 pub extern "C" fn Event_pending_htlcs_forwardable(time_forwardable: u64) -> Event {
2806 Event::PendingHTLCsForwardable {
2811 /// Utility method to constructs a new HTLCIntercepted-variant Event
2812 pub extern "C" fn Event_htlcintercepted(intercept_id: crate::c_types::ThirtyTwoBytes, requested_next_hop_scid: u64, payment_hash: crate::c_types::ThirtyTwoBytes, inbound_amount_msat: u64, expected_outbound_amount_msat: u64) -> Event {
2813 Event::HTLCIntercepted {
2815 requested_next_hop_scid,
2817 inbound_amount_msat,
2818 expected_outbound_amount_msat,
2822 /// Utility method to constructs a new SpendableOutputs-variant Event
2823 pub extern "C" fn Event_spendable_outputs(outputs: crate::c_types::derived::CVec_SpendableOutputDescriptorZ, channel_id: crate::c_types::derived::COption_ThirtyTwoBytesZ) -> Event {
2824 Event::SpendableOutputs {
2830 /// Utility method to constructs a new PaymentForwarded-variant Event
2831 pub extern "C" fn Event_payment_forwarded(prev_channel_id: crate::c_types::derived::COption_ThirtyTwoBytesZ, next_channel_id: crate::c_types::derived::COption_ThirtyTwoBytesZ, fee_earned_msat: crate::c_types::derived::COption_u64Z, claim_from_onchain_tx: bool, outbound_amount_forwarded_msat: crate::c_types::derived::COption_u64Z) -> Event {
2832 Event::PaymentForwarded {
2836 claim_from_onchain_tx,
2837 outbound_amount_forwarded_msat,
2841 /// Utility method to constructs a new ChannelPending-variant Event
2842 pub extern "C" fn Event_channel_pending(channel_id: crate::c_types::ThirtyTwoBytes, user_channel_id: crate::c_types::U128, former_temporary_channel_id: crate::c_types::derived::COption_ThirtyTwoBytesZ, counterparty_node_id: crate::c_types::PublicKey, funding_txo: crate::lightning::chain::transaction::OutPoint) -> Event {
2843 Event::ChannelPending {
2846 former_temporary_channel_id,
2847 counterparty_node_id,
2852 /// Utility method to constructs a new ChannelReady-variant Event
2853 pub extern "C" fn Event_channel_ready(channel_id: crate::c_types::ThirtyTwoBytes, user_channel_id: crate::c_types::U128, counterparty_node_id: crate::c_types::PublicKey, channel_type: crate::lightning::ln::features::ChannelTypeFeatures) -> Event {
2854 Event::ChannelReady {
2857 counterparty_node_id,
2862 /// Utility method to constructs a new ChannelClosed-variant Event
2863 pub extern "C" fn Event_channel_closed(channel_id: crate::c_types::ThirtyTwoBytes, user_channel_id: crate::c_types::U128, reason: crate::lightning::events::ClosureReason, counterparty_node_id: crate::c_types::PublicKey, channel_capacity_sats: crate::c_types::derived::COption_u64Z) -> Event {
2864 Event::ChannelClosed {
2868 counterparty_node_id,
2869 channel_capacity_sats,
2873 /// Utility method to constructs a new DiscardFunding-variant Event
2874 pub extern "C" fn Event_discard_funding(channel_id: crate::c_types::ThirtyTwoBytes, transaction: crate::c_types::Transaction) -> Event {
2875 Event::DiscardFunding {
2881 /// Utility method to constructs a new OpenChannelRequest-variant Event
2882 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 {
2883 Event::OpenChannelRequest {
2884 temporary_channel_id,
2885 counterparty_node_id,
2892 /// Utility method to constructs a new HTLCHandlingFailed-variant Event
2893 pub extern "C" fn Event_htlchandling_failed(prev_channel_id: crate::c_types::ThirtyTwoBytes, failed_next_destination: crate::lightning::events::HTLCDestination) -> Event {
2894 Event::HTLCHandlingFailed {
2896 failed_next_destination,
2900 /// Utility method to constructs a new BumpTransaction-variant Event
2901 pub extern "C" fn Event_bump_transaction(a: crate::lightning::events::bump_transaction::BumpTransactionEvent) -> Event {
2902 Event::BumpTransaction(a, )
2904 /// Checks if two Events contain equal inner contents.
2905 /// This ignores pointers and is_owned flags and looks at the values in fields.
2907 pub extern "C" fn Event_eq(a: &Event, b: &Event) -> bool {
2908 if &a.to_native() == &b.to_native() { true } else { false }
2911 /// Serialize the Event object into a byte array which can be read by Event_read
2912 pub extern "C" fn Event_write(obj: &crate::lightning::events::Event) -> crate::c_types::derived::CVec_u8Z {
2913 crate::c_types::serialize_obj(&unsafe { &*obj }.to_native())
2916 pub(crate) extern "C" fn Event_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
2917 Event_write(unsafe { &*(obj as *const Event) })
2920 /// Read a Event from a byte array, created by Event_write
2921 pub extern "C" fn Event_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_COption_EventZDecodeErrorZ {
2922 let res: Result<Option<lightning::events::Event>, lightning::ln::msgs::DecodeError> = crate::c_types::maybe_deserialize_obj(ser);
2923 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::events::Event::native_into(o.unwrap()) }) }; local_res_0 }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() };
2926 /// An event generated by ChannelManager which indicates a message should be sent to a peer (or
2927 /// broadcast to most peers).
2928 /// These events are handled by PeerManager::process_events if you are using a PeerManager.
2932 pub enum MessageSendEvent {
2933 /// Used to indicate that we've accepted a channel open and should send the accept_channel
2934 /// message provided to the given peer.
2936 /// The node_id of the node which should receive this message
2937 node_id: crate::c_types::PublicKey,
2938 /// The message which should be sent.
2939 msg: crate::lightning::ln::msgs::AcceptChannel,
2941 /// Used to indicate that we've accepted a V2 channel open and should send the accept_channel2
2942 /// message provided to the given peer.
2943 SendAcceptChannelV2 {
2944 /// The node_id of the node which should receive this message
2945 node_id: crate::c_types::PublicKey,
2946 /// The message which should be sent.
2947 msg: crate::lightning::ln::msgs::AcceptChannelV2,
2949 /// Used to indicate that we've initiated a channel open and should send the open_channel
2950 /// message provided to the given peer.
2952 /// The node_id of the node which should receive this message
2953 node_id: crate::c_types::PublicKey,
2954 /// The message which should be sent.
2955 msg: crate::lightning::ln::msgs::OpenChannel,
2957 /// Used to indicate that we've initiated a V2 channel open and should send the open_channel2
2958 /// message provided to the given peer.
2960 /// The node_id of the node which should receive this message
2961 node_id: crate::c_types::PublicKey,
2962 /// The message which should be sent.
2963 msg: crate::lightning::ln::msgs::OpenChannelV2,
2965 /// Used to indicate that a funding_created message should be sent to the peer with the given node_id.
2966 SendFundingCreated {
2967 /// The node_id of the node which should receive this message
2968 node_id: crate::c_types::PublicKey,
2969 /// The message which should be sent.
2970 msg: crate::lightning::ln::msgs::FundingCreated,
2972 /// Used to indicate that a funding_signed message should be sent to the peer with the given node_id.
2974 /// The node_id of the node which should receive this message
2975 node_id: crate::c_types::PublicKey,
2976 /// The message which should be sent.
2977 msg: crate::lightning::ln::msgs::FundingSigned,
2979 /// Used to indicate that a tx_add_input message should be sent to the peer with the given node_id.
2981 /// The node_id of the node which should receive this message
2982 node_id: crate::c_types::PublicKey,
2983 /// The message which should be sent.
2984 msg: crate::lightning::ln::msgs::TxAddInput,
2986 /// Used to indicate that a tx_add_output message should be sent to the peer with the given node_id.
2988 /// The node_id of the node which should receive this message
2989 node_id: crate::c_types::PublicKey,
2990 /// The message which should be sent.
2991 msg: crate::lightning::ln::msgs::TxAddOutput,
2993 /// Used to indicate that a tx_remove_input message should be sent to the peer with the given node_id.
2995 /// The node_id of the node which should receive this message
2996 node_id: crate::c_types::PublicKey,
2997 /// The message which should be sent.
2998 msg: crate::lightning::ln::msgs::TxRemoveInput,
3000 /// Used to indicate that a tx_remove_output message should be sent to the peer with the given node_id.
3001 SendTxRemoveOutput {
3002 /// The node_id of the node which should receive this message
3003 node_id: crate::c_types::PublicKey,
3004 /// The message which should be sent.
3005 msg: crate::lightning::ln::msgs::TxRemoveOutput,
3007 /// Used to indicate that a tx_complete message should be sent to the peer with the given node_id.
3009 /// The node_id of the node which should receive this message
3010 node_id: crate::c_types::PublicKey,
3011 /// The message which should be sent.
3012 msg: crate::lightning::ln::msgs::TxComplete,
3014 /// Used to indicate that a tx_signatures message should be sent to the peer with the given node_id.
3016 /// The node_id of the node which should receive this message
3017 node_id: crate::c_types::PublicKey,
3018 /// The message which should be sent.
3019 msg: crate::lightning::ln::msgs::TxSignatures,
3021 /// Used to indicate that a tx_init_rbf message should be sent to the peer with the given node_id.
3023 /// The node_id of the node which should receive this message
3024 node_id: crate::c_types::PublicKey,
3025 /// The message which should be sent.
3026 msg: crate::lightning::ln::msgs::TxInitRbf,
3028 /// Used to indicate that a tx_ack_rbf message should be sent to the peer with the given node_id.
3030 /// The node_id of the node which should receive this message
3031 node_id: crate::c_types::PublicKey,
3032 /// The message which should be sent.
3033 msg: crate::lightning::ln::msgs::TxAckRbf,
3035 /// Used to indicate that a tx_abort message should be sent to the peer with the given node_id.
3037 /// The node_id of the node which should receive this message
3038 node_id: crate::c_types::PublicKey,
3039 /// The message which should be sent.
3040 msg: crate::lightning::ln::msgs::TxAbort,
3042 /// Used to indicate that a channel_ready message should be sent to the peer with the given node_id.
3044 /// The node_id of the node which should receive these message(s)
3045 node_id: crate::c_types::PublicKey,
3046 /// The channel_ready message which should be sent.
3047 msg: crate::lightning::ln::msgs::ChannelReady,
3049 /// Used to indicate that an announcement_signatures message should be sent to the peer with the given node_id.
3050 SendAnnouncementSignatures {
3051 /// The node_id of the node which should receive these message(s)
3052 node_id: crate::c_types::PublicKey,
3053 /// The announcement_signatures message which should be sent.
3054 msg: crate::lightning::ln::msgs::AnnouncementSignatures,
3056 /// Used to indicate that a series of HTLC update messages, as well as a commitment_signed
3057 /// message should be sent to the peer with the given node_id.
3059 /// The node_id of the node which should receive these message(s)
3060 node_id: crate::c_types::PublicKey,
3061 /// The update messages which should be sent. ALL messages in the struct should be sent!
3062 updates: crate::lightning::ln::msgs::CommitmentUpdate,
3064 /// Used to indicate that a revoke_and_ack message should be sent to the peer with the given node_id.
3066 /// The node_id of the node which should receive this message
3067 node_id: crate::c_types::PublicKey,
3068 /// The message which should be sent.
3069 msg: crate::lightning::ln::msgs::RevokeAndACK,
3071 /// Used to indicate that a closing_signed message should be sent to the peer with the given node_id.
3073 /// The node_id of the node which should receive this message
3074 node_id: crate::c_types::PublicKey,
3075 /// The message which should be sent.
3076 msg: crate::lightning::ln::msgs::ClosingSigned,
3078 /// Used to indicate that a shutdown message should be sent to the peer with the given node_id.
3080 /// The node_id of the node which should receive this message
3081 node_id: crate::c_types::PublicKey,
3082 /// The message which should be sent.
3083 msg: crate::lightning::ln::msgs::Shutdown,
3085 /// Used to indicate that a channel_reestablish message should be sent to the peer with the given node_id.
3086 SendChannelReestablish {
3087 /// The node_id of the node which should receive this message
3088 node_id: crate::c_types::PublicKey,
3089 /// The message which should be sent.
3090 msg: crate::lightning::ln::msgs::ChannelReestablish,
3092 /// Used to send a channel_announcement and channel_update to a specific peer, likely on
3093 /// initial connection to ensure our peers know about our channels.
3094 SendChannelAnnouncement {
3095 /// The node_id of the node which should receive this message
3096 node_id: crate::c_types::PublicKey,
3097 /// The channel_announcement which should be sent.
3098 msg: crate::lightning::ln::msgs::ChannelAnnouncement,
3099 /// The followup channel_update which should be sent.
3100 update_msg: crate::lightning::ln::msgs::ChannelUpdate,
3102 /// Used to indicate that a channel_announcement and channel_update should be broadcast to all
3103 /// peers (except the peer with node_id either msg.contents.node_id_1 or msg.contents.node_id_2).
3105 /// Note that after doing so, you very likely (unless you did so very recently) want to
3106 /// broadcast a node_announcement (e.g. via [`PeerManager::broadcast_node_announcement`]). This
3107 /// ensures that any nodes which see our channel_announcement also have a relevant
3108 /// node_announcement, including relevant feature flags which may be important for routing
3109 /// through or to us.
3111 /// [`PeerManager::broadcast_node_announcement`]: crate::ln::peer_handler::PeerManager::broadcast_node_announcement
3112 BroadcastChannelAnnouncement {
3113 /// The channel_announcement which should be sent.
3114 msg: crate::lightning::ln::msgs::ChannelAnnouncement,
3115 /// The followup channel_update which should be sent.
3117 /// Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None
3118 update_msg: crate::lightning::ln::msgs::ChannelUpdate,
3120 /// Used to indicate that a channel_update should be broadcast to all peers.
3121 BroadcastChannelUpdate {
3122 /// The channel_update which should be sent.
3123 msg: crate::lightning::ln::msgs::ChannelUpdate,
3125 /// Used to indicate that a node_announcement should be broadcast to all peers.
3126 BroadcastNodeAnnouncement {
3127 /// The node_announcement which should be sent.
3128 msg: crate::lightning::ln::msgs::NodeAnnouncement,
3130 /// Used to indicate that a channel_update should be sent to a single peer.
3131 /// In contrast to [`Self::BroadcastChannelUpdate`], this is used when the channel is a
3132 /// private channel and we shouldn't be informing all of our peers of channel parameters.
3134 /// The node_id of the node which should receive this message
3135 node_id: crate::c_types::PublicKey,
3136 /// The channel_update which should be sent.
3137 msg: crate::lightning::ln::msgs::ChannelUpdate,
3139 /// Broadcast an error downstream to be handled
3141 /// The node_id of the node which should receive this message
3142 node_id: crate::c_types::PublicKey,
3143 /// The action which should be taken.
3144 action: crate::lightning::ln::msgs::ErrorAction,
3146 /// Query a peer for channels with funding transaction UTXOs in a block range.
3147 SendChannelRangeQuery {
3148 /// The node_id of this message recipient
3149 node_id: crate::c_types::PublicKey,
3150 /// The query_channel_range which should be sent.
3151 msg: crate::lightning::ln::msgs::QueryChannelRange,
3153 /// Request routing gossip messages from a peer for a list of channels identified by
3154 /// their short_channel_ids.
3156 /// The node_id of this message recipient
3157 node_id: crate::c_types::PublicKey,
3158 /// The query_short_channel_ids which should be sent.
3159 msg: crate::lightning::ln::msgs::QueryShortChannelIds,
3161 /// Sends a reply to a channel range query. This may be one of several SendReplyChannelRange events
3162 /// emitted during processing of the query.
3163 SendReplyChannelRange {
3164 /// The node_id of this message recipient
3165 node_id: crate::c_types::PublicKey,
3166 /// The reply_channel_range which should be sent.
3167 msg: crate::lightning::ln::msgs::ReplyChannelRange,
3169 /// Sends a timestamp filter for inbound gossip. This should be sent on each new connection to
3170 /// enable receiving gossip messages from the peer.
3171 SendGossipTimestampFilter {
3172 /// The node_id of this message recipient
3173 node_id: crate::c_types::PublicKey,
3174 /// The gossip_timestamp_filter which should be sent.
3175 msg: crate::lightning::ln::msgs::GossipTimestampFilter,
3178 use lightning::events::MessageSendEvent as MessageSendEventImport;
3179 pub(crate) type nativeMessageSendEvent = MessageSendEventImport;
3181 impl MessageSendEvent {
3183 pub(crate) fn to_native(&self) -> nativeMessageSendEvent {
3185 MessageSendEvent::SendAcceptChannel {ref node_id, ref msg, } => {
3186 let mut node_id_nonref = Clone::clone(node_id);
3187 let mut msg_nonref = Clone::clone(msg);
3188 nativeMessageSendEvent::SendAcceptChannel {
3189 node_id: node_id_nonref.into_rust(),
3190 msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) },
3193 MessageSendEvent::SendAcceptChannelV2 {ref node_id, ref msg, } => {
3194 let mut node_id_nonref = Clone::clone(node_id);
3195 let mut msg_nonref = Clone::clone(msg);
3196 nativeMessageSendEvent::SendAcceptChannelV2 {
3197 node_id: node_id_nonref.into_rust(),
3198 msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) },
3201 MessageSendEvent::SendOpenChannel {ref node_id, ref msg, } => {
3202 let mut node_id_nonref = Clone::clone(node_id);
3203 let mut msg_nonref = Clone::clone(msg);
3204 nativeMessageSendEvent::SendOpenChannel {
3205 node_id: node_id_nonref.into_rust(),
3206 msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) },
3209 MessageSendEvent::SendOpenChannelV2 {ref node_id, ref msg, } => {
3210 let mut node_id_nonref = Clone::clone(node_id);
3211 let mut msg_nonref = Clone::clone(msg);
3212 nativeMessageSendEvent::SendOpenChannelV2 {
3213 node_id: node_id_nonref.into_rust(),
3214 msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) },
3217 MessageSendEvent::SendFundingCreated {ref node_id, ref msg, } => {
3218 let mut node_id_nonref = Clone::clone(node_id);
3219 let mut msg_nonref = Clone::clone(msg);
3220 nativeMessageSendEvent::SendFundingCreated {
3221 node_id: node_id_nonref.into_rust(),
3222 msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) },
3225 MessageSendEvent::SendFundingSigned {ref node_id, ref msg, } => {
3226 let mut node_id_nonref = Clone::clone(node_id);
3227 let mut msg_nonref = Clone::clone(msg);
3228 nativeMessageSendEvent::SendFundingSigned {
3229 node_id: node_id_nonref.into_rust(),
3230 msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) },
3233 MessageSendEvent::SendTxAddInput {ref node_id, ref msg, } => {
3234 let mut node_id_nonref = Clone::clone(node_id);
3235 let mut msg_nonref = Clone::clone(msg);
3236 nativeMessageSendEvent::SendTxAddInput {
3237 node_id: node_id_nonref.into_rust(),
3238 msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) },
3241 MessageSendEvent::SendTxAddOutput {ref node_id, ref msg, } => {
3242 let mut node_id_nonref = Clone::clone(node_id);
3243 let mut msg_nonref = Clone::clone(msg);
3244 nativeMessageSendEvent::SendTxAddOutput {
3245 node_id: node_id_nonref.into_rust(),
3246 msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) },
3249 MessageSendEvent::SendTxRemoveInput {ref node_id, ref msg, } => {
3250 let mut node_id_nonref = Clone::clone(node_id);
3251 let mut msg_nonref = Clone::clone(msg);
3252 nativeMessageSendEvent::SendTxRemoveInput {
3253 node_id: node_id_nonref.into_rust(),
3254 msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) },
3257 MessageSendEvent::SendTxRemoveOutput {ref node_id, ref msg, } => {
3258 let mut node_id_nonref = Clone::clone(node_id);
3259 let mut msg_nonref = Clone::clone(msg);
3260 nativeMessageSendEvent::SendTxRemoveOutput {
3261 node_id: node_id_nonref.into_rust(),
3262 msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) },
3265 MessageSendEvent::SendTxComplete {ref node_id, ref msg, } => {
3266 let mut node_id_nonref = Clone::clone(node_id);
3267 let mut msg_nonref = Clone::clone(msg);
3268 nativeMessageSendEvent::SendTxComplete {
3269 node_id: node_id_nonref.into_rust(),
3270 msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) },
3273 MessageSendEvent::SendTxSignatures {ref node_id, ref msg, } => {
3274 let mut node_id_nonref = Clone::clone(node_id);
3275 let mut msg_nonref = Clone::clone(msg);
3276 nativeMessageSendEvent::SendTxSignatures {
3277 node_id: node_id_nonref.into_rust(),
3278 msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) },
3281 MessageSendEvent::SendTxInitRbf {ref node_id, ref msg, } => {
3282 let mut node_id_nonref = Clone::clone(node_id);
3283 let mut msg_nonref = Clone::clone(msg);
3284 nativeMessageSendEvent::SendTxInitRbf {
3285 node_id: node_id_nonref.into_rust(),
3286 msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) },
3289 MessageSendEvent::SendTxAckRbf {ref node_id, ref msg, } => {
3290 let mut node_id_nonref = Clone::clone(node_id);
3291 let mut msg_nonref = Clone::clone(msg);
3292 nativeMessageSendEvent::SendTxAckRbf {
3293 node_id: node_id_nonref.into_rust(),
3294 msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) },
3297 MessageSendEvent::SendTxAbort {ref node_id, ref msg, } => {
3298 let mut node_id_nonref = Clone::clone(node_id);
3299 let mut msg_nonref = Clone::clone(msg);
3300 nativeMessageSendEvent::SendTxAbort {
3301 node_id: node_id_nonref.into_rust(),
3302 msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) },
3305 MessageSendEvent::SendChannelReady {ref node_id, ref msg, } => {
3306 let mut node_id_nonref = Clone::clone(node_id);
3307 let mut msg_nonref = Clone::clone(msg);
3308 nativeMessageSendEvent::SendChannelReady {
3309 node_id: node_id_nonref.into_rust(),
3310 msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) },
3313 MessageSendEvent::SendAnnouncementSignatures {ref node_id, ref msg, } => {
3314 let mut node_id_nonref = Clone::clone(node_id);
3315 let mut msg_nonref = Clone::clone(msg);
3316 nativeMessageSendEvent::SendAnnouncementSignatures {
3317 node_id: node_id_nonref.into_rust(),
3318 msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) },
3321 MessageSendEvent::UpdateHTLCs {ref node_id, ref updates, } => {
3322 let mut node_id_nonref = Clone::clone(node_id);
3323 let mut updates_nonref = Clone::clone(updates);
3324 nativeMessageSendEvent::UpdateHTLCs {
3325 node_id: node_id_nonref.into_rust(),
3326 updates: *unsafe { Box::from_raw(updates_nonref.take_inner()) },
3329 MessageSendEvent::SendRevokeAndACK {ref node_id, ref msg, } => {
3330 let mut node_id_nonref = Clone::clone(node_id);
3331 let mut msg_nonref = Clone::clone(msg);
3332 nativeMessageSendEvent::SendRevokeAndACK {
3333 node_id: node_id_nonref.into_rust(),
3334 msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) },
3337 MessageSendEvent::SendClosingSigned {ref node_id, ref msg, } => {
3338 let mut node_id_nonref = Clone::clone(node_id);
3339 let mut msg_nonref = Clone::clone(msg);
3340 nativeMessageSendEvent::SendClosingSigned {
3341 node_id: node_id_nonref.into_rust(),
3342 msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) },
3345 MessageSendEvent::SendShutdown {ref node_id, ref msg, } => {
3346 let mut node_id_nonref = Clone::clone(node_id);
3347 let mut msg_nonref = Clone::clone(msg);
3348 nativeMessageSendEvent::SendShutdown {
3349 node_id: node_id_nonref.into_rust(),
3350 msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) },
3353 MessageSendEvent::SendChannelReestablish {ref node_id, ref msg, } => {
3354 let mut node_id_nonref = Clone::clone(node_id);
3355 let mut msg_nonref = Clone::clone(msg);
3356 nativeMessageSendEvent::SendChannelReestablish {
3357 node_id: node_id_nonref.into_rust(),
3358 msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) },
3361 MessageSendEvent::SendChannelAnnouncement {ref node_id, ref msg, ref update_msg, } => {
3362 let mut node_id_nonref = Clone::clone(node_id);
3363 let mut msg_nonref = Clone::clone(msg);
3364 let mut update_msg_nonref = Clone::clone(update_msg);
3365 nativeMessageSendEvent::SendChannelAnnouncement {
3366 node_id: node_id_nonref.into_rust(),
3367 msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) },
3368 update_msg: *unsafe { Box::from_raw(update_msg_nonref.take_inner()) },
3371 MessageSendEvent::BroadcastChannelAnnouncement {ref msg, ref update_msg, } => {
3372 let mut msg_nonref = Clone::clone(msg);
3373 let mut update_msg_nonref = Clone::clone(update_msg);
3374 let mut local_update_msg_nonref = if update_msg_nonref.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(update_msg_nonref.take_inner()) } }) };
3375 nativeMessageSendEvent::BroadcastChannelAnnouncement {
3376 msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) },
3377 update_msg: local_update_msg_nonref,
3380 MessageSendEvent::BroadcastChannelUpdate {ref msg, } => {
3381 let mut msg_nonref = Clone::clone(msg);
3382 nativeMessageSendEvent::BroadcastChannelUpdate {
3383 msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) },
3386 MessageSendEvent::BroadcastNodeAnnouncement {ref msg, } => {
3387 let mut msg_nonref = Clone::clone(msg);
3388 nativeMessageSendEvent::BroadcastNodeAnnouncement {
3389 msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) },
3392 MessageSendEvent::SendChannelUpdate {ref node_id, ref msg, } => {
3393 let mut node_id_nonref = Clone::clone(node_id);
3394 let mut msg_nonref = Clone::clone(msg);
3395 nativeMessageSendEvent::SendChannelUpdate {
3396 node_id: node_id_nonref.into_rust(),
3397 msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) },
3400 MessageSendEvent::HandleError {ref node_id, ref action, } => {
3401 let mut node_id_nonref = Clone::clone(node_id);
3402 let mut action_nonref = Clone::clone(action);
3403 nativeMessageSendEvent::HandleError {
3404 node_id: node_id_nonref.into_rust(),
3405 action: action_nonref.into_native(),
3408 MessageSendEvent::SendChannelRangeQuery {ref node_id, ref msg, } => {
3409 let mut node_id_nonref = Clone::clone(node_id);
3410 let mut msg_nonref = Clone::clone(msg);
3411 nativeMessageSendEvent::SendChannelRangeQuery {
3412 node_id: node_id_nonref.into_rust(),
3413 msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) },
3416 MessageSendEvent::SendShortIdsQuery {ref node_id, ref msg, } => {
3417 let mut node_id_nonref = Clone::clone(node_id);
3418 let mut msg_nonref = Clone::clone(msg);
3419 nativeMessageSendEvent::SendShortIdsQuery {
3420 node_id: node_id_nonref.into_rust(),
3421 msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) },
3424 MessageSendEvent::SendReplyChannelRange {ref node_id, ref msg, } => {
3425 let mut node_id_nonref = Clone::clone(node_id);
3426 let mut msg_nonref = Clone::clone(msg);
3427 nativeMessageSendEvent::SendReplyChannelRange {
3428 node_id: node_id_nonref.into_rust(),
3429 msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) },
3432 MessageSendEvent::SendGossipTimestampFilter {ref node_id, ref msg, } => {
3433 let mut node_id_nonref = Clone::clone(node_id);
3434 let mut msg_nonref = Clone::clone(msg);
3435 nativeMessageSendEvent::SendGossipTimestampFilter {
3436 node_id: node_id_nonref.into_rust(),
3437 msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) },
3443 pub(crate) fn into_native(self) -> nativeMessageSendEvent {
3445 MessageSendEvent::SendAcceptChannel {mut node_id, mut msg, } => {
3446 nativeMessageSendEvent::SendAcceptChannel {
3447 node_id: node_id.into_rust(),
3448 msg: *unsafe { Box::from_raw(msg.take_inner()) },
3451 MessageSendEvent::SendAcceptChannelV2 {mut node_id, mut msg, } => {
3452 nativeMessageSendEvent::SendAcceptChannelV2 {
3453 node_id: node_id.into_rust(),
3454 msg: *unsafe { Box::from_raw(msg.take_inner()) },
3457 MessageSendEvent::SendOpenChannel {mut node_id, mut msg, } => {
3458 nativeMessageSendEvent::SendOpenChannel {
3459 node_id: node_id.into_rust(),
3460 msg: *unsafe { Box::from_raw(msg.take_inner()) },
3463 MessageSendEvent::SendOpenChannelV2 {mut node_id, mut msg, } => {
3464 nativeMessageSendEvent::SendOpenChannelV2 {
3465 node_id: node_id.into_rust(),
3466 msg: *unsafe { Box::from_raw(msg.take_inner()) },
3469 MessageSendEvent::SendFundingCreated {mut node_id, mut msg, } => {
3470 nativeMessageSendEvent::SendFundingCreated {
3471 node_id: node_id.into_rust(),
3472 msg: *unsafe { Box::from_raw(msg.take_inner()) },
3475 MessageSendEvent::SendFundingSigned {mut node_id, mut msg, } => {
3476 nativeMessageSendEvent::SendFundingSigned {
3477 node_id: node_id.into_rust(),
3478 msg: *unsafe { Box::from_raw(msg.take_inner()) },
3481 MessageSendEvent::SendTxAddInput {mut node_id, mut msg, } => {
3482 nativeMessageSendEvent::SendTxAddInput {
3483 node_id: node_id.into_rust(),
3484 msg: *unsafe { Box::from_raw(msg.take_inner()) },
3487 MessageSendEvent::SendTxAddOutput {mut node_id, mut msg, } => {
3488 nativeMessageSendEvent::SendTxAddOutput {
3489 node_id: node_id.into_rust(),
3490 msg: *unsafe { Box::from_raw(msg.take_inner()) },
3493 MessageSendEvent::SendTxRemoveInput {mut node_id, mut msg, } => {
3494 nativeMessageSendEvent::SendTxRemoveInput {
3495 node_id: node_id.into_rust(),
3496 msg: *unsafe { Box::from_raw(msg.take_inner()) },
3499 MessageSendEvent::SendTxRemoveOutput {mut node_id, mut msg, } => {
3500 nativeMessageSendEvent::SendTxRemoveOutput {
3501 node_id: node_id.into_rust(),
3502 msg: *unsafe { Box::from_raw(msg.take_inner()) },
3505 MessageSendEvent::SendTxComplete {mut node_id, mut msg, } => {
3506 nativeMessageSendEvent::SendTxComplete {
3507 node_id: node_id.into_rust(),
3508 msg: *unsafe { Box::from_raw(msg.take_inner()) },
3511 MessageSendEvent::SendTxSignatures {mut node_id, mut msg, } => {
3512 nativeMessageSendEvent::SendTxSignatures {
3513 node_id: node_id.into_rust(),
3514 msg: *unsafe { Box::from_raw(msg.take_inner()) },
3517 MessageSendEvent::SendTxInitRbf {mut node_id, mut msg, } => {
3518 nativeMessageSendEvent::SendTxInitRbf {
3519 node_id: node_id.into_rust(),
3520 msg: *unsafe { Box::from_raw(msg.take_inner()) },
3523 MessageSendEvent::SendTxAckRbf {mut node_id, mut msg, } => {
3524 nativeMessageSendEvent::SendTxAckRbf {
3525 node_id: node_id.into_rust(),
3526 msg: *unsafe { Box::from_raw(msg.take_inner()) },
3529 MessageSendEvent::SendTxAbort {mut node_id, mut msg, } => {
3530 nativeMessageSendEvent::SendTxAbort {
3531 node_id: node_id.into_rust(),
3532 msg: *unsafe { Box::from_raw(msg.take_inner()) },
3535 MessageSendEvent::SendChannelReady {mut node_id, mut msg, } => {
3536 nativeMessageSendEvent::SendChannelReady {
3537 node_id: node_id.into_rust(),
3538 msg: *unsafe { Box::from_raw(msg.take_inner()) },
3541 MessageSendEvent::SendAnnouncementSignatures {mut node_id, mut msg, } => {
3542 nativeMessageSendEvent::SendAnnouncementSignatures {
3543 node_id: node_id.into_rust(),
3544 msg: *unsafe { Box::from_raw(msg.take_inner()) },
3547 MessageSendEvent::UpdateHTLCs {mut node_id, mut updates, } => {
3548 nativeMessageSendEvent::UpdateHTLCs {
3549 node_id: node_id.into_rust(),
3550 updates: *unsafe { Box::from_raw(updates.take_inner()) },
3553 MessageSendEvent::SendRevokeAndACK {mut node_id, mut msg, } => {
3554 nativeMessageSendEvent::SendRevokeAndACK {
3555 node_id: node_id.into_rust(),
3556 msg: *unsafe { Box::from_raw(msg.take_inner()) },
3559 MessageSendEvent::SendClosingSigned {mut node_id, mut msg, } => {
3560 nativeMessageSendEvent::SendClosingSigned {
3561 node_id: node_id.into_rust(),
3562 msg: *unsafe { Box::from_raw(msg.take_inner()) },
3565 MessageSendEvent::SendShutdown {mut node_id, mut msg, } => {
3566 nativeMessageSendEvent::SendShutdown {
3567 node_id: node_id.into_rust(),
3568 msg: *unsafe { Box::from_raw(msg.take_inner()) },
3571 MessageSendEvent::SendChannelReestablish {mut node_id, mut msg, } => {
3572 nativeMessageSendEvent::SendChannelReestablish {
3573 node_id: node_id.into_rust(),
3574 msg: *unsafe { Box::from_raw(msg.take_inner()) },
3577 MessageSendEvent::SendChannelAnnouncement {mut node_id, mut msg, mut update_msg, } => {
3578 nativeMessageSendEvent::SendChannelAnnouncement {
3579 node_id: node_id.into_rust(),
3580 msg: *unsafe { Box::from_raw(msg.take_inner()) },
3581 update_msg: *unsafe { Box::from_raw(update_msg.take_inner()) },
3584 MessageSendEvent::BroadcastChannelAnnouncement {mut msg, mut update_msg, } => {
3585 let mut local_update_msg = if update_msg.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(update_msg.take_inner()) } }) };
3586 nativeMessageSendEvent::BroadcastChannelAnnouncement {
3587 msg: *unsafe { Box::from_raw(msg.take_inner()) },
3588 update_msg: local_update_msg,
3591 MessageSendEvent::BroadcastChannelUpdate {mut msg, } => {
3592 nativeMessageSendEvent::BroadcastChannelUpdate {
3593 msg: *unsafe { Box::from_raw(msg.take_inner()) },
3596 MessageSendEvent::BroadcastNodeAnnouncement {mut msg, } => {
3597 nativeMessageSendEvent::BroadcastNodeAnnouncement {
3598 msg: *unsafe { Box::from_raw(msg.take_inner()) },
3601 MessageSendEvent::SendChannelUpdate {mut node_id, mut msg, } => {
3602 nativeMessageSendEvent::SendChannelUpdate {
3603 node_id: node_id.into_rust(),
3604 msg: *unsafe { Box::from_raw(msg.take_inner()) },
3607 MessageSendEvent::HandleError {mut node_id, mut action, } => {
3608 nativeMessageSendEvent::HandleError {
3609 node_id: node_id.into_rust(),
3610 action: action.into_native(),
3613 MessageSendEvent::SendChannelRangeQuery {mut node_id, mut msg, } => {
3614 nativeMessageSendEvent::SendChannelRangeQuery {
3615 node_id: node_id.into_rust(),
3616 msg: *unsafe { Box::from_raw(msg.take_inner()) },
3619 MessageSendEvent::SendShortIdsQuery {mut node_id, mut msg, } => {
3620 nativeMessageSendEvent::SendShortIdsQuery {
3621 node_id: node_id.into_rust(),
3622 msg: *unsafe { Box::from_raw(msg.take_inner()) },
3625 MessageSendEvent::SendReplyChannelRange {mut node_id, mut msg, } => {
3626 nativeMessageSendEvent::SendReplyChannelRange {
3627 node_id: node_id.into_rust(),
3628 msg: *unsafe { Box::from_raw(msg.take_inner()) },
3631 MessageSendEvent::SendGossipTimestampFilter {mut node_id, mut msg, } => {
3632 nativeMessageSendEvent::SendGossipTimestampFilter {
3633 node_id: node_id.into_rust(),
3634 msg: *unsafe { Box::from_raw(msg.take_inner()) },
3640 pub(crate) fn from_native(native: &nativeMessageSendEvent) -> Self {
3642 nativeMessageSendEvent::SendAcceptChannel {ref node_id, ref msg, } => {
3643 let mut node_id_nonref = Clone::clone(node_id);
3644 let mut msg_nonref = Clone::clone(msg);
3645 MessageSendEvent::SendAcceptChannel {
3646 node_id: crate::c_types::PublicKey::from_rust(&node_id_nonref),
3647 msg: crate::lightning::ln::msgs::AcceptChannel { inner: ObjOps::heap_alloc(msg_nonref), is_owned: true },
3650 nativeMessageSendEvent::SendAcceptChannelV2 {ref node_id, ref msg, } => {
3651 let mut node_id_nonref = Clone::clone(node_id);
3652 let mut msg_nonref = Clone::clone(msg);
3653 MessageSendEvent::SendAcceptChannelV2 {
3654 node_id: crate::c_types::PublicKey::from_rust(&node_id_nonref),
3655 msg: crate::lightning::ln::msgs::AcceptChannelV2 { inner: ObjOps::heap_alloc(msg_nonref), is_owned: true },
3658 nativeMessageSendEvent::SendOpenChannel {ref node_id, ref msg, } => {
3659 let mut node_id_nonref = Clone::clone(node_id);
3660 let mut msg_nonref = Clone::clone(msg);
3661 MessageSendEvent::SendOpenChannel {
3662 node_id: crate::c_types::PublicKey::from_rust(&node_id_nonref),
3663 msg: crate::lightning::ln::msgs::OpenChannel { inner: ObjOps::heap_alloc(msg_nonref), is_owned: true },
3666 nativeMessageSendEvent::SendOpenChannelV2 {ref node_id, ref msg, } => {
3667 let mut node_id_nonref = Clone::clone(node_id);
3668 let mut msg_nonref = Clone::clone(msg);
3669 MessageSendEvent::SendOpenChannelV2 {
3670 node_id: crate::c_types::PublicKey::from_rust(&node_id_nonref),
3671 msg: crate::lightning::ln::msgs::OpenChannelV2 { inner: ObjOps::heap_alloc(msg_nonref), is_owned: true },
3674 nativeMessageSendEvent::SendFundingCreated {ref node_id, ref msg, } => {
3675 let mut node_id_nonref = Clone::clone(node_id);
3676 let mut msg_nonref = Clone::clone(msg);
3677 MessageSendEvent::SendFundingCreated {
3678 node_id: crate::c_types::PublicKey::from_rust(&node_id_nonref),
3679 msg: crate::lightning::ln::msgs::FundingCreated { inner: ObjOps::heap_alloc(msg_nonref), is_owned: true },
3682 nativeMessageSendEvent::SendFundingSigned {ref node_id, ref msg, } => {
3683 let mut node_id_nonref = Clone::clone(node_id);
3684 let mut msg_nonref = Clone::clone(msg);
3685 MessageSendEvent::SendFundingSigned {
3686 node_id: crate::c_types::PublicKey::from_rust(&node_id_nonref),
3687 msg: crate::lightning::ln::msgs::FundingSigned { inner: ObjOps::heap_alloc(msg_nonref), is_owned: true },
3690 nativeMessageSendEvent::SendTxAddInput {ref node_id, ref msg, } => {
3691 let mut node_id_nonref = Clone::clone(node_id);
3692 let mut msg_nonref = Clone::clone(msg);
3693 MessageSendEvent::SendTxAddInput {
3694 node_id: crate::c_types::PublicKey::from_rust(&node_id_nonref),
3695 msg: crate::lightning::ln::msgs::TxAddInput { inner: ObjOps::heap_alloc(msg_nonref), is_owned: true },
3698 nativeMessageSendEvent::SendTxAddOutput {ref node_id, ref msg, } => {
3699 let mut node_id_nonref = Clone::clone(node_id);
3700 let mut msg_nonref = Clone::clone(msg);
3701 MessageSendEvent::SendTxAddOutput {
3702 node_id: crate::c_types::PublicKey::from_rust(&node_id_nonref),
3703 msg: crate::lightning::ln::msgs::TxAddOutput { inner: ObjOps::heap_alloc(msg_nonref), is_owned: true },
3706 nativeMessageSendEvent::SendTxRemoveInput {ref node_id, ref msg, } => {
3707 let mut node_id_nonref = Clone::clone(node_id);
3708 let mut msg_nonref = Clone::clone(msg);
3709 MessageSendEvent::SendTxRemoveInput {
3710 node_id: crate::c_types::PublicKey::from_rust(&node_id_nonref),
3711 msg: crate::lightning::ln::msgs::TxRemoveInput { inner: ObjOps::heap_alloc(msg_nonref), is_owned: true },
3714 nativeMessageSendEvent::SendTxRemoveOutput {ref node_id, ref msg, } => {
3715 let mut node_id_nonref = Clone::clone(node_id);
3716 let mut msg_nonref = Clone::clone(msg);
3717 MessageSendEvent::SendTxRemoveOutput {
3718 node_id: crate::c_types::PublicKey::from_rust(&node_id_nonref),
3719 msg: crate::lightning::ln::msgs::TxRemoveOutput { inner: ObjOps::heap_alloc(msg_nonref), is_owned: true },
3722 nativeMessageSendEvent::SendTxComplete {ref node_id, ref msg, } => {
3723 let mut node_id_nonref = Clone::clone(node_id);
3724 let mut msg_nonref = Clone::clone(msg);
3725 MessageSendEvent::SendTxComplete {
3726 node_id: crate::c_types::PublicKey::from_rust(&node_id_nonref),
3727 msg: crate::lightning::ln::msgs::TxComplete { inner: ObjOps::heap_alloc(msg_nonref), is_owned: true },
3730 nativeMessageSendEvent::SendTxSignatures {ref node_id, ref msg, } => {
3731 let mut node_id_nonref = Clone::clone(node_id);
3732 let mut msg_nonref = Clone::clone(msg);
3733 MessageSendEvent::SendTxSignatures {
3734 node_id: crate::c_types::PublicKey::from_rust(&node_id_nonref),
3735 msg: crate::lightning::ln::msgs::TxSignatures { inner: ObjOps::heap_alloc(msg_nonref), is_owned: true },
3738 nativeMessageSendEvent::SendTxInitRbf {ref node_id, ref msg, } => {
3739 let mut node_id_nonref = Clone::clone(node_id);
3740 let mut msg_nonref = Clone::clone(msg);
3741 MessageSendEvent::SendTxInitRbf {
3742 node_id: crate::c_types::PublicKey::from_rust(&node_id_nonref),
3743 msg: crate::lightning::ln::msgs::TxInitRbf { inner: ObjOps::heap_alloc(msg_nonref), is_owned: true },
3746 nativeMessageSendEvent::SendTxAckRbf {ref node_id, ref msg, } => {
3747 let mut node_id_nonref = Clone::clone(node_id);
3748 let mut msg_nonref = Clone::clone(msg);
3749 MessageSendEvent::SendTxAckRbf {
3750 node_id: crate::c_types::PublicKey::from_rust(&node_id_nonref),
3751 msg: crate::lightning::ln::msgs::TxAckRbf { inner: ObjOps::heap_alloc(msg_nonref), is_owned: true },
3754 nativeMessageSendEvent::SendTxAbort {ref node_id, ref msg, } => {
3755 let mut node_id_nonref = Clone::clone(node_id);
3756 let mut msg_nonref = Clone::clone(msg);
3757 MessageSendEvent::SendTxAbort {
3758 node_id: crate::c_types::PublicKey::from_rust(&node_id_nonref),
3759 msg: crate::lightning::ln::msgs::TxAbort { inner: ObjOps::heap_alloc(msg_nonref), is_owned: true },
3762 nativeMessageSendEvent::SendChannelReady {ref node_id, ref msg, } => {
3763 let mut node_id_nonref = Clone::clone(node_id);
3764 let mut msg_nonref = Clone::clone(msg);
3765 MessageSendEvent::SendChannelReady {
3766 node_id: crate::c_types::PublicKey::from_rust(&node_id_nonref),
3767 msg: crate::lightning::ln::msgs::ChannelReady { inner: ObjOps::heap_alloc(msg_nonref), is_owned: true },
3770 nativeMessageSendEvent::SendAnnouncementSignatures {ref node_id, ref msg, } => {
3771 let mut node_id_nonref = Clone::clone(node_id);
3772 let mut msg_nonref = Clone::clone(msg);
3773 MessageSendEvent::SendAnnouncementSignatures {
3774 node_id: crate::c_types::PublicKey::from_rust(&node_id_nonref),
3775 msg: crate::lightning::ln::msgs::AnnouncementSignatures { inner: ObjOps::heap_alloc(msg_nonref), is_owned: true },
3778 nativeMessageSendEvent::UpdateHTLCs {ref node_id, ref updates, } => {
3779 let mut node_id_nonref = Clone::clone(node_id);
3780 let mut updates_nonref = Clone::clone(updates);
3781 MessageSendEvent::UpdateHTLCs {
3782 node_id: crate::c_types::PublicKey::from_rust(&node_id_nonref),
3783 updates: crate::lightning::ln::msgs::CommitmentUpdate { inner: ObjOps::heap_alloc(updates_nonref), is_owned: true },
3786 nativeMessageSendEvent::SendRevokeAndACK {ref node_id, ref msg, } => {
3787 let mut node_id_nonref = Clone::clone(node_id);
3788 let mut msg_nonref = Clone::clone(msg);
3789 MessageSendEvent::SendRevokeAndACK {
3790 node_id: crate::c_types::PublicKey::from_rust(&node_id_nonref),
3791 msg: crate::lightning::ln::msgs::RevokeAndACK { inner: ObjOps::heap_alloc(msg_nonref), is_owned: true },
3794 nativeMessageSendEvent::SendClosingSigned {ref node_id, ref msg, } => {
3795 let mut node_id_nonref = Clone::clone(node_id);
3796 let mut msg_nonref = Clone::clone(msg);
3797 MessageSendEvent::SendClosingSigned {
3798 node_id: crate::c_types::PublicKey::from_rust(&node_id_nonref),
3799 msg: crate::lightning::ln::msgs::ClosingSigned { inner: ObjOps::heap_alloc(msg_nonref), is_owned: true },
3802 nativeMessageSendEvent::SendShutdown {ref node_id, ref msg, } => {
3803 let mut node_id_nonref = Clone::clone(node_id);
3804 let mut msg_nonref = Clone::clone(msg);
3805 MessageSendEvent::SendShutdown {
3806 node_id: crate::c_types::PublicKey::from_rust(&node_id_nonref),
3807 msg: crate::lightning::ln::msgs::Shutdown { inner: ObjOps::heap_alloc(msg_nonref), is_owned: true },
3810 nativeMessageSendEvent::SendChannelReestablish {ref node_id, ref msg, } => {
3811 let mut node_id_nonref = Clone::clone(node_id);
3812 let mut msg_nonref = Clone::clone(msg);
3813 MessageSendEvent::SendChannelReestablish {
3814 node_id: crate::c_types::PublicKey::from_rust(&node_id_nonref),
3815 msg: crate::lightning::ln::msgs::ChannelReestablish { inner: ObjOps::heap_alloc(msg_nonref), is_owned: true },
3818 nativeMessageSendEvent::SendChannelAnnouncement {ref node_id, ref msg, ref update_msg, } => {
3819 let mut node_id_nonref = Clone::clone(node_id);
3820 let mut msg_nonref = Clone::clone(msg);
3821 let mut update_msg_nonref = Clone::clone(update_msg);
3822 MessageSendEvent::SendChannelAnnouncement {
3823 node_id: crate::c_types::PublicKey::from_rust(&node_id_nonref),
3824 msg: crate::lightning::ln::msgs::ChannelAnnouncement { inner: ObjOps::heap_alloc(msg_nonref), is_owned: true },
3825 update_msg: crate::lightning::ln::msgs::ChannelUpdate { inner: ObjOps::heap_alloc(update_msg_nonref), is_owned: true },
3828 nativeMessageSendEvent::BroadcastChannelAnnouncement {ref msg, ref update_msg, } => {
3829 let mut msg_nonref = Clone::clone(msg);
3830 let mut update_msg_nonref = Clone::clone(update_msg);
3831 let mut local_update_msg_nonref = crate::lightning::ln::msgs::ChannelUpdate { inner: if update_msg_nonref.is_none() { core::ptr::null_mut() } else { { ObjOps::heap_alloc((update_msg_nonref.unwrap())) } }, is_owned: true };
3832 MessageSendEvent::BroadcastChannelAnnouncement {
3833 msg: crate::lightning::ln::msgs::ChannelAnnouncement { inner: ObjOps::heap_alloc(msg_nonref), is_owned: true },
3834 update_msg: local_update_msg_nonref,
3837 nativeMessageSendEvent::BroadcastChannelUpdate {ref msg, } => {
3838 let mut msg_nonref = Clone::clone(msg);
3839 MessageSendEvent::BroadcastChannelUpdate {
3840 msg: crate::lightning::ln::msgs::ChannelUpdate { inner: ObjOps::heap_alloc(msg_nonref), is_owned: true },
3843 nativeMessageSendEvent::BroadcastNodeAnnouncement {ref msg, } => {
3844 let mut msg_nonref = Clone::clone(msg);
3845 MessageSendEvent::BroadcastNodeAnnouncement {
3846 msg: crate::lightning::ln::msgs::NodeAnnouncement { inner: ObjOps::heap_alloc(msg_nonref), is_owned: true },
3849 nativeMessageSendEvent::SendChannelUpdate {ref node_id, ref msg, } => {
3850 let mut node_id_nonref = Clone::clone(node_id);
3851 let mut msg_nonref = Clone::clone(msg);
3852 MessageSendEvent::SendChannelUpdate {
3853 node_id: crate::c_types::PublicKey::from_rust(&node_id_nonref),
3854 msg: crate::lightning::ln::msgs::ChannelUpdate { inner: ObjOps::heap_alloc(msg_nonref), is_owned: true },
3857 nativeMessageSendEvent::HandleError {ref node_id, ref action, } => {
3858 let mut node_id_nonref = Clone::clone(node_id);
3859 let mut action_nonref = Clone::clone(action);
3860 MessageSendEvent::HandleError {
3861 node_id: crate::c_types::PublicKey::from_rust(&node_id_nonref),
3862 action: crate::lightning::ln::msgs::ErrorAction::native_into(action_nonref),
3865 nativeMessageSendEvent::SendChannelRangeQuery {ref node_id, ref msg, } => {
3866 let mut node_id_nonref = Clone::clone(node_id);
3867 let mut msg_nonref = Clone::clone(msg);
3868 MessageSendEvent::SendChannelRangeQuery {
3869 node_id: crate::c_types::PublicKey::from_rust(&node_id_nonref),
3870 msg: crate::lightning::ln::msgs::QueryChannelRange { inner: ObjOps::heap_alloc(msg_nonref), is_owned: true },
3873 nativeMessageSendEvent::SendShortIdsQuery {ref node_id, ref msg, } => {
3874 let mut node_id_nonref = Clone::clone(node_id);
3875 let mut msg_nonref = Clone::clone(msg);
3876 MessageSendEvent::SendShortIdsQuery {
3877 node_id: crate::c_types::PublicKey::from_rust(&node_id_nonref),
3878 msg: crate::lightning::ln::msgs::QueryShortChannelIds { inner: ObjOps::heap_alloc(msg_nonref), is_owned: true },
3881 nativeMessageSendEvent::SendReplyChannelRange {ref node_id, ref msg, } => {
3882 let mut node_id_nonref = Clone::clone(node_id);
3883 let mut msg_nonref = Clone::clone(msg);
3884 MessageSendEvent::SendReplyChannelRange {
3885 node_id: crate::c_types::PublicKey::from_rust(&node_id_nonref),
3886 msg: crate::lightning::ln::msgs::ReplyChannelRange { inner: ObjOps::heap_alloc(msg_nonref), is_owned: true },
3889 nativeMessageSendEvent::SendGossipTimestampFilter {ref node_id, ref msg, } => {
3890 let mut node_id_nonref = Clone::clone(node_id);
3891 let mut msg_nonref = Clone::clone(msg);
3892 MessageSendEvent::SendGossipTimestampFilter {
3893 node_id: crate::c_types::PublicKey::from_rust(&node_id_nonref),
3894 msg: crate::lightning::ln::msgs::GossipTimestampFilter { inner: ObjOps::heap_alloc(msg_nonref), is_owned: true },
3900 pub(crate) fn native_into(native: nativeMessageSendEvent) -> Self {
3902 nativeMessageSendEvent::SendAcceptChannel {mut node_id, mut msg, } => {
3903 MessageSendEvent::SendAcceptChannel {
3904 node_id: crate::c_types::PublicKey::from_rust(&node_id),
3905 msg: crate::lightning::ln::msgs::AcceptChannel { inner: ObjOps::heap_alloc(msg), is_owned: true },
3908 nativeMessageSendEvent::SendAcceptChannelV2 {mut node_id, mut msg, } => {
3909 MessageSendEvent::SendAcceptChannelV2 {
3910 node_id: crate::c_types::PublicKey::from_rust(&node_id),
3911 msg: crate::lightning::ln::msgs::AcceptChannelV2 { inner: ObjOps::heap_alloc(msg), is_owned: true },
3914 nativeMessageSendEvent::SendOpenChannel {mut node_id, mut msg, } => {
3915 MessageSendEvent::SendOpenChannel {
3916 node_id: crate::c_types::PublicKey::from_rust(&node_id),
3917 msg: crate::lightning::ln::msgs::OpenChannel { inner: ObjOps::heap_alloc(msg), is_owned: true },
3920 nativeMessageSendEvent::SendOpenChannelV2 {mut node_id, mut msg, } => {
3921 MessageSendEvent::SendOpenChannelV2 {
3922 node_id: crate::c_types::PublicKey::from_rust(&node_id),
3923 msg: crate::lightning::ln::msgs::OpenChannelV2 { inner: ObjOps::heap_alloc(msg), is_owned: true },
3926 nativeMessageSendEvent::SendFundingCreated {mut node_id, mut msg, } => {
3927 MessageSendEvent::SendFundingCreated {
3928 node_id: crate::c_types::PublicKey::from_rust(&node_id),
3929 msg: crate::lightning::ln::msgs::FundingCreated { inner: ObjOps::heap_alloc(msg), is_owned: true },
3932 nativeMessageSendEvent::SendFundingSigned {mut node_id, mut msg, } => {
3933 MessageSendEvent::SendFundingSigned {
3934 node_id: crate::c_types::PublicKey::from_rust(&node_id),
3935 msg: crate::lightning::ln::msgs::FundingSigned { inner: ObjOps::heap_alloc(msg), is_owned: true },
3938 nativeMessageSendEvent::SendTxAddInput {mut node_id, mut msg, } => {
3939 MessageSendEvent::SendTxAddInput {
3940 node_id: crate::c_types::PublicKey::from_rust(&node_id),
3941 msg: crate::lightning::ln::msgs::TxAddInput { inner: ObjOps::heap_alloc(msg), is_owned: true },
3944 nativeMessageSendEvent::SendTxAddOutput {mut node_id, mut msg, } => {
3945 MessageSendEvent::SendTxAddOutput {
3946 node_id: crate::c_types::PublicKey::from_rust(&node_id),
3947 msg: crate::lightning::ln::msgs::TxAddOutput { inner: ObjOps::heap_alloc(msg), is_owned: true },
3950 nativeMessageSendEvent::SendTxRemoveInput {mut node_id, mut msg, } => {
3951 MessageSendEvent::SendTxRemoveInput {
3952 node_id: crate::c_types::PublicKey::from_rust(&node_id),
3953 msg: crate::lightning::ln::msgs::TxRemoveInput { inner: ObjOps::heap_alloc(msg), is_owned: true },
3956 nativeMessageSendEvent::SendTxRemoveOutput {mut node_id, mut msg, } => {
3957 MessageSendEvent::SendTxRemoveOutput {
3958 node_id: crate::c_types::PublicKey::from_rust(&node_id),
3959 msg: crate::lightning::ln::msgs::TxRemoveOutput { inner: ObjOps::heap_alloc(msg), is_owned: true },
3962 nativeMessageSendEvent::SendTxComplete {mut node_id, mut msg, } => {
3963 MessageSendEvent::SendTxComplete {
3964 node_id: crate::c_types::PublicKey::from_rust(&node_id),
3965 msg: crate::lightning::ln::msgs::TxComplete { inner: ObjOps::heap_alloc(msg), is_owned: true },
3968 nativeMessageSendEvent::SendTxSignatures {mut node_id, mut msg, } => {
3969 MessageSendEvent::SendTxSignatures {
3970 node_id: crate::c_types::PublicKey::from_rust(&node_id),
3971 msg: crate::lightning::ln::msgs::TxSignatures { inner: ObjOps::heap_alloc(msg), is_owned: true },
3974 nativeMessageSendEvent::SendTxInitRbf {mut node_id, mut msg, } => {
3975 MessageSendEvent::SendTxInitRbf {
3976 node_id: crate::c_types::PublicKey::from_rust(&node_id),
3977 msg: crate::lightning::ln::msgs::TxInitRbf { inner: ObjOps::heap_alloc(msg), is_owned: true },
3980 nativeMessageSendEvent::SendTxAckRbf {mut node_id, mut msg, } => {
3981 MessageSendEvent::SendTxAckRbf {
3982 node_id: crate::c_types::PublicKey::from_rust(&node_id),
3983 msg: crate::lightning::ln::msgs::TxAckRbf { inner: ObjOps::heap_alloc(msg), is_owned: true },
3986 nativeMessageSendEvent::SendTxAbort {mut node_id, mut msg, } => {
3987 MessageSendEvent::SendTxAbort {
3988 node_id: crate::c_types::PublicKey::from_rust(&node_id),
3989 msg: crate::lightning::ln::msgs::TxAbort { inner: ObjOps::heap_alloc(msg), is_owned: true },
3992 nativeMessageSendEvent::SendChannelReady {mut node_id, mut msg, } => {
3993 MessageSendEvent::SendChannelReady {
3994 node_id: crate::c_types::PublicKey::from_rust(&node_id),
3995 msg: crate::lightning::ln::msgs::ChannelReady { inner: ObjOps::heap_alloc(msg), is_owned: true },
3998 nativeMessageSendEvent::SendAnnouncementSignatures {mut node_id, mut msg, } => {
3999 MessageSendEvent::SendAnnouncementSignatures {
4000 node_id: crate::c_types::PublicKey::from_rust(&node_id),
4001 msg: crate::lightning::ln::msgs::AnnouncementSignatures { inner: ObjOps::heap_alloc(msg), is_owned: true },
4004 nativeMessageSendEvent::UpdateHTLCs {mut node_id, mut updates, } => {
4005 MessageSendEvent::UpdateHTLCs {
4006 node_id: crate::c_types::PublicKey::from_rust(&node_id),
4007 updates: crate::lightning::ln::msgs::CommitmentUpdate { inner: ObjOps::heap_alloc(updates), is_owned: true },
4010 nativeMessageSendEvent::SendRevokeAndACK {mut node_id, mut msg, } => {
4011 MessageSendEvent::SendRevokeAndACK {
4012 node_id: crate::c_types::PublicKey::from_rust(&node_id),
4013 msg: crate::lightning::ln::msgs::RevokeAndACK { inner: ObjOps::heap_alloc(msg), is_owned: true },
4016 nativeMessageSendEvent::SendClosingSigned {mut node_id, mut msg, } => {
4017 MessageSendEvent::SendClosingSigned {
4018 node_id: crate::c_types::PublicKey::from_rust(&node_id),
4019 msg: crate::lightning::ln::msgs::ClosingSigned { inner: ObjOps::heap_alloc(msg), is_owned: true },
4022 nativeMessageSendEvent::SendShutdown {mut node_id, mut msg, } => {
4023 MessageSendEvent::SendShutdown {
4024 node_id: crate::c_types::PublicKey::from_rust(&node_id),
4025 msg: crate::lightning::ln::msgs::Shutdown { inner: ObjOps::heap_alloc(msg), is_owned: true },
4028 nativeMessageSendEvent::SendChannelReestablish {mut node_id, mut msg, } => {
4029 MessageSendEvent::SendChannelReestablish {
4030 node_id: crate::c_types::PublicKey::from_rust(&node_id),
4031 msg: crate::lightning::ln::msgs::ChannelReestablish { inner: ObjOps::heap_alloc(msg), is_owned: true },
4034 nativeMessageSendEvent::SendChannelAnnouncement {mut node_id, mut msg, mut update_msg, } => {
4035 MessageSendEvent::SendChannelAnnouncement {
4036 node_id: crate::c_types::PublicKey::from_rust(&node_id),
4037 msg: crate::lightning::ln::msgs::ChannelAnnouncement { inner: ObjOps::heap_alloc(msg), is_owned: true },
4038 update_msg: crate::lightning::ln::msgs::ChannelUpdate { inner: ObjOps::heap_alloc(update_msg), is_owned: true },
4041 nativeMessageSendEvent::BroadcastChannelAnnouncement {mut msg, mut update_msg, } => {
4042 let mut local_update_msg = crate::lightning::ln::msgs::ChannelUpdate { inner: if update_msg.is_none() { core::ptr::null_mut() } else { { ObjOps::heap_alloc((update_msg.unwrap())) } }, is_owned: true };
4043 MessageSendEvent::BroadcastChannelAnnouncement {
4044 msg: crate::lightning::ln::msgs::ChannelAnnouncement { inner: ObjOps::heap_alloc(msg), is_owned: true },
4045 update_msg: local_update_msg,
4048 nativeMessageSendEvent::BroadcastChannelUpdate {mut msg, } => {
4049 MessageSendEvent::BroadcastChannelUpdate {
4050 msg: crate::lightning::ln::msgs::ChannelUpdate { inner: ObjOps::heap_alloc(msg), is_owned: true },
4053 nativeMessageSendEvent::BroadcastNodeAnnouncement {mut msg, } => {
4054 MessageSendEvent::BroadcastNodeAnnouncement {
4055 msg: crate::lightning::ln::msgs::NodeAnnouncement { inner: ObjOps::heap_alloc(msg), is_owned: true },
4058 nativeMessageSendEvent::SendChannelUpdate {mut node_id, mut msg, } => {
4059 MessageSendEvent::SendChannelUpdate {
4060 node_id: crate::c_types::PublicKey::from_rust(&node_id),
4061 msg: crate::lightning::ln::msgs::ChannelUpdate { inner: ObjOps::heap_alloc(msg), is_owned: true },
4064 nativeMessageSendEvent::HandleError {mut node_id, mut action, } => {
4065 MessageSendEvent::HandleError {
4066 node_id: crate::c_types::PublicKey::from_rust(&node_id),
4067 action: crate::lightning::ln::msgs::ErrorAction::native_into(action),
4070 nativeMessageSendEvent::SendChannelRangeQuery {mut node_id, mut msg, } => {
4071 MessageSendEvent::SendChannelRangeQuery {
4072 node_id: crate::c_types::PublicKey::from_rust(&node_id),
4073 msg: crate::lightning::ln::msgs::QueryChannelRange { inner: ObjOps::heap_alloc(msg), is_owned: true },
4076 nativeMessageSendEvent::SendShortIdsQuery {mut node_id, mut msg, } => {
4077 MessageSendEvent::SendShortIdsQuery {
4078 node_id: crate::c_types::PublicKey::from_rust(&node_id),
4079 msg: crate::lightning::ln::msgs::QueryShortChannelIds { inner: ObjOps::heap_alloc(msg), is_owned: true },
4082 nativeMessageSendEvent::SendReplyChannelRange {mut node_id, mut msg, } => {
4083 MessageSendEvent::SendReplyChannelRange {
4084 node_id: crate::c_types::PublicKey::from_rust(&node_id),
4085 msg: crate::lightning::ln::msgs::ReplyChannelRange { inner: ObjOps::heap_alloc(msg), is_owned: true },
4088 nativeMessageSendEvent::SendGossipTimestampFilter {mut node_id, mut msg, } => {
4089 MessageSendEvent::SendGossipTimestampFilter {
4090 node_id: crate::c_types::PublicKey::from_rust(&node_id),
4091 msg: crate::lightning::ln::msgs::GossipTimestampFilter { inner: ObjOps::heap_alloc(msg), is_owned: true },
4097 /// Frees any resources used by the MessageSendEvent
4099 pub extern "C" fn MessageSendEvent_free(this_ptr: MessageSendEvent) { }
4100 /// Creates a copy of the MessageSendEvent
4102 pub extern "C" fn MessageSendEvent_clone(orig: &MessageSendEvent) -> MessageSendEvent {
4106 /// Used only if an object of this type is returned as a trait impl by a method
4107 pub(crate) extern "C" fn MessageSendEvent_clone_void(this_ptr: *const c_void) -> *mut c_void {
4108 Box::into_raw(Box::new(unsafe { (*(this_ptr as *const MessageSendEvent)).clone() })) as *mut c_void
4111 /// Used only if an object of this type is returned as a trait impl by a method
4112 pub(crate) extern "C" fn MessageSendEvent_free_void(this_ptr: *mut c_void) {
4113 let _ = unsafe { Box::from_raw(this_ptr as *mut MessageSendEvent) };
4116 /// Utility method to constructs a new SendAcceptChannel-variant MessageSendEvent
4117 pub extern "C" fn MessageSendEvent_send_accept_channel(node_id: crate::c_types::PublicKey, msg: crate::lightning::ln::msgs::AcceptChannel) -> MessageSendEvent {
4118 MessageSendEvent::SendAcceptChannel {
4124 /// Utility method to constructs a new SendAcceptChannelV2-variant MessageSendEvent
4125 pub extern "C" fn MessageSendEvent_send_accept_channel_v2(node_id: crate::c_types::PublicKey, msg: crate::lightning::ln::msgs::AcceptChannelV2) -> MessageSendEvent {
4126 MessageSendEvent::SendAcceptChannelV2 {
4132 /// Utility method to constructs a new SendOpenChannel-variant MessageSendEvent
4133 pub extern "C" fn MessageSendEvent_send_open_channel(node_id: crate::c_types::PublicKey, msg: crate::lightning::ln::msgs::OpenChannel) -> MessageSendEvent {
4134 MessageSendEvent::SendOpenChannel {
4140 /// Utility method to constructs a new SendOpenChannelV2-variant MessageSendEvent
4141 pub extern "C" fn MessageSendEvent_send_open_channel_v2(node_id: crate::c_types::PublicKey, msg: crate::lightning::ln::msgs::OpenChannelV2) -> MessageSendEvent {
4142 MessageSendEvent::SendOpenChannelV2 {
4148 /// Utility method to constructs a new SendFundingCreated-variant MessageSendEvent
4149 pub extern "C" fn MessageSendEvent_send_funding_created(node_id: crate::c_types::PublicKey, msg: crate::lightning::ln::msgs::FundingCreated) -> MessageSendEvent {
4150 MessageSendEvent::SendFundingCreated {
4156 /// Utility method to constructs a new SendFundingSigned-variant MessageSendEvent
4157 pub extern "C" fn MessageSendEvent_send_funding_signed(node_id: crate::c_types::PublicKey, msg: crate::lightning::ln::msgs::FundingSigned) -> MessageSendEvent {
4158 MessageSendEvent::SendFundingSigned {
4164 /// Utility method to constructs a new SendTxAddInput-variant MessageSendEvent
4165 pub extern "C" fn MessageSendEvent_send_tx_add_input(node_id: crate::c_types::PublicKey, msg: crate::lightning::ln::msgs::TxAddInput) -> MessageSendEvent {
4166 MessageSendEvent::SendTxAddInput {
4172 /// Utility method to constructs a new SendTxAddOutput-variant MessageSendEvent
4173 pub extern "C" fn MessageSendEvent_send_tx_add_output(node_id: crate::c_types::PublicKey, msg: crate::lightning::ln::msgs::TxAddOutput) -> MessageSendEvent {
4174 MessageSendEvent::SendTxAddOutput {
4180 /// Utility method to constructs a new SendTxRemoveInput-variant MessageSendEvent
4181 pub extern "C" fn MessageSendEvent_send_tx_remove_input(node_id: crate::c_types::PublicKey, msg: crate::lightning::ln::msgs::TxRemoveInput) -> MessageSendEvent {
4182 MessageSendEvent::SendTxRemoveInput {
4188 /// Utility method to constructs a new SendTxRemoveOutput-variant MessageSendEvent
4189 pub extern "C" fn MessageSendEvent_send_tx_remove_output(node_id: crate::c_types::PublicKey, msg: crate::lightning::ln::msgs::TxRemoveOutput) -> MessageSendEvent {
4190 MessageSendEvent::SendTxRemoveOutput {
4196 /// Utility method to constructs a new SendTxComplete-variant MessageSendEvent
4197 pub extern "C" fn MessageSendEvent_send_tx_complete(node_id: crate::c_types::PublicKey, msg: crate::lightning::ln::msgs::TxComplete) -> MessageSendEvent {
4198 MessageSendEvent::SendTxComplete {
4204 /// Utility method to constructs a new SendTxSignatures-variant MessageSendEvent
4205 pub extern "C" fn MessageSendEvent_send_tx_signatures(node_id: crate::c_types::PublicKey, msg: crate::lightning::ln::msgs::TxSignatures) -> MessageSendEvent {
4206 MessageSendEvent::SendTxSignatures {
4212 /// Utility method to constructs a new SendTxInitRbf-variant MessageSendEvent
4213 pub extern "C" fn MessageSendEvent_send_tx_init_rbf(node_id: crate::c_types::PublicKey, msg: crate::lightning::ln::msgs::TxInitRbf) -> MessageSendEvent {
4214 MessageSendEvent::SendTxInitRbf {
4220 /// Utility method to constructs a new SendTxAckRbf-variant MessageSendEvent
4221 pub extern "C" fn MessageSendEvent_send_tx_ack_rbf(node_id: crate::c_types::PublicKey, msg: crate::lightning::ln::msgs::TxAckRbf) -> MessageSendEvent {
4222 MessageSendEvent::SendTxAckRbf {
4228 /// Utility method to constructs a new SendTxAbort-variant MessageSendEvent
4229 pub extern "C" fn MessageSendEvent_send_tx_abort(node_id: crate::c_types::PublicKey, msg: crate::lightning::ln::msgs::TxAbort) -> MessageSendEvent {
4230 MessageSendEvent::SendTxAbort {
4236 /// Utility method to constructs a new SendChannelReady-variant MessageSendEvent
4237 pub extern "C" fn MessageSendEvent_send_channel_ready(node_id: crate::c_types::PublicKey, msg: crate::lightning::ln::msgs::ChannelReady) -> MessageSendEvent {
4238 MessageSendEvent::SendChannelReady {
4244 /// Utility method to constructs a new SendAnnouncementSignatures-variant MessageSendEvent
4245 pub extern "C" fn MessageSendEvent_send_announcement_signatures(node_id: crate::c_types::PublicKey, msg: crate::lightning::ln::msgs::AnnouncementSignatures) -> MessageSendEvent {
4246 MessageSendEvent::SendAnnouncementSignatures {
4252 /// Utility method to constructs a new UpdateHTLCs-variant MessageSendEvent
4253 pub extern "C" fn MessageSendEvent_update_htlcs(node_id: crate::c_types::PublicKey, updates: crate::lightning::ln::msgs::CommitmentUpdate) -> MessageSendEvent {
4254 MessageSendEvent::UpdateHTLCs {
4260 /// Utility method to constructs a new SendRevokeAndACK-variant MessageSendEvent
4261 pub extern "C" fn MessageSendEvent_send_revoke_and_ack(node_id: crate::c_types::PublicKey, msg: crate::lightning::ln::msgs::RevokeAndACK) -> MessageSendEvent {
4262 MessageSendEvent::SendRevokeAndACK {
4268 /// Utility method to constructs a new SendClosingSigned-variant MessageSendEvent
4269 pub extern "C" fn MessageSendEvent_send_closing_signed(node_id: crate::c_types::PublicKey, msg: crate::lightning::ln::msgs::ClosingSigned) -> MessageSendEvent {
4270 MessageSendEvent::SendClosingSigned {
4276 /// Utility method to constructs a new SendShutdown-variant MessageSendEvent
4277 pub extern "C" fn MessageSendEvent_send_shutdown(node_id: crate::c_types::PublicKey, msg: crate::lightning::ln::msgs::Shutdown) -> MessageSendEvent {
4278 MessageSendEvent::SendShutdown {
4284 /// Utility method to constructs a new SendChannelReestablish-variant MessageSendEvent
4285 pub extern "C" fn MessageSendEvent_send_channel_reestablish(node_id: crate::c_types::PublicKey, msg: crate::lightning::ln::msgs::ChannelReestablish) -> MessageSendEvent {
4286 MessageSendEvent::SendChannelReestablish {
4292 /// Utility method to constructs a new SendChannelAnnouncement-variant MessageSendEvent
4293 pub extern "C" fn MessageSendEvent_send_channel_announcement(node_id: crate::c_types::PublicKey, msg: crate::lightning::ln::msgs::ChannelAnnouncement, update_msg: crate::lightning::ln::msgs::ChannelUpdate) -> MessageSendEvent {
4294 MessageSendEvent::SendChannelAnnouncement {
4301 /// Utility method to constructs a new BroadcastChannelAnnouncement-variant MessageSendEvent
4302 pub extern "C" fn MessageSendEvent_broadcast_channel_announcement(msg: crate::lightning::ln::msgs::ChannelAnnouncement, update_msg: crate::lightning::ln::msgs::ChannelUpdate) -> MessageSendEvent {
4303 MessageSendEvent::BroadcastChannelAnnouncement {
4309 /// Utility method to constructs a new BroadcastChannelUpdate-variant MessageSendEvent
4310 pub extern "C" fn MessageSendEvent_broadcast_channel_update(msg: crate::lightning::ln::msgs::ChannelUpdate) -> MessageSendEvent {
4311 MessageSendEvent::BroadcastChannelUpdate {
4316 /// Utility method to constructs a new BroadcastNodeAnnouncement-variant MessageSendEvent
4317 pub extern "C" fn MessageSendEvent_broadcast_node_announcement(msg: crate::lightning::ln::msgs::NodeAnnouncement) -> MessageSendEvent {
4318 MessageSendEvent::BroadcastNodeAnnouncement {
4323 /// Utility method to constructs a new SendChannelUpdate-variant MessageSendEvent
4324 pub extern "C" fn MessageSendEvent_send_channel_update(node_id: crate::c_types::PublicKey, msg: crate::lightning::ln::msgs::ChannelUpdate) -> MessageSendEvent {
4325 MessageSendEvent::SendChannelUpdate {
4331 /// Utility method to constructs a new HandleError-variant MessageSendEvent
4332 pub extern "C" fn MessageSendEvent_handle_error(node_id: crate::c_types::PublicKey, action: crate::lightning::ln::msgs::ErrorAction) -> MessageSendEvent {
4333 MessageSendEvent::HandleError {
4339 /// Utility method to constructs a new SendChannelRangeQuery-variant MessageSendEvent
4340 pub extern "C" fn MessageSendEvent_send_channel_range_query(node_id: crate::c_types::PublicKey, msg: crate::lightning::ln::msgs::QueryChannelRange) -> MessageSendEvent {
4341 MessageSendEvent::SendChannelRangeQuery {
4347 /// Utility method to constructs a new SendShortIdsQuery-variant MessageSendEvent
4348 pub extern "C" fn MessageSendEvent_send_short_ids_query(node_id: crate::c_types::PublicKey, msg: crate::lightning::ln::msgs::QueryShortChannelIds) -> MessageSendEvent {
4349 MessageSendEvent::SendShortIdsQuery {
4355 /// Utility method to constructs a new SendReplyChannelRange-variant MessageSendEvent
4356 pub extern "C" fn MessageSendEvent_send_reply_channel_range(node_id: crate::c_types::PublicKey, msg: crate::lightning::ln::msgs::ReplyChannelRange) -> MessageSendEvent {
4357 MessageSendEvent::SendReplyChannelRange {
4363 /// Utility method to constructs a new SendGossipTimestampFilter-variant MessageSendEvent
4364 pub extern "C" fn MessageSendEvent_send_gossip_timestamp_filter(node_id: crate::c_types::PublicKey, msg: crate::lightning::ln::msgs::GossipTimestampFilter) -> MessageSendEvent {
4365 MessageSendEvent::SendGossipTimestampFilter {
4370 /// A trait indicating an object may generate message send events
4372 pub struct MessageSendEventsProvider {
4373 /// An opaque pointer which is passed to your function implementations as an argument.
4374 /// This has no meaning in the LDK, and can be NULL or any other value.
4375 pub this_arg: *mut c_void,
4376 /// Gets the list of pending events which were generated by previous actions, clearing the list
4378 pub get_and_clear_pending_msg_events: extern "C" fn (this_arg: *const c_void) -> crate::c_types::derived::CVec_MessageSendEventZ,
4379 /// Frees any resources associated with this object given its this_arg pointer.
4380 /// Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed.
4381 pub free: Option<extern "C" fn(this_arg: *mut c_void)>,
4383 unsafe impl Send for MessageSendEventsProvider {}
4384 unsafe impl Sync for MessageSendEventsProvider {}
4386 pub(crate) fn MessageSendEventsProvider_clone_fields(orig: &MessageSendEventsProvider) -> MessageSendEventsProvider {
4387 MessageSendEventsProvider {
4388 this_arg: orig.this_arg,
4389 get_and_clear_pending_msg_events: Clone::clone(&orig.get_and_clear_pending_msg_events),
4390 free: Clone::clone(&orig.free),
4394 use lightning::events::MessageSendEventsProvider as rustMessageSendEventsProvider;
4395 impl rustMessageSendEventsProvider for MessageSendEventsProvider {
4396 fn get_and_clear_pending_msg_events(&self) -> Vec<lightning::events::MessageSendEvent> {
4397 let mut ret = (self.get_and_clear_pending_msg_events)(self.this_arg);
4398 let mut local_ret = Vec::new(); for mut item in ret.into_rust().drain(..) { local_ret.push( { item.into_native() }); };
4403 // We're essentially a pointer already, or at least a set of pointers, so allow us to be used
4404 // directly as a Deref trait in higher-level structs:
4405 impl core::ops::Deref for MessageSendEventsProvider {
4407 fn deref(&self) -> &Self {
4411 impl core::ops::DerefMut for MessageSendEventsProvider {
4412 fn deref_mut(&mut self) -> &mut Self {
4416 /// Calls the free function if one is set
4418 pub extern "C" fn MessageSendEventsProvider_free(this_ptr: MessageSendEventsProvider) { }
4419 impl Drop for MessageSendEventsProvider {
4420 fn drop(&mut self) {
4421 if let Some(f) = self.free {
4426 /// A trait indicating an object may generate events.
4428 /// Events are processed by passing an [`EventHandler`] to [`process_pending_events`].
4430 /// Implementations of this trait may also feature an async version of event handling, as shown with
4431 /// [`ChannelManager::process_pending_events_async`] and
4432 /// [`ChainMonitor::process_pending_events_async`].
4436 /// When using this trait, [`process_pending_events`] will call [`handle_event`] for each pending
4437 /// event since the last invocation.
4439 /// In order to ensure no [`Event`]s are lost, implementors of this trait will persist [`Event`]s
4440 /// and replay any unhandled events on startup. An [`Event`] is considered handled when
4441 /// [`process_pending_events`] returns, thus handlers MUST fully handle [`Event`]s and persist any
4442 /// relevant changes to disk *before* returning.
4444 /// Further, because an application may crash between an [`Event`] being handled and the
4445 /// implementor of this trait being re-serialized, [`Event`] handling must be idempotent - in
4446 /// effect, [`Event`]s may be replayed.
4448 /// Note, handlers may call back into the provider and thus deadlocking must be avoided. Be sure to
4449 /// consult the provider's documentation on the implication of processing events and how a handler
4450 /// may safely use the provider (e.g., see [`ChannelManager::process_pending_events`] and
4451 /// [`ChainMonitor::process_pending_events`]).
4453 /// (C-not implementable) As there is likely no reason for a user to implement this trait on their
4456 /// [`process_pending_events`]: Self::process_pending_events
4457 /// [`handle_event`]: EventHandler::handle_event
4458 /// [`ChannelManager::process_pending_events`]: crate::ln::channelmanager::ChannelManager#method.process_pending_events
4459 /// [`ChainMonitor::process_pending_events`]: crate::chain::chainmonitor::ChainMonitor#method.process_pending_events
4460 /// [`ChannelManager::process_pending_events_async`]: crate::ln::channelmanager::ChannelManager::process_pending_events_async
4461 /// [`ChainMonitor::process_pending_events_async`]: crate::chain::chainmonitor::ChainMonitor::process_pending_events_async
4463 pub struct EventsProvider {
4464 /// An opaque pointer which is passed to your function implementations as an argument.
4465 /// This has no meaning in the LDK, and can be NULL or any other value.
4466 pub this_arg: *mut c_void,
4467 /// Processes any events generated since the last call using the given event handler.
4469 /// See the trait-level documentation for requirements.
4470 pub process_pending_events: extern "C" fn (this_arg: *const c_void, handler: crate::lightning::events::EventHandler),
4471 /// Frees any resources associated with this object given its this_arg pointer.
4472 /// Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed.
4473 pub free: Option<extern "C" fn(this_arg: *mut c_void)>,
4475 unsafe impl Send for EventsProvider {}
4476 unsafe impl Sync for EventsProvider {}
4478 pub(crate) fn EventsProvider_clone_fields(orig: &EventsProvider) -> EventsProvider {
4480 this_arg: orig.this_arg,
4481 process_pending_events: Clone::clone(&orig.process_pending_events),
4482 free: Clone::clone(&orig.free),
4486 use lightning::events::EventsProvider as rustEventsProvider;
4487 /// Calls the free function if one is set
4489 pub extern "C" fn EventsProvider_free(this_ptr: EventsProvider) { }
4490 impl Drop for EventsProvider {
4491 fn drop(&mut self) {
4492 if let Some(f) = self.free {
4497 /// A trait implemented for objects handling events from [`EventsProvider`].
4499 /// An async variation also exists for implementations of [`EventsProvider`] that support async
4500 /// event handling. The async event handler should satisfy the generic bounds: `F:
4501 /// core::future::Future, H: Fn(Event) -> F`.
4503 pub struct EventHandler {
4504 /// An opaque pointer which is passed to your function implementations as an argument.
4505 /// This has no meaning in the LDK, and can be NULL or any other value.
4506 pub this_arg: *mut c_void,
4507 /// Handles the given [`Event`].
4509 /// See [`EventsProvider`] for details that must be considered when implementing this method.
4510 pub handle_event: extern "C" fn (this_arg: *const c_void, event: crate::lightning::events::Event),
4511 /// Frees any resources associated with this object given its this_arg pointer.
4512 /// Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed.
4513 pub free: Option<extern "C" fn(this_arg: *mut c_void)>,
4515 unsafe impl Send for EventHandler {}
4516 unsafe impl Sync for EventHandler {}
4518 pub(crate) fn EventHandler_clone_fields(orig: &EventHandler) -> EventHandler {
4520 this_arg: orig.this_arg,
4521 handle_event: Clone::clone(&orig.handle_event),
4522 free: Clone::clone(&orig.free),
4526 use lightning::events::EventHandler as rustEventHandler;
4527 impl rustEventHandler for EventHandler {
4528 fn handle_event(&self, mut event: lightning::events::Event) {
4529 (self.handle_event)(self.this_arg, crate::lightning::events::Event::native_into(event))
4533 // We're essentially a pointer already, or at least a set of pointers, so allow us to be used
4534 // directly as a Deref trait in higher-level structs:
4535 impl core::ops::Deref for EventHandler {
4537 fn deref(&self) -> &Self {
4541 impl core::ops::DerefMut for EventHandler {
4542 fn deref_mut(&mut self) -> &mut Self {
4546 /// Calls the free function if one is set
4548 pub extern "C" fn EventHandler_free(this_ptr: EventHandler) { }
4549 impl Drop for EventHandler {
4550 fn drop(&mut self) {
4551 if let Some(f) = self.free {