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