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