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