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