7a85b836feffa26de37bcbbc78e2342053563090
[ldk-c-bindings] / lightning-c-bindings / src / lightning / events / mod.rs
1 // This file is Copyright its original authors, visible in version control
2 // history and in the source files from which this was generated.
3 //
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.
8
9 //! Events are returned from various bits in the library which indicate some action must be taken
10 //! by the client.
11 //!
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
14 //! few other things.
15
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};
24
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.
28 #[derive(Clone)]
29 #[must_use]
30 #[repr(C)]
31 pub enum PaymentPurpose {
32         /// Information for receiving a payment that we generated an invoice for.
33         InvoicePayment {
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`].
37                 ///
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`].
47                 ///
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,
52         },
53         /// Because this is a spontaneous payment, the payer generated their own preimage rather than us
54         /// (the payee) providing a preimage.
55         SpontaneousPayment(
56                 crate::c_types::ThirtyTwoBytes),
57 }
58 use lightning::events::PaymentPurpose as PaymentPurposeImport;
59 pub(crate) type nativePaymentPurpose = PaymentPurposeImport;
60
61 impl PaymentPurpose {
62         #[allow(unused)]
63         pub(crate) fn to_native(&self) -> nativePaymentPurpose {
64                 match self {
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),
72                                 }
73                         },
74                         PaymentPurpose::SpontaneousPayment (ref a, ) => {
75                                 let mut a_nonref = Clone::clone(a);
76                                 nativePaymentPurpose::SpontaneousPayment (
77                                         ::lightning::ln::PaymentPreimage(a_nonref.data),
78                                 )
79                         },
80                 }
81         }
82         #[allow(unused)]
83         pub(crate) fn into_native(self) -> nativePaymentPurpose {
84                 match self {
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),
90                                 }
91                         },
92                         PaymentPurpose::SpontaneousPayment (mut a, ) => {
93                                 nativePaymentPurpose::SpontaneousPayment (
94                                         ::lightning::ln::PaymentPreimage(a.data),
95                                 )
96                         },
97                 }
98         }
99         #[allow(unused)]
100         pub(crate) fn from_native(native: &nativePaymentPurpose) -> Self {
101                 match native {
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 },
109                                 }
110                         },
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 },
115                                 )
116                         },
117                 }
118         }
119         #[allow(unused)]
120         pub(crate) fn native_into(native: nativePaymentPurpose) -> Self {
121                 match native {
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 },
127                                 }
128                         },
129                         nativePaymentPurpose::SpontaneousPayment (mut a, ) => {
130                                 PaymentPurpose::SpontaneousPayment (
131                                         crate::c_types::ThirtyTwoBytes { data: a.0 },
132                                 )
133                         },
134                 }
135         }
136 }
137 /// Frees any resources used by the PaymentPurpose
138 #[no_mangle]
139 pub extern "C" fn PaymentPurpose_free(this_ptr: PaymentPurpose) { }
140 /// Creates a copy of the PaymentPurpose
141 #[no_mangle]
142 pub extern "C" fn PaymentPurpose_clone(orig: &PaymentPurpose) -> PaymentPurpose {
143         orig.clone()
144 }
145 #[no_mangle]
146 /// Utility method to constructs a new InvoicePayment-variant PaymentPurpose
147 pub extern "C" fn PaymentPurpose_invoice_payment(payment_preimage: crate::c_types::derived::COption_ThirtyTwoBytesZ, payment_secret: crate::c_types::ThirtyTwoBytes) -> PaymentPurpose {
148         PaymentPurpose::InvoicePayment {
149                 payment_preimage,
150                 payment_secret,
151         }
152 }
153 #[no_mangle]
154 /// Utility method to constructs a new SpontaneousPayment-variant PaymentPurpose
155 pub extern "C" fn PaymentPurpose_spontaneous_payment(a: crate::c_types::ThirtyTwoBytes) -> PaymentPurpose {
156         PaymentPurpose::SpontaneousPayment(a, )
157 }
158 /// Checks if two PaymentPurposes contain equal inner contents.
159 /// This ignores pointers and is_owned flags and looks at the values in fields.
160 #[no_mangle]
161 pub extern "C" fn PaymentPurpose_eq(a: &PaymentPurpose, b: &PaymentPurpose) -> bool {
162         if &a.to_native() == &b.to_native() { true } else { false }
163 }
164 #[no_mangle]
165 /// Serialize the PaymentPurpose object into a byte array which can be read by PaymentPurpose_read
166 pub extern "C" fn PaymentPurpose_write(obj: &crate::lightning::events::PaymentPurpose) -> crate::c_types::derived::CVec_u8Z {
167         crate::c_types::serialize_obj(&unsafe { &*obj }.to_native())
168 }
169 #[no_mangle]
170 /// Read a PaymentPurpose from a byte array, created by PaymentPurpose_write
171 pub extern "C" fn PaymentPurpose_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_PaymentPurposeDecodeErrorZ {
172         let res: Result<lightning::events::PaymentPurpose, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
173         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() };
174         local_res
175 }
176
177 use lightning::events::ClaimedHTLC as nativeClaimedHTLCImport;
178 pub(crate) type nativeClaimedHTLC = nativeClaimedHTLCImport;
179
180 /// Information about an HTLC that is part of a payment that can be claimed.
181 #[must_use]
182 #[repr(C)]
183 pub struct ClaimedHTLC {
184         /// A pointer to the opaque Rust object.
185
186         /// Nearly everywhere, inner must be non-null, however in places where
187         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
188         pub inner: *mut nativeClaimedHTLC,
189         /// Indicates that this is the only struct which contains the same pointer.
190
191         /// Rust functions which take ownership of an object provided via an argument require
192         /// this to be true and invalidate the object pointed to by inner.
193         pub is_owned: bool,
194 }
195
196 impl Drop for ClaimedHTLC {
197         fn drop(&mut self) {
198                 if self.is_owned && !<*mut nativeClaimedHTLC>::is_null(self.inner) {
199                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
200                 }
201         }
202 }
203 /// Frees any resources used by the ClaimedHTLC, if is_owned is set and inner is non-NULL.
204 #[no_mangle]
205 pub extern "C" fn ClaimedHTLC_free(this_obj: ClaimedHTLC) { }
206 #[allow(unused)]
207 /// Used only if an object of this type is returned as a trait impl by a method
208 pub(crate) extern "C" fn ClaimedHTLC_free_void(this_ptr: *mut c_void) {
209         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeClaimedHTLC) };
210 }
211 #[allow(unused)]
212 impl ClaimedHTLC {
213         pub(crate) fn get_native_ref(&self) -> &'static nativeClaimedHTLC {
214                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
215         }
216         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeClaimedHTLC {
217                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
218         }
219         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
220         pub(crate) fn take_inner(mut self) -> *mut nativeClaimedHTLC {
221                 assert!(self.is_owned);
222                 let ret = ObjOps::untweak_ptr(self.inner);
223                 self.inner = core::ptr::null_mut();
224                 ret
225         }
226 }
227 /// The `channel_id` of the channel over which the HTLC was received.
228 #[no_mangle]
229 pub extern "C" fn ClaimedHTLC_get_channel_id(this_ptr: &ClaimedHTLC) -> *const [u8; 32] {
230         let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
231         &inner_val.0
232 }
233 /// The `channel_id` of the channel over which the HTLC was received.
234 #[no_mangle]
235 pub extern "C" fn ClaimedHTLC_set_channel_id(this_ptr: &mut ClaimedHTLC, mut val: crate::c_types::ThirtyTwoBytes) {
236         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = ::lightning::ln::ChannelId(val.data);
237 }
238 /// The `user_channel_id` of the channel over which the HTLC was received. This is the value
239 /// passed in to [`ChannelManager::create_channel`] for outbound channels, or to
240 /// [`ChannelManager::accept_inbound_channel`] for inbound channels if
241 /// [`UserConfig::manually_accept_inbound_channels`] config flag is set to true. Otherwise
242 /// `user_channel_id` will be randomized for an inbound channel.
243 ///
244 /// This field will be zero for a payment that was serialized prior to LDK version 0.0.117. (This
245 /// should only happen in the case that a payment was claimable prior to LDK version 0.0.117, but
246 /// was not actually claimed until after upgrading.)
247 ///
248 /// [`ChannelManager::create_channel`]: crate::ln::channelmanager::ChannelManager::create_channel
249 /// [`ChannelManager::accept_inbound_channel`]: crate::ln::channelmanager::ChannelManager::accept_inbound_channel
250 /// [`UserConfig::manually_accept_inbound_channels`]: crate::util::config::UserConfig::manually_accept_inbound_channels
251 #[no_mangle]
252 pub extern "C" fn ClaimedHTLC_get_user_channel_id(this_ptr: &ClaimedHTLC) -> crate::c_types::U128 {
253         let mut inner_val = &mut this_ptr.get_native_mut_ref().user_channel_id;
254         inner_val.into()
255 }
256 /// The `user_channel_id` of the channel over which the HTLC was received. This is the value
257 /// passed in to [`ChannelManager::create_channel`] for outbound channels, or to
258 /// [`ChannelManager::accept_inbound_channel`] for inbound channels if
259 /// [`UserConfig::manually_accept_inbound_channels`] config flag is set to true. Otherwise
260 /// `user_channel_id` will be randomized for an inbound channel.
261 ///
262 /// This field will be zero for a payment that was serialized prior to LDK version 0.0.117. (This
263 /// should only happen in the case that a payment was claimable prior to LDK version 0.0.117, but
264 /// was not actually claimed until after upgrading.)
265 ///
266 /// [`ChannelManager::create_channel`]: crate::ln::channelmanager::ChannelManager::create_channel
267 /// [`ChannelManager::accept_inbound_channel`]: crate::ln::channelmanager::ChannelManager::accept_inbound_channel
268 /// [`UserConfig::manually_accept_inbound_channels`]: crate::util::config::UserConfig::manually_accept_inbound_channels
269 #[no_mangle]
270 pub extern "C" fn ClaimedHTLC_set_user_channel_id(this_ptr: &mut ClaimedHTLC, mut val: crate::c_types::U128) {
271         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.user_channel_id = val.into();
272 }
273 /// The block height at which this HTLC expires.
274 #[no_mangle]
275 pub extern "C" fn ClaimedHTLC_get_cltv_expiry(this_ptr: &ClaimedHTLC) -> u32 {
276         let mut inner_val = &mut this_ptr.get_native_mut_ref().cltv_expiry;
277         *inner_val
278 }
279 /// The block height at which this HTLC expires.
280 #[no_mangle]
281 pub extern "C" fn ClaimedHTLC_set_cltv_expiry(this_ptr: &mut ClaimedHTLC, mut val: u32) {
282         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.cltv_expiry = val;
283 }
284 /// The amount (in msats) of this part of an MPP.
285 #[no_mangle]
286 pub extern "C" fn ClaimedHTLC_get_value_msat(this_ptr: &ClaimedHTLC) -> u64 {
287         let mut inner_val = &mut this_ptr.get_native_mut_ref().value_msat;
288         *inner_val
289 }
290 /// The amount (in msats) of this part of an MPP.
291 #[no_mangle]
292 pub extern "C" fn ClaimedHTLC_set_value_msat(this_ptr: &mut ClaimedHTLC, mut val: u64) {
293         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.value_msat = val;
294 }
295 /// Constructs a new ClaimedHTLC given each field
296 #[must_use]
297 #[no_mangle]
298 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 {
299         ClaimedHTLC { inner: ObjOps::heap_alloc(nativeClaimedHTLC {
300                 channel_id: ::lightning::ln::ChannelId(channel_id_arg.data),
301                 user_channel_id: user_channel_id_arg.into(),
302                 cltv_expiry: cltv_expiry_arg,
303                 value_msat: value_msat_arg,
304         }), is_owned: true }
305 }
306 impl Clone for ClaimedHTLC {
307         fn clone(&self) -> Self {
308                 Self {
309                         inner: if <*mut nativeClaimedHTLC>::is_null(self.inner) { core::ptr::null_mut() } else {
310                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
311                         is_owned: true,
312                 }
313         }
314 }
315 #[allow(unused)]
316 /// Used only if an object of this type is returned as a trait impl by a method
317 pub(crate) extern "C" fn ClaimedHTLC_clone_void(this_ptr: *const c_void) -> *mut c_void {
318         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeClaimedHTLC)).clone() })) as *mut c_void
319 }
320 #[no_mangle]
321 /// Creates a copy of the ClaimedHTLC
322 pub extern "C" fn ClaimedHTLC_clone(orig: &ClaimedHTLC) -> ClaimedHTLC {
323         orig.clone()
324 }
325 /// Checks if two ClaimedHTLCs contain equal inner contents.
326 /// This ignores pointers and is_owned flags and looks at the values in fields.
327 /// Two objects with NULL inner values will be considered "equal" here.
328 #[no_mangle]
329 pub extern "C" fn ClaimedHTLC_eq(a: &ClaimedHTLC, b: &ClaimedHTLC) -> bool {
330         if a.inner == b.inner { return true; }
331         if a.inner.is_null() || b.inner.is_null() { return false; }
332         if a.get_native_ref() == b.get_native_ref() { true } else { false }
333 }
334 #[no_mangle]
335 /// Serialize the ClaimedHTLC object into a byte array which can be read by ClaimedHTLC_read
336 pub extern "C" fn ClaimedHTLC_write(obj: &crate::lightning::events::ClaimedHTLC) -> crate::c_types::derived::CVec_u8Z {
337         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
338 }
339 #[no_mangle]
340 pub(crate) extern "C" fn ClaimedHTLC_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
341         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeClaimedHTLC) })
342 }
343 #[no_mangle]
344 /// Read a ClaimedHTLC from a byte array, created by ClaimedHTLC_write
345 pub extern "C" fn ClaimedHTLC_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ClaimedHTLCDecodeErrorZ {
346         let res: Result<lightning::events::ClaimedHTLC, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
347         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() };
348         local_res
349 }
350 /// When the payment path failure took place and extra details about it. [`PathFailure::OnPath`] may
351 /// contain a [`NetworkUpdate`] that needs to be applied to the [`NetworkGraph`].
352 ///
353 /// [`NetworkUpdate`]: crate::routing::gossip::NetworkUpdate
354 /// [`NetworkGraph`]: crate::routing::gossip::NetworkGraph
355 #[derive(Clone)]
356 #[must_use]
357 #[repr(C)]
358 pub enum PathFailure {
359         /// We failed to initially send the payment and no HTLC was committed to. Contains the relevant
360         /// error.
361         InitialSend {
362                 /// The error surfaced from initial send.
363                 err: crate::lightning::util::errors::APIError,
364         },
365         /// A hop on the path failed to forward our payment.
366         OnPath {
367                 /// If present, this [`NetworkUpdate`] should be applied to the [`NetworkGraph`] so that routing
368                 /// decisions can take into account the update.
369                 ///
370                 /// [`NetworkUpdate`]: crate::routing::gossip::NetworkUpdate
371                 /// [`NetworkGraph`]: crate::routing::gossip::NetworkGraph
372                 network_update: crate::c_types::derived::COption_NetworkUpdateZ,
373         },
374 }
375 use lightning::events::PathFailure as PathFailureImport;
376 pub(crate) type nativePathFailure = PathFailureImport;
377
378 impl PathFailure {
379         #[allow(unused)]
380         pub(crate) fn to_native(&self) -> nativePathFailure {
381                 match self {
382                         PathFailure::InitialSend {ref err, } => {
383                                 let mut err_nonref = Clone::clone(err);
384                                 nativePathFailure::InitialSend {
385                                         err: err_nonref.into_native(),
386                                 }
387                         },
388                         PathFailure::OnPath {ref network_update, } => {
389                                 let mut network_update_nonref = Clone::clone(network_update);
390                                 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() }})} };
391                                 nativePathFailure::OnPath {
392                                         network_update: local_network_update_nonref,
393                                 }
394                         },
395                 }
396         }
397         #[allow(unused)]
398         pub(crate) fn into_native(self) -> nativePathFailure {
399                 match self {
400                         PathFailure::InitialSend {mut err, } => {
401                                 nativePathFailure::InitialSend {
402                                         err: err.into_native(),
403                                 }
404                         },
405                         PathFailure::OnPath {mut network_update, } => {
406                                 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() }})} };
407                                 nativePathFailure::OnPath {
408                                         network_update: local_network_update,
409                                 }
410                         },
411                 }
412         }
413         #[allow(unused)]
414         pub(crate) fn from_native(native: &nativePathFailure) -> Self {
415                 match native {
416                         nativePathFailure::InitialSend {ref err, } => {
417                                 let mut err_nonref = Clone::clone(err);
418                                 PathFailure::InitialSend {
419                                         err: crate::lightning::util::errors::APIError::native_into(err_nonref),
420                                 }
421                         },
422                         nativePathFailure::OnPath {ref network_update, } => {
423                                 let mut network_update_nonref = Clone::clone(network_update);
424                                 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()) }) };
425                                 PathFailure::OnPath {
426                                         network_update: local_network_update_nonref,
427                                 }
428                         },
429                 }
430         }
431         #[allow(unused)]
432         pub(crate) fn native_into(native: nativePathFailure) -> Self {
433                 match native {
434                         nativePathFailure::InitialSend {mut err, } => {
435                                 PathFailure::InitialSend {
436                                         err: crate::lightning::util::errors::APIError::native_into(err),
437                                 }
438                         },
439                         nativePathFailure::OnPath {mut network_update, } => {
440                                 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()) }) };
441                                 PathFailure::OnPath {
442                                         network_update: local_network_update,
443                                 }
444                         },
445                 }
446         }
447 }
448 /// Frees any resources used by the PathFailure
449 #[no_mangle]
450 pub extern "C" fn PathFailure_free(this_ptr: PathFailure) { }
451 /// Creates a copy of the PathFailure
452 #[no_mangle]
453 pub extern "C" fn PathFailure_clone(orig: &PathFailure) -> PathFailure {
454         orig.clone()
455 }
456 #[no_mangle]
457 /// Utility method to constructs a new InitialSend-variant PathFailure
458 pub extern "C" fn PathFailure_initial_send(err: crate::lightning::util::errors::APIError) -> PathFailure {
459         PathFailure::InitialSend {
460                 err,
461         }
462 }
463 #[no_mangle]
464 /// Utility method to constructs a new OnPath-variant PathFailure
465 pub extern "C" fn PathFailure_on_path(network_update: crate::c_types::derived::COption_NetworkUpdateZ) -> PathFailure {
466         PathFailure::OnPath {
467                 network_update,
468         }
469 }
470 /// Checks if two PathFailures contain equal inner contents.
471 /// This ignores pointers and is_owned flags and looks at the values in fields.
472 #[no_mangle]
473 pub extern "C" fn PathFailure_eq(a: &PathFailure, b: &PathFailure) -> bool {
474         if &a.to_native() == &b.to_native() { true } else { false }
475 }
476 #[no_mangle]
477 /// Serialize the PathFailure object into a byte array which can be read by PathFailure_read
478 pub extern "C" fn PathFailure_write(obj: &crate::lightning::events::PathFailure) -> crate::c_types::derived::CVec_u8Z {
479         crate::c_types::serialize_obj(&unsafe { &*obj }.to_native())
480 }
481 #[no_mangle]
482 /// Read a PathFailure from a byte array, created by PathFailure_write
483 pub extern "C" fn PathFailure_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_COption_PathFailureZDecodeErrorZ {
484         let res: Result<Option<lightning::events::PathFailure>, lightning::ln::msgs::DecodeError> = crate::c_types::maybe_deserialize_obj(ser);
485         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() };
486         local_res
487 }
488 /// The reason the channel was closed. See individual variants for more details.
489 #[derive(Clone)]
490 #[must_use]
491 #[repr(C)]
492 pub enum ClosureReason {
493         /// Closure generated from receiving a peer error message.
494         ///
495         /// Our counterparty may have broadcasted their latest commitment state, and we have
496         /// as well.
497         CounterpartyForceClosed {
498                 /// The error which the peer sent us.
499                 ///
500                 /// Be careful about printing the peer_msg, a well-crafted message could exploit
501                 /// a security vulnerability in the terminal emulator or the logging subsystem.
502                 /// To be safe, use `Display` on `UntrustedString`
503                 ///
504                 /// [`UntrustedString`]: crate::util::string::UntrustedString
505                 peer_msg: crate::lightning::util::string::UntrustedString,
506         },
507         /// Closure generated from [`ChannelManager::force_close_channel`], called by the user.
508         ///
509         /// [`ChannelManager::force_close_channel`]: crate::ln::channelmanager::ChannelManager::force_close_channel.
510         HolderForceClosed,
511         /// The channel was closed after negotiating a cooperative close and we've now broadcasted
512         /// the cooperative close transaction. Note the shutdown may have been initiated by us.
513         CooperativeClosure,
514         /// A commitment transaction was confirmed on chain, closing the channel. Most likely this
515         /// commitment transaction came from our counterparty, but it may also have come from
516         /// a copy of our own `ChannelMonitor`.
517         CommitmentTxConfirmed,
518         /// The funding transaction failed to confirm in a timely manner on an inbound channel.
519         FundingTimedOut,
520         /// Closure generated from processing an event, likely a HTLC forward/relay/reception.
521         ProcessingError {
522                 /// A developer-readable error message which we generated.
523                 err: crate::c_types::Str,
524         },
525         /// The peer disconnected prior to funding completing. In this case the spec mandates that we
526         /// forget the channel entirely - we can attempt again if the peer reconnects.
527         ///
528         /// This includes cases where we restarted prior to funding completion, including prior to the
529         /// initial [`ChannelMonitor`] persistence completing.
530         ///
531         /// In LDK versions prior to 0.0.107 this could also occur if we were unable to connect to the
532         /// peer because of mutual incompatibility between us and our channel counterparty.
533         ///
534         /// [`ChannelMonitor`]: crate::chain::channelmonitor::ChannelMonitor
535         DisconnectedPeer,
536         /// Closure generated from `ChannelManager::read` if the [`ChannelMonitor`] is newer than
537         /// the [`ChannelManager`] deserialized.
538         ///
539         /// [`ChannelMonitor`]: crate::chain::channelmonitor::ChannelMonitor
540         /// [`ChannelManager`]: crate::ln::channelmanager::ChannelManager
541         OutdatedChannelManager,
542         /// The counterparty requested a cooperative close of a channel that had not been funded yet.
543         /// The channel has been immediately closed.
544         CounterpartyCoopClosedUnfundedChannel,
545         /// Another channel in the same funding batch closed before the funding transaction
546         /// was ready to be broadcast.
547         FundingBatchClosure,
548 }
549 use lightning::events::ClosureReason as ClosureReasonImport;
550 pub(crate) type nativeClosureReason = ClosureReasonImport;
551
552 impl ClosureReason {
553         #[allow(unused)]
554         pub(crate) fn to_native(&self) -> nativeClosureReason {
555                 match self {
556                         ClosureReason::CounterpartyForceClosed {ref peer_msg, } => {
557                                 let mut peer_msg_nonref = Clone::clone(peer_msg);
558                                 nativeClosureReason::CounterpartyForceClosed {
559                                         peer_msg: *unsafe { Box::from_raw(peer_msg_nonref.take_inner()) },
560                                 }
561                         },
562                         ClosureReason::HolderForceClosed => nativeClosureReason::HolderForceClosed,
563                         ClosureReason::CooperativeClosure => nativeClosureReason::CooperativeClosure,
564                         ClosureReason::CommitmentTxConfirmed => nativeClosureReason::CommitmentTxConfirmed,
565                         ClosureReason::FundingTimedOut => nativeClosureReason::FundingTimedOut,
566                         ClosureReason::ProcessingError {ref err, } => {
567                                 let mut err_nonref = Clone::clone(err);
568                                 nativeClosureReason::ProcessingError {
569                                         err: err_nonref.into_string(),
570                                 }
571                         },
572                         ClosureReason::DisconnectedPeer => nativeClosureReason::DisconnectedPeer,
573                         ClosureReason::OutdatedChannelManager => nativeClosureReason::OutdatedChannelManager,
574                         ClosureReason::CounterpartyCoopClosedUnfundedChannel => nativeClosureReason::CounterpartyCoopClosedUnfundedChannel,
575                         ClosureReason::FundingBatchClosure => nativeClosureReason::FundingBatchClosure,
576                 }
577         }
578         #[allow(unused)]
579         pub(crate) fn into_native(self) -> nativeClosureReason {
580                 match self {
581                         ClosureReason::CounterpartyForceClosed {mut peer_msg, } => {
582                                 nativeClosureReason::CounterpartyForceClosed {
583                                         peer_msg: *unsafe { Box::from_raw(peer_msg.take_inner()) },
584                                 }
585                         },
586                         ClosureReason::HolderForceClosed => nativeClosureReason::HolderForceClosed,
587                         ClosureReason::CooperativeClosure => nativeClosureReason::CooperativeClosure,
588                         ClosureReason::CommitmentTxConfirmed => nativeClosureReason::CommitmentTxConfirmed,
589                         ClosureReason::FundingTimedOut => nativeClosureReason::FundingTimedOut,
590                         ClosureReason::ProcessingError {mut err, } => {
591                                 nativeClosureReason::ProcessingError {
592                                         err: err.into_string(),
593                                 }
594                         },
595                         ClosureReason::DisconnectedPeer => nativeClosureReason::DisconnectedPeer,
596                         ClosureReason::OutdatedChannelManager => nativeClosureReason::OutdatedChannelManager,
597                         ClosureReason::CounterpartyCoopClosedUnfundedChannel => nativeClosureReason::CounterpartyCoopClosedUnfundedChannel,
598                         ClosureReason::FundingBatchClosure => nativeClosureReason::FundingBatchClosure,
599                 }
600         }
601         #[allow(unused)]
602         pub(crate) fn from_native(native: &nativeClosureReason) -> Self {
603                 match native {
604                         nativeClosureReason::CounterpartyForceClosed {ref peer_msg, } => {
605                                 let mut peer_msg_nonref = Clone::clone(peer_msg);
606                                 ClosureReason::CounterpartyForceClosed {
607                                         peer_msg: crate::lightning::util::string::UntrustedString { inner: ObjOps::heap_alloc(peer_msg_nonref), is_owned: true },
608                                 }
609                         },
610                         nativeClosureReason::HolderForceClosed => ClosureReason::HolderForceClosed,
611                         nativeClosureReason::CooperativeClosure => ClosureReason::CooperativeClosure,
612                         nativeClosureReason::CommitmentTxConfirmed => ClosureReason::CommitmentTxConfirmed,
613                         nativeClosureReason::FundingTimedOut => ClosureReason::FundingTimedOut,
614                         nativeClosureReason::ProcessingError {ref err, } => {
615                                 let mut err_nonref = Clone::clone(err);
616                                 ClosureReason::ProcessingError {
617                                         err: err_nonref.into(),
618                                 }
619                         },
620                         nativeClosureReason::DisconnectedPeer => ClosureReason::DisconnectedPeer,
621                         nativeClosureReason::OutdatedChannelManager => ClosureReason::OutdatedChannelManager,
622                         nativeClosureReason::CounterpartyCoopClosedUnfundedChannel => ClosureReason::CounterpartyCoopClosedUnfundedChannel,
623                         nativeClosureReason::FundingBatchClosure => ClosureReason::FundingBatchClosure,
624                 }
625         }
626         #[allow(unused)]
627         pub(crate) fn native_into(native: nativeClosureReason) -> Self {
628                 match native {
629                         nativeClosureReason::CounterpartyForceClosed {mut peer_msg, } => {
630                                 ClosureReason::CounterpartyForceClosed {
631                                         peer_msg: crate::lightning::util::string::UntrustedString { inner: ObjOps::heap_alloc(peer_msg), is_owned: true },
632                                 }
633                         },
634                         nativeClosureReason::HolderForceClosed => ClosureReason::HolderForceClosed,
635                         nativeClosureReason::CooperativeClosure => ClosureReason::CooperativeClosure,
636                         nativeClosureReason::CommitmentTxConfirmed => ClosureReason::CommitmentTxConfirmed,
637                         nativeClosureReason::FundingTimedOut => ClosureReason::FundingTimedOut,
638                         nativeClosureReason::ProcessingError {mut err, } => {
639                                 ClosureReason::ProcessingError {
640                                         err: err.into(),
641                                 }
642                         },
643                         nativeClosureReason::DisconnectedPeer => ClosureReason::DisconnectedPeer,
644                         nativeClosureReason::OutdatedChannelManager => ClosureReason::OutdatedChannelManager,
645                         nativeClosureReason::CounterpartyCoopClosedUnfundedChannel => ClosureReason::CounterpartyCoopClosedUnfundedChannel,
646                         nativeClosureReason::FundingBatchClosure => ClosureReason::FundingBatchClosure,
647                 }
648         }
649 }
650 /// Frees any resources used by the ClosureReason
651 #[no_mangle]
652 pub extern "C" fn ClosureReason_free(this_ptr: ClosureReason) { }
653 /// Creates a copy of the ClosureReason
654 #[no_mangle]
655 pub extern "C" fn ClosureReason_clone(orig: &ClosureReason) -> ClosureReason {
656         orig.clone()
657 }
658 #[no_mangle]
659 /// Utility method to constructs a new CounterpartyForceClosed-variant ClosureReason
660 pub extern "C" fn ClosureReason_counterparty_force_closed(peer_msg: crate::lightning::util::string::UntrustedString) -> ClosureReason {
661         ClosureReason::CounterpartyForceClosed {
662                 peer_msg,
663         }
664 }
665 #[no_mangle]
666 /// Utility method to constructs a new HolderForceClosed-variant ClosureReason
667 pub extern "C" fn ClosureReason_holder_force_closed() -> ClosureReason {
668         ClosureReason::HolderForceClosed}
669 #[no_mangle]
670 /// Utility method to constructs a new CooperativeClosure-variant ClosureReason
671 pub extern "C" fn ClosureReason_cooperative_closure() -> ClosureReason {
672         ClosureReason::CooperativeClosure}
673 #[no_mangle]
674 /// Utility method to constructs a new CommitmentTxConfirmed-variant ClosureReason
675 pub extern "C" fn ClosureReason_commitment_tx_confirmed() -> ClosureReason {
676         ClosureReason::CommitmentTxConfirmed}
677 #[no_mangle]
678 /// Utility method to constructs a new FundingTimedOut-variant ClosureReason
679 pub extern "C" fn ClosureReason_funding_timed_out() -> ClosureReason {
680         ClosureReason::FundingTimedOut}
681 #[no_mangle]
682 /// Utility method to constructs a new ProcessingError-variant ClosureReason
683 pub extern "C" fn ClosureReason_processing_error(err: crate::c_types::Str) -> ClosureReason {
684         ClosureReason::ProcessingError {
685                 err,
686         }
687 }
688 #[no_mangle]
689 /// Utility method to constructs a new DisconnectedPeer-variant ClosureReason
690 pub extern "C" fn ClosureReason_disconnected_peer() -> ClosureReason {
691         ClosureReason::DisconnectedPeer}
692 #[no_mangle]
693 /// Utility method to constructs a new OutdatedChannelManager-variant ClosureReason
694 pub extern "C" fn ClosureReason_outdated_channel_manager() -> ClosureReason {
695         ClosureReason::OutdatedChannelManager}
696 #[no_mangle]
697 /// Utility method to constructs a new CounterpartyCoopClosedUnfundedChannel-variant ClosureReason
698 pub extern "C" fn ClosureReason_counterparty_coop_closed_unfunded_channel() -> ClosureReason {
699         ClosureReason::CounterpartyCoopClosedUnfundedChannel}
700 #[no_mangle]
701 /// Utility method to constructs a new FundingBatchClosure-variant ClosureReason
702 pub extern "C" fn ClosureReason_funding_batch_closure() -> ClosureReason {
703         ClosureReason::FundingBatchClosure}
704 /// Checks if two ClosureReasons contain equal inner contents.
705 /// This ignores pointers and is_owned flags and looks at the values in fields.
706 #[no_mangle]
707 pub extern "C" fn ClosureReason_eq(a: &ClosureReason, b: &ClosureReason) -> bool {
708         if &a.to_native() == &b.to_native() { true } else { false }
709 }
710 #[no_mangle]
711 /// Serialize the ClosureReason object into a byte array which can be read by ClosureReason_read
712 pub extern "C" fn ClosureReason_write(obj: &crate::lightning::events::ClosureReason) -> crate::c_types::derived::CVec_u8Z {
713         crate::c_types::serialize_obj(&unsafe { &*obj }.to_native())
714 }
715 #[no_mangle]
716 /// Read a ClosureReason from a byte array, created by ClosureReason_write
717 pub extern "C" fn ClosureReason_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_COption_ClosureReasonZDecodeErrorZ {
718         let res: Result<Option<lightning::events::ClosureReason>, lightning::ln::msgs::DecodeError> = crate::c_types::maybe_deserialize_obj(ser);
719         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() };
720         local_res
721 }
722 /// Intended destination of a failed HTLC as indicated in [`Event::HTLCHandlingFailed`].
723 #[derive(Clone)]
724 #[must_use]
725 #[repr(C)]
726 pub enum HTLCDestination {
727         /// We tried forwarding to a channel but failed to do so. An example of such an instance is when
728         /// there is insufficient capacity in our outbound channel.
729         NextHopChannel {
730                 /// The `node_id` of the next node. For backwards compatibility, this field is
731                 /// marked as optional, versions prior to 0.0.110 may not always be able to provide
732                 /// counterparty node information.
733                 ///
734                 /// Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None
735                 node_id: crate::c_types::PublicKey,
736                 /// The outgoing `channel_id` between us and the next node.
737                 channel_id: crate::c_types::ThirtyTwoBytes,
738         },
739         /// Scenario where we are unsure of the next node to forward the HTLC to.
740         UnknownNextHop {
741                 /// Short channel id we are requesting to forward an HTLC to.
742                 requested_forward_scid: u64,
743         },
744         /// We couldn't forward to the outgoing scid. An example would be attempting to send a duplicate
745         /// intercept HTLC.
746         InvalidForward {
747                 /// Short channel id we are requesting to forward an HTLC to.
748                 requested_forward_scid: u64,
749         },
750         /// Failure scenario where an HTLC may have been forwarded to be intended for us,
751         /// but is invalid for some reason, so we reject it.
752         ///
753         /// Some of the reasons may include:
754         /// * HTLC Timeouts
755         /// * Excess HTLCs for a payment that we have already fully received, over-paying for the
756         ///   payment,
757         /// * The counterparty node modified the HTLC in transit,
758         /// * A probing attack where an intermediary node is trying to detect if we are the ultimate
759         ///   recipient for a payment.
760         FailedPayment {
761                 /// The payment hash of the payment we attempted to process.
762                 payment_hash: crate::c_types::ThirtyTwoBytes,
763         },
764 }
765 use lightning::events::HTLCDestination as HTLCDestinationImport;
766 pub(crate) type nativeHTLCDestination = HTLCDestinationImport;
767
768 impl HTLCDestination {
769         #[allow(unused)]
770         pub(crate) fn to_native(&self) -> nativeHTLCDestination {
771                 match self {
772                         HTLCDestination::NextHopChannel {ref node_id, ref channel_id, } => {
773                                 let mut node_id_nonref = Clone::clone(node_id);
774                                 let mut local_node_id_nonref = if node_id_nonref.is_null() { None } else { Some( { node_id_nonref.into_rust() }) };
775                                 let mut channel_id_nonref = Clone::clone(channel_id);
776                                 nativeHTLCDestination::NextHopChannel {
777                                         node_id: local_node_id_nonref,
778                                         channel_id: ::lightning::ln::ChannelId(channel_id_nonref.data),
779                                 }
780                         },
781                         HTLCDestination::UnknownNextHop {ref requested_forward_scid, } => {
782                                 let mut requested_forward_scid_nonref = Clone::clone(requested_forward_scid);
783                                 nativeHTLCDestination::UnknownNextHop {
784                                         requested_forward_scid: requested_forward_scid_nonref,
785                                 }
786                         },
787                         HTLCDestination::InvalidForward {ref requested_forward_scid, } => {
788                                 let mut requested_forward_scid_nonref = Clone::clone(requested_forward_scid);
789                                 nativeHTLCDestination::InvalidForward {
790                                         requested_forward_scid: requested_forward_scid_nonref,
791                                 }
792                         },
793                         HTLCDestination::FailedPayment {ref payment_hash, } => {
794                                 let mut payment_hash_nonref = Clone::clone(payment_hash);
795                                 nativeHTLCDestination::FailedPayment {
796                                         payment_hash: ::lightning::ln::PaymentHash(payment_hash_nonref.data),
797                                 }
798                         },
799                 }
800         }
801         #[allow(unused)]
802         pub(crate) fn into_native(self) -> nativeHTLCDestination {
803                 match self {
804                         HTLCDestination::NextHopChannel {mut node_id, mut channel_id, } => {
805                                 let mut local_node_id = if node_id.is_null() { None } else { Some( { node_id.into_rust() }) };
806                                 nativeHTLCDestination::NextHopChannel {
807                                         node_id: local_node_id,
808                                         channel_id: ::lightning::ln::ChannelId(channel_id.data),
809                                 }
810                         },
811                         HTLCDestination::UnknownNextHop {mut requested_forward_scid, } => {
812                                 nativeHTLCDestination::UnknownNextHop {
813                                         requested_forward_scid: requested_forward_scid,
814                                 }
815                         },
816                         HTLCDestination::InvalidForward {mut requested_forward_scid, } => {
817                                 nativeHTLCDestination::InvalidForward {
818                                         requested_forward_scid: requested_forward_scid,
819                                 }
820                         },
821                         HTLCDestination::FailedPayment {mut payment_hash, } => {
822                                 nativeHTLCDestination::FailedPayment {
823                                         payment_hash: ::lightning::ln::PaymentHash(payment_hash.data),
824                                 }
825                         },
826                 }
827         }
828         #[allow(unused)]
829         pub(crate) fn from_native(native: &nativeHTLCDestination) -> Self {
830                 match native {
831                         nativeHTLCDestination::NextHopChannel {ref node_id, ref channel_id, } => {
832                                 let mut node_id_nonref = Clone::clone(node_id);
833                                 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())) } };
834                                 let mut channel_id_nonref = Clone::clone(channel_id);
835                                 HTLCDestination::NextHopChannel {
836                                         node_id: local_node_id_nonref,
837                                         channel_id: crate::c_types::ThirtyTwoBytes { data: channel_id_nonref.0 },
838                                 }
839                         },
840                         nativeHTLCDestination::UnknownNextHop {ref requested_forward_scid, } => {
841                                 let mut requested_forward_scid_nonref = Clone::clone(requested_forward_scid);
842                                 HTLCDestination::UnknownNextHop {
843                                         requested_forward_scid: requested_forward_scid_nonref,
844                                 }
845                         },
846                         nativeHTLCDestination::InvalidForward {ref requested_forward_scid, } => {
847                                 let mut requested_forward_scid_nonref = Clone::clone(requested_forward_scid);
848                                 HTLCDestination::InvalidForward {
849                                         requested_forward_scid: requested_forward_scid_nonref,
850                                 }
851                         },
852                         nativeHTLCDestination::FailedPayment {ref payment_hash, } => {
853                                 let mut payment_hash_nonref = Clone::clone(payment_hash);
854                                 HTLCDestination::FailedPayment {
855                                         payment_hash: crate::c_types::ThirtyTwoBytes { data: payment_hash_nonref.0 },
856                                 }
857                         },
858                 }
859         }
860         #[allow(unused)]
861         pub(crate) fn native_into(native: nativeHTLCDestination) -> Self {
862                 match native {
863                         nativeHTLCDestination::NextHopChannel {mut node_id, mut channel_id, } => {
864                                 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())) } };
865                                 HTLCDestination::NextHopChannel {
866                                         node_id: local_node_id,
867                                         channel_id: crate::c_types::ThirtyTwoBytes { data: channel_id.0 },
868                                 }
869                         },
870                         nativeHTLCDestination::UnknownNextHop {mut requested_forward_scid, } => {
871                                 HTLCDestination::UnknownNextHop {
872                                         requested_forward_scid: requested_forward_scid,
873                                 }
874                         },
875                         nativeHTLCDestination::InvalidForward {mut requested_forward_scid, } => {
876                                 HTLCDestination::InvalidForward {
877                                         requested_forward_scid: requested_forward_scid,
878                                 }
879                         },
880                         nativeHTLCDestination::FailedPayment {mut payment_hash, } => {
881                                 HTLCDestination::FailedPayment {
882                                         payment_hash: crate::c_types::ThirtyTwoBytes { data: payment_hash.0 },
883                                 }
884                         },
885                 }
886         }
887 }
888 /// Frees any resources used by the HTLCDestination
889 #[no_mangle]
890 pub extern "C" fn HTLCDestination_free(this_ptr: HTLCDestination) { }
891 /// Creates a copy of the HTLCDestination
892 #[no_mangle]
893 pub extern "C" fn HTLCDestination_clone(orig: &HTLCDestination) -> HTLCDestination {
894         orig.clone()
895 }
896 #[no_mangle]
897 /// Utility method to constructs a new NextHopChannel-variant HTLCDestination
898 pub extern "C" fn HTLCDestination_next_hop_channel(node_id: crate::c_types::PublicKey, channel_id: crate::c_types::ThirtyTwoBytes) -> HTLCDestination {
899         HTLCDestination::NextHopChannel {
900                 node_id,
901                 channel_id,
902         }
903 }
904 #[no_mangle]
905 /// Utility method to constructs a new UnknownNextHop-variant HTLCDestination
906 pub extern "C" fn HTLCDestination_unknown_next_hop(requested_forward_scid: u64) -> HTLCDestination {
907         HTLCDestination::UnknownNextHop {
908                 requested_forward_scid,
909         }
910 }
911 #[no_mangle]
912 /// Utility method to constructs a new InvalidForward-variant HTLCDestination
913 pub extern "C" fn HTLCDestination_invalid_forward(requested_forward_scid: u64) -> HTLCDestination {
914         HTLCDestination::InvalidForward {
915                 requested_forward_scid,
916         }
917 }
918 #[no_mangle]
919 /// Utility method to constructs a new FailedPayment-variant HTLCDestination
920 pub extern "C" fn HTLCDestination_failed_payment(payment_hash: crate::c_types::ThirtyTwoBytes) -> HTLCDestination {
921         HTLCDestination::FailedPayment {
922                 payment_hash,
923         }
924 }
925 /// Checks if two HTLCDestinations contain equal inner contents.
926 /// This ignores pointers and is_owned flags and looks at the values in fields.
927 #[no_mangle]
928 pub extern "C" fn HTLCDestination_eq(a: &HTLCDestination, b: &HTLCDestination) -> bool {
929         if &a.to_native() == &b.to_native() { true } else { false }
930 }
931 #[no_mangle]
932 /// Serialize the HTLCDestination object into a byte array which can be read by HTLCDestination_read
933 pub extern "C" fn HTLCDestination_write(obj: &crate::lightning::events::HTLCDestination) -> crate::c_types::derived::CVec_u8Z {
934         crate::c_types::serialize_obj(&unsafe { &*obj }.to_native())
935 }
936 #[no_mangle]
937 /// Read a HTLCDestination from a byte array, created by HTLCDestination_write
938 pub extern "C" fn HTLCDestination_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_COption_HTLCDestinationZDecodeErrorZ {
939         let res: Result<Option<lightning::events::HTLCDestination>, lightning::ln::msgs::DecodeError> = crate::c_types::maybe_deserialize_obj(ser);
940         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() };
941         local_res
942 }
943 /// The reason the payment failed. Used in [`Event::PaymentFailed`].
944 #[derive(Clone)]
945 #[must_use]
946 #[repr(C)]
947 pub enum PaymentFailureReason {
948         /// The intended recipient rejected our payment.
949         RecipientRejected,
950         /// The user chose to abandon this payment by calling [`ChannelManager::abandon_payment`].
951         ///
952         /// [`ChannelManager::abandon_payment`]: crate::ln::channelmanager::ChannelManager::abandon_payment
953         UserAbandoned,
954         /// We exhausted all of our retry attempts while trying to send the payment, or we
955         /// exhausted the [`Retry::Timeout`] if the user set one. If at any point a retry
956         /// attempt failed while being forwarded along the path, an [`Event::PaymentPathFailed`] will
957         /// have come before this.
958         ///
959         /// [`Retry::Timeout`]: crate::ln::channelmanager::Retry::Timeout
960         RetriesExhausted,
961         /// The payment expired while retrying, based on the provided
962         /// [`PaymentParameters::expiry_time`].
963         ///
964         /// [`PaymentParameters::expiry_time`]: crate::routing::router::PaymentParameters::expiry_time
965         PaymentExpired,
966         /// We failed to find a route while retrying the payment.
967         RouteNotFound,
968         /// This error should generally never happen. This likely means that there is a problem with
969         /// your router.
970         UnexpectedError,
971 }
972 use lightning::events::PaymentFailureReason as PaymentFailureReasonImport;
973 pub(crate) type nativePaymentFailureReason = PaymentFailureReasonImport;
974
975 impl PaymentFailureReason {
976         #[allow(unused)]
977         pub(crate) fn to_native(&self) -> nativePaymentFailureReason {
978                 match self {
979                         PaymentFailureReason::RecipientRejected => nativePaymentFailureReason::RecipientRejected,
980                         PaymentFailureReason::UserAbandoned => nativePaymentFailureReason::UserAbandoned,
981                         PaymentFailureReason::RetriesExhausted => nativePaymentFailureReason::RetriesExhausted,
982                         PaymentFailureReason::PaymentExpired => nativePaymentFailureReason::PaymentExpired,
983                         PaymentFailureReason::RouteNotFound => nativePaymentFailureReason::RouteNotFound,
984                         PaymentFailureReason::UnexpectedError => nativePaymentFailureReason::UnexpectedError,
985                 }
986         }
987         #[allow(unused)]
988         pub(crate) fn into_native(self) -> nativePaymentFailureReason {
989                 match self {
990                         PaymentFailureReason::RecipientRejected => nativePaymentFailureReason::RecipientRejected,
991                         PaymentFailureReason::UserAbandoned => nativePaymentFailureReason::UserAbandoned,
992                         PaymentFailureReason::RetriesExhausted => nativePaymentFailureReason::RetriesExhausted,
993                         PaymentFailureReason::PaymentExpired => nativePaymentFailureReason::PaymentExpired,
994                         PaymentFailureReason::RouteNotFound => nativePaymentFailureReason::RouteNotFound,
995                         PaymentFailureReason::UnexpectedError => nativePaymentFailureReason::UnexpectedError,
996                 }
997         }
998         #[allow(unused)]
999         pub(crate) fn from_native(native: &nativePaymentFailureReason) -> Self {
1000                 match native {
1001                         nativePaymentFailureReason::RecipientRejected => PaymentFailureReason::RecipientRejected,
1002                         nativePaymentFailureReason::UserAbandoned => PaymentFailureReason::UserAbandoned,
1003                         nativePaymentFailureReason::RetriesExhausted => PaymentFailureReason::RetriesExhausted,
1004                         nativePaymentFailureReason::PaymentExpired => PaymentFailureReason::PaymentExpired,
1005                         nativePaymentFailureReason::RouteNotFound => PaymentFailureReason::RouteNotFound,
1006                         nativePaymentFailureReason::UnexpectedError => PaymentFailureReason::UnexpectedError,
1007                 }
1008         }
1009         #[allow(unused)]
1010         pub(crate) fn native_into(native: nativePaymentFailureReason) -> Self {
1011                 match native {
1012                         nativePaymentFailureReason::RecipientRejected => PaymentFailureReason::RecipientRejected,
1013                         nativePaymentFailureReason::UserAbandoned => PaymentFailureReason::UserAbandoned,
1014                         nativePaymentFailureReason::RetriesExhausted => PaymentFailureReason::RetriesExhausted,
1015                         nativePaymentFailureReason::PaymentExpired => PaymentFailureReason::PaymentExpired,
1016                         nativePaymentFailureReason::RouteNotFound => PaymentFailureReason::RouteNotFound,
1017                         nativePaymentFailureReason::UnexpectedError => PaymentFailureReason::UnexpectedError,
1018                 }
1019         }
1020 }
1021 /// Creates a copy of the PaymentFailureReason
1022 #[no_mangle]
1023 pub extern "C" fn PaymentFailureReason_clone(orig: &PaymentFailureReason) -> PaymentFailureReason {
1024         orig.clone()
1025 }
1026 #[no_mangle]
1027 /// Utility method to constructs a new RecipientRejected-variant PaymentFailureReason
1028 pub extern "C" fn PaymentFailureReason_recipient_rejected() -> PaymentFailureReason {
1029         PaymentFailureReason::RecipientRejected}
1030 #[no_mangle]
1031 /// Utility method to constructs a new UserAbandoned-variant PaymentFailureReason
1032 pub extern "C" fn PaymentFailureReason_user_abandoned() -> PaymentFailureReason {
1033         PaymentFailureReason::UserAbandoned}
1034 #[no_mangle]
1035 /// Utility method to constructs a new RetriesExhausted-variant PaymentFailureReason
1036 pub extern "C" fn PaymentFailureReason_retries_exhausted() -> PaymentFailureReason {
1037         PaymentFailureReason::RetriesExhausted}
1038 #[no_mangle]
1039 /// Utility method to constructs a new PaymentExpired-variant PaymentFailureReason
1040 pub extern "C" fn PaymentFailureReason_payment_expired() -> PaymentFailureReason {
1041         PaymentFailureReason::PaymentExpired}
1042 #[no_mangle]
1043 /// Utility method to constructs a new RouteNotFound-variant PaymentFailureReason
1044 pub extern "C" fn PaymentFailureReason_route_not_found() -> PaymentFailureReason {
1045         PaymentFailureReason::RouteNotFound}
1046 #[no_mangle]
1047 /// Utility method to constructs a new UnexpectedError-variant PaymentFailureReason
1048 pub extern "C" fn PaymentFailureReason_unexpected_error() -> PaymentFailureReason {
1049         PaymentFailureReason::UnexpectedError}
1050 /// Checks if two PaymentFailureReasons contain equal inner contents.
1051 /// This ignores pointers and is_owned flags and looks at the values in fields.
1052 #[no_mangle]
1053 pub extern "C" fn PaymentFailureReason_eq(a: &PaymentFailureReason, b: &PaymentFailureReason) -> bool {
1054         if &a.to_native() == &b.to_native() { true } else { false }
1055 }
1056 #[no_mangle]
1057 /// Serialize the PaymentFailureReason object into a byte array which can be read by PaymentFailureReason_read
1058 pub extern "C" fn PaymentFailureReason_write(obj: &crate::lightning::events::PaymentFailureReason) -> crate::c_types::derived::CVec_u8Z {
1059         crate::c_types::serialize_obj(&unsafe { &*obj }.to_native())
1060 }
1061 #[no_mangle]
1062 /// Read a PaymentFailureReason from a byte array, created by PaymentFailureReason_write
1063 pub extern "C" fn PaymentFailureReason_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_PaymentFailureReasonDecodeErrorZ {
1064         let res: Result<lightning::events::PaymentFailureReason, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
1065         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() };
1066         local_res
1067 }
1068 /// An Event which you should probably take some action in response to.
1069 ///
1070 /// Note that while Writeable and Readable are implemented for Event, you probably shouldn't use
1071 /// them directly as they don't round-trip exactly (for example FundingGenerationReady is never
1072 /// written as it makes no sense to respond to it after reconnecting to peers).
1073 #[derive(Clone)]
1074 #[must_use]
1075 #[repr(C)]
1076 pub enum Event {
1077         /// Used to indicate that the client should generate a funding transaction with the given
1078         /// parameters and then call [`ChannelManager::funding_transaction_generated`].
1079         /// Generated in [`ChannelManager`] message handling.
1080         /// Note that *all inputs* in the funding transaction must spend SegWit outputs or your
1081         /// counterparty can steal your funds!
1082         ///
1083         /// [`ChannelManager`]: crate::ln::channelmanager::ChannelManager
1084         /// [`ChannelManager::funding_transaction_generated`]: crate::ln::channelmanager::ChannelManager::funding_transaction_generated
1085         FundingGenerationReady {
1086                 /// The random channel_id we picked which you'll need to pass into
1087                 /// [`ChannelManager::funding_transaction_generated`].
1088                 ///
1089                 /// [`ChannelManager::funding_transaction_generated`]: crate::ln::channelmanager::ChannelManager::funding_transaction_generated
1090                 temporary_channel_id: crate::c_types::ThirtyTwoBytes,
1091                 /// The counterparty's node_id, which you'll need to pass back into
1092                 /// [`ChannelManager::funding_transaction_generated`].
1093                 ///
1094                 /// [`ChannelManager::funding_transaction_generated`]: crate::ln::channelmanager::ChannelManager::funding_transaction_generated
1095                 counterparty_node_id: crate::c_types::PublicKey,
1096                 /// The value, in satoshis, that the output should have.
1097                 channel_value_satoshis: u64,
1098                 /// The script which should be used in the transaction output.
1099                 output_script: crate::c_types::derived::CVec_u8Z,
1100                 /// The `user_channel_id` value passed in to [`ChannelManager::create_channel`] for outbound
1101                 /// channels, or to [`ChannelManager::accept_inbound_channel`] for inbound channels if
1102                 /// [`UserConfig::manually_accept_inbound_channels`] config flag is set to true. Otherwise
1103                 /// `user_channel_id` will be randomized for an inbound channel.  This may be zero for objects
1104                 /// serialized with LDK versions prior to 0.0.113.
1105                 ///
1106                 /// [`ChannelManager::create_channel`]: crate::ln::channelmanager::ChannelManager::create_channel
1107                 /// [`ChannelManager::accept_inbound_channel`]: crate::ln::channelmanager::ChannelManager::accept_inbound_channel
1108                 /// [`UserConfig::manually_accept_inbound_channels`]: crate::util::config::UserConfig::manually_accept_inbound_channels
1109                 user_channel_id: crate::c_types::U128,
1110         },
1111         /// Indicates that we've been offered a payment and it needs to be claimed via calling
1112         /// [`ChannelManager::claim_funds`] with the preimage given in [`PaymentPurpose`].
1113         ///
1114         /// Note that if the preimage is not known, you should call
1115         /// [`ChannelManager::fail_htlc_backwards`] or [`ChannelManager::fail_htlc_backwards_with_reason`]
1116         /// to free up resources for this HTLC and avoid network congestion.
1117         ///
1118         /// If [`Event::PaymentClaimable::onion_fields`] is `Some`, and includes custom TLVs with even type
1119         /// numbers, you should use [`ChannelManager::fail_htlc_backwards_with_reason`] with
1120         /// [`FailureCode::InvalidOnionPayload`] if you fail to understand and handle the contents, or
1121         /// [`ChannelManager::claim_funds_with_known_custom_tlvs`] upon successful handling.
1122         /// If you don't intend to check for custom TLVs, you can simply use
1123         /// [`ChannelManager::claim_funds`], which will automatically fail back even custom TLVs.
1124         ///
1125         /// If you fail to call [`ChannelManager::claim_funds`],
1126         /// [`ChannelManager::claim_funds_with_known_custom_tlvs`],
1127         /// [`ChannelManager::fail_htlc_backwards`], or
1128         /// [`ChannelManager::fail_htlc_backwards_with_reason`] within the HTLC's timeout, the HTLC will
1129         /// be automatically failed.
1130         ///
1131         /// # Note
1132         /// LDK will not stop an inbound payment from being paid multiple times, so multiple
1133         /// `PaymentClaimable` events may be generated for the same payment. In such a case it is
1134         /// polite (and required in the lightning specification) to fail the payment the second time
1135         /// and give the sender their money back rather than accepting double payment.
1136         ///
1137         /// # Note
1138         /// This event used to be called `PaymentReceived` in LDK versions 0.0.112 and earlier.
1139         ///
1140         /// [`ChannelManager::claim_funds`]: crate::ln::channelmanager::ChannelManager::claim_funds
1141         /// [`ChannelManager::claim_funds_with_known_custom_tlvs`]: crate::ln::channelmanager::ChannelManager::claim_funds_with_known_custom_tlvs
1142         /// [`FailureCode::InvalidOnionPayload`]: crate::ln::channelmanager::FailureCode::InvalidOnionPayload
1143         /// [`ChannelManager::fail_htlc_backwards`]: crate::ln::channelmanager::ChannelManager::fail_htlc_backwards
1144         /// [`ChannelManager::fail_htlc_backwards_with_reason`]: crate::ln::channelmanager::ChannelManager::fail_htlc_backwards_with_reason
1145         PaymentClaimable {
1146                 /// The node that will receive the payment after it has been claimed.
1147                 /// This is useful to identify payments received via [phantom nodes].
1148                 /// This field will always be filled in when the event was generated by LDK versions
1149                 /// 0.0.113 and above.
1150                 ///
1151                 /// [phantom nodes]: crate::sign::PhantomKeysManager
1152                 ///
1153                 /// Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None
1154                 receiver_node_id: crate::c_types::PublicKey,
1155                 /// The hash for which the preimage should be handed to the ChannelManager. Note that LDK will
1156                 /// not stop you from registering duplicate payment hashes for inbound payments.
1157                 payment_hash: crate::c_types::ThirtyTwoBytes,
1158                 /// The fields in the onion which were received with each HTLC. Only fields which were
1159                 /// identical in each HTLC involved in the payment will be included here.
1160                 ///
1161                 /// Payments received on LDK versions prior to 0.0.115 will have this field unset.
1162                 ///
1163                 /// Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None
1164                 onion_fields: crate::lightning::ln::outbound_payment::RecipientOnionFields,
1165                 /// The value, in thousandths of a satoshi, that this payment is claimable for. May be greater
1166                 /// than the invoice amount.
1167                 ///
1168                 /// May be less than the invoice amount if [`ChannelConfig::accept_underpaying_htlcs`] is set
1169                 /// and the previous hop took an extra fee.
1170                 ///
1171                 /// # Note
1172                 /// If [`ChannelConfig::accept_underpaying_htlcs`] is set and you claim without verifying this
1173                 /// field, you may lose money!
1174                 ///
1175                 /// [`ChannelConfig::accept_underpaying_htlcs`]: crate::util::config::ChannelConfig::accept_underpaying_htlcs
1176                 amount_msat: u64,
1177                 /// The value, in thousands of a satoshi, that was skimmed off of this payment as an extra fee
1178                 /// taken by our channel counterparty.
1179                 ///
1180                 /// Will always be 0 unless [`ChannelConfig::accept_underpaying_htlcs`] is set.
1181                 ///
1182                 /// [`ChannelConfig::accept_underpaying_htlcs`]: crate::util::config::ChannelConfig::accept_underpaying_htlcs
1183                 counterparty_skimmed_fee_msat: u64,
1184                 /// Information for claiming this received payment, based on whether the purpose of the
1185                 /// payment is to pay an invoice or to send a spontaneous payment.
1186                 purpose: crate::lightning::events::PaymentPurpose,
1187                 /// The `channel_id` indicating over which channel we received the payment.
1188                 via_channel_id: crate::c_types::derived::COption_ThirtyTwoBytesZ,
1189                 /// The `user_channel_id` indicating over which channel we received the payment.
1190                 via_user_channel_id: crate::c_types::derived::COption_U128Z,
1191                 /// The block height at which this payment will be failed back and will no longer be
1192                 /// eligible for claiming.
1193                 ///
1194                 /// Prior to this height, a call to [`ChannelManager::claim_funds`] is guaranteed to
1195                 /// succeed, however you should wait for [`Event::PaymentClaimed`] to be sure.
1196                 ///
1197                 /// [`ChannelManager::claim_funds`]: crate::ln::channelmanager::ChannelManager::claim_funds
1198                 claim_deadline: crate::c_types::derived::COption_u32Z,
1199         },
1200         /// Indicates a payment has been claimed and we've received money!
1201         ///
1202         /// This most likely occurs when [`ChannelManager::claim_funds`] has been called in response
1203         /// to an [`Event::PaymentClaimable`]. However, if we previously crashed during a
1204         /// [`ChannelManager::claim_funds`] call you may see this event without a corresponding
1205         /// [`Event::PaymentClaimable`] event.
1206         ///
1207         /// # Note
1208         /// LDK will not stop an inbound payment from being paid multiple times, so multiple
1209         /// `PaymentClaimable` events may be generated for the same payment. If you then call
1210         /// [`ChannelManager::claim_funds`] twice for the same [`Event::PaymentClaimable`] you may get
1211         /// multiple `PaymentClaimed` events.
1212         ///
1213         /// [`ChannelManager::claim_funds`]: crate::ln::channelmanager::ChannelManager::claim_funds
1214         PaymentClaimed {
1215                 /// The node that received the payment.
1216                 /// This is useful to identify payments which were received via [phantom nodes].
1217                 /// This field will always be filled in when the event was generated by LDK versions
1218                 /// 0.0.113 and above.
1219                 ///
1220                 /// [phantom nodes]: crate::sign::PhantomKeysManager
1221                 ///
1222                 /// Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None
1223                 receiver_node_id: crate::c_types::PublicKey,
1224                 /// The payment hash of the claimed payment. Note that LDK will not stop you from
1225                 /// registering duplicate payment hashes for inbound payments.
1226                 payment_hash: crate::c_types::ThirtyTwoBytes,
1227                 /// The value, in thousandths of a satoshi, that this payment is for. May be greater than the
1228                 /// invoice amount.
1229                 amount_msat: u64,
1230                 /// The purpose of the claimed payment, i.e. whether the payment was for an invoice or a
1231                 /// spontaneous payment.
1232                 purpose: crate::lightning::events::PaymentPurpose,
1233                 /// The HTLCs that comprise the claimed payment. This will be empty for events serialized prior
1234                 /// to LDK version 0.0.117.
1235                 htlcs: crate::c_types::derived::CVec_ClaimedHTLCZ,
1236                 /// The sender-intended sum total of all the MPP parts. This will be `None` for events
1237                 /// serialized prior to LDK version 0.0.117.
1238                 sender_intended_total_msat: crate::c_types::derived::COption_u64Z,
1239         },
1240         /// Indicates an outbound payment we made succeeded (i.e. it made it all the way to its target
1241         /// and we got back the payment preimage for it).
1242         ///
1243         /// Note for MPP payments: in rare cases, this event may be preceded by a `PaymentPathFailed`
1244         /// event. In this situation, you SHOULD treat this payment as having succeeded.
1245         PaymentSent {
1246                 /// The `payment_id` passed to [`ChannelManager::send_payment`].
1247                 ///
1248                 /// [`ChannelManager::send_payment`]: crate::ln::channelmanager::ChannelManager::send_payment
1249                 payment_id: crate::c_types::derived::COption_ThirtyTwoBytesZ,
1250                 /// The preimage to the hash given to ChannelManager::send_payment.
1251                 /// Note that this serves as a payment receipt, if you wish to have such a thing, you must
1252                 /// store it somehow!
1253                 payment_preimage: crate::c_types::ThirtyTwoBytes,
1254                 /// The hash that was given to [`ChannelManager::send_payment`].
1255                 ///
1256                 /// [`ChannelManager::send_payment`]: crate::ln::channelmanager::ChannelManager::send_payment
1257                 payment_hash: crate::c_types::ThirtyTwoBytes,
1258                 /// The total fee which was spent at intermediate hops in this payment, across all paths.
1259                 ///
1260                 /// Note that, like [`Route::get_total_fees`] this does *not* include any potential
1261                 /// overpayment to the recipient node.
1262                 ///
1263                 /// If the recipient or an intermediate node misbehaves and gives us free money, this may
1264                 /// overstate the amount paid, though this is unlikely.
1265                 ///
1266                 /// [`Route::get_total_fees`]: crate::routing::router::Route::get_total_fees
1267                 fee_paid_msat: crate::c_types::derived::COption_u64Z,
1268         },
1269         /// Indicates an outbound payment failed. Individual [`Event::PaymentPathFailed`] events
1270         /// provide failure information for each path attempt in the payment, including retries.
1271         ///
1272         /// This event is provided once there are no further pending HTLCs for the payment and the
1273         /// payment is no longer retryable, due either to the [`Retry`] provided or
1274         /// [`ChannelManager::abandon_payment`] having been called for the corresponding payment.
1275         ///
1276         /// In exceedingly rare cases, it is possible that an [`Event::PaymentFailed`] is generated for
1277         /// a payment after an [`Event::PaymentSent`] event for this same payment has already been
1278         /// received and processed. In this case, the [`Event::PaymentFailed`] event MUST be ignored,
1279         /// and the payment MUST be treated as having succeeded.
1280         ///
1281         /// [`Retry`]: crate::ln::channelmanager::Retry
1282         /// [`ChannelManager::abandon_payment`]: crate::ln::channelmanager::ChannelManager::abandon_payment
1283         PaymentFailed {
1284                 /// The `payment_id` passed to [`ChannelManager::send_payment`].
1285                 ///
1286                 /// [`ChannelManager::send_payment`]: crate::ln::channelmanager::ChannelManager::send_payment
1287                 payment_id: crate::c_types::ThirtyTwoBytes,
1288                 /// The hash that was given to [`ChannelManager::send_payment`].
1289                 ///
1290                 /// [`ChannelManager::send_payment`]: crate::ln::channelmanager::ChannelManager::send_payment
1291                 payment_hash: crate::c_types::ThirtyTwoBytes,
1292                 /// The reason the payment failed. This is only `None` for events generated or serialized
1293                 /// by versions prior to 0.0.115.
1294                 reason: crate::c_types::derived::COption_PaymentFailureReasonZ,
1295         },
1296         /// Indicates that a path for an outbound payment was successful.
1297         ///
1298         /// Always generated after [`Event::PaymentSent`] and thus useful for scoring channels. See
1299         /// [`Event::PaymentSent`] for obtaining the payment preimage.
1300         PaymentPathSuccessful {
1301                 /// The `payment_id` passed to [`ChannelManager::send_payment`].
1302                 ///
1303                 /// [`ChannelManager::send_payment`]: crate::ln::channelmanager::ChannelManager::send_payment
1304                 payment_id: crate::c_types::ThirtyTwoBytes,
1305                 /// The hash that was given to [`ChannelManager::send_payment`].
1306                 ///
1307                 /// This will be `Some` for all payments which completed on LDK 0.0.104 or later.
1308                 ///
1309                 /// [`ChannelManager::send_payment`]: crate::ln::channelmanager::ChannelManager::send_payment
1310                 payment_hash: crate::c_types::derived::COption_ThirtyTwoBytesZ,
1311                 /// The payment path that was successful.
1312                 ///
1313                 /// May contain a closed channel if the HTLC sent along the path was fulfilled on chain.
1314                 path: crate::lightning::routing::router::Path,
1315         },
1316         /// Indicates an outbound HTLC we sent failed, likely due to an intermediary node being unable to
1317         /// handle the HTLC.
1318         ///
1319         /// Note that this does *not* indicate that all paths for an MPP payment have failed, see
1320         /// [`Event::PaymentFailed`].
1321         ///
1322         /// See [`ChannelManager::abandon_payment`] for giving up on this payment before its retries have
1323         /// been exhausted.
1324         ///
1325         /// [`ChannelManager::abandon_payment`]: crate::ln::channelmanager::ChannelManager::abandon_payment
1326         PaymentPathFailed {
1327                 /// The `payment_id` passed to [`ChannelManager::send_payment`].
1328                 ///
1329                 /// This will be `Some` for all payment paths which failed on LDK 0.0.103 or later.
1330                 ///
1331                 /// [`ChannelManager::send_payment`]: crate::ln::channelmanager::ChannelManager::send_payment
1332                 /// [`ChannelManager::abandon_payment`]: crate::ln::channelmanager::ChannelManager::abandon_payment
1333                 payment_id: crate::c_types::derived::COption_ThirtyTwoBytesZ,
1334                 /// The hash that was given to [`ChannelManager::send_payment`].
1335                 ///
1336                 /// [`ChannelManager::send_payment`]: crate::ln::channelmanager::ChannelManager::send_payment
1337                 payment_hash: crate::c_types::ThirtyTwoBytes,
1338                 /// Indicates the payment was rejected for some reason by the recipient. This implies that
1339                 /// the payment has failed, not just the route in question. If this is not set, the payment may
1340                 /// be retried via a different route.
1341                 payment_failed_permanently: bool,
1342                 /// Extra error details based on the failure type. May contain an update that needs to be
1343                 /// applied to the [`NetworkGraph`].
1344                 ///
1345                 /// [`NetworkGraph`]: crate::routing::gossip::NetworkGraph
1346                 failure: crate::lightning::events::PathFailure,
1347                 /// The payment path that failed.
1348                 path: crate::lightning::routing::router::Path,
1349                 /// The channel responsible for the failed payment path.
1350                 ///
1351                 /// Note that for route hints or for the first hop in a path this may be an SCID alias and
1352                 /// may not refer to a channel in the public network graph. These aliases may also collide
1353                 /// with channels in the public network graph.
1354                 ///
1355                 /// If this is `Some`, then the corresponding channel should be avoided when the payment is
1356                 /// retried. May be `None` for older [`Event`] serializations.
1357                 short_channel_id: crate::c_types::derived::COption_u64Z,
1358         },
1359         /// Indicates that a probe payment we sent returned successful, i.e., only failed at the destination.
1360         ProbeSuccessful {
1361                 /// The id returned by [`ChannelManager::send_probe`].
1362                 ///
1363                 /// [`ChannelManager::send_probe`]: crate::ln::channelmanager::ChannelManager::send_probe
1364                 payment_id: crate::c_types::ThirtyTwoBytes,
1365                 /// The hash generated by [`ChannelManager::send_probe`].
1366                 ///
1367                 /// [`ChannelManager::send_probe`]: crate::ln::channelmanager::ChannelManager::send_probe
1368                 payment_hash: crate::c_types::ThirtyTwoBytes,
1369                 /// The payment path that was successful.
1370                 path: crate::lightning::routing::router::Path,
1371         },
1372         /// Indicates that a probe payment we sent failed at an intermediary node on the path.
1373         ProbeFailed {
1374                 /// The id returned by [`ChannelManager::send_probe`].
1375                 ///
1376                 /// [`ChannelManager::send_probe`]: crate::ln::channelmanager::ChannelManager::send_probe
1377                 payment_id: crate::c_types::ThirtyTwoBytes,
1378                 /// The hash generated by [`ChannelManager::send_probe`].
1379                 ///
1380                 /// [`ChannelManager::send_probe`]: crate::ln::channelmanager::ChannelManager::send_probe
1381                 payment_hash: crate::c_types::ThirtyTwoBytes,
1382                 /// The payment path that failed.
1383                 path: crate::lightning::routing::router::Path,
1384                 /// The channel responsible for the failed probe.
1385                 ///
1386                 /// Note that for route hints or for the first hop in a path this may be an SCID alias and
1387                 /// may not refer to a channel in the public network graph. These aliases may also collide
1388                 /// with channels in the public network graph.
1389                 short_channel_id: crate::c_types::derived::COption_u64Z,
1390         },
1391         /// Used to indicate that [`ChannelManager::process_pending_htlc_forwards`] should be called at
1392         /// a time in the future.
1393         ///
1394         /// [`ChannelManager::process_pending_htlc_forwards`]: crate::ln::channelmanager::ChannelManager::process_pending_htlc_forwards
1395         PendingHTLCsForwardable {
1396                 /// The minimum amount of time that should be waited prior to calling
1397                 /// process_pending_htlc_forwards. To increase the effort required to correlate payments,
1398                 /// you should wait a random amount of time in roughly the range (now + time_forwardable,
1399                 /// now + 5*time_forwardable).
1400                 time_forwardable: u64,
1401         },
1402         /// Used to indicate that we've intercepted an HTLC forward. This event will only be generated if
1403         /// you've encoded an intercept scid in the receiver's invoice route hints using
1404         /// [`ChannelManager::get_intercept_scid`] and have set [`UserConfig::accept_intercept_htlcs`].
1405         ///
1406         /// [`ChannelManager::forward_intercepted_htlc`] or
1407         /// [`ChannelManager::fail_intercepted_htlc`] MUST be called in response to this event. See
1408         /// their docs for more information.
1409         ///
1410         /// [`ChannelManager::get_intercept_scid`]: crate::ln::channelmanager::ChannelManager::get_intercept_scid
1411         /// [`UserConfig::accept_intercept_htlcs`]: crate::util::config::UserConfig::accept_intercept_htlcs
1412         /// [`ChannelManager::forward_intercepted_htlc`]: crate::ln::channelmanager::ChannelManager::forward_intercepted_htlc
1413         /// [`ChannelManager::fail_intercepted_htlc`]: crate::ln::channelmanager::ChannelManager::fail_intercepted_htlc
1414         HTLCIntercepted {
1415                 /// An id to help LDK identify which HTLC is being forwarded or failed.
1416                 intercept_id: crate::c_types::ThirtyTwoBytes,
1417                 /// The fake scid that was programmed as the next hop's scid, generated using
1418                 /// [`ChannelManager::get_intercept_scid`].
1419                 ///
1420                 /// [`ChannelManager::get_intercept_scid`]: crate::ln::channelmanager::ChannelManager::get_intercept_scid
1421                 requested_next_hop_scid: u64,
1422                 /// The payment hash used for this HTLC.
1423                 payment_hash: crate::c_types::ThirtyTwoBytes,
1424                 /// How many msats were received on the inbound edge of this HTLC.
1425                 inbound_amount_msat: u64,
1426                 /// How many msats the payer intended to route to the next node. Depending on the reason you are
1427                 /// intercepting this payment, you might take a fee by forwarding less than this amount.
1428                 /// Forwarding less than this amount may break compatibility with LDK versions prior to 0.0.116.
1429                 ///
1430                 /// Note that LDK will NOT check that expected fees were factored into this value. You MUST
1431                 /// check that whatever fee you want has been included here or subtract it as required. Further,
1432                 /// LDK will not stop you from forwarding more than you received.
1433                 expected_outbound_amount_msat: u64,
1434         },
1435         /// Used to indicate that an output which you should know how to spend was confirmed on chain
1436         /// and is now spendable.
1437         /// Such an output will *not* ever be spent by rust-lightning, and are not at risk of your
1438         /// counterparty spending them due to some kind of timeout. Thus, you need to store them
1439         /// somewhere and spend them when you create on-chain transactions.
1440         SpendableOutputs {
1441                 /// The outputs which you should store as spendable by you.
1442                 outputs: crate::c_types::derived::CVec_SpendableOutputDescriptorZ,
1443                 /// The `channel_id` indicating which channel the spendable outputs belong to.
1444                 ///
1445                 /// This will always be `Some` for events generated by LDK versions 0.0.117 and above.
1446                 channel_id: crate::c_types::derived::COption_ThirtyTwoBytesZ,
1447         },
1448         /// This event is generated when a payment has been successfully forwarded through us and a
1449         /// forwarding fee earned.
1450         PaymentForwarded {
1451                 /// The incoming channel between the previous node and us. This is only `None` for events
1452                 /// generated or serialized by versions prior to 0.0.107.
1453                 prev_channel_id: crate::c_types::derived::COption_ThirtyTwoBytesZ,
1454                 /// The outgoing channel between the next node and us. This is only `None` for events
1455                 /// generated or serialized by versions prior to 0.0.107.
1456                 next_channel_id: crate::c_types::derived::COption_ThirtyTwoBytesZ,
1457                 /// The fee, in milli-satoshis, which was earned as a result of the payment.
1458                 ///
1459                 /// Note that if we force-closed the channel over which we forwarded an HTLC while the HTLC
1460                 /// was pending, the amount the next hop claimed will have been rounded down to the nearest
1461                 /// whole satoshi. Thus, the fee calculated here may be higher than expected as we still
1462                 /// claimed the full value in millisatoshis from the source. In this case,
1463                 /// `claim_from_onchain_tx` will be set.
1464                 ///
1465                 /// If the channel which sent us the payment has been force-closed, we will claim the funds
1466                 /// via an on-chain transaction. In that case we do not yet know the on-chain transaction
1467                 /// fees which we will spend and will instead set this to `None`. It is possible duplicate
1468                 /// `PaymentForwarded` events are generated for the same payment iff `fee_earned_msat` is
1469                 /// `None`.
1470                 fee_earned_msat: crate::c_types::derived::COption_u64Z,
1471                 /// If this is `true`, the forwarded HTLC was claimed by our counterparty via an on-chain
1472                 /// transaction.
1473                 claim_from_onchain_tx: bool,
1474                 /// The final amount forwarded, in milli-satoshis, after the fee is deducted.
1475                 ///
1476                 /// The caveat described above the `fee_earned_msat` field applies here as well.
1477                 outbound_amount_forwarded_msat: crate::c_types::derived::COption_u64Z,
1478         },
1479         /// Used to indicate that a channel with the given `channel_id` is being opened and pending
1480         /// confirmation on-chain.
1481         ///
1482         /// This event is emitted when the funding transaction has been signed and is broadcast to the
1483         /// network. For 0conf channels it will be immediately followed by the corresponding
1484         /// [`Event::ChannelReady`] event.
1485         ChannelPending {
1486                 /// The `channel_id` of the channel that is pending confirmation.
1487                 channel_id: crate::c_types::ThirtyTwoBytes,
1488                 /// The `user_channel_id` value passed in to [`ChannelManager::create_channel`] for outbound
1489                 /// channels, or to [`ChannelManager::accept_inbound_channel`] for inbound channels if
1490                 /// [`UserConfig::manually_accept_inbound_channels`] config flag is set to true. Otherwise
1491                 /// `user_channel_id` will be randomized for an inbound channel.
1492                 ///
1493                 /// [`ChannelManager::create_channel`]: crate::ln::channelmanager::ChannelManager::create_channel
1494                 /// [`ChannelManager::accept_inbound_channel`]: crate::ln::channelmanager::ChannelManager::accept_inbound_channel
1495                 /// [`UserConfig::manually_accept_inbound_channels`]: crate::util::config::UserConfig::manually_accept_inbound_channels
1496                 user_channel_id: crate::c_types::U128,
1497                 /// The `temporary_channel_id` this channel used to be known by during channel establishment.
1498                 ///
1499                 /// Will be `None` for channels created prior to LDK version 0.0.115.
1500                 former_temporary_channel_id: crate::c_types::derived::COption_ThirtyTwoBytesZ,
1501                 /// The `node_id` of the channel counterparty.
1502                 counterparty_node_id: crate::c_types::PublicKey,
1503                 /// The outpoint of the channel's funding transaction.
1504                 funding_txo: crate::lightning::chain::transaction::OutPoint,
1505         },
1506         /// Used to indicate that a channel with the given `channel_id` is ready to
1507         /// be used. This event is emitted either when the funding transaction has been confirmed
1508         /// on-chain, or, in case of a 0conf channel, when both parties have confirmed the channel
1509         /// establishment.
1510         ChannelReady {
1511                 /// The `channel_id` of the channel that is ready.
1512                 channel_id: crate::c_types::ThirtyTwoBytes,
1513                 /// The `user_channel_id` value passed in to [`ChannelManager::create_channel`] for outbound
1514                 /// channels, or to [`ChannelManager::accept_inbound_channel`] for inbound channels if
1515                 /// [`UserConfig::manually_accept_inbound_channels`] config flag is set to true. Otherwise
1516                 /// `user_channel_id` will be randomized for an inbound channel.
1517                 ///
1518                 /// [`ChannelManager::create_channel`]: crate::ln::channelmanager::ChannelManager::create_channel
1519                 /// [`ChannelManager::accept_inbound_channel`]: crate::ln::channelmanager::ChannelManager::accept_inbound_channel
1520                 /// [`UserConfig::manually_accept_inbound_channels`]: crate::util::config::UserConfig::manually_accept_inbound_channels
1521                 user_channel_id: crate::c_types::U128,
1522                 /// The `node_id` of the channel counterparty.
1523                 counterparty_node_id: crate::c_types::PublicKey,
1524                 /// The features that this channel will operate with.
1525                 channel_type: crate::lightning::ln::features::ChannelTypeFeatures,
1526         },
1527         /// Used to indicate that a previously opened channel with the given `channel_id` is in the
1528         /// process of closure.
1529         ///
1530         /// Note that this event is only triggered for accepted channels: if the
1531         /// [`UserConfig::manually_accept_inbound_channels`] config flag is set to true and the channel is
1532         /// rejected, no `ChannelClosed` event will be sent.
1533         ///
1534         /// [`ChannelManager::accept_inbound_channel`]: crate::ln::channelmanager::ChannelManager::accept_inbound_channel
1535         /// [`UserConfig::manually_accept_inbound_channels`]: crate::util::config::UserConfig::manually_accept_inbound_channels
1536         ChannelClosed {
1537                 /// The `channel_id` of the channel which has been closed. Note that on-chain transactions
1538                 /// resolving the channel are likely still awaiting confirmation.
1539                 channel_id: crate::c_types::ThirtyTwoBytes,
1540                 /// The `user_channel_id` value passed in to [`ChannelManager::create_channel`] for outbound
1541                 /// channels, or to [`ChannelManager::accept_inbound_channel`] for inbound channels if
1542                 /// [`UserConfig::manually_accept_inbound_channels`] config flag is set to true. Otherwise
1543                 /// `user_channel_id` will be randomized for inbound channels.
1544                 /// This may be zero for inbound channels serialized prior to 0.0.113 and will always be
1545                 /// zero for objects serialized with LDK versions prior to 0.0.102.
1546                 ///
1547                 /// [`ChannelManager::create_channel`]: crate::ln::channelmanager::ChannelManager::create_channel
1548                 /// [`ChannelManager::accept_inbound_channel`]: crate::ln::channelmanager::ChannelManager::accept_inbound_channel
1549                 /// [`UserConfig::manually_accept_inbound_channels`]: crate::util::config::UserConfig::manually_accept_inbound_channels
1550                 user_channel_id: crate::c_types::U128,
1551                 /// The reason the channel was closed.
1552                 reason: crate::lightning::events::ClosureReason,
1553                 /// Counterparty in the closed channel.
1554                 ///
1555                 /// This field will be `None` for objects serialized prior to LDK 0.0.117.
1556                 ///
1557                 /// Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None
1558                 counterparty_node_id: crate::c_types::PublicKey,
1559                 /// Channel capacity of the closing channel (sats).
1560                 ///
1561                 /// This field will be `None` for objects serialized prior to LDK 0.0.117.
1562                 channel_capacity_sats: crate::c_types::derived::COption_u64Z,
1563         },
1564         /// Used to indicate to the user that they can abandon the funding transaction and recycle the
1565         /// inputs for another purpose.
1566         ///
1567         /// This event is not guaranteed to be generated for channels that are closed due to a restart.
1568         DiscardFunding {
1569                 /// The channel_id of the channel which has been closed.
1570                 channel_id: crate::c_types::ThirtyTwoBytes,
1571                 /// The full transaction received from the user
1572                 transaction: crate::c_types::Transaction,
1573         },
1574         /// Indicates a request to open a new channel by a peer.
1575         ///
1576         /// To accept the request, call [`ChannelManager::accept_inbound_channel`]. To reject the request,
1577         /// call [`ChannelManager::force_close_without_broadcasting_txn`]. Note that a ['ChannelClosed`]
1578         /// event will _not_ be triggered if the channel is rejected.
1579         ///
1580         /// The event is only triggered when a new open channel request is received and the
1581         /// [`UserConfig::manually_accept_inbound_channels`] config flag is set to true.
1582         ///
1583         /// [`ChannelManager::accept_inbound_channel`]: crate::ln::channelmanager::ChannelManager::accept_inbound_channel
1584         /// [`ChannelManager::force_close_without_broadcasting_txn`]: crate::ln::channelmanager::ChannelManager::force_close_without_broadcasting_txn
1585         /// [`UserConfig::manually_accept_inbound_channels`]: crate::util::config::UserConfig::manually_accept_inbound_channels
1586         OpenChannelRequest {
1587                 /// The temporary channel ID of the channel requested to be opened.
1588                 ///
1589                 /// When responding to the request, the `temporary_channel_id` should be passed
1590                 /// back to the ChannelManager through [`ChannelManager::accept_inbound_channel`] to accept,
1591                 /// or through [`ChannelManager::force_close_without_broadcasting_txn`] to reject.
1592                 ///
1593                 /// [`ChannelManager::accept_inbound_channel`]: crate::ln::channelmanager::ChannelManager::accept_inbound_channel
1594                 /// [`ChannelManager::force_close_without_broadcasting_txn`]: crate::ln::channelmanager::ChannelManager::force_close_without_broadcasting_txn
1595                 temporary_channel_id: crate::c_types::ThirtyTwoBytes,
1596                 /// The node_id of the counterparty requesting to open the channel.
1597                 ///
1598                 /// When responding to the request, the `counterparty_node_id` should be passed
1599                 /// back to the `ChannelManager` through [`ChannelManager::accept_inbound_channel`] to
1600                 /// accept the request, or through [`ChannelManager::force_close_without_broadcasting_txn`] to reject the
1601                 /// request.
1602                 ///
1603                 /// [`ChannelManager::accept_inbound_channel`]: crate::ln::channelmanager::ChannelManager::accept_inbound_channel
1604                 /// [`ChannelManager::force_close_without_broadcasting_txn`]: crate::ln::channelmanager::ChannelManager::force_close_without_broadcasting_txn
1605                 counterparty_node_id: crate::c_types::PublicKey,
1606                 /// The channel value of the requested channel.
1607                 funding_satoshis: u64,
1608                 /// Our starting balance in the channel if the request is accepted, in milli-satoshi.
1609                 push_msat: u64,
1610                 /// The features that this channel will operate with. If you reject the channel, a
1611                 /// well-behaved counterparty may automatically re-attempt the channel with a new set of
1612                 /// feature flags.
1613                 ///
1614                 /// Note that if [`ChannelTypeFeatures::supports_scid_privacy`] returns true on this type,
1615                 /// the resulting [`ChannelManager`] will not be readable by versions of LDK prior to
1616                 /// 0.0.106.
1617                 ///
1618                 /// Furthermore, note that if [`ChannelTypeFeatures::supports_zero_conf`] returns true on this type,
1619                 /// the resulting [`ChannelManager`] will not be readable by versions of LDK prior to
1620                 /// 0.0.107. Channels setting this type also need to get manually accepted via
1621                 /// [`crate::ln::channelmanager::ChannelManager::accept_inbound_channel_from_trusted_peer_0conf`],
1622                 /// or will be rejected otherwise.
1623                 ///
1624                 /// [`ChannelManager`]: crate::ln::channelmanager::ChannelManager
1625                 channel_type: crate::lightning::ln::features::ChannelTypeFeatures,
1626         },
1627         /// Indicates that the HTLC was accepted, but could not be processed when or after attempting to
1628         /// forward it.
1629         ///
1630         /// Some scenarios where this event may be sent include:
1631         /// * Insufficient capacity in the outbound channel
1632         /// * While waiting to forward the HTLC, the channel it is meant to be forwarded through closes
1633         /// * When an unknown SCID is requested for forwarding a payment.
1634         /// * Expected MPP amount has already been reached
1635         /// * The HTLC has timed out
1636         ///
1637         /// This event, however, does not get generated if an HTLC fails to meet the forwarding
1638         /// requirements (i.e. insufficient fees paid, or a CLTV that is too soon).
1639         HTLCHandlingFailed {
1640                 /// The channel over which the HTLC was received.
1641                 prev_channel_id: crate::c_types::ThirtyTwoBytes,
1642                 /// Destination of the HTLC that failed to be processed.
1643                 failed_next_destination: crate::lightning::events::HTLCDestination,
1644         },
1645         /// Indicates that a transaction originating from LDK needs to have its fee bumped. This event
1646         /// requires confirmed external funds to be readily available to spend.
1647         ///
1648         /// LDK does not currently generate this event unless the
1649         /// [`ChannelHandshakeConfig::negotiate_anchors_zero_fee_htlc_tx`] config flag is set to true.
1650         /// It is limited to the scope of channels with anchor outputs.
1651         ///
1652         /// [`ChannelHandshakeConfig::negotiate_anchors_zero_fee_htlc_tx`]: crate::util::config::ChannelHandshakeConfig::negotiate_anchors_zero_fee_htlc_tx
1653         BumpTransaction(
1654                 crate::lightning::events::bump_transaction::BumpTransactionEvent),
1655 }
1656 use lightning::events::Event as EventImport;
1657 pub(crate) type nativeEvent = EventImport;
1658
1659 impl Event {
1660         #[allow(unused)]
1661         pub(crate) fn to_native(&self) -> nativeEvent {
1662                 match self {
1663                         Event::FundingGenerationReady {ref temporary_channel_id, ref counterparty_node_id, ref channel_value_satoshis, ref output_script, ref user_channel_id, } => {
1664                                 let mut temporary_channel_id_nonref = Clone::clone(temporary_channel_id);
1665                                 let mut counterparty_node_id_nonref = Clone::clone(counterparty_node_id);
1666                                 let mut channel_value_satoshis_nonref = Clone::clone(channel_value_satoshis);
1667                                 let mut output_script_nonref = Clone::clone(output_script);
1668                                 let mut user_channel_id_nonref = Clone::clone(user_channel_id);
1669                                 nativeEvent::FundingGenerationReady {
1670                                         temporary_channel_id: ::lightning::ln::ChannelId(temporary_channel_id_nonref.data),
1671                                         counterparty_node_id: counterparty_node_id_nonref.into_rust(),
1672                                         channel_value_satoshis: channel_value_satoshis_nonref,
1673                                         output_script: ::bitcoin::blockdata::script::Script::from(output_script_nonref.into_rust()),
1674                                         user_channel_id: user_channel_id_nonref.into(),
1675                                 }
1676                         },
1677                         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, } => {
1678                                 let mut receiver_node_id_nonref = Clone::clone(receiver_node_id);
1679                                 let mut local_receiver_node_id_nonref = if receiver_node_id_nonref.is_null() { None } else { Some( { receiver_node_id_nonref.into_rust() }) };
1680                                 let mut payment_hash_nonref = Clone::clone(payment_hash);
1681                                 let mut onion_fields_nonref = Clone::clone(onion_fields);
1682                                 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()) } }) };
1683                                 let mut amount_msat_nonref = Clone::clone(amount_msat);
1684                                 let mut counterparty_skimmed_fee_msat_nonref = Clone::clone(counterparty_skimmed_fee_msat);
1685                                 let mut purpose_nonref = Clone::clone(purpose);
1686                                 let mut via_channel_id_nonref = Clone::clone(via_channel_id);
1687                                 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) }})} };
1688                                 let mut via_user_channel_id_nonref = Clone::clone(via_user_channel_id);
1689                                 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() }})} };
1690                                 let mut claim_deadline_nonref = Clone::clone(claim_deadline);
1691                                 let mut local_claim_deadline_nonref = if claim_deadline_nonref.is_some() { Some( { claim_deadline_nonref.take() }) } else { None };
1692                                 nativeEvent::PaymentClaimable {
1693                                         receiver_node_id: local_receiver_node_id_nonref,
1694                                         payment_hash: ::lightning::ln::PaymentHash(payment_hash_nonref.data),
1695                                         onion_fields: local_onion_fields_nonref,
1696                                         amount_msat: amount_msat_nonref,
1697                                         counterparty_skimmed_fee_msat: counterparty_skimmed_fee_msat_nonref,
1698                                         purpose: purpose_nonref.into_native(),
1699                                         via_channel_id: local_via_channel_id_nonref,
1700                                         via_user_channel_id: local_via_user_channel_id_nonref,
1701                                         claim_deadline: local_claim_deadline_nonref,
1702                                 }
1703                         },
1704                         Event::PaymentClaimed {ref receiver_node_id, ref payment_hash, ref amount_msat, ref purpose, ref htlcs, ref sender_intended_total_msat, } => {
1705                                 let mut receiver_node_id_nonref = Clone::clone(receiver_node_id);
1706                                 let mut local_receiver_node_id_nonref = if receiver_node_id_nonref.is_null() { None } else { Some( { receiver_node_id_nonref.into_rust() }) };
1707                                 let mut payment_hash_nonref = Clone::clone(payment_hash);
1708                                 let mut amount_msat_nonref = Clone::clone(amount_msat);
1709                                 let mut purpose_nonref = Clone::clone(purpose);
1710                                 let mut htlcs_nonref = Clone::clone(htlcs);
1711                                 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()) } }); };
1712                                 let mut sender_intended_total_msat_nonref = Clone::clone(sender_intended_total_msat);
1713                                 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 };
1714                                 nativeEvent::PaymentClaimed {
1715                                         receiver_node_id: local_receiver_node_id_nonref,
1716                                         payment_hash: ::lightning::ln::PaymentHash(payment_hash_nonref.data),
1717                                         amount_msat: amount_msat_nonref,
1718                                         purpose: purpose_nonref.into_native(),
1719                                         htlcs: local_htlcs_nonref,
1720                                         sender_intended_total_msat: local_sender_intended_total_msat_nonref,
1721                                 }
1722                         },
1723                         Event::PaymentSent {ref payment_id, ref payment_preimage, ref payment_hash, ref fee_paid_msat, } => {
1724                                 let mut payment_id_nonref = Clone::clone(payment_id);
1725                                 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) }})} };
1726                                 let mut payment_preimage_nonref = Clone::clone(payment_preimage);
1727                                 let mut payment_hash_nonref = Clone::clone(payment_hash);
1728                                 let mut fee_paid_msat_nonref = Clone::clone(fee_paid_msat);
1729                                 let mut local_fee_paid_msat_nonref = if fee_paid_msat_nonref.is_some() { Some( { fee_paid_msat_nonref.take() }) } else { None };
1730                                 nativeEvent::PaymentSent {
1731                                         payment_id: local_payment_id_nonref,
1732                                         payment_preimage: ::lightning::ln::PaymentPreimage(payment_preimage_nonref.data),
1733                                         payment_hash: ::lightning::ln::PaymentHash(payment_hash_nonref.data),
1734                                         fee_paid_msat: local_fee_paid_msat_nonref,
1735                                 }
1736                         },
1737                         Event::PaymentFailed {ref payment_id, ref payment_hash, ref reason, } => {
1738                                 let mut payment_id_nonref = Clone::clone(payment_id);
1739                                 let mut payment_hash_nonref = Clone::clone(payment_hash);
1740                                 let mut reason_nonref = Clone::clone(reason);
1741                                 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() }})} };
1742                                 nativeEvent::PaymentFailed {
1743                                         payment_id: ::lightning::ln::channelmanager::PaymentId(payment_id_nonref.data),
1744                                         payment_hash: ::lightning::ln::PaymentHash(payment_hash_nonref.data),
1745                                         reason: local_reason_nonref,
1746                                 }
1747                         },
1748                         Event::PaymentPathSuccessful {ref payment_id, ref payment_hash, ref path, } => {
1749                                 let mut payment_id_nonref = Clone::clone(payment_id);
1750                                 let mut payment_hash_nonref = Clone::clone(payment_hash);
1751                                 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) }})} };
1752                                 let mut path_nonref = Clone::clone(path);
1753                                 nativeEvent::PaymentPathSuccessful {
1754                                         payment_id: ::lightning::ln::channelmanager::PaymentId(payment_id_nonref.data),
1755                                         payment_hash: local_payment_hash_nonref,
1756                                         path: *unsafe { Box::from_raw(path_nonref.take_inner()) },
1757                                 }
1758                         },
1759                         Event::PaymentPathFailed {ref payment_id, ref payment_hash, ref payment_failed_permanently, ref failure, ref path, ref short_channel_id, } => {
1760                                 let mut payment_id_nonref = Clone::clone(payment_id);
1761                                 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) }})} };
1762                                 let mut payment_hash_nonref = Clone::clone(payment_hash);
1763                                 let mut payment_failed_permanently_nonref = Clone::clone(payment_failed_permanently);
1764                                 let mut failure_nonref = Clone::clone(failure);
1765                                 let mut path_nonref = Clone::clone(path);
1766                                 let mut short_channel_id_nonref = Clone::clone(short_channel_id);
1767                                 let mut local_short_channel_id_nonref = if short_channel_id_nonref.is_some() { Some( { short_channel_id_nonref.take() }) } else { None };
1768                                 nativeEvent::PaymentPathFailed {
1769                                         payment_id: local_payment_id_nonref,
1770                                         payment_hash: ::lightning::ln::PaymentHash(payment_hash_nonref.data),
1771                                         payment_failed_permanently: payment_failed_permanently_nonref,
1772                                         failure: failure_nonref.into_native(),
1773                                         path: *unsafe { Box::from_raw(path_nonref.take_inner()) },
1774                                         short_channel_id: local_short_channel_id_nonref,
1775                                 }
1776                         },
1777                         Event::ProbeSuccessful {ref payment_id, ref payment_hash, ref path, } => {
1778                                 let mut payment_id_nonref = Clone::clone(payment_id);
1779                                 let mut payment_hash_nonref = Clone::clone(payment_hash);
1780                                 let mut path_nonref = Clone::clone(path);
1781                                 nativeEvent::ProbeSuccessful {
1782                                         payment_id: ::lightning::ln::channelmanager::PaymentId(payment_id_nonref.data),
1783                                         payment_hash: ::lightning::ln::PaymentHash(payment_hash_nonref.data),
1784                                         path: *unsafe { Box::from_raw(path_nonref.take_inner()) },
1785                                 }
1786                         },
1787                         Event::ProbeFailed {ref payment_id, ref payment_hash, ref path, ref short_channel_id, } => {
1788                                 let mut payment_id_nonref = Clone::clone(payment_id);
1789                                 let mut payment_hash_nonref = Clone::clone(payment_hash);
1790                                 let mut path_nonref = Clone::clone(path);
1791                                 let mut short_channel_id_nonref = Clone::clone(short_channel_id);
1792                                 let mut local_short_channel_id_nonref = if short_channel_id_nonref.is_some() { Some( { short_channel_id_nonref.take() }) } else { None };
1793                                 nativeEvent::ProbeFailed {
1794                                         payment_id: ::lightning::ln::channelmanager::PaymentId(payment_id_nonref.data),
1795                                         payment_hash: ::lightning::ln::PaymentHash(payment_hash_nonref.data),
1796                                         path: *unsafe { Box::from_raw(path_nonref.take_inner()) },
1797                                         short_channel_id: local_short_channel_id_nonref,
1798                                 }
1799                         },
1800                         Event::PendingHTLCsForwardable {ref time_forwardable, } => {
1801                                 let mut time_forwardable_nonref = Clone::clone(time_forwardable);
1802                                 nativeEvent::PendingHTLCsForwardable {
1803                                         time_forwardable: core::time::Duration::from_secs(time_forwardable_nonref),
1804                                 }
1805                         },
1806                         Event::HTLCIntercepted {ref intercept_id, ref requested_next_hop_scid, ref payment_hash, ref inbound_amount_msat, ref expected_outbound_amount_msat, } => {
1807                                 let mut intercept_id_nonref = Clone::clone(intercept_id);
1808                                 let mut requested_next_hop_scid_nonref = Clone::clone(requested_next_hop_scid);
1809                                 let mut payment_hash_nonref = Clone::clone(payment_hash);
1810                                 let mut inbound_amount_msat_nonref = Clone::clone(inbound_amount_msat);
1811                                 let mut expected_outbound_amount_msat_nonref = Clone::clone(expected_outbound_amount_msat);
1812                                 nativeEvent::HTLCIntercepted {
1813                                         intercept_id: ::lightning::ln::channelmanager::InterceptId(intercept_id_nonref.data),
1814                                         requested_next_hop_scid: requested_next_hop_scid_nonref,
1815                                         payment_hash: ::lightning::ln::PaymentHash(payment_hash_nonref.data),
1816                                         inbound_amount_msat: inbound_amount_msat_nonref,
1817                                         expected_outbound_amount_msat: expected_outbound_amount_msat_nonref,
1818                                 }
1819                         },
1820                         Event::SpendableOutputs {ref outputs, ref channel_id, } => {
1821                                 let mut outputs_nonref = Clone::clone(outputs);
1822                                 let mut local_outputs_nonref = Vec::new(); for mut item in outputs_nonref.into_rust().drain(..) { local_outputs_nonref.push( { item.into_native() }); };
1823                                 let mut channel_id_nonref = Clone::clone(channel_id);
1824                                 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) }})} };
1825                                 nativeEvent::SpendableOutputs {
1826                                         outputs: local_outputs_nonref,
1827                                         channel_id: local_channel_id_nonref,
1828                                 }
1829                         },
1830                         Event::PaymentForwarded {ref prev_channel_id, ref next_channel_id, ref fee_earned_msat, ref claim_from_onchain_tx, ref outbound_amount_forwarded_msat, } => {
1831                                 let mut prev_channel_id_nonref = Clone::clone(prev_channel_id);
1832                                 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) }})} };
1833                                 let mut next_channel_id_nonref = Clone::clone(next_channel_id);
1834                                 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) }})} };
1835                                 let mut fee_earned_msat_nonref = Clone::clone(fee_earned_msat);
1836                                 let mut local_fee_earned_msat_nonref = if fee_earned_msat_nonref.is_some() { Some( { fee_earned_msat_nonref.take() }) } else { None };
1837                                 let mut claim_from_onchain_tx_nonref = Clone::clone(claim_from_onchain_tx);
1838                                 let mut outbound_amount_forwarded_msat_nonref = Clone::clone(outbound_amount_forwarded_msat);
1839                                 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 };
1840                                 nativeEvent::PaymentForwarded {
1841                                         prev_channel_id: local_prev_channel_id_nonref,
1842                                         next_channel_id: local_next_channel_id_nonref,
1843                                         fee_earned_msat: local_fee_earned_msat_nonref,
1844                                         claim_from_onchain_tx: claim_from_onchain_tx_nonref,
1845                                         outbound_amount_forwarded_msat: local_outbound_amount_forwarded_msat_nonref,
1846                                 }
1847                         },
1848                         Event::ChannelPending {ref channel_id, ref user_channel_id, ref former_temporary_channel_id, ref counterparty_node_id, ref funding_txo, } => {
1849                                 let mut channel_id_nonref = Clone::clone(channel_id);
1850                                 let mut user_channel_id_nonref = Clone::clone(user_channel_id);
1851                                 let mut former_temporary_channel_id_nonref = Clone::clone(former_temporary_channel_id);
1852                                 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) }})} };
1853                                 let mut counterparty_node_id_nonref = Clone::clone(counterparty_node_id);
1854                                 let mut funding_txo_nonref = Clone::clone(funding_txo);
1855                                 nativeEvent::ChannelPending {
1856                                         channel_id: ::lightning::ln::ChannelId(channel_id_nonref.data),
1857                                         user_channel_id: user_channel_id_nonref.into(),
1858                                         former_temporary_channel_id: local_former_temporary_channel_id_nonref,
1859                                         counterparty_node_id: counterparty_node_id_nonref.into_rust(),
1860                                         funding_txo: crate::c_types::C_to_bitcoin_outpoint(funding_txo_nonref),
1861                                 }
1862                         },
1863                         Event::ChannelReady {ref channel_id, ref user_channel_id, ref counterparty_node_id, ref channel_type, } => {
1864                                 let mut channel_id_nonref = Clone::clone(channel_id);
1865                                 let mut user_channel_id_nonref = Clone::clone(user_channel_id);
1866                                 let mut counterparty_node_id_nonref = Clone::clone(counterparty_node_id);
1867                                 let mut channel_type_nonref = Clone::clone(channel_type);
1868                                 nativeEvent::ChannelReady {
1869                                         channel_id: ::lightning::ln::ChannelId(channel_id_nonref.data),
1870                                         user_channel_id: user_channel_id_nonref.into(),
1871                                         counterparty_node_id: counterparty_node_id_nonref.into_rust(),
1872                                         channel_type: *unsafe { Box::from_raw(channel_type_nonref.take_inner()) },
1873                                 }
1874                         },
1875                         Event::ChannelClosed {ref channel_id, ref user_channel_id, ref reason, ref counterparty_node_id, ref channel_capacity_sats, } => {
1876                                 let mut channel_id_nonref = Clone::clone(channel_id);
1877                                 let mut user_channel_id_nonref = Clone::clone(user_channel_id);
1878                                 let mut reason_nonref = Clone::clone(reason);
1879                                 let mut counterparty_node_id_nonref = Clone::clone(counterparty_node_id);
1880                                 let mut local_counterparty_node_id_nonref = if counterparty_node_id_nonref.is_null() { None } else { Some( { counterparty_node_id_nonref.into_rust() }) };
1881                                 let mut channel_capacity_sats_nonref = Clone::clone(channel_capacity_sats);
1882                                 let mut local_channel_capacity_sats_nonref = if channel_capacity_sats_nonref.is_some() { Some( { channel_capacity_sats_nonref.take() }) } else { None };
1883                                 nativeEvent::ChannelClosed {
1884                                         channel_id: ::lightning::ln::ChannelId(channel_id_nonref.data),
1885                                         user_channel_id: user_channel_id_nonref.into(),
1886                                         reason: reason_nonref.into_native(),
1887                                         counterparty_node_id: local_counterparty_node_id_nonref,
1888                                         channel_capacity_sats: local_channel_capacity_sats_nonref,
1889                                 }
1890                         },
1891                         Event::DiscardFunding {ref channel_id, ref transaction, } => {
1892                                 let mut channel_id_nonref = Clone::clone(channel_id);
1893                                 let mut transaction_nonref = Clone::clone(transaction);
1894                                 nativeEvent::DiscardFunding {
1895                                         channel_id: ::lightning::ln::ChannelId(channel_id_nonref.data),
1896                                         transaction: transaction_nonref.into_bitcoin(),
1897                                 }
1898                         },
1899                         Event::OpenChannelRequest {ref temporary_channel_id, ref counterparty_node_id, ref funding_satoshis, ref push_msat, ref channel_type, } => {
1900                                 let mut temporary_channel_id_nonref = Clone::clone(temporary_channel_id);
1901                                 let mut counterparty_node_id_nonref = Clone::clone(counterparty_node_id);
1902                                 let mut funding_satoshis_nonref = Clone::clone(funding_satoshis);
1903                                 let mut push_msat_nonref = Clone::clone(push_msat);
1904                                 let mut channel_type_nonref = Clone::clone(channel_type);
1905                                 nativeEvent::OpenChannelRequest {
1906                                         temporary_channel_id: ::lightning::ln::ChannelId(temporary_channel_id_nonref.data),
1907                                         counterparty_node_id: counterparty_node_id_nonref.into_rust(),
1908                                         funding_satoshis: funding_satoshis_nonref,
1909                                         push_msat: push_msat_nonref,
1910                                         channel_type: *unsafe { Box::from_raw(channel_type_nonref.take_inner()) },
1911                                 }
1912                         },
1913                         Event::HTLCHandlingFailed {ref prev_channel_id, ref failed_next_destination, } => {
1914                                 let mut prev_channel_id_nonref = Clone::clone(prev_channel_id);
1915                                 let mut failed_next_destination_nonref = Clone::clone(failed_next_destination);
1916                                 nativeEvent::HTLCHandlingFailed {
1917                                         prev_channel_id: ::lightning::ln::ChannelId(prev_channel_id_nonref.data),
1918                                         failed_next_destination: failed_next_destination_nonref.into_native(),
1919                                 }
1920                         },
1921                         Event::BumpTransaction (ref a, ) => {
1922                                 let mut a_nonref = Clone::clone(a);
1923                                 nativeEvent::BumpTransaction (
1924                                         a_nonref.into_native(),
1925                                 )
1926                         },
1927                 }
1928         }
1929         #[allow(unused)]
1930         pub(crate) fn into_native(self) -> nativeEvent {
1931                 match self {
1932                         Event::FundingGenerationReady {mut temporary_channel_id, mut counterparty_node_id, mut channel_value_satoshis, mut output_script, mut user_channel_id, } => {
1933                                 nativeEvent::FundingGenerationReady {
1934                                         temporary_channel_id: ::lightning::ln::ChannelId(temporary_channel_id.data),
1935                                         counterparty_node_id: counterparty_node_id.into_rust(),
1936                                         channel_value_satoshis: channel_value_satoshis,
1937                                         output_script: ::bitcoin::blockdata::script::Script::from(output_script.into_rust()),
1938                                         user_channel_id: user_channel_id.into(),
1939                                 }
1940                         },
1941                         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, } => {
1942                                 let mut local_receiver_node_id = if receiver_node_id.is_null() { None } else { Some( { receiver_node_id.into_rust() }) };
1943                                 let mut local_onion_fields = if onion_fields.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(onion_fields.take_inner()) } }) };
1944                                 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) }})} };
1945                                 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() }})} };
1946                                 let mut local_claim_deadline = if claim_deadline.is_some() { Some( { claim_deadline.take() }) } else { None };
1947                                 nativeEvent::PaymentClaimable {
1948                                         receiver_node_id: local_receiver_node_id,
1949                                         payment_hash: ::lightning::ln::PaymentHash(payment_hash.data),
1950                                         onion_fields: local_onion_fields,
1951                                         amount_msat: amount_msat,
1952                                         counterparty_skimmed_fee_msat: counterparty_skimmed_fee_msat,
1953                                         purpose: purpose.into_native(),
1954                                         via_channel_id: local_via_channel_id,
1955                                         via_user_channel_id: local_via_user_channel_id,
1956                                         claim_deadline: local_claim_deadline,
1957                                 }
1958                         },
1959                         Event::PaymentClaimed {mut receiver_node_id, mut payment_hash, mut amount_msat, mut purpose, mut htlcs, mut sender_intended_total_msat, } => {
1960                                 let mut local_receiver_node_id = if receiver_node_id.is_null() { None } else { Some( { receiver_node_id.into_rust() }) };
1961                                 let mut local_htlcs = Vec::new(); for mut item in htlcs.into_rust().drain(..) { local_htlcs.push( { *unsafe { Box::from_raw(item.take_inner()) } }); };
1962                                 let mut local_sender_intended_total_msat = if sender_intended_total_msat.is_some() { Some( { sender_intended_total_msat.take() }) } else { None };
1963                                 nativeEvent::PaymentClaimed {
1964                                         receiver_node_id: local_receiver_node_id,
1965                                         payment_hash: ::lightning::ln::PaymentHash(payment_hash.data),
1966                                         amount_msat: amount_msat,
1967                                         purpose: purpose.into_native(),
1968                                         htlcs: local_htlcs,
1969                                         sender_intended_total_msat: local_sender_intended_total_msat,
1970                                 }
1971                         },
1972                         Event::PaymentSent {mut payment_id, mut payment_preimage, mut payment_hash, mut fee_paid_msat, } => {
1973                                 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) }})} };
1974                                 let mut local_fee_paid_msat = if fee_paid_msat.is_some() { Some( { fee_paid_msat.take() }) } else { None };
1975                                 nativeEvent::PaymentSent {
1976                                         payment_id: local_payment_id,
1977                                         payment_preimage: ::lightning::ln::PaymentPreimage(payment_preimage.data),
1978                                         payment_hash: ::lightning::ln::PaymentHash(payment_hash.data),
1979                                         fee_paid_msat: local_fee_paid_msat,
1980                                 }
1981                         },
1982                         Event::PaymentFailed {mut payment_id, mut payment_hash, mut reason, } => {
1983                                 let mut local_reason = { /*reason*/ let reason_opt = reason; if reason_opt.is_none() { None } else { Some({ { { reason_opt.take() }.into_native() }})} };
1984                                 nativeEvent::PaymentFailed {
1985                                         payment_id: ::lightning::ln::channelmanager::PaymentId(payment_id.data),
1986                                         payment_hash: ::lightning::ln::PaymentHash(payment_hash.data),
1987                                         reason: local_reason,
1988                                 }
1989                         },
1990                         Event::PaymentPathSuccessful {mut payment_id, mut payment_hash, mut path, } => {
1991                                 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) }})} };
1992                                 nativeEvent::PaymentPathSuccessful {
1993                                         payment_id: ::lightning::ln::channelmanager::PaymentId(payment_id.data),
1994                                         payment_hash: local_payment_hash,
1995                                         path: *unsafe { Box::from_raw(path.take_inner()) },
1996                                 }
1997                         },
1998                         Event::PaymentPathFailed {mut payment_id, mut payment_hash, mut payment_failed_permanently, mut failure, mut path, mut short_channel_id, } => {
1999                                 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) }})} };
2000                                 let mut local_short_channel_id = if short_channel_id.is_some() { Some( { short_channel_id.take() }) } else { None };
2001                                 nativeEvent::PaymentPathFailed {
2002                                         payment_id: local_payment_id,
2003                                         payment_hash: ::lightning::ln::PaymentHash(payment_hash.data),
2004                                         payment_failed_permanently: payment_failed_permanently,
2005                                         failure: failure.into_native(),
2006                                         path: *unsafe { Box::from_raw(path.take_inner()) },
2007                                         short_channel_id: local_short_channel_id,
2008                                 }
2009                         },
2010                         Event::ProbeSuccessful {mut payment_id, mut payment_hash, mut path, } => {
2011                                 nativeEvent::ProbeSuccessful {
2012                                         payment_id: ::lightning::ln::channelmanager::PaymentId(payment_id.data),
2013                                         payment_hash: ::lightning::ln::PaymentHash(payment_hash.data),
2014                                         path: *unsafe { Box::from_raw(path.take_inner()) },
2015                                 }
2016                         },
2017                         Event::ProbeFailed {mut payment_id, mut payment_hash, mut path, mut short_channel_id, } => {
2018                                 let mut local_short_channel_id = if short_channel_id.is_some() { Some( { short_channel_id.take() }) } else { None };
2019                                 nativeEvent::ProbeFailed {
2020                                         payment_id: ::lightning::ln::channelmanager::PaymentId(payment_id.data),
2021                                         payment_hash: ::lightning::ln::PaymentHash(payment_hash.data),
2022                                         path: *unsafe { Box::from_raw(path.take_inner()) },
2023                                         short_channel_id: local_short_channel_id,
2024                                 }
2025                         },
2026                         Event::PendingHTLCsForwardable {mut time_forwardable, } => {
2027                                 nativeEvent::PendingHTLCsForwardable {
2028                                         time_forwardable: core::time::Duration::from_secs(time_forwardable),
2029                                 }
2030                         },
2031                         Event::HTLCIntercepted {mut intercept_id, mut requested_next_hop_scid, mut payment_hash, mut inbound_amount_msat, mut expected_outbound_amount_msat, } => {
2032                                 nativeEvent::HTLCIntercepted {
2033                                         intercept_id: ::lightning::ln::channelmanager::InterceptId(intercept_id.data),
2034                                         requested_next_hop_scid: requested_next_hop_scid,
2035                                         payment_hash: ::lightning::ln::PaymentHash(payment_hash.data),
2036                                         inbound_amount_msat: inbound_amount_msat,
2037                                         expected_outbound_amount_msat: expected_outbound_amount_msat,
2038                                 }
2039                         },
2040                         Event::SpendableOutputs {mut outputs, mut channel_id, } => {
2041                                 let mut local_outputs = Vec::new(); for mut item in outputs.into_rust().drain(..) { local_outputs.push( { item.into_native() }); };
2042                                 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) }})} };
2043                                 nativeEvent::SpendableOutputs {
2044                                         outputs: local_outputs,
2045                                         channel_id: local_channel_id,
2046                                 }
2047                         },
2048                         Event::PaymentForwarded {mut prev_channel_id, mut next_channel_id, mut fee_earned_msat, mut claim_from_onchain_tx, mut outbound_amount_forwarded_msat, } => {
2049                                 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) }})} };
2050                                 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) }})} };
2051                                 let mut local_fee_earned_msat = if fee_earned_msat.is_some() { Some( { fee_earned_msat.take() }) } else { None };
2052                                 let mut local_outbound_amount_forwarded_msat = if outbound_amount_forwarded_msat.is_some() { Some( { outbound_amount_forwarded_msat.take() }) } else { None };
2053                                 nativeEvent::PaymentForwarded {
2054                                         prev_channel_id: local_prev_channel_id,
2055                                         next_channel_id: local_next_channel_id,
2056                                         fee_earned_msat: local_fee_earned_msat,
2057                                         claim_from_onchain_tx: claim_from_onchain_tx,
2058                                         outbound_amount_forwarded_msat: local_outbound_amount_forwarded_msat,
2059                                 }
2060                         },
2061                         Event::ChannelPending {mut channel_id, mut user_channel_id, mut former_temporary_channel_id, mut counterparty_node_id, mut funding_txo, } => {
2062                                 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) }})} };
2063                                 nativeEvent::ChannelPending {
2064                                         channel_id: ::lightning::ln::ChannelId(channel_id.data),
2065                                         user_channel_id: user_channel_id.into(),
2066                                         former_temporary_channel_id: local_former_temporary_channel_id,
2067                                         counterparty_node_id: counterparty_node_id.into_rust(),
2068                                         funding_txo: crate::c_types::C_to_bitcoin_outpoint(funding_txo),
2069                                 }
2070                         },
2071                         Event::ChannelReady {mut channel_id, mut user_channel_id, mut counterparty_node_id, mut channel_type, } => {
2072                                 nativeEvent::ChannelReady {
2073                                         channel_id: ::lightning::ln::ChannelId(channel_id.data),
2074                                         user_channel_id: user_channel_id.into(),
2075                                         counterparty_node_id: counterparty_node_id.into_rust(),
2076                                         channel_type: *unsafe { Box::from_raw(channel_type.take_inner()) },
2077                                 }
2078                         },
2079                         Event::ChannelClosed {mut channel_id, mut user_channel_id, mut reason, mut counterparty_node_id, mut channel_capacity_sats, } => {
2080                                 let mut local_counterparty_node_id = if counterparty_node_id.is_null() { None } else { Some( { counterparty_node_id.into_rust() }) };
2081                                 let mut local_channel_capacity_sats = if channel_capacity_sats.is_some() { Some( { channel_capacity_sats.take() }) } else { None };
2082                                 nativeEvent::ChannelClosed {
2083                                         channel_id: ::lightning::ln::ChannelId(channel_id.data),
2084                                         user_channel_id: user_channel_id.into(),
2085                                         reason: reason.into_native(),
2086                                         counterparty_node_id: local_counterparty_node_id,
2087                                         channel_capacity_sats: local_channel_capacity_sats,
2088                                 }
2089                         },
2090                         Event::DiscardFunding {mut channel_id, mut transaction, } => {
2091                                 nativeEvent::DiscardFunding {
2092                                         channel_id: ::lightning::ln::ChannelId(channel_id.data),
2093                                         transaction: transaction.into_bitcoin(),
2094                                 }
2095                         },
2096                         Event::OpenChannelRequest {mut temporary_channel_id, mut counterparty_node_id, mut funding_satoshis, mut push_msat, mut channel_type, } => {
2097                                 nativeEvent::OpenChannelRequest {
2098                                         temporary_channel_id: ::lightning::ln::ChannelId(temporary_channel_id.data),
2099                                         counterparty_node_id: counterparty_node_id.into_rust(),
2100                                         funding_satoshis: funding_satoshis,
2101                                         push_msat: push_msat,
2102                                         channel_type: *unsafe { Box::from_raw(channel_type.take_inner()) },
2103                                 }
2104                         },
2105                         Event::HTLCHandlingFailed {mut prev_channel_id, mut failed_next_destination, } => {
2106                                 nativeEvent::HTLCHandlingFailed {
2107                                         prev_channel_id: ::lightning::ln::ChannelId(prev_channel_id.data),
2108                                         failed_next_destination: failed_next_destination.into_native(),
2109                                 }
2110                         },
2111                         Event::BumpTransaction (mut a, ) => {
2112                                 nativeEvent::BumpTransaction (
2113                                         a.into_native(),
2114                                 )
2115                         },
2116                 }
2117         }
2118         #[allow(unused)]
2119         pub(crate) fn from_native(native: &nativeEvent) -> Self {
2120                 match native {
2121                         nativeEvent::FundingGenerationReady {ref temporary_channel_id, ref counterparty_node_id, ref channel_value_satoshis, ref output_script, ref user_channel_id, } => {
2122                                 let mut temporary_channel_id_nonref = Clone::clone(temporary_channel_id);
2123                                 let mut counterparty_node_id_nonref = Clone::clone(counterparty_node_id);
2124                                 let mut channel_value_satoshis_nonref = Clone::clone(channel_value_satoshis);
2125                                 let mut output_script_nonref = Clone::clone(output_script);
2126                                 let mut user_channel_id_nonref = Clone::clone(user_channel_id);
2127                                 Event::FundingGenerationReady {
2128                                         temporary_channel_id: crate::c_types::ThirtyTwoBytes { data: temporary_channel_id_nonref.0 },
2129                                         counterparty_node_id: crate::c_types::PublicKey::from_rust(&counterparty_node_id_nonref),
2130                                         channel_value_satoshis: channel_value_satoshis_nonref,
2131                                         output_script: output_script_nonref.into_bytes().into(),
2132                                         user_channel_id: user_channel_id_nonref.into(),
2133                                 }
2134                         },
2135                         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, } => {
2136                                 let mut receiver_node_id_nonref = Clone::clone(receiver_node_id);
2137                                 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())) } };
2138                                 let mut payment_hash_nonref = Clone::clone(payment_hash);
2139                                 let mut onion_fields_nonref = Clone::clone(onion_fields);
2140                                 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 };
2141                                 let mut amount_msat_nonref = Clone::clone(amount_msat);
2142                                 let mut counterparty_skimmed_fee_msat_nonref = Clone::clone(counterparty_skimmed_fee_msat);
2143                                 let mut purpose_nonref = Clone::clone(purpose);
2144                                 let mut via_channel_id_nonref = Clone::clone(via_channel_id);
2145                                 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 } }) };
2146                                 let mut via_user_channel_id_nonref = Clone::clone(via_user_channel_id);
2147                                 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() }) };
2148                                 let mut claim_deadline_nonref = Clone::clone(claim_deadline);
2149                                 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() }) };
2150                                 Event::PaymentClaimable {
2151                                         receiver_node_id: local_receiver_node_id_nonref,
2152                                         payment_hash: crate::c_types::ThirtyTwoBytes { data: payment_hash_nonref.0 },
2153                                         onion_fields: local_onion_fields_nonref,
2154                                         amount_msat: amount_msat_nonref,
2155                                         counterparty_skimmed_fee_msat: counterparty_skimmed_fee_msat_nonref,
2156                                         purpose: crate::lightning::events::PaymentPurpose::native_into(purpose_nonref),
2157                                         via_channel_id: local_via_channel_id_nonref,
2158                                         via_user_channel_id: local_via_user_channel_id_nonref,
2159                                         claim_deadline: local_claim_deadline_nonref,
2160                                 }
2161                         },
2162                         nativeEvent::PaymentClaimed {ref receiver_node_id, ref payment_hash, ref amount_msat, ref purpose, ref htlcs, ref sender_intended_total_msat, } => {
2163                                 let mut receiver_node_id_nonref = Clone::clone(receiver_node_id);
2164                                 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())) } };
2165                                 let mut payment_hash_nonref = Clone::clone(payment_hash);
2166                                 let mut amount_msat_nonref = Clone::clone(amount_msat);
2167                                 let mut purpose_nonref = Clone::clone(purpose);
2168                                 let mut htlcs_nonref = Clone::clone(htlcs);
2169                                 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 } }); };
2170                                 let mut sender_intended_total_msat_nonref = Clone::clone(sender_intended_total_msat);
2171                                 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() }) };
2172                                 Event::PaymentClaimed {
2173                                         receiver_node_id: local_receiver_node_id_nonref,
2174                                         payment_hash: crate::c_types::ThirtyTwoBytes { data: payment_hash_nonref.0 },
2175                                         amount_msat: amount_msat_nonref,
2176                                         purpose: crate::lightning::events::PaymentPurpose::native_into(purpose_nonref),
2177                                         htlcs: local_htlcs_nonref.into(),
2178                                         sender_intended_total_msat: local_sender_intended_total_msat_nonref,
2179                                 }
2180                         },
2181                         nativeEvent::PaymentSent {ref payment_id, ref payment_preimage, ref payment_hash, ref fee_paid_msat, } => {
2182                                 let mut payment_id_nonref = Clone::clone(payment_id);
2183                                 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 } }) };
2184                                 let mut payment_preimage_nonref = Clone::clone(payment_preimage);
2185                                 let mut payment_hash_nonref = Clone::clone(payment_hash);
2186                                 let mut fee_paid_msat_nonref = Clone::clone(fee_paid_msat);
2187                                 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() }) };
2188                                 Event::PaymentSent {
2189                                         payment_id: local_payment_id_nonref,
2190                                         payment_preimage: crate::c_types::ThirtyTwoBytes { data: payment_preimage_nonref.0 },
2191                                         payment_hash: crate::c_types::ThirtyTwoBytes { data: payment_hash_nonref.0 },
2192                                         fee_paid_msat: local_fee_paid_msat_nonref,
2193                                 }
2194                         },
2195                         nativeEvent::PaymentFailed {ref payment_id, ref payment_hash, ref reason, } => {
2196                                 let mut payment_id_nonref = Clone::clone(payment_id);
2197                                 let mut payment_hash_nonref = Clone::clone(payment_hash);
2198                                 let mut reason_nonref = Clone::clone(reason);
2199                                 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()) }) };
2200                                 Event::PaymentFailed {
2201                                         payment_id: crate::c_types::ThirtyTwoBytes { data: payment_id_nonref.0 },
2202                                         payment_hash: crate::c_types::ThirtyTwoBytes { data: payment_hash_nonref.0 },
2203                                         reason: local_reason_nonref,
2204                                 }
2205                         },
2206                         nativeEvent::PaymentPathSuccessful {ref payment_id, ref payment_hash, ref path, } => {
2207                                 let mut payment_id_nonref = Clone::clone(payment_id);
2208                                 let mut payment_hash_nonref = Clone::clone(payment_hash);
2209                                 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 } }) };
2210                                 let mut path_nonref = Clone::clone(path);
2211                                 Event::PaymentPathSuccessful {
2212                                         payment_id: crate::c_types::ThirtyTwoBytes { data: payment_id_nonref.0 },
2213                                         payment_hash: local_payment_hash_nonref,
2214                                         path: crate::lightning::routing::router::Path { inner: ObjOps::heap_alloc(path_nonref), is_owned: true },
2215                                 }
2216                         },
2217                         nativeEvent::PaymentPathFailed {ref payment_id, ref payment_hash, ref payment_failed_permanently, ref failure, ref path, ref short_channel_id, } => {
2218                                 let mut payment_id_nonref = Clone::clone(payment_id);
2219                                 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 } }) };
2220                                 let mut payment_hash_nonref = Clone::clone(payment_hash);
2221                                 let mut payment_failed_permanently_nonref = Clone::clone(payment_failed_permanently);
2222                                 let mut failure_nonref = Clone::clone(failure);
2223                                 let mut path_nonref = Clone::clone(path);
2224                                 let mut short_channel_id_nonref = Clone::clone(short_channel_id);
2225                                 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() }) };
2226                                 Event::PaymentPathFailed {
2227                                         payment_id: local_payment_id_nonref,
2228                                         payment_hash: crate::c_types::ThirtyTwoBytes { data: payment_hash_nonref.0 },
2229                                         payment_failed_permanently: payment_failed_permanently_nonref,
2230                                         failure: crate::lightning::events::PathFailure::native_into(failure_nonref),
2231                                         path: crate::lightning::routing::router::Path { inner: ObjOps::heap_alloc(path_nonref), is_owned: true },
2232                                         short_channel_id: local_short_channel_id_nonref,
2233                                 }
2234                         },
2235                         nativeEvent::ProbeSuccessful {ref payment_id, ref payment_hash, ref path, } => {
2236                                 let mut payment_id_nonref = Clone::clone(payment_id);
2237                                 let mut payment_hash_nonref = Clone::clone(payment_hash);
2238                                 let mut path_nonref = Clone::clone(path);
2239                                 Event::ProbeSuccessful {
2240                                         payment_id: crate::c_types::ThirtyTwoBytes { data: payment_id_nonref.0 },
2241                                         payment_hash: crate::c_types::ThirtyTwoBytes { data: payment_hash_nonref.0 },
2242                                         path: crate::lightning::routing::router::Path { inner: ObjOps::heap_alloc(path_nonref), is_owned: true },
2243                                 }
2244                         },
2245                         nativeEvent::ProbeFailed {ref payment_id, ref payment_hash, ref path, ref short_channel_id, } => {
2246                                 let mut payment_id_nonref = Clone::clone(payment_id);
2247                                 let mut payment_hash_nonref = Clone::clone(payment_hash);
2248                                 let mut path_nonref = Clone::clone(path);
2249                                 let mut short_channel_id_nonref = Clone::clone(short_channel_id);
2250                                 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() }) };
2251                                 Event::ProbeFailed {
2252                                         payment_id: crate::c_types::ThirtyTwoBytes { data: payment_id_nonref.0 },
2253                                         payment_hash: crate::c_types::ThirtyTwoBytes { data: payment_hash_nonref.0 },
2254                                         path: crate::lightning::routing::router::Path { inner: ObjOps::heap_alloc(path_nonref), is_owned: true },
2255                                         short_channel_id: local_short_channel_id_nonref,
2256                                 }
2257                         },
2258                         nativeEvent::PendingHTLCsForwardable {ref time_forwardable, } => {
2259                                 let mut time_forwardable_nonref = Clone::clone(time_forwardable);
2260                                 Event::PendingHTLCsForwardable {
2261                                         time_forwardable: time_forwardable_nonref.as_secs(),
2262                                 }
2263                         },
2264                         nativeEvent::HTLCIntercepted {ref intercept_id, ref requested_next_hop_scid, ref payment_hash, ref inbound_amount_msat, ref expected_outbound_amount_msat, } => {
2265                                 let mut intercept_id_nonref = Clone::clone(intercept_id);
2266                                 let mut requested_next_hop_scid_nonref = Clone::clone(requested_next_hop_scid);
2267                                 let mut payment_hash_nonref = Clone::clone(payment_hash);
2268                                 let mut inbound_amount_msat_nonref = Clone::clone(inbound_amount_msat);
2269                                 let mut expected_outbound_amount_msat_nonref = Clone::clone(expected_outbound_amount_msat);
2270                                 Event::HTLCIntercepted {
2271                                         intercept_id: crate::c_types::ThirtyTwoBytes { data: intercept_id_nonref.0 },
2272                                         requested_next_hop_scid: requested_next_hop_scid_nonref,
2273                                         payment_hash: crate::c_types::ThirtyTwoBytes { data: payment_hash_nonref.0 },
2274                                         inbound_amount_msat: inbound_amount_msat_nonref,
2275                                         expected_outbound_amount_msat: expected_outbound_amount_msat_nonref,
2276                                 }
2277                         },
2278                         nativeEvent::SpendableOutputs {ref outputs, ref channel_id, } => {
2279                                 let mut outputs_nonref = Clone::clone(outputs);
2280                                 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) }); };
2281                                 let mut channel_id_nonref = Clone::clone(channel_id);
2282                                 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 } }) };
2283                                 Event::SpendableOutputs {
2284                                         outputs: local_outputs_nonref.into(),
2285                                         channel_id: local_channel_id_nonref,
2286                                 }
2287                         },
2288                         nativeEvent::PaymentForwarded {ref prev_channel_id, ref next_channel_id, ref fee_earned_msat, ref claim_from_onchain_tx, ref outbound_amount_forwarded_msat, } => {
2289                                 let mut prev_channel_id_nonref = Clone::clone(prev_channel_id);
2290                                 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 } }) };
2291                                 let mut next_channel_id_nonref = Clone::clone(next_channel_id);
2292                                 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 } }) };
2293                                 let mut fee_earned_msat_nonref = Clone::clone(fee_earned_msat);
2294                                 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() }) };
2295                                 let mut claim_from_onchain_tx_nonref = Clone::clone(claim_from_onchain_tx);
2296                                 let mut outbound_amount_forwarded_msat_nonref = Clone::clone(outbound_amount_forwarded_msat);
2297                                 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() }) };
2298                                 Event::PaymentForwarded {
2299                                         prev_channel_id: local_prev_channel_id_nonref,
2300                                         next_channel_id: local_next_channel_id_nonref,
2301                                         fee_earned_msat: local_fee_earned_msat_nonref,
2302                                         claim_from_onchain_tx: claim_from_onchain_tx_nonref,
2303                                         outbound_amount_forwarded_msat: local_outbound_amount_forwarded_msat_nonref,
2304                                 }
2305                         },
2306                         nativeEvent::ChannelPending {ref channel_id, ref user_channel_id, ref former_temporary_channel_id, ref counterparty_node_id, ref funding_txo, } => {
2307                                 let mut channel_id_nonref = Clone::clone(channel_id);
2308                                 let mut user_channel_id_nonref = Clone::clone(user_channel_id);
2309                                 let mut former_temporary_channel_id_nonref = Clone::clone(former_temporary_channel_id);
2310                                 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 } }) };
2311                                 let mut counterparty_node_id_nonref = Clone::clone(counterparty_node_id);
2312                                 let mut funding_txo_nonref = Clone::clone(funding_txo);
2313                                 Event::ChannelPending {
2314                                         channel_id: crate::c_types::ThirtyTwoBytes { data: channel_id_nonref.0 },
2315                                         user_channel_id: user_channel_id_nonref.into(),
2316                                         former_temporary_channel_id: local_former_temporary_channel_id_nonref,
2317                                         counterparty_node_id: crate::c_types::PublicKey::from_rust(&counterparty_node_id_nonref),
2318                                         funding_txo: crate::c_types::bitcoin_to_C_outpoint(&funding_txo_nonref),
2319                                 }
2320                         },
2321                         nativeEvent::ChannelReady {ref channel_id, ref user_channel_id, ref counterparty_node_id, ref channel_type, } => {
2322                                 let mut channel_id_nonref = Clone::clone(channel_id);
2323                                 let mut user_channel_id_nonref = Clone::clone(user_channel_id);
2324                                 let mut counterparty_node_id_nonref = Clone::clone(counterparty_node_id);
2325                                 let mut channel_type_nonref = Clone::clone(channel_type);
2326                                 Event::ChannelReady {
2327                                         channel_id: crate::c_types::ThirtyTwoBytes { data: channel_id_nonref.0 },
2328                                         user_channel_id: user_channel_id_nonref.into(),
2329                                         counterparty_node_id: crate::c_types::PublicKey::from_rust(&counterparty_node_id_nonref),
2330                                         channel_type: crate::lightning::ln::features::ChannelTypeFeatures { inner: ObjOps::heap_alloc(channel_type_nonref), is_owned: true },
2331                                 }
2332                         },
2333                         nativeEvent::ChannelClosed {ref channel_id, ref user_channel_id, ref reason, ref counterparty_node_id, ref channel_capacity_sats, } => {
2334                                 let mut channel_id_nonref = Clone::clone(channel_id);
2335                                 let mut user_channel_id_nonref = Clone::clone(user_channel_id);
2336                                 let mut reason_nonref = Clone::clone(reason);
2337                                 let mut counterparty_node_id_nonref = Clone::clone(counterparty_node_id);
2338                                 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())) } };
2339                                 let mut channel_capacity_sats_nonref = Clone::clone(channel_capacity_sats);
2340                                 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() }) };
2341                                 Event::ChannelClosed {
2342                                         channel_id: crate::c_types::ThirtyTwoBytes { data: channel_id_nonref.0 },
2343                                         user_channel_id: user_channel_id_nonref.into(),
2344                                         reason: crate::lightning::events::ClosureReason::native_into(reason_nonref),
2345                                         counterparty_node_id: local_counterparty_node_id_nonref,
2346                                         channel_capacity_sats: local_channel_capacity_sats_nonref,
2347                                 }
2348                         },
2349                         nativeEvent::DiscardFunding {ref channel_id, ref transaction, } => {
2350                                 let mut channel_id_nonref = Clone::clone(channel_id);
2351                                 let mut transaction_nonref = Clone::clone(transaction);
2352                                 Event::DiscardFunding {
2353                                         channel_id: crate::c_types::ThirtyTwoBytes { data: channel_id_nonref.0 },
2354                                         transaction: crate::c_types::Transaction::from_bitcoin(&transaction_nonref),
2355                                 }
2356                         },
2357                         nativeEvent::OpenChannelRequest {ref temporary_channel_id, ref counterparty_node_id, ref funding_satoshis, ref push_msat, ref channel_type, } => {
2358                                 let mut temporary_channel_id_nonref = Clone::clone(temporary_channel_id);
2359                                 let mut counterparty_node_id_nonref = Clone::clone(counterparty_node_id);
2360                                 let mut funding_satoshis_nonref = Clone::clone(funding_satoshis);
2361                                 let mut push_msat_nonref = Clone::clone(push_msat);
2362                                 let mut channel_type_nonref = Clone::clone(channel_type);
2363                                 Event::OpenChannelRequest {
2364                                         temporary_channel_id: crate::c_types::ThirtyTwoBytes { data: temporary_channel_id_nonref.0 },
2365                                         counterparty_node_id: crate::c_types::PublicKey::from_rust(&counterparty_node_id_nonref),
2366                                         funding_satoshis: funding_satoshis_nonref,
2367                                         push_msat: push_msat_nonref,
2368                                         channel_type: crate::lightning::ln::features::ChannelTypeFeatures { inner: ObjOps::heap_alloc(channel_type_nonref), is_owned: true },
2369                                 }
2370                         },
2371                         nativeEvent::HTLCHandlingFailed {ref prev_channel_id, ref failed_next_destination, } => {
2372                                 let mut prev_channel_id_nonref = Clone::clone(prev_channel_id);
2373                                 let mut failed_next_destination_nonref = Clone::clone(failed_next_destination);
2374                                 Event::HTLCHandlingFailed {
2375                                         prev_channel_id: crate::c_types::ThirtyTwoBytes { data: prev_channel_id_nonref.0 },
2376                                         failed_next_destination: crate::lightning::events::HTLCDestination::native_into(failed_next_destination_nonref),
2377                                 }
2378                         },
2379                         nativeEvent::BumpTransaction (ref a, ) => {
2380                                 let mut a_nonref = Clone::clone(a);
2381                                 Event::BumpTransaction (
2382                                         crate::lightning::events::bump_transaction::BumpTransactionEvent::native_into(a_nonref),
2383                                 )
2384                         },
2385                 }
2386         }
2387         #[allow(unused)]
2388         pub(crate) fn native_into(native: nativeEvent) -> Self {
2389                 match native {
2390                         nativeEvent::FundingGenerationReady {mut temporary_channel_id, mut counterparty_node_id, mut channel_value_satoshis, mut output_script, mut user_channel_id, } => {
2391                                 Event::FundingGenerationReady {
2392                                         temporary_channel_id: crate::c_types::ThirtyTwoBytes { data: temporary_channel_id.0 },
2393                                         counterparty_node_id: crate::c_types::PublicKey::from_rust(&counterparty_node_id),
2394                                         channel_value_satoshis: channel_value_satoshis,
2395                                         output_script: output_script.into_bytes().into(),
2396                                         user_channel_id: user_channel_id.into(),
2397                                 }
2398                         },
2399                         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, } => {
2400                                 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())) } };
2401                                 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 };
2402                                 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 } }) };
2403                                 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() }) };
2404                                 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() }) };
2405                                 Event::PaymentClaimable {
2406                                         receiver_node_id: local_receiver_node_id,
2407                                         payment_hash: crate::c_types::ThirtyTwoBytes { data: payment_hash.0 },
2408                                         onion_fields: local_onion_fields,
2409                                         amount_msat: amount_msat,
2410                                         counterparty_skimmed_fee_msat: counterparty_skimmed_fee_msat,
2411                                         purpose: crate::lightning::events::PaymentPurpose::native_into(purpose),
2412                                         via_channel_id: local_via_channel_id,
2413                                         via_user_channel_id: local_via_user_channel_id,
2414                                         claim_deadline: local_claim_deadline,
2415                                 }
2416                         },
2417                         nativeEvent::PaymentClaimed {mut receiver_node_id, mut payment_hash, mut amount_msat, mut purpose, mut htlcs, mut sender_intended_total_msat, } => {
2418                                 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())) } };
2419                                 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 } }); };
2420                                 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() }) };
2421                                 Event::PaymentClaimed {
2422                                         receiver_node_id: local_receiver_node_id,
2423                                         payment_hash: crate::c_types::ThirtyTwoBytes { data: payment_hash.0 },
2424                                         amount_msat: amount_msat,
2425                                         purpose: crate::lightning::events::PaymentPurpose::native_into(purpose),
2426                                         htlcs: local_htlcs.into(),
2427                                         sender_intended_total_msat: local_sender_intended_total_msat,
2428                                 }
2429                         },
2430                         nativeEvent::PaymentSent {mut payment_id, mut payment_preimage, mut payment_hash, mut fee_paid_msat, } => {
2431                                 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 } }) };
2432                                 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() }) };
2433                                 Event::PaymentSent {
2434                                         payment_id: local_payment_id,
2435                                         payment_preimage: crate::c_types::ThirtyTwoBytes { data: payment_preimage.0 },
2436                                         payment_hash: crate::c_types::ThirtyTwoBytes { data: payment_hash.0 },
2437                                         fee_paid_msat: local_fee_paid_msat,
2438                                 }
2439                         },
2440                         nativeEvent::PaymentFailed {mut payment_id, mut payment_hash, mut reason, } => {
2441                                 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()) }) };
2442                                 Event::PaymentFailed {
2443                                         payment_id: crate::c_types::ThirtyTwoBytes { data: payment_id.0 },
2444                                         payment_hash: crate::c_types::ThirtyTwoBytes { data: payment_hash.0 },
2445                                         reason: local_reason,
2446                                 }
2447                         },
2448                         nativeEvent::PaymentPathSuccessful {mut payment_id, mut payment_hash, mut path, } => {
2449                                 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 } }) };
2450                                 Event::PaymentPathSuccessful {
2451                                         payment_id: crate::c_types::ThirtyTwoBytes { data: payment_id.0 },
2452                                         payment_hash: local_payment_hash,
2453                                         path: crate::lightning::routing::router::Path { inner: ObjOps::heap_alloc(path), is_owned: true },
2454                                 }
2455                         },
2456                         nativeEvent::PaymentPathFailed {mut payment_id, mut payment_hash, mut payment_failed_permanently, mut failure, mut path, mut short_channel_id, } => {
2457                                 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 } }) };
2458                                 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() }) };
2459                                 Event::PaymentPathFailed {
2460                                         payment_id: local_payment_id,
2461                                         payment_hash: crate::c_types::ThirtyTwoBytes { data: payment_hash.0 },
2462                                         payment_failed_permanently: payment_failed_permanently,
2463                                         failure: crate::lightning::events::PathFailure::native_into(failure),
2464                                         path: crate::lightning::routing::router::Path { inner: ObjOps::heap_alloc(path), is_owned: true },
2465                                         short_channel_id: local_short_channel_id,
2466                                 }
2467                         },
2468                         nativeEvent::ProbeSuccessful {mut payment_id, mut payment_hash, mut path, } => {
2469                                 Event::ProbeSuccessful {
2470                                         payment_id: crate::c_types::ThirtyTwoBytes { data: payment_id.0 },
2471                                         payment_hash: crate::c_types::ThirtyTwoBytes { data: payment_hash.0 },
2472                                         path: crate::lightning::routing::router::Path { inner: ObjOps::heap_alloc(path), is_owned: true },
2473                                 }
2474                         },
2475                         nativeEvent::ProbeFailed {mut payment_id, mut payment_hash, mut path, mut short_channel_id, } => {
2476                                 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() }) };
2477                                 Event::ProbeFailed {
2478                                         payment_id: crate::c_types::ThirtyTwoBytes { data: payment_id.0 },
2479                                         payment_hash: crate::c_types::ThirtyTwoBytes { data: payment_hash.0 },
2480                                         path: crate::lightning::routing::router::Path { inner: ObjOps::heap_alloc(path), is_owned: true },
2481                                         short_channel_id: local_short_channel_id,
2482                                 }
2483                         },
2484                         nativeEvent::PendingHTLCsForwardable {mut time_forwardable, } => {
2485                                 Event::PendingHTLCsForwardable {
2486                                         time_forwardable: time_forwardable.as_secs(),
2487                                 }
2488                         },
2489                         nativeEvent::HTLCIntercepted {mut intercept_id, mut requested_next_hop_scid, mut payment_hash, mut inbound_amount_msat, mut expected_outbound_amount_msat, } => {
2490                                 Event::HTLCIntercepted {
2491                                         intercept_id: crate::c_types::ThirtyTwoBytes { data: intercept_id.0 },
2492                                         requested_next_hop_scid: requested_next_hop_scid,
2493                                         payment_hash: crate::c_types::ThirtyTwoBytes { data: payment_hash.0 },
2494                                         inbound_amount_msat: inbound_amount_msat,
2495                                         expected_outbound_amount_msat: expected_outbound_amount_msat,
2496                                 }
2497                         },
2498                         nativeEvent::SpendableOutputs {mut outputs, mut channel_id, } => {
2499                                 let mut local_outputs = Vec::new(); for mut item in outputs.drain(..) { local_outputs.push( { crate::lightning::sign::SpendableOutputDescriptor::native_into(item) }); };
2500                                 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 } }) };
2501                                 Event::SpendableOutputs {
2502                                         outputs: local_outputs.into(),
2503                                         channel_id: local_channel_id,
2504                                 }
2505                         },
2506                         nativeEvent::PaymentForwarded {mut prev_channel_id, mut next_channel_id, mut fee_earned_msat, mut claim_from_onchain_tx, mut outbound_amount_forwarded_msat, } => {
2507                                 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 } }) };
2508                                 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 } }) };
2509                                 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() }) };
2510                                 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() }) };
2511                                 Event::PaymentForwarded {
2512                                         prev_channel_id: local_prev_channel_id,
2513                                         next_channel_id: local_next_channel_id,
2514                                         fee_earned_msat: local_fee_earned_msat,
2515                                         claim_from_onchain_tx: claim_from_onchain_tx,
2516                                         outbound_amount_forwarded_msat: local_outbound_amount_forwarded_msat,
2517                                 }
2518                         },
2519                         nativeEvent::ChannelPending {mut channel_id, mut user_channel_id, mut former_temporary_channel_id, mut counterparty_node_id, mut funding_txo, } => {
2520                                 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 } }) };
2521                                 Event::ChannelPending {
2522                                         channel_id: crate::c_types::ThirtyTwoBytes { data: channel_id.0 },
2523                                         user_channel_id: user_channel_id.into(),
2524                                         former_temporary_channel_id: local_former_temporary_channel_id,
2525                                         counterparty_node_id: crate::c_types::PublicKey::from_rust(&counterparty_node_id),
2526                                         funding_txo: crate::c_types::bitcoin_to_C_outpoint(&funding_txo),
2527                                 }
2528                         },
2529                         nativeEvent::ChannelReady {mut channel_id, mut user_channel_id, mut counterparty_node_id, mut channel_type, } => {
2530                                 Event::ChannelReady {
2531                                         channel_id: crate::c_types::ThirtyTwoBytes { data: channel_id.0 },
2532                                         user_channel_id: user_channel_id.into(),
2533                                         counterparty_node_id: crate::c_types::PublicKey::from_rust(&counterparty_node_id),
2534                                         channel_type: crate::lightning::ln::features::ChannelTypeFeatures { inner: ObjOps::heap_alloc(channel_type), is_owned: true },
2535                                 }
2536                         },
2537                         nativeEvent::ChannelClosed {mut channel_id, mut user_channel_id, mut reason, mut counterparty_node_id, mut channel_capacity_sats, } => {
2538                                 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())) } };
2539                                 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() }) };
2540                                 Event::ChannelClosed {
2541                                         channel_id: crate::c_types::ThirtyTwoBytes { data: channel_id.0 },
2542                                         user_channel_id: user_channel_id.into(),
2543                                         reason: crate::lightning::events::ClosureReason::native_into(reason),
2544                                         counterparty_node_id: local_counterparty_node_id,
2545                                         channel_capacity_sats: local_channel_capacity_sats,
2546                                 }
2547                         },
2548                         nativeEvent::DiscardFunding {mut channel_id, mut transaction, } => {
2549                                 Event::DiscardFunding {
2550                                         channel_id: crate::c_types::ThirtyTwoBytes { data: channel_id.0 },
2551                                         transaction: crate::c_types::Transaction::from_bitcoin(&transaction),
2552                                 }
2553                         },
2554                         nativeEvent::OpenChannelRequest {mut temporary_channel_id, mut counterparty_node_id, mut funding_satoshis, mut push_msat, mut channel_type, } => {
2555                                 Event::OpenChannelRequest {
2556                                         temporary_channel_id: crate::c_types::ThirtyTwoBytes { data: temporary_channel_id.0 },
2557                                         counterparty_node_id: crate::c_types::PublicKey::from_rust(&counterparty_node_id),
2558                                         funding_satoshis: funding_satoshis,
2559                                         push_msat: push_msat,
2560                                         channel_type: crate::lightning::ln::features::ChannelTypeFeatures { inner: ObjOps::heap_alloc(channel_type), is_owned: true },
2561                                 }
2562                         },
2563                         nativeEvent::HTLCHandlingFailed {mut prev_channel_id, mut failed_next_destination, } => {
2564                                 Event::HTLCHandlingFailed {
2565                                         prev_channel_id: crate::c_types::ThirtyTwoBytes { data: prev_channel_id.0 },
2566                                         failed_next_destination: crate::lightning::events::HTLCDestination::native_into(failed_next_destination),
2567                                 }
2568                         },
2569                         nativeEvent::BumpTransaction (mut a, ) => {
2570                                 Event::BumpTransaction (
2571                                         crate::lightning::events::bump_transaction::BumpTransactionEvent::native_into(a),
2572                                 )
2573                         },
2574                 }
2575         }
2576 }
2577 /// Frees any resources used by the Event
2578 #[no_mangle]
2579 pub extern "C" fn Event_free(this_ptr: Event) { }
2580 /// Creates a copy of the Event
2581 #[no_mangle]
2582 pub extern "C" fn Event_clone(orig: &Event) -> Event {
2583         orig.clone()
2584 }
2585 #[no_mangle]
2586 /// Utility method to constructs a new FundingGenerationReady-variant Event
2587 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 {
2588         Event::FundingGenerationReady {
2589                 temporary_channel_id,
2590                 counterparty_node_id,
2591                 channel_value_satoshis,
2592                 output_script,
2593                 user_channel_id,
2594         }
2595 }
2596 #[no_mangle]
2597 /// Utility method to constructs a new PaymentClaimable-variant Event
2598 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 {
2599         Event::PaymentClaimable {
2600                 receiver_node_id,
2601                 payment_hash,
2602                 onion_fields,
2603                 amount_msat,
2604                 counterparty_skimmed_fee_msat,
2605                 purpose,
2606                 via_channel_id,
2607                 via_user_channel_id,
2608                 claim_deadline,
2609         }
2610 }
2611 #[no_mangle]
2612 /// Utility method to constructs a new PaymentClaimed-variant Event
2613 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 {
2614         Event::PaymentClaimed {
2615                 receiver_node_id,
2616                 payment_hash,
2617                 amount_msat,
2618                 purpose,
2619                 htlcs,
2620                 sender_intended_total_msat,
2621         }
2622 }
2623 #[no_mangle]
2624 /// Utility method to constructs a new PaymentSent-variant Event
2625 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 {
2626         Event::PaymentSent {
2627                 payment_id,
2628                 payment_preimage,
2629                 payment_hash,
2630                 fee_paid_msat,
2631         }
2632 }
2633 #[no_mangle]
2634 /// Utility method to constructs a new PaymentFailed-variant Event
2635 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 {
2636         Event::PaymentFailed {
2637                 payment_id,
2638                 payment_hash,
2639                 reason,
2640         }
2641 }
2642 #[no_mangle]
2643 /// Utility method to constructs a new PaymentPathSuccessful-variant Event
2644 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 {
2645         Event::PaymentPathSuccessful {
2646                 payment_id,
2647                 payment_hash,
2648                 path,
2649         }
2650 }
2651 #[no_mangle]
2652 /// Utility method to constructs a new PaymentPathFailed-variant Event
2653 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 {
2654         Event::PaymentPathFailed {
2655                 payment_id,
2656                 payment_hash,
2657                 payment_failed_permanently,
2658                 failure,
2659                 path,
2660                 short_channel_id,
2661         }
2662 }
2663 #[no_mangle]
2664 /// Utility method to constructs a new ProbeSuccessful-variant Event
2665 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 {
2666         Event::ProbeSuccessful {
2667                 payment_id,
2668                 payment_hash,
2669                 path,
2670         }
2671 }
2672 #[no_mangle]
2673 /// Utility method to constructs a new ProbeFailed-variant Event
2674 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 {
2675         Event::ProbeFailed {
2676                 payment_id,
2677                 payment_hash,
2678                 path,
2679                 short_channel_id,
2680         }
2681 }
2682 #[no_mangle]
2683 /// Utility method to constructs a new PendingHTLCsForwardable-variant Event
2684 pub extern "C" fn Event_pending_htlcs_forwardable(time_forwardable: u64) -> Event {
2685         Event::PendingHTLCsForwardable {
2686                 time_forwardable,
2687         }
2688 }
2689 #[no_mangle]
2690 /// Utility method to constructs a new HTLCIntercepted-variant Event
2691 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 {
2692         Event::HTLCIntercepted {
2693                 intercept_id,
2694                 requested_next_hop_scid,
2695                 payment_hash,
2696                 inbound_amount_msat,
2697                 expected_outbound_amount_msat,
2698         }
2699 }
2700 #[no_mangle]
2701 /// Utility method to constructs a new SpendableOutputs-variant Event
2702 pub extern "C" fn Event_spendable_outputs(outputs: crate::c_types::derived::CVec_SpendableOutputDescriptorZ, channel_id: crate::c_types::derived::COption_ThirtyTwoBytesZ) -> Event {
2703         Event::SpendableOutputs {
2704                 outputs,
2705                 channel_id,
2706         }
2707 }
2708 #[no_mangle]
2709 /// Utility method to constructs a new PaymentForwarded-variant Event
2710 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 {
2711         Event::PaymentForwarded {
2712                 prev_channel_id,
2713                 next_channel_id,
2714                 fee_earned_msat,
2715                 claim_from_onchain_tx,
2716                 outbound_amount_forwarded_msat,
2717         }
2718 }
2719 #[no_mangle]
2720 /// Utility method to constructs a new ChannelPending-variant Event
2721 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 {
2722         Event::ChannelPending {
2723                 channel_id,
2724                 user_channel_id,
2725                 former_temporary_channel_id,
2726                 counterparty_node_id,
2727                 funding_txo,
2728         }
2729 }
2730 #[no_mangle]
2731 /// Utility method to constructs a new ChannelReady-variant Event
2732 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 {
2733         Event::ChannelReady {
2734                 channel_id,
2735                 user_channel_id,
2736                 counterparty_node_id,
2737                 channel_type,
2738         }
2739 }
2740 #[no_mangle]
2741 /// Utility method to constructs a new ChannelClosed-variant Event
2742 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 {
2743         Event::ChannelClosed {
2744                 channel_id,
2745                 user_channel_id,
2746                 reason,
2747                 counterparty_node_id,
2748                 channel_capacity_sats,
2749         }
2750 }
2751 #[no_mangle]
2752 /// Utility method to constructs a new DiscardFunding-variant Event
2753 pub extern "C" fn Event_discard_funding(channel_id: crate::c_types::ThirtyTwoBytes, transaction: crate::c_types::Transaction) -> Event {
2754         Event::DiscardFunding {
2755                 channel_id,
2756                 transaction,
2757         }
2758 }
2759 #[no_mangle]
2760 /// Utility method to constructs a new OpenChannelRequest-variant Event
2761 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 {
2762         Event::OpenChannelRequest {
2763                 temporary_channel_id,
2764                 counterparty_node_id,
2765                 funding_satoshis,
2766                 push_msat,
2767                 channel_type,
2768         }
2769 }
2770 #[no_mangle]
2771 /// Utility method to constructs a new HTLCHandlingFailed-variant Event
2772 pub extern "C" fn Event_htlchandling_failed(prev_channel_id: crate::c_types::ThirtyTwoBytes, failed_next_destination: crate::lightning::events::HTLCDestination) -> Event {
2773         Event::HTLCHandlingFailed {
2774                 prev_channel_id,
2775                 failed_next_destination,
2776         }
2777 }
2778 #[no_mangle]
2779 /// Utility method to constructs a new BumpTransaction-variant Event
2780 pub extern "C" fn Event_bump_transaction(a: crate::lightning::events::bump_transaction::BumpTransactionEvent) -> Event {
2781         Event::BumpTransaction(a, )
2782 }
2783 /// Checks if two Events contain equal inner contents.
2784 /// This ignores pointers and is_owned flags and looks at the values in fields.
2785 #[no_mangle]
2786 pub extern "C" fn Event_eq(a: &Event, b: &Event) -> bool {
2787         if &a.to_native() == &b.to_native() { true } else { false }
2788 }
2789 #[no_mangle]
2790 /// Serialize the Event object into a byte array which can be read by Event_read
2791 pub extern "C" fn Event_write(obj: &crate::lightning::events::Event) -> crate::c_types::derived::CVec_u8Z {
2792         crate::c_types::serialize_obj(&unsafe { &*obj }.to_native())
2793 }
2794 #[no_mangle]
2795 /// Read a Event from a byte array, created by Event_write
2796 pub extern "C" fn Event_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_COption_EventZDecodeErrorZ {
2797         let res: Result<Option<lightning::events::Event>, lightning::ln::msgs::DecodeError> = crate::c_types::maybe_deserialize_obj(ser);
2798         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() };
2799         local_res
2800 }
2801 /// An event generated by ChannelManager which indicates a message should be sent to a peer (or
2802 /// broadcast to most peers).
2803 /// These events are handled by PeerManager::process_events if you are using a PeerManager.
2804 #[derive(Clone)]
2805 #[must_use]
2806 #[repr(C)]
2807 pub enum MessageSendEvent {
2808         /// Used to indicate that we've accepted a channel open and should send the accept_channel
2809         /// message provided to the given peer.
2810         SendAcceptChannel {
2811                 /// The node_id of the node which should receive this message
2812                 node_id: crate::c_types::PublicKey,
2813                 /// The message which should be sent.
2814                 msg: crate::lightning::ln::msgs::AcceptChannel,
2815         },
2816         /// Used to indicate that we've accepted a V2 channel open and should send the accept_channel2
2817         /// message provided to the given peer.
2818         SendAcceptChannelV2 {
2819                 /// The node_id of the node which should receive this message
2820                 node_id: crate::c_types::PublicKey,
2821                 /// The message which should be sent.
2822                 msg: crate::lightning::ln::msgs::AcceptChannelV2,
2823         },
2824         /// Used to indicate that we've initiated a channel open and should send the open_channel
2825         /// message provided to the given peer.
2826         SendOpenChannel {
2827                 /// The node_id of the node which should receive this message
2828                 node_id: crate::c_types::PublicKey,
2829                 /// The message which should be sent.
2830                 msg: crate::lightning::ln::msgs::OpenChannel,
2831         },
2832         /// Used to indicate that we've initiated a V2 channel open and should send the open_channel2
2833         /// message provided to the given peer.
2834         SendOpenChannelV2 {
2835                 /// The node_id of the node which should receive this message
2836                 node_id: crate::c_types::PublicKey,
2837                 /// The message which should be sent.
2838                 msg: crate::lightning::ln::msgs::OpenChannelV2,
2839         },
2840         /// Used to indicate that a funding_created message should be sent to the peer with the given node_id.
2841         SendFundingCreated {
2842                 /// The node_id of the node which should receive this message
2843                 node_id: crate::c_types::PublicKey,
2844                 /// The message which should be sent.
2845                 msg: crate::lightning::ln::msgs::FundingCreated,
2846         },
2847         /// Used to indicate that a funding_signed message should be sent to the peer with the given node_id.
2848         SendFundingSigned {
2849                 /// The node_id of the node which should receive this message
2850                 node_id: crate::c_types::PublicKey,
2851                 /// The message which should be sent.
2852                 msg: crate::lightning::ln::msgs::FundingSigned,
2853         },
2854         /// Used to indicate that a tx_add_input message should be sent to the peer with the given node_id.
2855         SendTxAddInput {
2856                 /// The node_id of the node which should receive this message
2857                 node_id: crate::c_types::PublicKey,
2858                 /// The message which should be sent.
2859                 msg: crate::lightning::ln::msgs::TxAddInput,
2860         },
2861         /// Used to indicate that a tx_add_output message should be sent to the peer with the given node_id.
2862         SendTxAddOutput {
2863                 /// The node_id of the node which should receive this message
2864                 node_id: crate::c_types::PublicKey,
2865                 /// The message which should be sent.
2866                 msg: crate::lightning::ln::msgs::TxAddOutput,
2867         },
2868         /// Used to indicate that a tx_remove_input message should be sent to the peer with the given node_id.
2869         SendTxRemoveInput {
2870                 /// The node_id of the node which should receive this message
2871                 node_id: crate::c_types::PublicKey,
2872                 /// The message which should be sent.
2873                 msg: crate::lightning::ln::msgs::TxRemoveInput,
2874         },
2875         /// Used to indicate that a tx_remove_output message should be sent to the peer with the given node_id.
2876         SendTxRemoveOutput {
2877                 /// The node_id of the node which should receive this message
2878                 node_id: crate::c_types::PublicKey,
2879                 /// The message which should be sent.
2880                 msg: crate::lightning::ln::msgs::TxRemoveOutput,
2881         },
2882         /// Used to indicate that a tx_complete message should be sent to the peer with the given node_id.
2883         SendTxComplete {
2884                 /// The node_id of the node which should receive this message
2885                 node_id: crate::c_types::PublicKey,
2886                 /// The message which should be sent.
2887                 msg: crate::lightning::ln::msgs::TxComplete,
2888         },
2889         /// Used to indicate that a tx_signatures message should be sent to the peer with the given node_id.
2890         SendTxSignatures {
2891                 /// The node_id of the node which should receive this message
2892                 node_id: crate::c_types::PublicKey,
2893                 /// The message which should be sent.
2894                 msg: crate::lightning::ln::msgs::TxSignatures,
2895         },
2896         /// Used to indicate that a tx_init_rbf message should be sent to the peer with the given node_id.
2897         SendTxInitRbf {
2898                 /// The node_id of the node which should receive this message
2899                 node_id: crate::c_types::PublicKey,
2900                 /// The message which should be sent.
2901                 msg: crate::lightning::ln::msgs::TxInitRbf,
2902         },
2903         /// Used to indicate that a tx_ack_rbf message should be sent to the peer with the given node_id.
2904         SendTxAckRbf {
2905                 /// The node_id of the node which should receive this message
2906                 node_id: crate::c_types::PublicKey,
2907                 /// The message which should be sent.
2908                 msg: crate::lightning::ln::msgs::TxAckRbf,
2909         },
2910         /// Used to indicate that a tx_abort message should be sent to the peer with the given node_id.
2911         SendTxAbort {
2912                 /// The node_id of the node which should receive this message
2913                 node_id: crate::c_types::PublicKey,
2914                 /// The message which should be sent.
2915                 msg: crate::lightning::ln::msgs::TxAbort,
2916         },
2917         /// Used to indicate that a channel_ready message should be sent to the peer with the given node_id.
2918         SendChannelReady {
2919                 /// The node_id of the node which should receive these message(s)
2920                 node_id: crate::c_types::PublicKey,
2921                 /// The channel_ready message which should be sent.
2922                 msg: crate::lightning::ln::msgs::ChannelReady,
2923         },
2924         /// Used to indicate that an announcement_signatures message should be sent to the peer with the given node_id.
2925         SendAnnouncementSignatures {
2926                 /// The node_id of the node which should receive these message(s)
2927                 node_id: crate::c_types::PublicKey,
2928                 /// The announcement_signatures message which should be sent.
2929                 msg: crate::lightning::ln::msgs::AnnouncementSignatures,
2930         },
2931         /// Used to indicate that a series of HTLC update messages, as well as a commitment_signed
2932         /// message should be sent to the peer with the given node_id.
2933         UpdateHTLCs {
2934                 /// The node_id of the node which should receive these message(s)
2935                 node_id: crate::c_types::PublicKey,
2936                 /// The update messages which should be sent. ALL messages in the struct should be sent!
2937                 updates: crate::lightning::ln::msgs::CommitmentUpdate,
2938         },
2939         /// Used to indicate that a revoke_and_ack message should be sent to the peer with the given node_id.
2940         SendRevokeAndACK {
2941                 /// The node_id of the node which should receive this message
2942                 node_id: crate::c_types::PublicKey,
2943                 /// The message which should be sent.
2944                 msg: crate::lightning::ln::msgs::RevokeAndACK,
2945         },
2946         /// Used to indicate that a closing_signed message should be sent to the peer with the given node_id.
2947         SendClosingSigned {
2948                 /// The node_id of the node which should receive this message
2949                 node_id: crate::c_types::PublicKey,
2950                 /// The message which should be sent.
2951                 msg: crate::lightning::ln::msgs::ClosingSigned,
2952         },
2953         /// Used to indicate that a shutdown message should be sent to the peer with the given node_id.
2954         SendShutdown {
2955                 /// The node_id of the node which should receive this message
2956                 node_id: crate::c_types::PublicKey,
2957                 /// The message which should be sent.
2958                 msg: crate::lightning::ln::msgs::Shutdown,
2959         },
2960         /// Used to indicate that a channel_reestablish message should be sent to the peer with the given node_id.
2961         SendChannelReestablish {
2962                 /// The node_id of the node which should receive this message
2963                 node_id: crate::c_types::PublicKey,
2964                 /// The message which should be sent.
2965                 msg: crate::lightning::ln::msgs::ChannelReestablish,
2966         },
2967         /// Used to send a channel_announcement and channel_update to a specific peer, likely on
2968         /// initial connection to ensure our peers know about our channels.
2969         SendChannelAnnouncement {
2970                 /// The node_id of the node which should receive this message
2971                 node_id: crate::c_types::PublicKey,
2972                 /// The channel_announcement which should be sent.
2973                 msg: crate::lightning::ln::msgs::ChannelAnnouncement,
2974                 /// The followup channel_update which should be sent.
2975                 update_msg: crate::lightning::ln::msgs::ChannelUpdate,
2976         },
2977         /// Used to indicate that a channel_announcement and channel_update should be broadcast to all
2978         /// peers (except the peer with node_id either msg.contents.node_id_1 or msg.contents.node_id_2).
2979         ///
2980         /// Note that after doing so, you very likely (unless you did so very recently) want to
2981         /// broadcast a node_announcement (e.g. via [`PeerManager::broadcast_node_announcement`]). This
2982         /// ensures that any nodes which see our channel_announcement also have a relevant
2983         /// node_announcement, including relevant feature flags which may be important for routing
2984         /// through or to us.
2985         ///
2986         /// [`PeerManager::broadcast_node_announcement`]: crate::ln::peer_handler::PeerManager::broadcast_node_announcement
2987         BroadcastChannelAnnouncement {
2988                 /// The channel_announcement which should be sent.
2989                 msg: crate::lightning::ln::msgs::ChannelAnnouncement,
2990                 /// The followup channel_update which should be sent.
2991                 ///
2992                 /// Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None
2993                 update_msg: crate::lightning::ln::msgs::ChannelUpdate,
2994         },
2995         /// Used to indicate that a channel_update should be broadcast to all peers.
2996         BroadcastChannelUpdate {
2997                 /// The channel_update which should be sent.
2998                 msg: crate::lightning::ln::msgs::ChannelUpdate,
2999         },
3000         /// Used to indicate that a node_announcement should be broadcast to all peers.
3001         BroadcastNodeAnnouncement {
3002                 /// The node_announcement which should be sent.
3003                 msg: crate::lightning::ln::msgs::NodeAnnouncement,
3004         },
3005         /// Used to indicate that a channel_update should be sent to a single peer.
3006         /// In contrast to [`Self::BroadcastChannelUpdate`], this is used when the channel is a
3007         /// private channel and we shouldn't be informing all of our peers of channel parameters.
3008         SendChannelUpdate {
3009                 /// The node_id of the node which should receive this message
3010                 node_id: crate::c_types::PublicKey,
3011                 /// The channel_update which should be sent.
3012                 msg: crate::lightning::ln::msgs::ChannelUpdate,
3013         },
3014         /// Broadcast an error downstream to be handled
3015         HandleError {
3016                 /// The node_id of the node which should receive this message
3017                 node_id: crate::c_types::PublicKey,
3018                 /// The action which should be taken.
3019                 action: crate::lightning::ln::msgs::ErrorAction,
3020         },
3021         /// Query a peer for channels with funding transaction UTXOs in a block range.
3022         SendChannelRangeQuery {
3023                 /// The node_id of this message recipient
3024                 node_id: crate::c_types::PublicKey,
3025                 /// The query_channel_range which should be sent.
3026                 msg: crate::lightning::ln::msgs::QueryChannelRange,
3027         },
3028         /// Request routing gossip messages from a peer for a list of channels identified by
3029         /// their short_channel_ids.
3030         SendShortIdsQuery {
3031                 /// The node_id of this message recipient
3032                 node_id: crate::c_types::PublicKey,
3033                 /// The query_short_channel_ids which should be sent.
3034                 msg: crate::lightning::ln::msgs::QueryShortChannelIds,
3035         },
3036         /// Sends a reply to a channel range query. This may be one of several SendReplyChannelRange events
3037         /// emitted during processing of the query.
3038         SendReplyChannelRange {
3039                 /// The node_id of this message recipient
3040                 node_id: crate::c_types::PublicKey,
3041                 /// The reply_channel_range which should be sent.
3042                 msg: crate::lightning::ln::msgs::ReplyChannelRange,
3043         },
3044         /// Sends a timestamp filter for inbound gossip. This should be sent on each new connection to
3045         /// enable receiving gossip messages from the peer.
3046         SendGossipTimestampFilter {
3047                 /// The node_id of this message recipient
3048                 node_id: crate::c_types::PublicKey,
3049                 /// The gossip_timestamp_filter which should be sent.
3050                 msg: crate::lightning::ln::msgs::GossipTimestampFilter,
3051         },
3052 }
3053 use lightning::events::MessageSendEvent as MessageSendEventImport;
3054 pub(crate) type nativeMessageSendEvent = MessageSendEventImport;
3055
3056 impl MessageSendEvent {
3057         #[allow(unused)]
3058         pub(crate) fn to_native(&self) -> nativeMessageSendEvent {
3059                 match self {
3060                         MessageSendEvent::SendAcceptChannel {ref node_id, ref msg, } => {
3061                                 let mut node_id_nonref = Clone::clone(node_id);
3062                                 let mut msg_nonref = Clone::clone(msg);
3063                                 nativeMessageSendEvent::SendAcceptChannel {
3064                                         node_id: node_id_nonref.into_rust(),
3065                                         msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) },
3066                                 }
3067                         },
3068                         MessageSendEvent::SendAcceptChannelV2 {ref node_id, ref msg, } => {
3069                                 let mut node_id_nonref = Clone::clone(node_id);
3070                                 let mut msg_nonref = Clone::clone(msg);
3071                                 nativeMessageSendEvent::SendAcceptChannelV2 {
3072                                         node_id: node_id_nonref.into_rust(),
3073                                         msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) },
3074                                 }
3075                         },
3076                         MessageSendEvent::SendOpenChannel {ref node_id, ref msg, } => {
3077                                 let mut node_id_nonref = Clone::clone(node_id);
3078                                 let mut msg_nonref = Clone::clone(msg);
3079                                 nativeMessageSendEvent::SendOpenChannel {
3080                                         node_id: node_id_nonref.into_rust(),
3081                                         msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) },
3082                                 }
3083                         },
3084                         MessageSendEvent::SendOpenChannelV2 {ref node_id, ref msg, } => {
3085                                 let mut node_id_nonref = Clone::clone(node_id);
3086                                 let mut msg_nonref = Clone::clone(msg);
3087                                 nativeMessageSendEvent::SendOpenChannelV2 {
3088                                         node_id: node_id_nonref.into_rust(),
3089                                         msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) },
3090                                 }
3091                         },
3092                         MessageSendEvent::SendFundingCreated {ref node_id, ref msg, } => {
3093                                 let mut node_id_nonref = Clone::clone(node_id);
3094                                 let mut msg_nonref = Clone::clone(msg);
3095                                 nativeMessageSendEvent::SendFundingCreated {
3096                                         node_id: node_id_nonref.into_rust(),
3097                                         msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) },
3098                                 }
3099                         },
3100                         MessageSendEvent::SendFundingSigned {ref node_id, ref msg, } => {
3101                                 let mut node_id_nonref = Clone::clone(node_id);
3102                                 let mut msg_nonref = Clone::clone(msg);
3103                                 nativeMessageSendEvent::SendFundingSigned {
3104                                         node_id: node_id_nonref.into_rust(),
3105                                         msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) },
3106                                 }
3107                         },
3108                         MessageSendEvent::SendTxAddInput {ref node_id, ref msg, } => {
3109                                 let mut node_id_nonref = Clone::clone(node_id);
3110                                 let mut msg_nonref = Clone::clone(msg);
3111                                 nativeMessageSendEvent::SendTxAddInput {
3112                                         node_id: node_id_nonref.into_rust(),
3113                                         msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) },
3114                                 }
3115                         },
3116                         MessageSendEvent::SendTxAddOutput {ref node_id, ref msg, } => {
3117                                 let mut node_id_nonref = Clone::clone(node_id);
3118                                 let mut msg_nonref = Clone::clone(msg);
3119                                 nativeMessageSendEvent::SendTxAddOutput {
3120                                         node_id: node_id_nonref.into_rust(),
3121                                         msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) },
3122                                 }
3123                         },
3124                         MessageSendEvent::SendTxRemoveInput {ref node_id, ref msg, } => {
3125                                 let mut node_id_nonref = Clone::clone(node_id);
3126                                 let mut msg_nonref = Clone::clone(msg);
3127                                 nativeMessageSendEvent::SendTxRemoveInput {
3128                                         node_id: node_id_nonref.into_rust(),
3129                                         msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) },
3130                                 }
3131                         },
3132                         MessageSendEvent::SendTxRemoveOutput {ref node_id, ref msg, } => {
3133                                 let mut node_id_nonref = Clone::clone(node_id);
3134                                 let mut msg_nonref = Clone::clone(msg);
3135                                 nativeMessageSendEvent::SendTxRemoveOutput {
3136                                         node_id: node_id_nonref.into_rust(),
3137                                         msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) },
3138                                 }
3139                         },
3140                         MessageSendEvent::SendTxComplete {ref node_id, ref msg, } => {
3141                                 let mut node_id_nonref = Clone::clone(node_id);
3142                                 let mut msg_nonref = Clone::clone(msg);
3143                                 nativeMessageSendEvent::SendTxComplete {
3144                                         node_id: node_id_nonref.into_rust(),
3145                                         msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) },
3146                                 }
3147                         },
3148                         MessageSendEvent::SendTxSignatures {ref node_id, ref msg, } => {
3149                                 let mut node_id_nonref = Clone::clone(node_id);
3150                                 let mut msg_nonref = Clone::clone(msg);
3151                                 nativeMessageSendEvent::SendTxSignatures {
3152                                         node_id: node_id_nonref.into_rust(),
3153                                         msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) },
3154                                 }
3155                         },
3156                         MessageSendEvent::SendTxInitRbf {ref node_id, ref msg, } => {
3157                                 let mut node_id_nonref = Clone::clone(node_id);
3158                                 let mut msg_nonref = Clone::clone(msg);
3159                                 nativeMessageSendEvent::SendTxInitRbf {
3160                                         node_id: node_id_nonref.into_rust(),
3161                                         msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) },
3162                                 }
3163                         },
3164                         MessageSendEvent::SendTxAckRbf {ref node_id, ref msg, } => {
3165                                 let mut node_id_nonref = Clone::clone(node_id);
3166                                 let mut msg_nonref = Clone::clone(msg);
3167                                 nativeMessageSendEvent::SendTxAckRbf {
3168                                         node_id: node_id_nonref.into_rust(),
3169                                         msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) },
3170                                 }
3171                         },
3172                         MessageSendEvent::SendTxAbort {ref node_id, ref msg, } => {
3173                                 let mut node_id_nonref = Clone::clone(node_id);
3174                                 let mut msg_nonref = Clone::clone(msg);
3175                                 nativeMessageSendEvent::SendTxAbort {
3176                                         node_id: node_id_nonref.into_rust(),
3177                                         msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) },
3178                                 }
3179                         },
3180                         MessageSendEvent::SendChannelReady {ref node_id, ref msg, } => {
3181                                 let mut node_id_nonref = Clone::clone(node_id);
3182                                 let mut msg_nonref = Clone::clone(msg);
3183                                 nativeMessageSendEvent::SendChannelReady {
3184                                         node_id: node_id_nonref.into_rust(),
3185                                         msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) },
3186                                 }
3187                         },
3188                         MessageSendEvent::SendAnnouncementSignatures {ref node_id, ref msg, } => {
3189                                 let mut node_id_nonref = Clone::clone(node_id);
3190                                 let mut msg_nonref = Clone::clone(msg);
3191                                 nativeMessageSendEvent::SendAnnouncementSignatures {
3192                                         node_id: node_id_nonref.into_rust(),
3193                                         msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) },
3194                                 }
3195                         },
3196                         MessageSendEvent::UpdateHTLCs {ref node_id, ref updates, } => {
3197                                 let mut node_id_nonref = Clone::clone(node_id);
3198                                 let mut updates_nonref = Clone::clone(updates);
3199                                 nativeMessageSendEvent::UpdateHTLCs {
3200                                         node_id: node_id_nonref.into_rust(),
3201                                         updates: *unsafe { Box::from_raw(updates_nonref.take_inner()) },
3202                                 }
3203                         },
3204                         MessageSendEvent::SendRevokeAndACK {ref node_id, ref msg, } => {
3205                                 let mut node_id_nonref = Clone::clone(node_id);
3206                                 let mut msg_nonref = Clone::clone(msg);
3207                                 nativeMessageSendEvent::SendRevokeAndACK {
3208                                         node_id: node_id_nonref.into_rust(),
3209                                         msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) },
3210                                 }
3211                         },
3212                         MessageSendEvent::SendClosingSigned {ref node_id, ref msg, } => {
3213                                 let mut node_id_nonref = Clone::clone(node_id);
3214                                 let mut msg_nonref = Clone::clone(msg);
3215                                 nativeMessageSendEvent::SendClosingSigned {
3216                                         node_id: node_id_nonref.into_rust(),
3217                                         msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) },
3218                                 }
3219                         },
3220                         MessageSendEvent::SendShutdown {ref node_id, ref msg, } => {
3221                                 let mut node_id_nonref = Clone::clone(node_id);
3222                                 let mut msg_nonref = Clone::clone(msg);
3223                                 nativeMessageSendEvent::SendShutdown {
3224                                         node_id: node_id_nonref.into_rust(),
3225                                         msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) },
3226                                 }
3227                         },
3228                         MessageSendEvent::SendChannelReestablish {ref node_id, ref msg, } => {
3229                                 let mut node_id_nonref = Clone::clone(node_id);
3230                                 let mut msg_nonref = Clone::clone(msg);
3231                                 nativeMessageSendEvent::SendChannelReestablish {
3232                                         node_id: node_id_nonref.into_rust(),
3233                                         msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) },
3234                                 }
3235                         },
3236                         MessageSendEvent::SendChannelAnnouncement {ref node_id, ref msg, ref update_msg, } => {
3237                                 let mut node_id_nonref = Clone::clone(node_id);
3238                                 let mut msg_nonref = Clone::clone(msg);
3239                                 let mut update_msg_nonref = Clone::clone(update_msg);
3240                                 nativeMessageSendEvent::SendChannelAnnouncement {
3241                                         node_id: node_id_nonref.into_rust(),
3242                                         msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) },
3243                                         update_msg: *unsafe { Box::from_raw(update_msg_nonref.take_inner()) },
3244                                 }
3245                         },
3246                         MessageSendEvent::BroadcastChannelAnnouncement {ref msg, ref update_msg, } => {
3247                                 let mut msg_nonref = Clone::clone(msg);
3248                                 let mut update_msg_nonref = Clone::clone(update_msg);
3249                                 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()) } }) };
3250                                 nativeMessageSendEvent::BroadcastChannelAnnouncement {
3251                                         msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) },
3252                                         update_msg: local_update_msg_nonref,
3253                                 }
3254                         },
3255                         MessageSendEvent::BroadcastChannelUpdate {ref msg, } => {
3256                                 let mut msg_nonref = Clone::clone(msg);
3257                                 nativeMessageSendEvent::BroadcastChannelUpdate {
3258                                         msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) },
3259                                 }
3260                         },
3261                         MessageSendEvent::BroadcastNodeAnnouncement {ref msg, } => {
3262                                 let mut msg_nonref = Clone::clone(msg);
3263                                 nativeMessageSendEvent::BroadcastNodeAnnouncement {
3264                                         msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) },
3265                                 }
3266                         },
3267                         MessageSendEvent::SendChannelUpdate {ref node_id, ref msg, } => {
3268                                 let mut node_id_nonref = Clone::clone(node_id);
3269                                 let mut msg_nonref = Clone::clone(msg);
3270                                 nativeMessageSendEvent::SendChannelUpdate {
3271                                         node_id: node_id_nonref.into_rust(),
3272                                         msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) },
3273                                 }
3274                         },
3275                         MessageSendEvent::HandleError {ref node_id, ref action, } => {
3276                                 let mut node_id_nonref = Clone::clone(node_id);
3277                                 let mut action_nonref = Clone::clone(action);
3278                                 nativeMessageSendEvent::HandleError {
3279                                         node_id: node_id_nonref.into_rust(),
3280                                         action: action_nonref.into_native(),
3281                                 }
3282                         },
3283                         MessageSendEvent::SendChannelRangeQuery {ref node_id, ref msg, } => {
3284                                 let mut node_id_nonref = Clone::clone(node_id);
3285                                 let mut msg_nonref = Clone::clone(msg);
3286                                 nativeMessageSendEvent::SendChannelRangeQuery {
3287                                         node_id: node_id_nonref.into_rust(),
3288                                         msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) },
3289                                 }
3290                         },
3291                         MessageSendEvent::SendShortIdsQuery {ref node_id, ref msg, } => {
3292                                 let mut node_id_nonref = Clone::clone(node_id);
3293                                 let mut msg_nonref = Clone::clone(msg);
3294                                 nativeMessageSendEvent::SendShortIdsQuery {
3295                                         node_id: node_id_nonref.into_rust(),
3296                                         msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) },
3297                                 }
3298                         },
3299                         MessageSendEvent::SendReplyChannelRange {ref node_id, ref msg, } => {
3300                                 let mut node_id_nonref = Clone::clone(node_id);
3301                                 let mut msg_nonref = Clone::clone(msg);
3302                                 nativeMessageSendEvent::SendReplyChannelRange {
3303                                         node_id: node_id_nonref.into_rust(),
3304                                         msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) },
3305                                 }
3306                         },
3307                         MessageSendEvent::SendGossipTimestampFilter {ref node_id, ref msg, } => {
3308                                 let mut node_id_nonref = Clone::clone(node_id);
3309                                 let mut msg_nonref = Clone::clone(msg);
3310                                 nativeMessageSendEvent::SendGossipTimestampFilter {
3311                                         node_id: node_id_nonref.into_rust(),
3312                                         msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) },
3313                                 }
3314                         },
3315                 }
3316         }
3317         #[allow(unused)]
3318         pub(crate) fn into_native(self) -> nativeMessageSendEvent {
3319                 match self {
3320                         MessageSendEvent::SendAcceptChannel {mut node_id, mut msg, } => {
3321                                 nativeMessageSendEvent::SendAcceptChannel {
3322                                         node_id: node_id.into_rust(),
3323                                         msg: *unsafe { Box::from_raw(msg.take_inner()) },
3324                                 }
3325                         },
3326                         MessageSendEvent::SendAcceptChannelV2 {mut node_id, mut msg, } => {
3327                                 nativeMessageSendEvent::SendAcceptChannelV2 {
3328                                         node_id: node_id.into_rust(),
3329                                         msg: *unsafe { Box::from_raw(msg.take_inner()) },
3330                                 }
3331                         },
3332                         MessageSendEvent::SendOpenChannel {mut node_id, mut msg, } => {
3333                                 nativeMessageSendEvent::SendOpenChannel {
3334                                         node_id: node_id.into_rust(),
3335                                         msg: *unsafe { Box::from_raw(msg.take_inner()) },
3336                                 }
3337                         },
3338                         MessageSendEvent::SendOpenChannelV2 {mut node_id, mut msg, } => {
3339                                 nativeMessageSendEvent::SendOpenChannelV2 {
3340                                         node_id: node_id.into_rust(),
3341                                         msg: *unsafe { Box::from_raw(msg.take_inner()) },
3342                                 }
3343                         },
3344                         MessageSendEvent::SendFundingCreated {mut node_id, mut msg, } => {
3345                                 nativeMessageSendEvent::SendFundingCreated {
3346                                         node_id: node_id.into_rust(),
3347                                         msg: *unsafe { Box::from_raw(msg.take_inner()) },
3348                                 }
3349                         },
3350                         MessageSendEvent::SendFundingSigned {mut node_id, mut msg, } => {
3351                                 nativeMessageSendEvent::SendFundingSigned {
3352                                         node_id: node_id.into_rust(),
3353                                         msg: *unsafe { Box::from_raw(msg.take_inner()) },
3354                                 }
3355                         },
3356                         MessageSendEvent::SendTxAddInput {mut node_id, mut msg, } => {
3357                                 nativeMessageSendEvent::SendTxAddInput {
3358                                         node_id: node_id.into_rust(),
3359                                         msg: *unsafe { Box::from_raw(msg.take_inner()) },
3360                                 }
3361                         },
3362                         MessageSendEvent::SendTxAddOutput {mut node_id, mut msg, } => {
3363                                 nativeMessageSendEvent::SendTxAddOutput {
3364                                         node_id: node_id.into_rust(),
3365                                         msg: *unsafe { Box::from_raw(msg.take_inner()) },
3366                                 }
3367                         },
3368                         MessageSendEvent::SendTxRemoveInput {mut node_id, mut msg, } => {
3369                                 nativeMessageSendEvent::SendTxRemoveInput {
3370                                         node_id: node_id.into_rust(),
3371                                         msg: *unsafe { Box::from_raw(msg.take_inner()) },
3372                                 }
3373                         },
3374                         MessageSendEvent::SendTxRemoveOutput {mut node_id, mut msg, } => {
3375                                 nativeMessageSendEvent::SendTxRemoveOutput {
3376                                         node_id: node_id.into_rust(),
3377                                         msg: *unsafe { Box::from_raw(msg.take_inner()) },
3378                                 }
3379                         },
3380                         MessageSendEvent::SendTxComplete {mut node_id, mut msg, } => {
3381                                 nativeMessageSendEvent::SendTxComplete {
3382                                         node_id: node_id.into_rust(),
3383                                         msg: *unsafe { Box::from_raw(msg.take_inner()) },
3384                                 }
3385                         },
3386                         MessageSendEvent::SendTxSignatures {mut node_id, mut msg, } => {
3387                                 nativeMessageSendEvent::SendTxSignatures {
3388                                         node_id: node_id.into_rust(),
3389                                         msg: *unsafe { Box::from_raw(msg.take_inner()) },
3390                                 }
3391                         },
3392                         MessageSendEvent::SendTxInitRbf {mut node_id, mut msg, } => {
3393                                 nativeMessageSendEvent::SendTxInitRbf {
3394                                         node_id: node_id.into_rust(),
3395                                         msg: *unsafe { Box::from_raw(msg.take_inner()) },
3396                                 }
3397                         },
3398                         MessageSendEvent::SendTxAckRbf {mut node_id, mut msg, } => {
3399                                 nativeMessageSendEvent::SendTxAckRbf {
3400                                         node_id: node_id.into_rust(),
3401                                         msg: *unsafe { Box::from_raw(msg.take_inner()) },
3402                                 }
3403                         },
3404                         MessageSendEvent::SendTxAbort {mut node_id, mut msg, } => {
3405                                 nativeMessageSendEvent::SendTxAbort {
3406                                         node_id: node_id.into_rust(),
3407                                         msg: *unsafe { Box::from_raw(msg.take_inner()) },
3408                                 }
3409                         },
3410                         MessageSendEvent::SendChannelReady {mut node_id, mut msg, } => {
3411                                 nativeMessageSendEvent::SendChannelReady {
3412                                         node_id: node_id.into_rust(),
3413                                         msg: *unsafe { Box::from_raw(msg.take_inner()) },
3414                                 }
3415                         },
3416                         MessageSendEvent::SendAnnouncementSignatures {mut node_id, mut msg, } => {
3417                                 nativeMessageSendEvent::SendAnnouncementSignatures {
3418                                         node_id: node_id.into_rust(),
3419                                         msg: *unsafe { Box::from_raw(msg.take_inner()) },
3420                                 }
3421                         },
3422                         MessageSendEvent::UpdateHTLCs {mut node_id, mut updates, } => {
3423                                 nativeMessageSendEvent::UpdateHTLCs {
3424                                         node_id: node_id.into_rust(),
3425                                         updates: *unsafe { Box::from_raw(updates.take_inner()) },
3426                                 }
3427                         },
3428                         MessageSendEvent::SendRevokeAndACK {mut node_id, mut msg, } => {
3429                                 nativeMessageSendEvent::SendRevokeAndACK {
3430                                         node_id: node_id.into_rust(),
3431                                         msg: *unsafe { Box::from_raw(msg.take_inner()) },
3432                                 }
3433                         },
3434                         MessageSendEvent::SendClosingSigned {mut node_id, mut msg, } => {
3435                                 nativeMessageSendEvent::SendClosingSigned {
3436                                         node_id: node_id.into_rust(),
3437                                         msg: *unsafe { Box::from_raw(msg.take_inner()) },
3438                                 }
3439                         },
3440                         MessageSendEvent::SendShutdown {mut node_id, mut msg, } => {
3441                                 nativeMessageSendEvent::SendShutdown {
3442                                         node_id: node_id.into_rust(),
3443                                         msg: *unsafe { Box::from_raw(msg.take_inner()) },
3444                                 }
3445                         },
3446                         MessageSendEvent::SendChannelReestablish {mut node_id, mut msg, } => {
3447                                 nativeMessageSendEvent::SendChannelReestablish {
3448                                         node_id: node_id.into_rust(),
3449                                         msg: *unsafe { Box::from_raw(msg.take_inner()) },
3450                                 }
3451                         },
3452                         MessageSendEvent::SendChannelAnnouncement {mut node_id, mut msg, mut update_msg, } => {
3453                                 nativeMessageSendEvent::SendChannelAnnouncement {
3454                                         node_id: node_id.into_rust(),
3455                                         msg: *unsafe { Box::from_raw(msg.take_inner()) },
3456                                         update_msg: *unsafe { Box::from_raw(update_msg.take_inner()) },
3457                                 }
3458                         },
3459                         MessageSendEvent::BroadcastChannelAnnouncement {mut msg, mut update_msg, } => {
3460                                 let mut local_update_msg = if update_msg.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(update_msg.take_inner()) } }) };
3461                                 nativeMessageSendEvent::BroadcastChannelAnnouncement {
3462                                         msg: *unsafe { Box::from_raw(msg.take_inner()) },
3463                                         update_msg: local_update_msg,
3464                                 }
3465                         },
3466                         MessageSendEvent::BroadcastChannelUpdate {mut msg, } => {
3467                                 nativeMessageSendEvent::BroadcastChannelUpdate {
3468                                         msg: *unsafe { Box::from_raw(msg.take_inner()) },
3469                                 }
3470                         },
3471                         MessageSendEvent::BroadcastNodeAnnouncement {mut msg, } => {
3472                                 nativeMessageSendEvent::BroadcastNodeAnnouncement {
3473                                         msg: *unsafe { Box::from_raw(msg.take_inner()) },
3474                                 }
3475                         },
3476                         MessageSendEvent::SendChannelUpdate {mut node_id, mut msg, } => {
3477                                 nativeMessageSendEvent::SendChannelUpdate {
3478                                         node_id: node_id.into_rust(),
3479                                         msg: *unsafe { Box::from_raw(msg.take_inner()) },
3480                                 }
3481                         },
3482                         MessageSendEvent::HandleError {mut node_id, mut action, } => {
3483                                 nativeMessageSendEvent::HandleError {
3484                                         node_id: node_id.into_rust(),
3485                                         action: action.into_native(),
3486                                 }
3487                         },
3488                         MessageSendEvent::SendChannelRangeQuery {mut node_id, mut msg, } => {
3489                                 nativeMessageSendEvent::SendChannelRangeQuery {
3490                                         node_id: node_id.into_rust(),
3491                                         msg: *unsafe { Box::from_raw(msg.take_inner()) },
3492                                 }
3493                         },
3494                         MessageSendEvent::SendShortIdsQuery {mut node_id, mut msg, } => {
3495                                 nativeMessageSendEvent::SendShortIdsQuery {
3496                                         node_id: node_id.into_rust(),
3497                                         msg: *unsafe { Box::from_raw(msg.take_inner()) },
3498                                 }
3499                         },
3500                         MessageSendEvent::SendReplyChannelRange {mut node_id, mut msg, } => {
3501                                 nativeMessageSendEvent::SendReplyChannelRange {
3502                                         node_id: node_id.into_rust(),
3503                                         msg: *unsafe { Box::from_raw(msg.take_inner()) },
3504                                 }
3505                         },
3506                         MessageSendEvent::SendGossipTimestampFilter {mut node_id, mut msg, } => {
3507                                 nativeMessageSendEvent::SendGossipTimestampFilter {
3508                                         node_id: node_id.into_rust(),
3509                                         msg: *unsafe { Box::from_raw(msg.take_inner()) },
3510                                 }
3511                         },
3512                 }
3513         }
3514         #[allow(unused)]
3515         pub(crate) fn from_native(native: &nativeMessageSendEvent) -> Self {
3516                 match native {
3517                         nativeMessageSendEvent::SendAcceptChannel {ref node_id, ref msg, } => {
3518                                 let mut node_id_nonref = Clone::clone(node_id);
3519                                 let mut msg_nonref = Clone::clone(msg);
3520                                 MessageSendEvent::SendAcceptChannel {
3521                                         node_id: crate::c_types::PublicKey::from_rust(&node_id_nonref),
3522                                         msg: crate::lightning::ln::msgs::AcceptChannel { inner: ObjOps::heap_alloc(msg_nonref), is_owned: true },
3523                                 }
3524                         },
3525                         nativeMessageSendEvent::SendAcceptChannelV2 {ref node_id, ref msg, } => {
3526                                 let mut node_id_nonref = Clone::clone(node_id);
3527                                 let mut msg_nonref = Clone::clone(msg);
3528                                 MessageSendEvent::SendAcceptChannelV2 {
3529                                         node_id: crate::c_types::PublicKey::from_rust(&node_id_nonref),
3530                                         msg: crate::lightning::ln::msgs::AcceptChannelV2 { inner: ObjOps::heap_alloc(msg_nonref), is_owned: true },
3531                                 }
3532                         },
3533                         nativeMessageSendEvent::SendOpenChannel {ref node_id, ref msg, } => {
3534                                 let mut node_id_nonref = Clone::clone(node_id);
3535                                 let mut msg_nonref = Clone::clone(msg);
3536                                 MessageSendEvent::SendOpenChannel {
3537                                         node_id: crate::c_types::PublicKey::from_rust(&node_id_nonref),
3538                                         msg: crate::lightning::ln::msgs::OpenChannel { inner: ObjOps::heap_alloc(msg_nonref), is_owned: true },
3539                                 }
3540                         },
3541                         nativeMessageSendEvent::SendOpenChannelV2 {ref node_id, ref msg, } => {
3542                                 let mut node_id_nonref = Clone::clone(node_id);
3543                                 let mut msg_nonref = Clone::clone(msg);
3544                                 MessageSendEvent::SendOpenChannelV2 {
3545                                         node_id: crate::c_types::PublicKey::from_rust(&node_id_nonref),
3546                                         msg: crate::lightning::ln::msgs::OpenChannelV2 { inner: ObjOps::heap_alloc(msg_nonref), is_owned: true },
3547                                 }
3548                         },
3549                         nativeMessageSendEvent::SendFundingCreated {ref node_id, ref msg, } => {
3550                                 let mut node_id_nonref = Clone::clone(node_id);
3551                                 let mut msg_nonref = Clone::clone(msg);
3552                                 MessageSendEvent::SendFundingCreated {
3553                                         node_id: crate::c_types::PublicKey::from_rust(&node_id_nonref),
3554                                         msg: crate::lightning::ln::msgs::FundingCreated { inner: ObjOps::heap_alloc(msg_nonref), is_owned: true },
3555                                 }
3556                         },
3557                         nativeMessageSendEvent::SendFundingSigned {ref node_id, ref msg, } => {
3558                                 let mut node_id_nonref = Clone::clone(node_id);
3559                                 let mut msg_nonref = Clone::clone(msg);
3560                                 MessageSendEvent::SendFundingSigned {
3561                                         node_id: crate::c_types::PublicKey::from_rust(&node_id_nonref),
3562                                         msg: crate::lightning::ln::msgs::FundingSigned { inner: ObjOps::heap_alloc(msg_nonref), is_owned: true },
3563                                 }
3564                         },
3565                         nativeMessageSendEvent::SendTxAddInput {ref node_id, ref msg, } => {
3566                                 let mut node_id_nonref = Clone::clone(node_id);
3567                                 let mut msg_nonref = Clone::clone(msg);
3568                                 MessageSendEvent::SendTxAddInput {
3569                                         node_id: crate::c_types::PublicKey::from_rust(&node_id_nonref),
3570                                         msg: crate::lightning::ln::msgs::TxAddInput { inner: ObjOps::heap_alloc(msg_nonref), is_owned: true },
3571                                 }
3572                         },
3573                         nativeMessageSendEvent::SendTxAddOutput {ref node_id, ref msg, } => {
3574                                 let mut node_id_nonref = Clone::clone(node_id);
3575                                 let mut msg_nonref = Clone::clone(msg);
3576                                 MessageSendEvent::SendTxAddOutput {
3577                                         node_id: crate::c_types::PublicKey::from_rust(&node_id_nonref),
3578                                         msg: crate::lightning::ln::msgs::TxAddOutput { inner: ObjOps::heap_alloc(msg_nonref), is_owned: true },
3579                                 }
3580                         },
3581                         nativeMessageSendEvent::SendTxRemoveInput {ref node_id, ref msg, } => {
3582                                 let mut node_id_nonref = Clone::clone(node_id);
3583                                 let mut msg_nonref = Clone::clone(msg);
3584                                 MessageSendEvent::SendTxRemoveInput {
3585                                         node_id: crate::c_types::PublicKey::from_rust(&node_id_nonref),
3586                                         msg: crate::lightning::ln::msgs::TxRemoveInput { inner: ObjOps::heap_alloc(msg_nonref), is_owned: true },
3587                                 }
3588                         },
3589                         nativeMessageSendEvent::SendTxRemoveOutput {ref node_id, ref msg, } => {
3590                                 let mut node_id_nonref = Clone::clone(node_id);
3591                                 let mut msg_nonref = Clone::clone(msg);
3592                                 MessageSendEvent::SendTxRemoveOutput {
3593                                         node_id: crate::c_types::PublicKey::from_rust(&node_id_nonref),
3594                                         msg: crate::lightning::ln::msgs::TxRemoveOutput { inner: ObjOps::heap_alloc(msg_nonref), is_owned: true },
3595                                 }
3596                         },
3597                         nativeMessageSendEvent::SendTxComplete {ref node_id, ref msg, } => {
3598                                 let mut node_id_nonref = Clone::clone(node_id);
3599                                 let mut msg_nonref = Clone::clone(msg);
3600                                 MessageSendEvent::SendTxComplete {
3601                                         node_id: crate::c_types::PublicKey::from_rust(&node_id_nonref),
3602                                         msg: crate::lightning::ln::msgs::TxComplete { inner: ObjOps::heap_alloc(msg_nonref), is_owned: true },
3603                                 }
3604                         },
3605                         nativeMessageSendEvent::SendTxSignatures {ref node_id, ref msg, } => {
3606                                 let mut node_id_nonref = Clone::clone(node_id);
3607                                 let mut msg_nonref = Clone::clone(msg);
3608                                 MessageSendEvent::SendTxSignatures {
3609                                         node_id: crate::c_types::PublicKey::from_rust(&node_id_nonref),
3610                                         msg: crate::lightning::ln::msgs::TxSignatures { inner: ObjOps::heap_alloc(msg_nonref), is_owned: true },
3611                                 }
3612                         },
3613                         nativeMessageSendEvent::SendTxInitRbf {ref node_id, ref msg, } => {
3614                                 let mut node_id_nonref = Clone::clone(node_id);
3615                                 let mut msg_nonref = Clone::clone(msg);
3616                                 MessageSendEvent::SendTxInitRbf {
3617                                         node_id: crate::c_types::PublicKey::from_rust(&node_id_nonref),
3618                                         msg: crate::lightning::ln::msgs::TxInitRbf { inner: ObjOps::heap_alloc(msg_nonref), is_owned: true },
3619                                 }
3620                         },
3621                         nativeMessageSendEvent::SendTxAckRbf {ref node_id, ref msg, } => {
3622                                 let mut node_id_nonref = Clone::clone(node_id);
3623                                 let mut msg_nonref = Clone::clone(msg);
3624                                 MessageSendEvent::SendTxAckRbf {
3625                                         node_id: crate::c_types::PublicKey::from_rust(&node_id_nonref),
3626                                         msg: crate::lightning::ln::msgs::TxAckRbf { inner: ObjOps::heap_alloc(msg_nonref), is_owned: true },
3627                                 }
3628                         },
3629                         nativeMessageSendEvent::SendTxAbort {ref node_id, ref msg, } => {
3630                                 let mut node_id_nonref = Clone::clone(node_id);
3631                                 let mut msg_nonref = Clone::clone(msg);
3632                                 MessageSendEvent::SendTxAbort {
3633                                         node_id: crate::c_types::PublicKey::from_rust(&node_id_nonref),
3634                                         msg: crate::lightning::ln::msgs::TxAbort { inner: ObjOps::heap_alloc(msg_nonref), is_owned: true },
3635                                 }
3636                         },
3637                         nativeMessageSendEvent::SendChannelReady {ref node_id, ref msg, } => {
3638                                 let mut node_id_nonref = Clone::clone(node_id);
3639                                 let mut msg_nonref = Clone::clone(msg);
3640                                 MessageSendEvent::SendChannelReady {
3641                                         node_id: crate::c_types::PublicKey::from_rust(&node_id_nonref),
3642                                         msg: crate::lightning::ln::msgs::ChannelReady { inner: ObjOps::heap_alloc(msg_nonref), is_owned: true },
3643                                 }
3644                         },
3645                         nativeMessageSendEvent::SendAnnouncementSignatures {ref node_id, ref msg, } => {
3646                                 let mut node_id_nonref = Clone::clone(node_id);
3647                                 let mut msg_nonref = Clone::clone(msg);
3648                                 MessageSendEvent::SendAnnouncementSignatures {
3649                                         node_id: crate::c_types::PublicKey::from_rust(&node_id_nonref),
3650                                         msg: crate::lightning::ln::msgs::AnnouncementSignatures { inner: ObjOps::heap_alloc(msg_nonref), is_owned: true },
3651                                 }
3652                         },
3653                         nativeMessageSendEvent::UpdateHTLCs {ref node_id, ref updates, } => {
3654                                 let mut node_id_nonref = Clone::clone(node_id);
3655                                 let mut updates_nonref = Clone::clone(updates);
3656                                 MessageSendEvent::UpdateHTLCs {
3657                                         node_id: crate::c_types::PublicKey::from_rust(&node_id_nonref),
3658                                         updates: crate::lightning::ln::msgs::CommitmentUpdate { inner: ObjOps::heap_alloc(updates_nonref), is_owned: true },
3659                                 }
3660                         },
3661                         nativeMessageSendEvent::SendRevokeAndACK {ref node_id, ref msg, } => {
3662                                 let mut node_id_nonref = Clone::clone(node_id);
3663                                 let mut msg_nonref = Clone::clone(msg);
3664                                 MessageSendEvent::SendRevokeAndACK {
3665                                         node_id: crate::c_types::PublicKey::from_rust(&node_id_nonref),
3666                                         msg: crate::lightning::ln::msgs::RevokeAndACK { inner: ObjOps::heap_alloc(msg_nonref), is_owned: true },
3667                                 }
3668                         },
3669                         nativeMessageSendEvent::SendClosingSigned {ref node_id, ref msg, } => {
3670                                 let mut node_id_nonref = Clone::clone(node_id);
3671                                 let mut msg_nonref = Clone::clone(msg);
3672                                 MessageSendEvent::SendClosingSigned {
3673                                         node_id: crate::c_types::PublicKey::from_rust(&node_id_nonref),
3674                                         msg: crate::lightning::ln::msgs::ClosingSigned { inner: ObjOps::heap_alloc(msg_nonref), is_owned: true },
3675                                 }
3676                         },
3677                         nativeMessageSendEvent::SendShutdown {ref node_id, ref msg, } => {
3678                                 let mut node_id_nonref = Clone::clone(node_id);
3679                                 let mut msg_nonref = Clone::clone(msg);
3680                                 MessageSendEvent::SendShutdown {
3681                                         node_id: crate::c_types::PublicKey::from_rust(&node_id_nonref),
3682                                         msg: crate::lightning::ln::msgs::Shutdown { inner: ObjOps::heap_alloc(msg_nonref), is_owned: true },
3683                                 }
3684                         },
3685                         nativeMessageSendEvent::SendChannelReestablish {ref node_id, ref msg, } => {
3686                                 let mut node_id_nonref = Clone::clone(node_id);
3687                                 let mut msg_nonref = Clone::clone(msg);
3688                                 MessageSendEvent::SendChannelReestablish {
3689                                         node_id: crate::c_types::PublicKey::from_rust(&node_id_nonref),
3690                                         msg: crate::lightning::ln::msgs::ChannelReestablish { inner: ObjOps::heap_alloc(msg_nonref), is_owned: true },
3691                                 }
3692                         },
3693                         nativeMessageSendEvent::SendChannelAnnouncement {ref node_id, ref msg, ref update_msg, } => {
3694                                 let mut node_id_nonref = Clone::clone(node_id);
3695                                 let mut msg_nonref = Clone::clone(msg);
3696                                 let mut update_msg_nonref = Clone::clone(update_msg);
3697                                 MessageSendEvent::SendChannelAnnouncement {
3698                                         node_id: crate::c_types::PublicKey::from_rust(&node_id_nonref),
3699                                         msg: crate::lightning::ln::msgs::ChannelAnnouncement { inner: ObjOps::heap_alloc(msg_nonref), is_owned: true },
3700                                         update_msg: crate::lightning::ln::msgs::ChannelUpdate { inner: ObjOps::heap_alloc(update_msg_nonref), is_owned: true },
3701                                 }
3702                         },
3703                         nativeMessageSendEvent::BroadcastChannelAnnouncement {ref msg, ref update_msg, } => {
3704                                 let mut msg_nonref = Clone::clone(msg);
3705                                 let mut update_msg_nonref = Clone::clone(update_msg);
3706                                 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 };
3707                                 MessageSendEvent::BroadcastChannelAnnouncement {
3708                                         msg: crate::lightning::ln::msgs::ChannelAnnouncement { inner: ObjOps::heap_alloc(msg_nonref), is_owned: true },
3709                                         update_msg: local_update_msg_nonref,
3710                                 }
3711                         },
3712                         nativeMessageSendEvent::BroadcastChannelUpdate {ref msg, } => {
3713                                 let mut msg_nonref = Clone::clone(msg);
3714                                 MessageSendEvent::BroadcastChannelUpdate {
3715                                         msg: crate::lightning::ln::msgs::ChannelUpdate { inner: ObjOps::heap_alloc(msg_nonref), is_owned: true },
3716                                 }
3717                         },
3718                         nativeMessageSendEvent::BroadcastNodeAnnouncement {ref msg, } => {
3719                                 let mut msg_nonref = Clone::clone(msg);
3720                                 MessageSendEvent::BroadcastNodeAnnouncement {
3721                                         msg: crate::lightning::ln::msgs::NodeAnnouncement { inner: ObjOps::heap_alloc(msg_nonref), is_owned: true },
3722                                 }
3723                         },
3724                         nativeMessageSendEvent::SendChannelUpdate {ref node_id, ref msg, } => {
3725                                 let mut node_id_nonref = Clone::clone(node_id);
3726                                 let mut msg_nonref = Clone::clone(msg);
3727                                 MessageSendEvent::SendChannelUpdate {
3728                                         node_id: crate::c_types::PublicKey::from_rust(&node_id_nonref),
3729                                         msg: crate::lightning::ln::msgs::ChannelUpdate { inner: ObjOps::heap_alloc(msg_nonref), is_owned: true },
3730                                 }
3731                         },
3732                         nativeMessageSendEvent::HandleError {ref node_id, ref action, } => {
3733                                 let mut node_id_nonref = Clone::clone(node_id);
3734                                 let mut action_nonref = Clone::clone(action);
3735                                 MessageSendEvent::HandleError {
3736                                         node_id: crate::c_types::PublicKey::from_rust(&node_id_nonref),
3737                                         action: crate::lightning::ln::msgs::ErrorAction::native_into(action_nonref),
3738                                 }
3739                         },
3740                         nativeMessageSendEvent::SendChannelRangeQuery {ref node_id, ref msg, } => {
3741                                 let mut node_id_nonref = Clone::clone(node_id);
3742                                 let mut msg_nonref = Clone::clone(msg);
3743                                 MessageSendEvent::SendChannelRangeQuery {
3744                                         node_id: crate::c_types::PublicKey::from_rust(&node_id_nonref),
3745                                         msg: crate::lightning::ln::msgs::QueryChannelRange { inner: ObjOps::heap_alloc(msg_nonref), is_owned: true },
3746                                 }
3747                         },
3748                         nativeMessageSendEvent::SendShortIdsQuery {ref node_id, ref msg, } => {
3749                                 let mut node_id_nonref = Clone::clone(node_id);
3750                                 let mut msg_nonref = Clone::clone(msg);
3751                                 MessageSendEvent::SendShortIdsQuery {
3752                                         node_id: crate::c_types::PublicKey::from_rust(&node_id_nonref),
3753                                         msg: crate::lightning::ln::msgs::QueryShortChannelIds { inner: ObjOps::heap_alloc(msg_nonref), is_owned: true },
3754                                 }
3755                         },
3756                         nativeMessageSendEvent::SendReplyChannelRange {ref node_id, ref msg, } => {
3757                                 let mut node_id_nonref = Clone::clone(node_id);
3758                                 let mut msg_nonref = Clone::clone(msg);
3759                                 MessageSendEvent::SendReplyChannelRange {
3760                                         node_id: crate::c_types::PublicKey::from_rust(&node_id_nonref),
3761                                         msg: crate::lightning::ln::msgs::ReplyChannelRange { inner: ObjOps::heap_alloc(msg_nonref), is_owned: true },
3762                                 }
3763                         },
3764                         nativeMessageSendEvent::SendGossipTimestampFilter {ref node_id, ref msg, } => {
3765                                 let mut node_id_nonref = Clone::clone(node_id);
3766                                 let mut msg_nonref = Clone::clone(msg);
3767                                 MessageSendEvent::SendGossipTimestampFilter {
3768                                         node_id: crate::c_types::PublicKey::from_rust(&node_id_nonref),
3769                                         msg: crate::lightning::ln::msgs::GossipTimestampFilter { inner: ObjOps::heap_alloc(msg_nonref), is_owned: true },
3770                                 }
3771                         },
3772                 }
3773         }
3774         #[allow(unused)]
3775         pub(crate) fn native_into(native: nativeMessageSendEvent) -> Self {
3776                 match native {
3777                         nativeMessageSendEvent::SendAcceptChannel {mut node_id, mut msg, } => {
3778                                 MessageSendEvent::SendAcceptChannel {
3779                                         node_id: crate::c_types::PublicKey::from_rust(&node_id),
3780                                         msg: crate::lightning::ln::msgs::AcceptChannel { inner: ObjOps::heap_alloc(msg), is_owned: true },
3781                                 }
3782                         },
3783                         nativeMessageSendEvent::SendAcceptChannelV2 {mut node_id, mut msg, } => {
3784                                 MessageSendEvent::SendAcceptChannelV2 {
3785                                         node_id: crate::c_types::PublicKey::from_rust(&node_id),
3786                                         msg: crate::lightning::ln::msgs::AcceptChannelV2 { inner: ObjOps::heap_alloc(msg), is_owned: true },
3787                                 }
3788                         },
3789                         nativeMessageSendEvent::SendOpenChannel {mut node_id, mut msg, } => {
3790                                 MessageSendEvent::SendOpenChannel {
3791                                         node_id: crate::c_types::PublicKey::from_rust(&node_id),
3792                                         msg: crate::lightning::ln::msgs::OpenChannel { inner: ObjOps::heap_alloc(msg), is_owned: true },
3793                                 }
3794                         },
3795                         nativeMessageSendEvent::SendOpenChannelV2 {mut node_id, mut msg, } => {
3796                                 MessageSendEvent::SendOpenChannelV2 {
3797                                         node_id: crate::c_types::PublicKey::from_rust(&node_id),
3798                                         msg: crate::lightning::ln::msgs::OpenChannelV2 { inner: ObjOps::heap_alloc(msg), is_owned: true },
3799                                 }
3800                         },
3801                         nativeMessageSendEvent::SendFundingCreated {mut node_id, mut msg, } => {
3802                                 MessageSendEvent::SendFundingCreated {
3803                                         node_id: crate::c_types::PublicKey::from_rust(&node_id),
3804                                         msg: crate::lightning::ln::msgs::FundingCreated { inner: ObjOps::heap_alloc(msg), is_owned: true },
3805                                 }
3806                         },
3807                         nativeMessageSendEvent::SendFundingSigned {mut node_id, mut msg, } => {
3808                                 MessageSendEvent::SendFundingSigned {
3809                                         node_id: crate::c_types::PublicKey::from_rust(&node_id),
3810                                         msg: crate::lightning::ln::msgs::FundingSigned { inner: ObjOps::heap_alloc(msg), is_owned: true },
3811                                 }
3812                         },
3813                         nativeMessageSendEvent::SendTxAddInput {mut node_id, mut msg, } => {
3814                                 MessageSendEvent::SendTxAddInput {
3815                                         node_id: crate::c_types::PublicKey::from_rust(&node_id),
3816                                         msg: crate::lightning::ln::msgs::TxAddInput { inner: ObjOps::heap_alloc(msg), is_owned: true },
3817                                 }
3818                         },
3819                         nativeMessageSendEvent::SendTxAddOutput {mut node_id, mut msg, } => {
3820                                 MessageSendEvent::SendTxAddOutput {
3821                                         node_id: crate::c_types::PublicKey::from_rust(&node_id),
3822                                         msg: crate::lightning::ln::msgs::TxAddOutput { inner: ObjOps::heap_alloc(msg), is_owned: true },
3823                                 }
3824                         },
3825                         nativeMessageSendEvent::SendTxRemoveInput {mut node_id, mut msg, } => {
3826                                 MessageSendEvent::SendTxRemoveInput {
3827                                         node_id: crate::c_types::PublicKey::from_rust(&node_id),
3828                                         msg: crate::lightning::ln::msgs::TxRemoveInput { inner: ObjOps::heap_alloc(msg), is_owned: true },
3829                                 }
3830                         },
3831                         nativeMessageSendEvent::SendTxRemoveOutput {mut node_id, mut msg, } => {
3832                                 MessageSendEvent::SendTxRemoveOutput {
3833                                         node_id: crate::c_types::PublicKey::from_rust(&node_id),
3834                                         msg: crate::lightning::ln::msgs::TxRemoveOutput { inner: ObjOps::heap_alloc(msg), is_owned: true },
3835                                 }
3836                         },
3837                         nativeMessageSendEvent::SendTxComplete {mut node_id, mut msg, } => {
3838                                 MessageSendEvent::SendTxComplete {
3839                                         node_id: crate::c_types::PublicKey::from_rust(&node_id),
3840                                         msg: crate::lightning::ln::msgs::TxComplete { inner: ObjOps::heap_alloc(msg), is_owned: true },
3841                                 }
3842                         },
3843                         nativeMessageSendEvent::SendTxSignatures {mut node_id, mut msg, } => {
3844                                 MessageSendEvent::SendTxSignatures {
3845                                         node_id: crate::c_types::PublicKey::from_rust(&node_id),
3846                                         msg: crate::lightning::ln::msgs::TxSignatures { inner: ObjOps::heap_alloc(msg), is_owned: true },
3847                                 }
3848                         },
3849                         nativeMessageSendEvent::SendTxInitRbf {mut node_id, mut msg, } => {
3850                                 MessageSendEvent::SendTxInitRbf {
3851                                         node_id: crate::c_types::PublicKey::from_rust(&node_id),
3852                                         msg: crate::lightning::ln::msgs::TxInitRbf { inner: ObjOps::heap_alloc(msg), is_owned: true },
3853                                 }
3854                         },
3855                         nativeMessageSendEvent::SendTxAckRbf {mut node_id, mut msg, } => {
3856                                 MessageSendEvent::SendTxAckRbf {
3857                                         node_id: crate::c_types::PublicKey::from_rust(&node_id),
3858                                         msg: crate::lightning::ln::msgs::TxAckRbf { inner: ObjOps::heap_alloc(msg), is_owned: true },
3859                                 }
3860                         },
3861                         nativeMessageSendEvent::SendTxAbort {mut node_id, mut msg, } => {
3862                                 MessageSendEvent::SendTxAbort {
3863                                         node_id: crate::c_types::PublicKey::from_rust(&node_id),
3864                                         msg: crate::lightning::ln::msgs::TxAbort { inner: ObjOps::heap_alloc(msg), is_owned: true },
3865                                 }
3866                         },
3867                         nativeMessageSendEvent::SendChannelReady {mut node_id, mut msg, } => {
3868                                 MessageSendEvent::SendChannelReady {
3869                                         node_id: crate::c_types::PublicKey::from_rust(&node_id),
3870                                         msg: crate::lightning::ln::msgs::ChannelReady { inner: ObjOps::heap_alloc(msg), is_owned: true },
3871                                 }
3872                         },
3873                         nativeMessageSendEvent::SendAnnouncementSignatures {mut node_id, mut msg, } => {
3874                                 MessageSendEvent::SendAnnouncementSignatures {
3875                                         node_id: crate::c_types::PublicKey::from_rust(&node_id),
3876                                         msg: crate::lightning::ln::msgs::AnnouncementSignatures { inner: ObjOps::heap_alloc(msg), is_owned: true },
3877                                 }
3878                         },
3879                         nativeMessageSendEvent::UpdateHTLCs {mut node_id, mut updates, } => {
3880                                 MessageSendEvent::UpdateHTLCs {
3881                                         node_id: crate::c_types::PublicKey::from_rust(&node_id),
3882                                         updates: crate::lightning::ln::msgs::CommitmentUpdate { inner: ObjOps::heap_alloc(updates), is_owned: true },
3883                                 }
3884                         },
3885                         nativeMessageSendEvent::SendRevokeAndACK {mut node_id, mut msg, } => {
3886                                 MessageSendEvent::SendRevokeAndACK {
3887                                         node_id: crate::c_types::PublicKey::from_rust(&node_id),
3888                                         msg: crate::lightning::ln::msgs::RevokeAndACK { inner: ObjOps::heap_alloc(msg), is_owned: true },
3889                                 }
3890                         },
3891                         nativeMessageSendEvent::SendClosingSigned {mut node_id, mut msg, } => {
3892                                 MessageSendEvent::SendClosingSigned {
3893                                         node_id: crate::c_types::PublicKey::from_rust(&node_id),
3894                                         msg: crate::lightning::ln::msgs::ClosingSigned { inner: ObjOps::heap_alloc(msg), is_owned: true },
3895                                 }
3896                         },
3897                         nativeMessageSendEvent::SendShutdown {mut node_id, mut msg, } => {
3898                                 MessageSendEvent::SendShutdown {
3899                                         node_id: crate::c_types::PublicKey::from_rust(&node_id),
3900                                         msg: crate::lightning::ln::msgs::Shutdown { inner: ObjOps::heap_alloc(msg), is_owned: true },
3901                                 }
3902                         },
3903                         nativeMessageSendEvent::SendChannelReestablish {mut node_id, mut msg, } => {
3904                                 MessageSendEvent::SendChannelReestablish {
3905                                         node_id: crate::c_types::PublicKey::from_rust(&node_id),
3906                                         msg: crate::lightning::ln::msgs::ChannelReestablish { inner: ObjOps::heap_alloc(msg), is_owned: true },
3907                                 }
3908                         },
3909                         nativeMessageSendEvent::SendChannelAnnouncement {mut node_id, mut msg, mut update_msg, } => {
3910                                 MessageSendEvent::SendChannelAnnouncement {
3911                                         node_id: crate::c_types::PublicKey::from_rust(&node_id),
3912                                         msg: crate::lightning::ln::msgs::ChannelAnnouncement { inner: ObjOps::heap_alloc(msg), is_owned: true },
3913                                         update_msg: crate::lightning::ln::msgs::ChannelUpdate { inner: ObjOps::heap_alloc(update_msg), is_owned: true },
3914                                 }
3915                         },
3916                         nativeMessageSendEvent::BroadcastChannelAnnouncement {mut msg, mut update_msg, } => {
3917                                 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 };
3918                                 MessageSendEvent::BroadcastChannelAnnouncement {
3919                                         msg: crate::lightning::ln::msgs::ChannelAnnouncement { inner: ObjOps::heap_alloc(msg), is_owned: true },
3920                                         update_msg: local_update_msg,
3921                                 }
3922                         },
3923                         nativeMessageSendEvent::BroadcastChannelUpdate {mut msg, } => {
3924                                 MessageSendEvent::BroadcastChannelUpdate {
3925                                         msg: crate::lightning::ln::msgs::ChannelUpdate { inner: ObjOps::heap_alloc(msg), is_owned: true },
3926                                 }
3927                         },
3928                         nativeMessageSendEvent::BroadcastNodeAnnouncement {mut msg, } => {
3929                                 MessageSendEvent::BroadcastNodeAnnouncement {
3930                                         msg: crate::lightning::ln::msgs::NodeAnnouncement { inner: ObjOps::heap_alloc(msg), is_owned: true },
3931                                 }
3932                         },
3933                         nativeMessageSendEvent::SendChannelUpdate {mut node_id, mut msg, } => {
3934                                 MessageSendEvent::SendChannelUpdate {
3935                                         node_id: crate::c_types::PublicKey::from_rust(&node_id),
3936                                         msg: crate::lightning::ln::msgs::ChannelUpdate { inner: ObjOps::heap_alloc(msg), is_owned: true },
3937                                 }
3938                         },
3939                         nativeMessageSendEvent::HandleError {mut node_id, mut action, } => {
3940                                 MessageSendEvent::HandleError {
3941                                         node_id: crate::c_types::PublicKey::from_rust(&node_id),
3942                                         action: crate::lightning::ln::msgs::ErrorAction::native_into(action),
3943                                 }
3944                         },
3945                         nativeMessageSendEvent::SendChannelRangeQuery {mut node_id, mut msg, } => {
3946                                 MessageSendEvent::SendChannelRangeQuery {
3947                                         node_id: crate::c_types::PublicKey::from_rust(&node_id),
3948                                         msg: crate::lightning::ln::msgs::QueryChannelRange { inner: ObjOps::heap_alloc(msg), is_owned: true },
3949                                 }
3950                         },
3951                         nativeMessageSendEvent::SendShortIdsQuery {mut node_id, mut msg, } => {
3952                                 MessageSendEvent::SendShortIdsQuery {
3953                                         node_id: crate::c_types::PublicKey::from_rust(&node_id),
3954                                         msg: crate::lightning::ln::msgs::QueryShortChannelIds { inner: ObjOps::heap_alloc(msg), is_owned: true },
3955                                 }
3956                         },
3957                         nativeMessageSendEvent::SendReplyChannelRange {mut node_id, mut msg, } => {
3958                                 MessageSendEvent::SendReplyChannelRange {
3959                                         node_id: crate::c_types::PublicKey::from_rust(&node_id),
3960                                         msg: crate::lightning::ln::msgs::ReplyChannelRange { inner: ObjOps::heap_alloc(msg), is_owned: true },
3961                                 }
3962                         },
3963                         nativeMessageSendEvent::SendGossipTimestampFilter {mut node_id, mut msg, } => {
3964                                 MessageSendEvent::SendGossipTimestampFilter {
3965                                         node_id: crate::c_types::PublicKey::from_rust(&node_id),
3966                                         msg: crate::lightning::ln::msgs::GossipTimestampFilter { inner: ObjOps::heap_alloc(msg), is_owned: true },
3967                                 }
3968                         },
3969                 }
3970         }
3971 }
3972 /// Frees any resources used by the MessageSendEvent
3973 #[no_mangle]
3974 pub extern "C" fn MessageSendEvent_free(this_ptr: MessageSendEvent) { }
3975 /// Creates a copy of the MessageSendEvent
3976 #[no_mangle]
3977 pub extern "C" fn MessageSendEvent_clone(orig: &MessageSendEvent) -> MessageSendEvent {
3978         orig.clone()
3979 }
3980 #[no_mangle]
3981 /// Utility method to constructs a new SendAcceptChannel-variant MessageSendEvent
3982 pub extern "C" fn MessageSendEvent_send_accept_channel(node_id: crate::c_types::PublicKey, msg: crate::lightning::ln::msgs::AcceptChannel) -> MessageSendEvent {
3983         MessageSendEvent::SendAcceptChannel {
3984                 node_id,
3985                 msg,
3986         }
3987 }
3988 #[no_mangle]
3989 /// Utility method to constructs a new SendAcceptChannelV2-variant MessageSendEvent
3990 pub extern "C" fn MessageSendEvent_send_accept_channel_v2(node_id: crate::c_types::PublicKey, msg: crate::lightning::ln::msgs::AcceptChannelV2) -> MessageSendEvent {
3991         MessageSendEvent::SendAcceptChannelV2 {
3992                 node_id,
3993                 msg,
3994         }
3995 }
3996 #[no_mangle]
3997 /// Utility method to constructs a new SendOpenChannel-variant MessageSendEvent
3998 pub extern "C" fn MessageSendEvent_send_open_channel(node_id: crate::c_types::PublicKey, msg: crate::lightning::ln::msgs::OpenChannel) -> MessageSendEvent {
3999         MessageSendEvent::SendOpenChannel {
4000                 node_id,
4001                 msg,
4002         }
4003 }
4004 #[no_mangle]
4005 /// Utility method to constructs a new SendOpenChannelV2-variant MessageSendEvent
4006 pub extern "C" fn MessageSendEvent_send_open_channel_v2(node_id: crate::c_types::PublicKey, msg: crate::lightning::ln::msgs::OpenChannelV2) -> MessageSendEvent {
4007         MessageSendEvent::SendOpenChannelV2 {
4008                 node_id,
4009                 msg,
4010         }
4011 }
4012 #[no_mangle]
4013 /// Utility method to constructs a new SendFundingCreated-variant MessageSendEvent
4014 pub extern "C" fn MessageSendEvent_send_funding_created(node_id: crate::c_types::PublicKey, msg: crate::lightning::ln::msgs::FundingCreated) -> MessageSendEvent {
4015         MessageSendEvent::SendFundingCreated {
4016                 node_id,
4017                 msg,
4018         }
4019 }
4020 #[no_mangle]
4021 /// Utility method to constructs a new SendFundingSigned-variant MessageSendEvent
4022 pub extern "C" fn MessageSendEvent_send_funding_signed(node_id: crate::c_types::PublicKey, msg: crate::lightning::ln::msgs::FundingSigned) -> MessageSendEvent {
4023         MessageSendEvent::SendFundingSigned {
4024                 node_id,
4025                 msg,
4026         }
4027 }
4028 #[no_mangle]
4029 /// Utility method to constructs a new SendTxAddInput-variant MessageSendEvent
4030 pub extern "C" fn MessageSendEvent_send_tx_add_input(node_id: crate::c_types::PublicKey, msg: crate::lightning::ln::msgs::TxAddInput) -> MessageSendEvent {
4031         MessageSendEvent::SendTxAddInput {
4032                 node_id,
4033                 msg,
4034         }
4035 }
4036 #[no_mangle]
4037 /// Utility method to constructs a new SendTxAddOutput-variant MessageSendEvent
4038 pub extern "C" fn MessageSendEvent_send_tx_add_output(node_id: crate::c_types::PublicKey, msg: crate::lightning::ln::msgs::TxAddOutput) -> MessageSendEvent {
4039         MessageSendEvent::SendTxAddOutput {
4040                 node_id,
4041                 msg,
4042         }
4043 }
4044 #[no_mangle]
4045 /// Utility method to constructs a new SendTxRemoveInput-variant MessageSendEvent
4046 pub extern "C" fn MessageSendEvent_send_tx_remove_input(node_id: crate::c_types::PublicKey, msg: crate::lightning::ln::msgs::TxRemoveInput) -> MessageSendEvent {
4047         MessageSendEvent::SendTxRemoveInput {
4048                 node_id,
4049                 msg,
4050         }
4051 }
4052 #[no_mangle]
4053 /// Utility method to constructs a new SendTxRemoveOutput-variant MessageSendEvent
4054 pub extern "C" fn MessageSendEvent_send_tx_remove_output(node_id: crate::c_types::PublicKey, msg: crate::lightning::ln::msgs::TxRemoveOutput) -> MessageSendEvent {
4055         MessageSendEvent::SendTxRemoveOutput {
4056                 node_id,
4057                 msg,
4058         }
4059 }
4060 #[no_mangle]
4061 /// Utility method to constructs a new SendTxComplete-variant MessageSendEvent
4062 pub extern "C" fn MessageSendEvent_send_tx_complete(node_id: crate::c_types::PublicKey, msg: crate::lightning::ln::msgs::TxComplete) -> MessageSendEvent {
4063         MessageSendEvent::SendTxComplete {
4064                 node_id,
4065                 msg,
4066         }
4067 }
4068 #[no_mangle]
4069 /// Utility method to constructs a new SendTxSignatures-variant MessageSendEvent
4070 pub extern "C" fn MessageSendEvent_send_tx_signatures(node_id: crate::c_types::PublicKey, msg: crate::lightning::ln::msgs::TxSignatures) -> MessageSendEvent {
4071         MessageSendEvent::SendTxSignatures {
4072                 node_id,
4073                 msg,
4074         }
4075 }
4076 #[no_mangle]
4077 /// Utility method to constructs a new SendTxInitRbf-variant MessageSendEvent
4078 pub extern "C" fn MessageSendEvent_send_tx_init_rbf(node_id: crate::c_types::PublicKey, msg: crate::lightning::ln::msgs::TxInitRbf) -> MessageSendEvent {
4079         MessageSendEvent::SendTxInitRbf {
4080                 node_id,
4081                 msg,
4082         }
4083 }
4084 #[no_mangle]
4085 /// Utility method to constructs a new SendTxAckRbf-variant MessageSendEvent
4086 pub extern "C" fn MessageSendEvent_send_tx_ack_rbf(node_id: crate::c_types::PublicKey, msg: crate::lightning::ln::msgs::TxAckRbf) -> MessageSendEvent {
4087         MessageSendEvent::SendTxAckRbf {
4088                 node_id,
4089                 msg,
4090         }
4091 }
4092 #[no_mangle]
4093 /// Utility method to constructs a new SendTxAbort-variant MessageSendEvent
4094 pub extern "C" fn MessageSendEvent_send_tx_abort(node_id: crate::c_types::PublicKey, msg: crate::lightning::ln::msgs::TxAbort) -> MessageSendEvent {
4095         MessageSendEvent::SendTxAbort {
4096                 node_id,
4097                 msg,
4098         }
4099 }
4100 #[no_mangle]
4101 /// Utility method to constructs a new SendChannelReady-variant MessageSendEvent
4102 pub extern "C" fn MessageSendEvent_send_channel_ready(node_id: crate::c_types::PublicKey, msg: crate::lightning::ln::msgs::ChannelReady) -> MessageSendEvent {
4103         MessageSendEvent::SendChannelReady {
4104                 node_id,
4105                 msg,
4106         }
4107 }
4108 #[no_mangle]
4109 /// Utility method to constructs a new SendAnnouncementSignatures-variant MessageSendEvent
4110 pub extern "C" fn MessageSendEvent_send_announcement_signatures(node_id: crate::c_types::PublicKey, msg: crate::lightning::ln::msgs::AnnouncementSignatures) -> MessageSendEvent {
4111         MessageSendEvent::SendAnnouncementSignatures {
4112                 node_id,
4113                 msg,
4114         }
4115 }
4116 #[no_mangle]
4117 /// Utility method to constructs a new UpdateHTLCs-variant MessageSendEvent
4118 pub extern "C" fn MessageSendEvent_update_htlcs(node_id: crate::c_types::PublicKey, updates: crate::lightning::ln::msgs::CommitmentUpdate) -> MessageSendEvent {
4119         MessageSendEvent::UpdateHTLCs {
4120                 node_id,
4121                 updates,
4122         }
4123 }
4124 #[no_mangle]
4125 /// Utility method to constructs a new SendRevokeAndACK-variant MessageSendEvent
4126 pub extern "C" fn MessageSendEvent_send_revoke_and_ack(node_id: crate::c_types::PublicKey, msg: crate::lightning::ln::msgs::RevokeAndACK) -> MessageSendEvent {
4127         MessageSendEvent::SendRevokeAndACK {
4128                 node_id,
4129                 msg,
4130         }
4131 }
4132 #[no_mangle]
4133 /// Utility method to constructs a new SendClosingSigned-variant MessageSendEvent
4134 pub extern "C" fn MessageSendEvent_send_closing_signed(node_id: crate::c_types::PublicKey, msg: crate::lightning::ln::msgs::ClosingSigned) -> MessageSendEvent {
4135         MessageSendEvent::SendClosingSigned {
4136                 node_id,
4137                 msg,
4138         }
4139 }
4140 #[no_mangle]
4141 /// Utility method to constructs a new SendShutdown-variant MessageSendEvent
4142 pub extern "C" fn MessageSendEvent_send_shutdown(node_id: crate::c_types::PublicKey, msg: crate::lightning::ln::msgs::Shutdown) -> MessageSendEvent {
4143         MessageSendEvent::SendShutdown {
4144                 node_id,
4145                 msg,
4146         }
4147 }
4148 #[no_mangle]
4149 /// Utility method to constructs a new SendChannelReestablish-variant MessageSendEvent
4150 pub extern "C" fn MessageSendEvent_send_channel_reestablish(node_id: crate::c_types::PublicKey, msg: crate::lightning::ln::msgs::ChannelReestablish) -> MessageSendEvent {
4151         MessageSendEvent::SendChannelReestablish {
4152                 node_id,
4153                 msg,
4154         }
4155 }
4156 #[no_mangle]
4157 /// Utility method to constructs a new SendChannelAnnouncement-variant MessageSendEvent
4158 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 {
4159         MessageSendEvent::SendChannelAnnouncement {
4160                 node_id,
4161                 msg,
4162                 update_msg,
4163         }
4164 }
4165 #[no_mangle]
4166 /// Utility method to constructs a new BroadcastChannelAnnouncement-variant MessageSendEvent
4167 pub extern "C" fn MessageSendEvent_broadcast_channel_announcement(msg: crate::lightning::ln::msgs::ChannelAnnouncement, update_msg: crate::lightning::ln::msgs::ChannelUpdate) -> MessageSendEvent {
4168         MessageSendEvent::BroadcastChannelAnnouncement {
4169                 msg,
4170                 update_msg,
4171         }
4172 }
4173 #[no_mangle]
4174 /// Utility method to constructs a new BroadcastChannelUpdate-variant MessageSendEvent
4175 pub extern "C" fn MessageSendEvent_broadcast_channel_update(msg: crate::lightning::ln::msgs::ChannelUpdate) -> MessageSendEvent {
4176         MessageSendEvent::BroadcastChannelUpdate {
4177                 msg,
4178         }
4179 }
4180 #[no_mangle]
4181 /// Utility method to constructs a new BroadcastNodeAnnouncement-variant MessageSendEvent
4182 pub extern "C" fn MessageSendEvent_broadcast_node_announcement(msg: crate::lightning::ln::msgs::NodeAnnouncement) -> MessageSendEvent {
4183         MessageSendEvent::BroadcastNodeAnnouncement {
4184                 msg,
4185         }
4186 }
4187 #[no_mangle]
4188 /// Utility method to constructs a new SendChannelUpdate-variant MessageSendEvent
4189 pub extern "C" fn MessageSendEvent_send_channel_update(node_id: crate::c_types::PublicKey, msg: crate::lightning::ln::msgs::ChannelUpdate) -> MessageSendEvent {
4190         MessageSendEvent::SendChannelUpdate {
4191                 node_id,
4192                 msg,
4193         }
4194 }
4195 #[no_mangle]
4196 /// Utility method to constructs a new HandleError-variant MessageSendEvent
4197 pub extern "C" fn MessageSendEvent_handle_error(node_id: crate::c_types::PublicKey, action: crate::lightning::ln::msgs::ErrorAction) -> MessageSendEvent {
4198         MessageSendEvent::HandleError {
4199                 node_id,
4200                 action,
4201         }
4202 }
4203 #[no_mangle]
4204 /// Utility method to constructs a new SendChannelRangeQuery-variant MessageSendEvent
4205 pub extern "C" fn MessageSendEvent_send_channel_range_query(node_id: crate::c_types::PublicKey, msg: crate::lightning::ln::msgs::QueryChannelRange) -> MessageSendEvent {
4206         MessageSendEvent::SendChannelRangeQuery {
4207                 node_id,
4208                 msg,
4209         }
4210 }
4211 #[no_mangle]
4212 /// Utility method to constructs a new SendShortIdsQuery-variant MessageSendEvent
4213 pub extern "C" fn MessageSendEvent_send_short_ids_query(node_id: crate::c_types::PublicKey, msg: crate::lightning::ln::msgs::QueryShortChannelIds) -> MessageSendEvent {
4214         MessageSendEvent::SendShortIdsQuery {
4215                 node_id,
4216                 msg,
4217         }
4218 }
4219 #[no_mangle]
4220 /// Utility method to constructs a new SendReplyChannelRange-variant MessageSendEvent
4221 pub extern "C" fn MessageSendEvent_send_reply_channel_range(node_id: crate::c_types::PublicKey, msg: crate::lightning::ln::msgs::ReplyChannelRange) -> MessageSendEvent {
4222         MessageSendEvent::SendReplyChannelRange {
4223                 node_id,
4224                 msg,
4225         }
4226 }
4227 #[no_mangle]
4228 /// Utility method to constructs a new SendGossipTimestampFilter-variant MessageSendEvent
4229 pub extern "C" fn MessageSendEvent_send_gossip_timestamp_filter(node_id: crate::c_types::PublicKey, msg: crate::lightning::ln::msgs::GossipTimestampFilter) -> MessageSendEvent {
4230         MessageSendEvent::SendGossipTimestampFilter {
4231                 node_id,
4232                 msg,
4233         }
4234 }
4235 /// A trait indicating an object may generate message send events
4236 #[repr(C)]
4237 pub struct MessageSendEventsProvider {
4238         /// An opaque pointer which is passed to your function implementations as an argument.
4239         /// This has no meaning in the LDK, and can be NULL or any other value.
4240         pub this_arg: *mut c_void,
4241         /// Gets the list of pending events which were generated by previous actions, clearing the list
4242         /// in the process.
4243         pub get_and_clear_pending_msg_events: extern "C" fn (this_arg: *const c_void) -> crate::c_types::derived::CVec_MessageSendEventZ,
4244         /// Frees any resources associated with this object given its this_arg pointer.
4245         /// Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed.
4246         pub free: Option<extern "C" fn(this_arg: *mut c_void)>,
4247 }
4248 unsafe impl Send for MessageSendEventsProvider {}
4249 unsafe impl Sync for MessageSendEventsProvider {}
4250 pub(crate) fn MessageSendEventsProvider_clone_fields(orig: &MessageSendEventsProvider) -> MessageSendEventsProvider {
4251         MessageSendEventsProvider {
4252                 this_arg: orig.this_arg,
4253                 get_and_clear_pending_msg_events: Clone::clone(&orig.get_and_clear_pending_msg_events),
4254                 free: Clone::clone(&orig.free),
4255         }
4256 }
4257
4258 use lightning::events::MessageSendEventsProvider as rustMessageSendEventsProvider;
4259 impl rustMessageSendEventsProvider for MessageSendEventsProvider {
4260         fn get_and_clear_pending_msg_events(&self) -> Vec<lightning::events::MessageSendEvent> {
4261                 let mut ret = (self.get_and_clear_pending_msg_events)(self.this_arg);
4262                 let mut local_ret = Vec::new(); for mut item in ret.into_rust().drain(..) { local_ret.push( { item.into_native() }); };
4263                 local_ret
4264         }
4265 }
4266
4267 // We're essentially a pointer already, or at least a set of pointers, so allow us to be used
4268 // directly as a Deref trait in higher-level structs:
4269 impl core::ops::Deref for MessageSendEventsProvider {
4270         type Target = Self;
4271         fn deref(&self) -> &Self {
4272                 self
4273         }
4274 }
4275 impl core::ops::DerefMut for MessageSendEventsProvider {
4276         fn deref_mut(&mut self) -> &mut Self {
4277                 self
4278         }
4279 }
4280 /// Calls the free function if one is set
4281 #[no_mangle]
4282 pub extern "C" fn MessageSendEventsProvider_free(this_ptr: MessageSendEventsProvider) { }
4283 impl Drop for MessageSendEventsProvider {
4284         fn drop(&mut self) {
4285                 if let Some(f) = self.free {
4286                         f(self.this_arg);
4287                 }
4288         }
4289 }
4290 /// A trait indicating an object may generate onion messages to send
4291 #[repr(C)]
4292 pub struct OnionMessageProvider {
4293         /// An opaque pointer which is passed to your function implementations as an argument.
4294         /// This has no meaning in the LDK, and can be NULL or any other value.
4295         pub this_arg: *mut c_void,
4296         /// Gets the next pending onion message for the peer with the given node id.
4297         ///
4298         /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
4299         pub next_onion_message_for_peer: extern "C" fn (this_arg: *const c_void, peer_node_id: crate::c_types::PublicKey) -> crate::lightning::ln::msgs::OnionMessage,
4300         /// Frees any resources associated with this object given its this_arg pointer.
4301         /// Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed.
4302         pub free: Option<extern "C" fn(this_arg: *mut c_void)>,
4303 }
4304 unsafe impl Send for OnionMessageProvider {}
4305 unsafe impl Sync for OnionMessageProvider {}
4306 pub(crate) fn OnionMessageProvider_clone_fields(orig: &OnionMessageProvider) -> OnionMessageProvider {
4307         OnionMessageProvider {
4308                 this_arg: orig.this_arg,
4309                 next_onion_message_for_peer: Clone::clone(&orig.next_onion_message_for_peer),
4310                 free: Clone::clone(&orig.free),
4311         }
4312 }
4313
4314 use lightning::events::OnionMessageProvider as rustOnionMessageProvider;
4315 impl rustOnionMessageProvider for OnionMessageProvider {
4316         fn next_onion_message_for_peer(&self, mut peer_node_id: bitcoin::secp256k1::PublicKey) -> Option<lightning::ln::msgs::OnionMessage> {
4317                 let mut ret = (self.next_onion_message_for_peer)(self.this_arg, crate::c_types::PublicKey::from_rust(&peer_node_id));
4318                 let mut local_ret = if ret.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(ret.take_inner()) } }) };
4319                 local_ret
4320         }
4321 }
4322
4323 // We're essentially a pointer already, or at least a set of pointers, so allow us to be used
4324 // directly as a Deref trait in higher-level structs:
4325 impl core::ops::Deref for OnionMessageProvider {
4326         type Target = Self;
4327         fn deref(&self) -> &Self {
4328                 self
4329         }
4330 }
4331 impl core::ops::DerefMut for OnionMessageProvider {
4332         fn deref_mut(&mut self) -> &mut Self {
4333                 self
4334         }
4335 }
4336 /// Calls the free function if one is set
4337 #[no_mangle]
4338 pub extern "C" fn OnionMessageProvider_free(this_ptr: OnionMessageProvider) { }
4339 impl Drop for OnionMessageProvider {
4340         fn drop(&mut self) {
4341                 if let Some(f) = self.free {
4342                         f(self.this_arg);
4343                 }
4344         }
4345 }
4346 /// A trait indicating an object may generate events.
4347 ///
4348 /// Events are processed by passing an [`EventHandler`] to [`process_pending_events`].
4349 ///
4350 /// Implementations of this trait may also feature an async version of event handling, as shown with
4351 /// [`ChannelManager::process_pending_events_async`] and
4352 /// [`ChainMonitor::process_pending_events_async`].
4353 ///
4354 /// # Requirements
4355 ///
4356 /// When using this trait, [`process_pending_events`] will call [`handle_event`] for each pending
4357 /// event since the last invocation.
4358 ///
4359 /// In order to ensure no [`Event`]s are lost, implementors of this trait will persist [`Event`]s
4360 /// and replay any unhandled events on startup. An [`Event`] is considered handled when
4361 /// [`process_pending_events`] returns, thus handlers MUST fully handle [`Event`]s and persist any
4362 /// relevant changes to disk *before* returning.
4363 ///
4364 /// Further, because an application may crash between an [`Event`] being handled and the
4365 /// implementor of this trait being re-serialized, [`Event`] handling must be idempotent - in
4366 /// effect, [`Event`]s may be replayed.
4367 ///
4368 /// Note, handlers may call back into the provider and thus deadlocking must be avoided. Be sure to
4369 /// consult the provider's documentation on the implication of processing events and how a handler
4370 /// may safely use the provider (e.g., see [`ChannelManager::process_pending_events`] and
4371 /// [`ChainMonitor::process_pending_events`]).
4372 ///
4373 /// (C-not implementable) As there is likely no reason for a user to implement this trait on their
4374 /// own type(s).
4375 ///
4376 /// [`process_pending_events`]: Self::process_pending_events
4377 /// [`handle_event`]: EventHandler::handle_event
4378 /// [`ChannelManager::process_pending_events`]: crate::ln::channelmanager::ChannelManager#method.process_pending_events
4379 /// [`ChainMonitor::process_pending_events`]: crate::chain::chainmonitor::ChainMonitor#method.process_pending_events
4380 /// [`ChannelManager::process_pending_events_async`]: crate::ln::channelmanager::ChannelManager::process_pending_events_async
4381 /// [`ChainMonitor::process_pending_events_async`]: crate::chain::chainmonitor::ChainMonitor::process_pending_events_async
4382 #[repr(C)]
4383 pub struct EventsProvider {
4384         /// An opaque pointer which is passed to your function implementations as an argument.
4385         /// This has no meaning in the LDK, and can be NULL or any other value.
4386         pub this_arg: *mut c_void,
4387         /// Processes any events generated since the last call using the given event handler.
4388         ///
4389         /// See the trait-level documentation for requirements.
4390         pub process_pending_events: extern "C" fn (this_arg: *const c_void, handler: crate::lightning::events::EventHandler),
4391         /// Frees any resources associated with this object given its this_arg pointer.
4392         /// Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed.
4393         pub free: Option<extern "C" fn(this_arg: *mut c_void)>,
4394 }
4395 unsafe impl Send for EventsProvider {}
4396 unsafe impl Sync for EventsProvider {}
4397 pub(crate) fn EventsProvider_clone_fields(orig: &EventsProvider) -> EventsProvider {
4398         EventsProvider {
4399                 this_arg: orig.this_arg,
4400                 process_pending_events: Clone::clone(&orig.process_pending_events),
4401                 free: Clone::clone(&orig.free),
4402         }
4403 }
4404
4405 use lightning::events::EventsProvider as rustEventsProvider;
4406 /// Calls the free function if one is set
4407 #[no_mangle]
4408 pub extern "C" fn EventsProvider_free(this_ptr: EventsProvider) { }
4409 impl Drop for EventsProvider {
4410         fn drop(&mut self) {
4411                 if let Some(f) = self.free {
4412                         f(self.this_arg);
4413                 }
4414         }
4415 }
4416 /// A trait implemented for objects handling events from [`EventsProvider`].
4417 ///
4418 /// An async variation also exists for implementations of [`EventsProvider`] that support async
4419 /// event handling. The async event handler should satisfy the generic bounds: `F:
4420 /// core::future::Future, H: Fn(Event) -> F`.
4421 #[repr(C)]
4422 pub struct EventHandler {
4423         /// An opaque pointer which is passed to your function implementations as an argument.
4424         /// This has no meaning in the LDK, and can be NULL or any other value.
4425         pub this_arg: *mut c_void,
4426         /// Handles the given [`Event`].
4427         ///
4428         /// See [`EventsProvider`] for details that must be considered when implementing this method.
4429         pub handle_event: extern "C" fn (this_arg: *const c_void, event: crate::lightning::events::Event),
4430         /// Frees any resources associated with this object given its this_arg pointer.
4431         /// Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed.
4432         pub free: Option<extern "C" fn(this_arg: *mut c_void)>,
4433 }
4434 unsafe impl Send for EventHandler {}
4435 unsafe impl Sync for EventHandler {}
4436 pub(crate) fn EventHandler_clone_fields(orig: &EventHandler) -> EventHandler {
4437         EventHandler {
4438                 this_arg: orig.this_arg,
4439                 handle_event: Clone::clone(&orig.handle_event),
4440                 free: Clone::clone(&orig.free),
4441         }
4442 }
4443
4444 use lightning::events::EventHandler as rustEventHandler;
4445 impl rustEventHandler for EventHandler {
4446         fn handle_event(&self, mut event: lightning::events::Event) {
4447                 (self.handle_event)(self.this_arg, crate::lightning::events::Event::native_into(event))
4448         }
4449 }
4450
4451 // We're essentially a pointer already, or at least a set of pointers, so allow us to be used
4452 // directly as a Deref trait in higher-level structs:
4453 impl core::ops::Deref for EventHandler {
4454         type Target = Self;
4455         fn deref(&self) -> &Self {
4456                 self
4457         }
4458 }
4459 impl core::ops::DerefMut for EventHandler {
4460         fn deref_mut(&mut self) -> &mut Self {
4461                 self
4462         }
4463 }
4464 /// Calls the free function if one is set
4465 #[no_mangle]
4466 pub extern "C" fn EventHandler_free(this_ptr: EventHandler) { }
4467 impl Drop for EventHandler {
4468         fn drop(&mut self) {
4469                 if let Some(f) = self.free {
4470                         f(self.this_arg);
4471                 }
4472         }
4473 }