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