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