Update auto-generated bindings with latest upstream + generator
[ldk-c-bindings] / lightning-c-bindings / src / util / events.rs
1 // This file is Copyright its original authors, visible in version control
2 // history and in the source files from which this was generated.
3 //
4 // This file is licensed under the license available in the LICENSE or LICENSE.md
5 // file in the root of this repository or, if no such file exists, the same
6 // license as that which applies to the original source files from which this
7 // source was automatically generated.
8
9 //! Events are returned from various bits in the library which indicate some action must be taken
10 //! by the client.
11 //!
12 //! Because we don't have a built-in runtime, it's up to the client to call events at a time in the
13 //! future, as well as generate and broadcast funding transactions handle payment preimages and a
14 //! few other things.
15
16 use std::ffi::c_void;
17 use bitcoin::hashes::Hash;
18 use crate::c_types::*;
19
20 /// An Event which you should probably take some action in response to.
21 ///
22 /// Note that while Writeable and Readable are implemented for Event, you probably shouldn't use
23 /// them directly as they don't round-trip exactly (for example FundingGenerationReady is never
24 /// written as it makes no sense to respond to it after reconnecting to peers).
25 #[must_use]
26 #[derive(Clone)]
27 #[repr(C)]
28 pub enum Event {
29         /// Used to indicate that the client should generate a funding transaction with the given
30         /// parameters and then call ChannelManager::funding_transaction_generated.
31         /// Generated in ChannelManager message handling.
32         /// Note that *all inputs* in the funding transaction must spend SegWit outputs or your
33         /// counterparty can steal your funds!
34         FundingGenerationReady {
35                 /// The random channel_id we picked which you'll need to pass into
36                 /// ChannelManager::funding_transaction_generated.
37                 temporary_channel_id: crate::c_types::ThirtyTwoBytes,
38                 /// The value, in satoshis, that the output should have.
39                 channel_value_satoshis: u64,
40                 /// The script which should be used in the transaction output.
41                 output_script: crate::c_types::derived::CVec_u8Z,
42                 /// The value passed in to ChannelManager::create_channel
43                 user_channel_id: u64,
44         },
45         /// Indicates we've received money! Just gotta dig out that payment preimage and feed it to
46         /// ChannelManager::claim_funds to get it....
47         /// Note that if the preimage is not known or the amount paid is incorrect, you should call
48         /// ChannelManager::fail_htlc_backwards to free up resources for this HTLC and avoid
49         /// network congestion.
50         /// The amount paid should be considered 'incorrect' when it is less than or more than twice
51         /// the amount expected.
52         /// If you fail to call either ChannelManager::claim_funds or
53         /// ChannelManager::fail_htlc_backwards within the HTLC's timeout, the HTLC will be
54         /// automatically failed.
55         PaymentReceived {
56                 /// The hash for which the preimage should be handed to the ChannelManager.
57                 payment_hash: crate::c_types::ThirtyTwoBytes,
58                 /// The \"payment secret\". This authenticates the sender to the recipient, preventing a
59                 /// number of deanonymization attacks during the routing process.
60                 /// As nodes upgrade, the invoices you provide should likely migrate to setting the
61                 /// payment_secret feature to required, at which point you should fail_backwards any HTLCs
62                 /// which have a None here.
63                 /// Until then, however, values of None should be ignored, and only incorrect Some values
64                 /// should result in an HTLC fail_backwards.
65                 /// Note that, in any case, this value must be passed as-is to any fail or claim calls as
66                 /// the HTLC index includes this value.
67                 payment_secret: crate::c_types::ThirtyTwoBytes,
68                 /// The value, in thousandths of a satoshi, that this payment is for. Note that you must
69                 /// compare this to the expected value before accepting the payment (as otherwise you are
70                 /// providing proof-of-payment for less than the value you expected!).
71                 amt: u64,
72         },
73         /// Indicates an outbound payment we made succeeded (ie it made it all the way to its target
74         /// and we got back the payment preimage for it).
75         /// Note that duplicative PaymentSent Events may be generated - it is your responsibility to
76         /// deduplicate them by payment_preimage (which MUST be unique)!
77         PaymentSent {
78                 /// The preimage to the hash given to ChannelManager::send_payment.
79                 /// Note that this serves as a payment receipt, if you wish to have such a thing, you must
80                 /// store it somehow!
81                 payment_preimage: crate::c_types::ThirtyTwoBytes,
82         },
83         /// Indicates an outbound payment we made failed. Probably some intermediary node dropped
84         /// something. You may wish to retry with a different route.
85         /// Note that duplicative PaymentFailed Events may be generated - it is your responsibility to
86         /// deduplicate them by payment_hash (which MUST be unique)!
87         PaymentFailed {
88                 /// The hash which was given to ChannelManager::send_payment.
89                 payment_hash: crate::c_types::ThirtyTwoBytes,
90                 /// Indicates the payment was rejected for some reason by the recipient. This implies that
91                 /// the payment has failed, not just the route in question. If this is not set, you may
92                 /// retry the payment via a different route.
93                 rejected_by_dest: bool,
94         },
95         /// Used to indicate that ChannelManager::process_pending_htlc_forwards should be called at a
96         /// time in the future.
97         PendingHTLCsForwardable {
98                 /// The minimum amount of time that should be waited prior to calling
99                 /// process_pending_htlc_forwards. To increase the effort required to correlate payments,
100                 /// you should wait a random amount of time in roughly the range (now + time_forwardable,
101                 /// now + 5*time_forwardable).
102                 time_forwardable: u64,
103         },
104         /// Used to indicate that an output was generated on-chain which you should know how to spend.
105         /// Such an output will *not* ever be spent by rust-lightning, and are not at risk of your
106         /// counterparty spending them due to some kind of timeout. Thus, you need to store them
107         /// somewhere and spend them when you create on-chain transactions.
108         SpendableOutputs {
109                 /// The outputs which you should store as spendable by you.
110                 outputs: crate::c_types::derived::CVec_SpendableOutputDescriptorZ,
111         },
112 }
113 use lightning::util::events::Event as nativeEvent;
114 impl Event {
115         #[allow(unused)]
116         pub(crate) fn to_native(&self) -> nativeEvent {
117                 match self {
118                         Event::FundingGenerationReady {ref temporary_channel_id, ref channel_value_satoshis, ref output_script, ref user_channel_id, } => {
119                                 let mut temporary_channel_id_nonref = (*temporary_channel_id).clone();
120                                 let mut channel_value_satoshis_nonref = (*channel_value_satoshis).clone();
121                                 let mut output_script_nonref = (*output_script).clone();
122                                 let mut user_channel_id_nonref = (*user_channel_id).clone();
123                                 nativeEvent::FundingGenerationReady {
124                                         temporary_channel_id: temporary_channel_id_nonref.data,
125                                         channel_value_satoshis: channel_value_satoshis_nonref,
126                                         output_script: ::bitcoin::blockdata::script::Script::from(output_script_nonref.into_rust()),
127                                         user_channel_id: user_channel_id_nonref,
128                                 }
129                         },
130                         Event::PaymentReceived {ref payment_hash, ref payment_secret, ref amt, } => {
131                                 let mut payment_hash_nonref = (*payment_hash).clone();
132                                 let mut payment_secret_nonref = (*payment_secret).clone();
133                                 let mut local_payment_secret_nonref = if payment_secret_nonref.data == [0; 32] { None } else { Some( { ::lightning::ln::channelmanager::PaymentSecret(payment_secret_nonref.data) }) };
134                                 let mut amt_nonref = (*amt).clone();
135                                 nativeEvent::PaymentReceived {
136                                         payment_hash: ::lightning::ln::channelmanager::PaymentHash(payment_hash_nonref.data),
137                                         payment_secret: local_payment_secret_nonref,
138                                         amt: amt_nonref,
139                                 }
140                         },
141                         Event::PaymentSent {ref payment_preimage, } => {
142                                 let mut payment_preimage_nonref = (*payment_preimage).clone();
143                                 nativeEvent::PaymentSent {
144                                         payment_preimage: ::lightning::ln::channelmanager::PaymentPreimage(payment_preimage_nonref.data),
145                                 }
146                         },
147                         Event::PaymentFailed {ref payment_hash, ref rejected_by_dest, } => {
148                                 let mut payment_hash_nonref = (*payment_hash).clone();
149                                 let mut rejected_by_dest_nonref = (*rejected_by_dest).clone();
150                                 nativeEvent::PaymentFailed {
151                                         payment_hash: ::lightning::ln::channelmanager::PaymentHash(payment_hash_nonref.data),
152                                         rejected_by_dest: rejected_by_dest_nonref,
153                                 }
154                         },
155                         Event::PendingHTLCsForwardable {ref time_forwardable, } => {
156                                 let mut time_forwardable_nonref = (*time_forwardable).clone();
157                                 nativeEvent::PendingHTLCsForwardable {
158                                         time_forwardable: std::time::Duration::from_secs(time_forwardable_nonref),
159                                 }
160                         },
161                         Event::SpendableOutputs {ref outputs, } => {
162                                 let mut outputs_nonref = (*outputs).clone();
163                                 let mut local_outputs_nonref = Vec::new(); for mut item in outputs_nonref.into_rust().drain(..) { local_outputs_nonref.push( { item.into_native() }); };
164                                 nativeEvent::SpendableOutputs {
165                                         outputs: local_outputs_nonref,
166                                 }
167                         },
168                 }
169         }
170         #[allow(unused)]
171         pub(crate) fn into_native(self) -> nativeEvent {
172                 match self {
173                         Event::FundingGenerationReady {mut temporary_channel_id, mut channel_value_satoshis, mut output_script, mut user_channel_id, } => {
174                                 nativeEvent::FundingGenerationReady {
175                                         temporary_channel_id: temporary_channel_id.data,
176                                         channel_value_satoshis: channel_value_satoshis,
177                                         output_script: ::bitcoin::blockdata::script::Script::from(output_script.into_rust()),
178                                         user_channel_id: user_channel_id,
179                                 }
180                         },
181                         Event::PaymentReceived {mut payment_hash, mut payment_secret, mut amt, } => {
182                                 let mut local_payment_secret = if payment_secret.data == [0; 32] { None } else { Some( { ::lightning::ln::channelmanager::PaymentSecret(payment_secret.data) }) };
183                                 nativeEvent::PaymentReceived {
184                                         payment_hash: ::lightning::ln::channelmanager::PaymentHash(payment_hash.data),
185                                         payment_secret: local_payment_secret,
186                                         amt: amt,
187                                 }
188                         },
189                         Event::PaymentSent {mut payment_preimage, } => {
190                                 nativeEvent::PaymentSent {
191                                         payment_preimage: ::lightning::ln::channelmanager::PaymentPreimage(payment_preimage.data),
192                                 }
193                         },
194                         Event::PaymentFailed {mut payment_hash, mut rejected_by_dest, } => {
195                                 nativeEvent::PaymentFailed {
196                                         payment_hash: ::lightning::ln::channelmanager::PaymentHash(payment_hash.data),
197                                         rejected_by_dest: rejected_by_dest,
198                                 }
199                         },
200                         Event::PendingHTLCsForwardable {mut time_forwardable, } => {
201                                 nativeEvent::PendingHTLCsForwardable {
202                                         time_forwardable: std::time::Duration::from_secs(time_forwardable),
203                                 }
204                         },
205                         Event::SpendableOutputs {mut outputs, } => {
206                                 let mut local_outputs = Vec::new(); for mut item in outputs.into_rust().drain(..) { local_outputs.push( { item.into_native() }); };
207                                 nativeEvent::SpendableOutputs {
208                                         outputs: local_outputs,
209                                 }
210                         },
211                 }
212         }
213         #[allow(unused)]
214         pub(crate) fn from_native(native: &nativeEvent) -> Self {
215                 match native {
216                         nativeEvent::FundingGenerationReady {ref temporary_channel_id, ref channel_value_satoshis, ref output_script, ref user_channel_id, } => {
217                                 let mut temporary_channel_id_nonref = (*temporary_channel_id).clone();
218                                 let mut channel_value_satoshis_nonref = (*channel_value_satoshis).clone();
219                                 let mut output_script_nonref = (*output_script).clone();
220                                 let mut user_channel_id_nonref = (*user_channel_id).clone();
221                                 Event::FundingGenerationReady {
222                                         temporary_channel_id: crate::c_types::ThirtyTwoBytes { data: temporary_channel_id_nonref },
223                                         channel_value_satoshis: channel_value_satoshis_nonref,
224                                         output_script: output_script_nonref.into_bytes().into(),
225                                         user_channel_id: user_channel_id_nonref,
226                                 }
227                         },
228                         nativeEvent::PaymentReceived {ref payment_hash, ref payment_secret, ref amt, } => {
229                                 let mut payment_hash_nonref = (*payment_hash).clone();
230                                 let mut payment_secret_nonref = (*payment_secret).clone();
231                                 let mut local_payment_secret_nonref = if payment_secret_nonref.is_none() { crate::c_types::ThirtyTwoBytes::null() } else {  { crate::c_types::ThirtyTwoBytes { data: (payment_secret_nonref.unwrap()).0 } } };
232                                 let mut amt_nonref = (*amt).clone();
233                                 Event::PaymentReceived {
234                                         payment_hash: crate::c_types::ThirtyTwoBytes { data: payment_hash_nonref.0 },
235                                         payment_secret: local_payment_secret_nonref,
236                                         amt: amt_nonref,
237                                 }
238                         },
239                         nativeEvent::PaymentSent {ref payment_preimage, } => {
240                                 let mut payment_preimage_nonref = (*payment_preimage).clone();
241                                 Event::PaymentSent {
242                                         payment_preimage: crate::c_types::ThirtyTwoBytes { data: payment_preimage_nonref.0 },
243                                 }
244                         },
245                         nativeEvent::PaymentFailed {ref payment_hash, ref rejected_by_dest, } => {
246                                 let mut payment_hash_nonref = (*payment_hash).clone();
247                                 let mut rejected_by_dest_nonref = (*rejected_by_dest).clone();
248                                 Event::PaymentFailed {
249                                         payment_hash: crate::c_types::ThirtyTwoBytes { data: payment_hash_nonref.0 },
250                                         rejected_by_dest: rejected_by_dest_nonref,
251                                 }
252                         },
253                         nativeEvent::PendingHTLCsForwardable {ref time_forwardable, } => {
254                                 let mut time_forwardable_nonref = (*time_forwardable).clone();
255                                 Event::PendingHTLCsForwardable {
256                                         time_forwardable: time_forwardable_nonref.as_secs(),
257                                 }
258                         },
259                         nativeEvent::SpendableOutputs {ref outputs, } => {
260                                 let mut outputs_nonref = (*outputs).clone();
261                                 let mut local_outputs_nonref = Vec::new(); for mut item in outputs_nonref.drain(..) { local_outputs_nonref.push( { crate::chain::keysinterface::SpendableOutputDescriptor::native_into(item) }); };
262                                 Event::SpendableOutputs {
263                                         outputs: local_outputs_nonref.into(),
264                                 }
265                         },
266                 }
267         }
268         #[allow(unused)]
269         pub(crate) fn native_into(native: nativeEvent) -> Self {
270                 match native {
271                         nativeEvent::FundingGenerationReady {mut temporary_channel_id, mut channel_value_satoshis, mut output_script, mut user_channel_id, } => {
272                                 Event::FundingGenerationReady {
273                                         temporary_channel_id: crate::c_types::ThirtyTwoBytes { data: temporary_channel_id },
274                                         channel_value_satoshis: channel_value_satoshis,
275                                         output_script: output_script.into_bytes().into(),
276                                         user_channel_id: user_channel_id,
277                                 }
278                         },
279                         nativeEvent::PaymentReceived {mut payment_hash, mut payment_secret, mut amt, } => {
280                                 let mut local_payment_secret = if payment_secret.is_none() { crate::c_types::ThirtyTwoBytes::null() } else {  { crate::c_types::ThirtyTwoBytes { data: (payment_secret.unwrap()).0 } } };
281                                 Event::PaymentReceived {
282                                         payment_hash: crate::c_types::ThirtyTwoBytes { data: payment_hash.0 },
283                                         payment_secret: local_payment_secret,
284                                         amt: amt,
285                                 }
286                         },
287                         nativeEvent::PaymentSent {mut payment_preimage, } => {
288                                 Event::PaymentSent {
289                                         payment_preimage: crate::c_types::ThirtyTwoBytes { data: payment_preimage.0 },
290                                 }
291                         },
292                         nativeEvent::PaymentFailed {mut payment_hash, mut rejected_by_dest, } => {
293                                 Event::PaymentFailed {
294                                         payment_hash: crate::c_types::ThirtyTwoBytes { data: payment_hash.0 },
295                                         rejected_by_dest: rejected_by_dest,
296                                 }
297                         },
298                         nativeEvent::PendingHTLCsForwardable {mut time_forwardable, } => {
299                                 Event::PendingHTLCsForwardable {
300                                         time_forwardable: time_forwardable.as_secs(),
301                                 }
302                         },
303                         nativeEvent::SpendableOutputs {mut outputs, } => {
304                                 let mut local_outputs = Vec::new(); for mut item in outputs.drain(..) { local_outputs.push( { crate::chain::keysinterface::SpendableOutputDescriptor::native_into(item) }); };
305                                 Event::SpendableOutputs {
306                                         outputs: local_outputs.into(),
307                                 }
308                         },
309                 }
310         }
311 }
312 /// Frees any resources used by the Event
313 #[no_mangle]
314 pub extern "C" fn Event_free(this_ptr: Event) { }
315 /// Creates a copy of the Event
316 #[no_mangle]
317 pub extern "C" fn Event_clone(orig: &Event) -> Event {
318         orig.clone()
319 }
320 #[no_mangle]
321 /// Serialize the Event object into a byte array which can be read by Event_read
322 pub extern "C" fn Event_write(obj: &Event) -> crate::c_types::derived::CVec_u8Z {
323         crate::c_types::serialize_obj(&unsafe { &*obj }.to_native())
324 }
325 /// An event generated by ChannelManager which indicates a message should be sent to a peer (or
326 /// broadcast to most peers).
327 /// These events are handled by PeerManager::process_events if you are using a PeerManager.
328 #[must_use]
329 #[derive(Clone)]
330 #[repr(C)]
331 pub enum MessageSendEvent {
332         /// Used to indicate that we've accepted a channel open and should send the accept_channel
333         /// message provided to the given peer.
334         SendAcceptChannel {
335                 /// The node_id of the node which should receive this message
336                 node_id: crate::c_types::PublicKey,
337                 /// The message which should be sent.
338                 msg: crate::ln::msgs::AcceptChannel,
339         },
340         /// Used to indicate that we've initiated a channel open and should send the open_channel
341         /// message provided to the given peer.
342         SendOpenChannel {
343                 /// The node_id of the node which should receive this message
344                 node_id: crate::c_types::PublicKey,
345                 /// The message which should be sent.
346                 msg: crate::ln::msgs::OpenChannel,
347         },
348         /// Used to indicate that a funding_created message should be sent to the peer with the given node_id.
349         SendFundingCreated {
350                 /// The node_id of the node which should receive this message
351                 node_id: crate::c_types::PublicKey,
352                 /// The message which should be sent.
353                 msg: crate::ln::msgs::FundingCreated,
354         },
355         /// Used to indicate that a funding_signed message should be sent to the peer with the given node_id.
356         SendFundingSigned {
357                 /// The node_id of the node which should receive this message
358                 node_id: crate::c_types::PublicKey,
359                 /// The message which should be sent.
360                 msg: crate::ln::msgs::FundingSigned,
361         },
362         /// Used to indicate that a funding_locked message should be sent to the peer with the given node_id.
363         SendFundingLocked {
364                 /// The node_id of the node which should receive these message(s)
365                 node_id: crate::c_types::PublicKey,
366                 /// The funding_locked message which should be sent.
367                 msg: crate::ln::msgs::FundingLocked,
368         },
369         /// Used to indicate that an announcement_signatures message should be sent to the peer with the given node_id.
370         SendAnnouncementSignatures {
371                 /// The node_id of the node which should receive these message(s)
372                 node_id: crate::c_types::PublicKey,
373                 /// The announcement_signatures message which should be sent.
374                 msg: crate::ln::msgs::AnnouncementSignatures,
375         },
376         /// Used to indicate that a series of HTLC update messages, as well as a commitment_signed
377         /// message should be sent to the peer with the given node_id.
378         UpdateHTLCs {
379                 /// The node_id of the node which should receive these message(s)
380                 node_id: crate::c_types::PublicKey,
381                 /// The update messages which should be sent. ALL messages in the struct should be sent!
382                 updates: crate::ln::msgs::CommitmentUpdate,
383         },
384         /// Used to indicate that a revoke_and_ack message should be sent to the peer with the given node_id.
385         SendRevokeAndACK {
386                 /// The node_id of the node which should receive this message
387                 node_id: crate::c_types::PublicKey,
388                 /// The message which should be sent.
389                 msg: crate::ln::msgs::RevokeAndACK,
390         },
391         /// Used to indicate that a closing_signed message should be sent to the peer with the given node_id.
392         SendClosingSigned {
393                 /// The node_id of the node which should receive this message
394                 node_id: crate::c_types::PublicKey,
395                 /// The message which should be sent.
396                 msg: crate::ln::msgs::ClosingSigned,
397         },
398         /// Used to indicate that a shutdown message should be sent to the peer with the given node_id.
399         SendShutdown {
400                 /// The node_id of the node which should receive this message
401                 node_id: crate::c_types::PublicKey,
402                 /// The message which should be sent.
403                 msg: crate::ln::msgs::Shutdown,
404         },
405         /// Used to indicate that a channel_reestablish message should be sent to the peer with the given node_id.
406         SendChannelReestablish {
407                 /// The node_id of the node which should receive this message
408                 node_id: crate::c_types::PublicKey,
409                 /// The message which should be sent.
410                 msg: crate::ln::msgs::ChannelReestablish,
411         },
412         /// Used to indicate that a channel_announcement and channel_update should be broadcast to all
413         /// peers (except the peer with node_id either msg.contents.node_id_1 or msg.contents.node_id_2).
414         ///
415         /// Note that after doing so, you very likely (unless you did so very recently) want to call
416         /// ChannelManager::broadcast_node_announcement to trigger a BroadcastNodeAnnouncement event.
417         /// This ensures that any nodes which see our channel_announcement also have a relevant
418         /// node_announcement, including relevant feature flags which may be important for routing
419         /// through or to us.
420         BroadcastChannelAnnouncement {
421                 /// The channel_announcement which should be sent.
422                 msg: crate::ln::msgs::ChannelAnnouncement,
423                 /// The followup channel_update which should be sent.
424                 update_msg: crate::ln::msgs::ChannelUpdate,
425         },
426         /// Used to indicate that a node_announcement should be broadcast to all peers.
427         BroadcastNodeAnnouncement {
428                 /// The node_announcement which should be sent.
429                 msg: crate::ln::msgs::NodeAnnouncement,
430         },
431         /// Used to indicate that a channel_update should be broadcast to all peers.
432         BroadcastChannelUpdate {
433                 /// The channel_update which should be sent.
434                 msg: crate::ln::msgs::ChannelUpdate,
435         },
436         /// Broadcast an error downstream to be handled
437         HandleError {
438                 /// The node_id of the node which should receive this message
439                 node_id: crate::c_types::PublicKey,
440                 /// The action which should be taken.
441                 action: crate::ln::msgs::ErrorAction,
442         },
443         /// When a payment fails we may receive updates back from the hop where it failed. In such
444         /// cases this event is generated so that we can inform the network graph of this information.
445         PaymentFailureNetworkUpdate {
446                 /// The channel/node update which should be sent to NetGraphMsgHandler
447                 update: crate::ln::msgs::HTLCFailChannelUpdate,
448         },
449         /// Query a peer for channels with funding transaction UTXOs in a block range.
450         SendChannelRangeQuery {
451                 /// The node_id of this message recipient
452                 node_id: crate::c_types::PublicKey,
453                 /// The query_channel_range which should be sent.
454                 msg: crate::ln::msgs::QueryChannelRange,
455         },
456         /// Request routing gossip messages from a peer for a list of channels identified by
457         /// their short_channel_ids.
458         SendShortIdsQuery {
459                 /// The node_id of this message recipient
460                 node_id: crate::c_types::PublicKey,
461                 /// The query_short_channel_ids which should be sent.
462                 msg: crate::ln::msgs::QueryShortChannelIds,
463         },
464         /// Sends a reply to a channel range query. This may be one of several SendReplyChannelRange events
465         /// emitted during processing of the query.
466         SendReplyChannelRange {
467                 /// The node_id of this message recipient
468                 node_id: crate::c_types::PublicKey,
469                 /// The reply_channel_range which should be sent.
470                 msg: crate::ln::msgs::ReplyChannelRange,
471         },
472 }
473 use lightning::util::events::MessageSendEvent as nativeMessageSendEvent;
474 impl MessageSendEvent {
475         #[allow(unused)]
476         pub(crate) fn to_native(&self) -> nativeMessageSendEvent {
477                 match self {
478                         MessageSendEvent::SendAcceptChannel {ref node_id, ref msg, } => {
479                                 let mut node_id_nonref = (*node_id).clone();
480                                 let mut msg_nonref = (*msg).clone();
481                                 nativeMessageSendEvent::SendAcceptChannel {
482                                         node_id: node_id_nonref.into_rust(),
483                                         msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) },
484                                 }
485                         },
486                         MessageSendEvent::SendOpenChannel {ref node_id, ref msg, } => {
487                                 let mut node_id_nonref = (*node_id).clone();
488                                 let mut msg_nonref = (*msg).clone();
489                                 nativeMessageSendEvent::SendOpenChannel {
490                                         node_id: node_id_nonref.into_rust(),
491                                         msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) },
492                                 }
493                         },
494                         MessageSendEvent::SendFundingCreated {ref node_id, ref msg, } => {
495                                 let mut node_id_nonref = (*node_id).clone();
496                                 let mut msg_nonref = (*msg).clone();
497                                 nativeMessageSendEvent::SendFundingCreated {
498                                         node_id: node_id_nonref.into_rust(),
499                                         msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) },
500                                 }
501                         },
502                         MessageSendEvent::SendFundingSigned {ref node_id, ref msg, } => {
503                                 let mut node_id_nonref = (*node_id).clone();
504                                 let mut msg_nonref = (*msg).clone();
505                                 nativeMessageSendEvent::SendFundingSigned {
506                                         node_id: node_id_nonref.into_rust(),
507                                         msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) },
508                                 }
509                         },
510                         MessageSendEvent::SendFundingLocked {ref node_id, ref msg, } => {
511                                 let mut node_id_nonref = (*node_id).clone();
512                                 let mut msg_nonref = (*msg).clone();
513                                 nativeMessageSendEvent::SendFundingLocked {
514                                         node_id: node_id_nonref.into_rust(),
515                                         msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) },
516                                 }
517                         },
518                         MessageSendEvent::SendAnnouncementSignatures {ref node_id, ref msg, } => {
519                                 let mut node_id_nonref = (*node_id).clone();
520                                 let mut msg_nonref = (*msg).clone();
521                                 nativeMessageSendEvent::SendAnnouncementSignatures {
522                                         node_id: node_id_nonref.into_rust(),
523                                         msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) },
524                                 }
525                         },
526                         MessageSendEvent::UpdateHTLCs {ref node_id, ref updates, } => {
527                                 let mut node_id_nonref = (*node_id).clone();
528                                 let mut updates_nonref = (*updates).clone();
529                                 nativeMessageSendEvent::UpdateHTLCs {
530                                         node_id: node_id_nonref.into_rust(),
531                                         updates: *unsafe { Box::from_raw(updates_nonref.take_inner()) },
532                                 }
533                         },
534                         MessageSendEvent::SendRevokeAndACK {ref node_id, ref msg, } => {
535                                 let mut node_id_nonref = (*node_id).clone();
536                                 let mut msg_nonref = (*msg).clone();
537                                 nativeMessageSendEvent::SendRevokeAndACK {
538                                         node_id: node_id_nonref.into_rust(),
539                                         msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) },
540                                 }
541                         },
542                         MessageSendEvent::SendClosingSigned {ref node_id, ref msg, } => {
543                                 let mut node_id_nonref = (*node_id).clone();
544                                 let mut msg_nonref = (*msg).clone();
545                                 nativeMessageSendEvent::SendClosingSigned {
546                                         node_id: node_id_nonref.into_rust(),
547                                         msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) },
548                                 }
549                         },
550                         MessageSendEvent::SendShutdown {ref node_id, ref msg, } => {
551                                 let mut node_id_nonref = (*node_id).clone();
552                                 let mut msg_nonref = (*msg).clone();
553                                 nativeMessageSendEvent::SendShutdown {
554                                         node_id: node_id_nonref.into_rust(),
555                                         msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) },
556                                 }
557                         },
558                         MessageSendEvent::SendChannelReestablish {ref node_id, ref msg, } => {
559                                 let mut node_id_nonref = (*node_id).clone();
560                                 let mut msg_nonref = (*msg).clone();
561                                 nativeMessageSendEvent::SendChannelReestablish {
562                                         node_id: node_id_nonref.into_rust(),
563                                         msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) },
564                                 }
565                         },
566                         MessageSendEvent::BroadcastChannelAnnouncement {ref msg, ref update_msg, } => {
567                                 let mut msg_nonref = (*msg).clone();
568                                 let mut update_msg_nonref = (*update_msg).clone();
569                                 nativeMessageSendEvent::BroadcastChannelAnnouncement {
570                                         msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) },
571                                         update_msg: *unsafe { Box::from_raw(update_msg_nonref.take_inner()) },
572                                 }
573                         },
574                         MessageSendEvent::BroadcastNodeAnnouncement {ref msg, } => {
575                                 let mut msg_nonref = (*msg).clone();
576                                 nativeMessageSendEvent::BroadcastNodeAnnouncement {
577                                         msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) },
578                                 }
579                         },
580                         MessageSendEvent::BroadcastChannelUpdate {ref msg, } => {
581                                 let mut msg_nonref = (*msg).clone();
582                                 nativeMessageSendEvent::BroadcastChannelUpdate {
583                                         msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) },
584                                 }
585                         },
586                         MessageSendEvent::HandleError {ref node_id, ref action, } => {
587                                 let mut node_id_nonref = (*node_id).clone();
588                                 let mut action_nonref = (*action).clone();
589                                 nativeMessageSendEvent::HandleError {
590                                         node_id: node_id_nonref.into_rust(),
591                                         action: action_nonref.into_native(),
592                                 }
593                         },
594                         MessageSendEvent::PaymentFailureNetworkUpdate {ref update, } => {
595                                 let mut update_nonref = (*update).clone();
596                                 nativeMessageSendEvent::PaymentFailureNetworkUpdate {
597                                         update: update_nonref.into_native(),
598                                 }
599                         },
600                         MessageSendEvent::SendChannelRangeQuery {ref node_id, ref msg, } => {
601                                 let mut node_id_nonref = (*node_id).clone();
602                                 let mut msg_nonref = (*msg).clone();
603                                 nativeMessageSendEvent::SendChannelRangeQuery {
604                                         node_id: node_id_nonref.into_rust(),
605                                         msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) },
606                                 }
607                         },
608                         MessageSendEvent::SendShortIdsQuery {ref node_id, ref msg, } => {
609                                 let mut node_id_nonref = (*node_id).clone();
610                                 let mut msg_nonref = (*msg).clone();
611                                 nativeMessageSendEvent::SendShortIdsQuery {
612                                         node_id: node_id_nonref.into_rust(),
613                                         msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) },
614                                 }
615                         },
616                         MessageSendEvent::SendReplyChannelRange {ref node_id, ref msg, } => {
617                                 let mut node_id_nonref = (*node_id).clone();
618                                 let mut msg_nonref = (*msg).clone();
619                                 nativeMessageSendEvent::SendReplyChannelRange {
620                                         node_id: node_id_nonref.into_rust(),
621                                         msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) },
622                                 }
623                         },
624                 }
625         }
626         #[allow(unused)]
627         pub(crate) fn into_native(self) -> nativeMessageSendEvent {
628                 match self {
629                         MessageSendEvent::SendAcceptChannel {mut node_id, mut msg, } => {
630                                 nativeMessageSendEvent::SendAcceptChannel {
631                                         node_id: node_id.into_rust(),
632                                         msg: *unsafe { Box::from_raw(msg.take_inner()) },
633                                 }
634                         },
635                         MessageSendEvent::SendOpenChannel {mut node_id, mut msg, } => {
636                                 nativeMessageSendEvent::SendOpenChannel {
637                                         node_id: node_id.into_rust(),
638                                         msg: *unsafe { Box::from_raw(msg.take_inner()) },
639                                 }
640                         },
641                         MessageSendEvent::SendFundingCreated {mut node_id, mut msg, } => {
642                                 nativeMessageSendEvent::SendFundingCreated {
643                                         node_id: node_id.into_rust(),
644                                         msg: *unsafe { Box::from_raw(msg.take_inner()) },
645                                 }
646                         },
647                         MessageSendEvent::SendFundingSigned {mut node_id, mut msg, } => {
648                                 nativeMessageSendEvent::SendFundingSigned {
649                                         node_id: node_id.into_rust(),
650                                         msg: *unsafe { Box::from_raw(msg.take_inner()) },
651                                 }
652                         },
653                         MessageSendEvent::SendFundingLocked {mut node_id, mut msg, } => {
654                                 nativeMessageSendEvent::SendFundingLocked {
655                                         node_id: node_id.into_rust(),
656                                         msg: *unsafe { Box::from_raw(msg.take_inner()) },
657                                 }
658                         },
659                         MessageSendEvent::SendAnnouncementSignatures {mut node_id, mut msg, } => {
660                                 nativeMessageSendEvent::SendAnnouncementSignatures {
661                                         node_id: node_id.into_rust(),
662                                         msg: *unsafe { Box::from_raw(msg.take_inner()) },
663                                 }
664                         },
665                         MessageSendEvent::UpdateHTLCs {mut node_id, mut updates, } => {
666                                 nativeMessageSendEvent::UpdateHTLCs {
667                                         node_id: node_id.into_rust(),
668                                         updates: *unsafe { Box::from_raw(updates.take_inner()) },
669                                 }
670                         },
671                         MessageSendEvent::SendRevokeAndACK {mut node_id, mut msg, } => {
672                                 nativeMessageSendEvent::SendRevokeAndACK {
673                                         node_id: node_id.into_rust(),
674                                         msg: *unsafe { Box::from_raw(msg.take_inner()) },
675                                 }
676                         },
677                         MessageSendEvent::SendClosingSigned {mut node_id, mut msg, } => {
678                                 nativeMessageSendEvent::SendClosingSigned {
679                                         node_id: node_id.into_rust(),
680                                         msg: *unsafe { Box::from_raw(msg.take_inner()) },
681                                 }
682                         },
683                         MessageSendEvent::SendShutdown {mut node_id, mut msg, } => {
684                                 nativeMessageSendEvent::SendShutdown {
685                                         node_id: node_id.into_rust(),
686                                         msg: *unsafe { Box::from_raw(msg.take_inner()) },
687                                 }
688                         },
689                         MessageSendEvent::SendChannelReestablish {mut node_id, mut msg, } => {
690                                 nativeMessageSendEvent::SendChannelReestablish {
691                                         node_id: node_id.into_rust(),
692                                         msg: *unsafe { Box::from_raw(msg.take_inner()) },
693                                 }
694                         },
695                         MessageSendEvent::BroadcastChannelAnnouncement {mut msg, mut update_msg, } => {
696                                 nativeMessageSendEvent::BroadcastChannelAnnouncement {
697                                         msg: *unsafe { Box::from_raw(msg.take_inner()) },
698                                         update_msg: *unsafe { Box::from_raw(update_msg.take_inner()) },
699                                 }
700                         },
701                         MessageSendEvent::BroadcastNodeAnnouncement {mut msg, } => {
702                                 nativeMessageSendEvent::BroadcastNodeAnnouncement {
703                                         msg: *unsafe { Box::from_raw(msg.take_inner()) },
704                                 }
705                         },
706                         MessageSendEvent::BroadcastChannelUpdate {mut msg, } => {
707                                 nativeMessageSendEvent::BroadcastChannelUpdate {
708                                         msg: *unsafe { Box::from_raw(msg.take_inner()) },
709                                 }
710                         },
711                         MessageSendEvent::HandleError {mut node_id, mut action, } => {
712                                 nativeMessageSendEvent::HandleError {
713                                         node_id: node_id.into_rust(),
714                                         action: action.into_native(),
715                                 }
716                         },
717                         MessageSendEvent::PaymentFailureNetworkUpdate {mut update, } => {
718                                 nativeMessageSendEvent::PaymentFailureNetworkUpdate {
719                                         update: update.into_native(),
720                                 }
721                         },
722                         MessageSendEvent::SendChannelRangeQuery {mut node_id, mut msg, } => {
723                                 nativeMessageSendEvent::SendChannelRangeQuery {
724                                         node_id: node_id.into_rust(),
725                                         msg: *unsafe { Box::from_raw(msg.take_inner()) },
726                                 }
727                         },
728                         MessageSendEvent::SendShortIdsQuery {mut node_id, mut msg, } => {
729                                 nativeMessageSendEvent::SendShortIdsQuery {
730                                         node_id: node_id.into_rust(),
731                                         msg: *unsafe { Box::from_raw(msg.take_inner()) },
732                                 }
733                         },
734                         MessageSendEvent::SendReplyChannelRange {mut node_id, mut msg, } => {
735                                 nativeMessageSendEvent::SendReplyChannelRange {
736                                         node_id: node_id.into_rust(),
737                                         msg: *unsafe { Box::from_raw(msg.take_inner()) },
738                                 }
739                         },
740                 }
741         }
742         #[allow(unused)]
743         pub(crate) fn from_native(native: &nativeMessageSendEvent) -> Self {
744                 match native {
745                         nativeMessageSendEvent::SendAcceptChannel {ref node_id, ref msg, } => {
746                                 let mut node_id_nonref = (*node_id).clone();
747                                 let mut msg_nonref = (*msg).clone();
748                                 MessageSendEvent::SendAcceptChannel {
749                                         node_id: crate::c_types::PublicKey::from_rust(&node_id_nonref),
750                                         msg: crate::ln::msgs::AcceptChannel { inner: Box::into_raw(Box::new(msg_nonref)), is_owned: true },
751                                 }
752                         },
753                         nativeMessageSendEvent::SendOpenChannel {ref node_id, ref msg, } => {
754                                 let mut node_id_nonref = (*node_id).clone();
755                                 let mut msg_nonref = (*msg).clone();
756                                 MessageSendEvent::SendOpenChannel {
757                                         node_id: crate::c_types::PublicKey::from_rust(&node_id_nonref),
758                                         msg: crate::ln::msgs::OpenChannel { inner: Box::into_raw(Box::new(msg_nonref)), is_owned: true },
759                                 }
760                         },
761                         nativeMessageSendEvent::SendFundingCreated {ref node_id, ref msg, } => {
762                                 let mut node_id_nonref = (*node_id).clone();
763                                 let mut msg_nonref = (*msg).clone();
764                                 MessageSendEvent::SendFundingCreated {
765                                         node_id: crate::c_types::PublicKey::from_rust(&node_id_nonref),
766                                         msg: crate::ln::msgs::FundingCreated { inner: Box::into_raw(Box::new(msg_nonref)), is_owned: true },
767                                 }
768                         },
769                         nativeMessageSendEvent::SendFundingSigned {ref node_id, ref msg, } => {
770                                 let mut node_id_nonref = (*node_id).clone();
771                                 let mut msg_nonref = (*msg).clone();
772                                 MessageSendEvent::SendFundingSigned {
773                                         node_id: crate::c_types::PublicKey::from_rust(&node_id_nonref),
774                                         msg: crate::ln::msgs::FundingSigned { inner: Box::into_raw(Box::new(msg_nonref)), is_owned: true },
775                                 }
776                         },
777                         nativeMessageSendEvent::SendFundingLocked {ref node_id, ref msg, } => {
778                                 let mut node_id_nonref = (*node_id).clone();
779                                 let mut msg_nonref = (*msg).clone();
780                                 MessageSendEvent::SendFundingLocked {
781                                         node_id: crate::c_types::PublicKey::from_rust(&node_id_nonref),
782                                         msg: crate::ln::msgs::FundingLocked { inner: Box::into_raw(Box::new(msg_nonref)), is_owned: true },
783                                 }
784                         },
785                         nativeMessageSendEvent::SendAnnouncementSignatures {ref node_id, ref msg, } => {
786                                 let mut node_id_nonref = (*node_id).clone();
787                                 let mut msg_nonref = (*msg).clone();
788                                 MessageSendEvent::SendAnnouncementSignatures {
789                                         node_id: crate::c_types::PublicKey::from_rust(&node_id_nonref),
790                                         msg: crate::ln::msgs::AnnouncementSignatures { inner: Box::into_raw(Box::new(msg_nonref)), is_owned: true },
791                                 }
792                         },
793                         nativeMessageSendEvent::UpdateHTLCs {ref node_id, ref updates, } => {
794                                 let mut node_id_nonref = (*node_id).clone();
795                                 let mut updates_nonref = (*updates).clone();
796                                 MessageSendEvent::UpdateHTLCs {
797                                         node_id: crate::c_types::PublicKey::from_rust(&node_id_nonref),
798                                         updates: crate::ln::msgs::CommitmentUpdate { inner: Box::into_raw(Box::new(updates_nonref)), is_owned: true },
799                                 }
800                         },
801                         nativeMessageSendEvent::SendRevokeAndACK {ref node_id, ref msg, } => {
802                                 let mut node_id_nonref = (*node_id).clone();
803                                 let mut msg_nonref = (*msg).clone();
804                                 MessageSendEvent::SendRevokeAndACK {
805                                         node_id: crate::c_types::PublicKey::from_rust(&node_id_nonref),
806                                         msg: crate::ln::msgs::RevokeAndACK { inner: Box::into_raw(Box::new(msg_nonref)), is_owned: true },
807                                 }
808                         },
809                         nativeMessageSendEvent::SendClosingSigned {ref node_id, ref msg, } => {
810                                 let mut node_id_nonref = (*node_id).clone();
811                                 let mut msg_nonref = (*msg).clone();
812                                 MessageSendEvent::SendClosingSigned {
813                                         node_id: crate::c_types::PublicKey::from_rust(&node_id_nonref),
814                                         msg: crate::ln::msgs::ClosingSigned { inner: Box::into_raw(Box::new(msg_nonref)), is_owned: true },
815                                 }
816                         },
817                         nativeMessageSendEvent::SendShutdown {ref node_id, ref msg, } => {
818                                 let mut node_id_nonref = (*node_id).clone();
819                                 let mut msg_nonref = (*msg).clone();
820                                 MessageSendEvent::SendShutdown {
821                                         node_id: crate::c_types::PublicKey::from_rust(&node_id_nonref),
822                                         msg: crate::ln::msgs::Shutdown { inner: Box::into_raw(Box::new(msg_nonref)), is_owned: true },
823                                 }
824                         },
825                         nativeMessageSendEvent::SendChannelReestablish {ref node_id, ref msg, } => {
826                                 let mut node_id_nonref = (*node_id).clone();
827                                 let mut msg_nonref = (*msg).clone();
828                                 MessageSendEvent::SendChannelReestablish {
829                                         node_id: crate::c_types::PublicKey::from_rust(&node_id_nonref),
830                                         msg: crate::ln::msgs::ChannelReestablish { inner: Box::into_raw(Box::new(msg_nonref)), is_owned: true },
831                                 }
832                         },
833                         nativeMessageSendEvent::BroadcastChannelAnnouncement {ref msg, ref update_msg, } => {
834                                 let mut msg_nonref = (*msg).clone();
835                                 let mut update_msg_nonref = (*update_msg).clone();
836                                 MessageSendEvent::BroadcastChannelAnnouncement {
837                                         msg: crate::ln::msgs::ChannelAnnouncement { inner: Box::into_raw(Box::new(msg_nonref)), is_owned: true },
838                                         update_msg: crate::ln::msgs::ChannelUpdate { inner: Box::into_raw(Box::new(update_msg_nonref)), is_owned: true },
839                                 }
840                         },
841                         nativeMessageSendEvent::BroadcastNodeAnnouncement {ref msg, } => {
842                                 let mut msg_nonref = (*msg).clone();
843                                 MessageSendEvent::BroadcastNodeAnnouncement {
844                                         msg: crate::ln::msgs::NodeAnnouncement { inner: Box::into_raw(Box::new(msg_nonref)), is_owned: true },
845                                 }
846                         },
847                         nativeMessageSendEvent::BroadcastChannelUpdate {ref msg, } => {
848                                 let mut msg_nonref = (*msg).clone();
849                                 MessageSendEvent::BroadcastChannelUpdate {
850                                         msg: crate::ln::msgs::ChannelUpdate { inner: Box::into_raw(Box::new(msg_nonref)), is_owned: true },
851                                 }
852                         },
853                         nativeMessageSendEvent::HandleError {ref node_id, ref action, } => {
854                                 let mut node_id_nonref = (*node_id).clone();
855                                 let mut action_nonref = (*action).clone();
856                                 MessageSendEvent::HandleError {
857                                         node_id: crate::c_types::PublicKey::from_rust(&node_id_nonref),
858                                         action: crate::ln::msgs::ErrorAction::native_into(action_nonref),
859                                 }
860                         },
861                         nativeMessageSendEvent::PaymentFailureNetworkUpdate {ref update, } => {
862                                 let mut update_nonref = (*update).clone();
863                                 MessageSendEvent::PaymentFailureNetworkUpdate {
864                                         update: crate::ln::msgs::HTLCFailChannelUpdate::native_into(update_nonref),
865                                 }
866                         },
867                         nativeMessageSendEvent::SendChannelRangeQuery {ref node_id, ref msg, } => {
868                                 let mut node_id_nonref = (*node_id).clone();
869                                 let mut msg_nonref = (*msg).clone();
870                                 MessageSendEvent::SendChannelRangeQuery {
871                                         node_id: crate::c_types::PublicKey::from_rust(&node_id_nonref),
872                                         msg: crate::ln::msgs::QueryChannelRange { inner: Box::into_raw(Box::new(msg_nonref)), is_owned: true },
873                                 }
874                         },
875                         nativeMessageSendEvent::SendShortIdsQuery {ref node_id, ref msg, } => {
876                                 let mut node_id_nonref = (*node_id).clone();
877                                 let mut msg_nonref = (*msg).clone();
878                                 MessageSendEvent::SendShortIdsQuery {
879                                         node_id: crate::c_types::PublicKey::from_rust(&node_id_nonref),
880                                         msg: crate::ln::msgs::QueryShortChannelIds { inner: Box::into_raw(Box::new(msg_nonref)), is_owned: true },
881                                 }
882                         },
883                         nativeMessageSendEvent::SendReplyChannelRange {ref node_id, ref msg, } => {
884                                 let mut node_id_nonref = (*node_id).clone();
885                                 let mut msg_nonref = (*msg).clone();
886                                 MessageSendEvent::SendReplyChannelRange {
887                                         node_id: crate::c_types::PublicKey::from_rust(&node_id_nonref),
888                                         msg: crate::ln::msgs::ReplyChannelRange { inner: Box::into_raw(Box::new(msg_nonref)), is_owned: true },
889                                 }
890                         },
891                 }
892         }
893         #[allow(unused)]
894         pub(crate) fn native_into(native: nativeMessageSendEvent) -> Self {
895                 match native {
896                         nativeMessageSendEvent::SendAcceptChannel {mut node_id, mut msg, } => {
897                                 MessageSendEvent::SendAcceptChannel {
898                                         node_id: crate::c_types::PublicKey::from_rust(&node_id),
899                                         msg: crate::ln::msgs::AcceptChannel { inner: Box::into_raw(Box::new(msg)), is_owned: true },
900                                 }
901                         },
902                         nativeMessageSendEvent::SendOpenChannel {mut node_id, mut msg, } => {
903                                 MessageSendEvent::SendOpenChannel {
904                                         node_id: crate::c_types::PublicKey::from_rust(&node_id),
905                                         msg: crate::ln::msgs::OpenChannel { inner: Box::into_raw(Box::new(msg)), is_owned: true },
906                                 }
907                         },
908                         nativeMessageSendEvent::SendFundingCreated {mut node_id, mut msg, } => {
909                                 MessageSendEvent::SendFundingCreated {
910                                         node_id: crate::c_types::PublicKey::from_rust(&node_id),
911                                         msg: crate::ln::msgs::FundingCreated { inner: Box::into_raw(Box::new(msg)), is_owned: true },
912                                 }
913                         },
914                         nativeMessageSendEvent::SendFundingSigned {mut node_id, mut msg, } => {
915                                 MessageSendEvent::SendFundingSigned {
916                                         node_id: crate::c_types::PublicKey::from_rust(&node_id),
917                                         msg: crate::ln::msgs::FundingSigned { inner: Box::into_raw(Box::new(msg)), is_owned: true },
918                                 }
919                         },
920                         nativeMessageSendEvent::SendFundingLocked {mut node_id, mut msg, } => {
921                                 MessageSendEvent::SendFundingLocked {
922                                         node_id: crate::c_types::PublicKey::from_rust(&node_id),
923                                         msg: crate::ln::msgs::FundingLocked { inner: Box::into_raw(Box::new(msg)), is_owned: true },
924                                 }
925                         },
926                         nativeMessageSendEvent::SendAnnouncementSignatures {mut node_id, mut msg, } => {
927                                 MessageSendEvent::SendAnnouncementSignatures {
928                                         node_id: crate::c_types::PublicKey::from_rust(&node_id),
929                                         msg: crate::ln::msgs::AnnouncementSignatures { inner: Box::into_raw(Box::new(msg)), is_owned: true },
930                                 }
931                         },
932                         nativeMessageSendEvent::UpdateHTLCs {mut node_id, mut updates, } => {
933                                 MessageSendEvent::UpdateHTLCs {
934                                         node_id: crate::c_types::PublicKey::from_rust(&node_id),
935                                         updates: crate::ln::msgs::CommitmentUpdate { inner: Box::into_raw(Box::new(updates)), is_owned: true },
936                                 }
937                         },
938                         nativeMessageSendEvent::SendRevokeAndACK {mut node_id, mut msg, } => {
939                                 MessageSendEvent::SendRevokeAndACK {
940                                         node_id: crate::c_types::PublicKey::from_rust(&node_id),
941                                         msg: crate::ln::msgs::RevokeAndACK { inner: Box::into_raw(Box::new(msg)), is_owned: true },
942                                 }
943                         },
944                         nativeMessageSendEvent::SendClosingSigned {mut node_id, mut msg, } => {
945                                 MessageSendEvent::SendClosingSigned {
946                                         node_id: crate::c_types::PublicKey::from_rust(&node_id),
947                                         msg: crate::ln::msgs::ClosingSigned { inner: Box::into_raw(Box::new(msg)), is_owned: true },
948                                 }
949                         },
950                         nativeMessageSendEvent::SendShutdown {mut node_id, mut msg, } => {
951                                 MessageSendEvent::SendShutdown {
952                                         node_id: crate::c_types::PublicKey::from_rust(&node_id),
953                                         msg: crate::ln::msgs::Shutdown { inner: Box::into_raw(Box::new(msg)), is_owned: true },
954                                 }
955                         },
956                         nativeMessageSendEvent::SendChannelReestablish {mut node_id, mut msg, } => {
957                                 MessageSendEvent::SendChannelReestablish {
958                                         node_id: crate::c_types::PublicKey::from_rust(&node_id),
959                                         msg: crate::ln::msgs::ChannelReestablish { inner: Box::into_raw(Box::new(msg)), is_owned: true },
960                                 }
961                         },
962                         nativeMessageSendEvent::BroadcastChannelAnnouncement {mut msg, mut update_msg, } => {
963                                 MessageSendEvent::BroadcastChannelAnnouncement {
964                                         msg: crate::ln::msgs::ChannelAnnouncement { inner: Box::into_raw(Box::new(msg)), is_owned: true },
965                                         update_msg: crate::ln::msgs::ChannelUpdate { inner: Box::into_raw(Box::new(update_msg)), is_owned: true },
966                                 }
967                         },
968                         nativeMessageSendEvent::BroadcastNodeAnnouncement {mut msg, } => {
969                                 MessageSendEvent::BroadcastNodeAnnouncement {
970                                         msg: crate::ln::msgs::NodeAnnouncement { inner: Box::into_raw(Box::new(msg)), is_owned: true },
971                                 }
972                         },
973                         nativeMessageSendEvent::BroadcastChannelUpdate {mut msg, } => {
974                                 MessageSendEvent::BroadcastChannelUpdate {
975                                         msg: crate::ln::msgs::ChannelUpdate { inner: Box::into_raw(Box::new(msg)), is_owned: true },
976                                 }
977                         },
978                         nativeMessageSendEvent::HandleError {mut node_id, mut action, } => {
979                                 MessageSendEvent::HandleError {
980                                         node_id: crate::c_types::PublicKey::from_rust(&node_id),
981                                         action: crate::ln::msgs::ErrorAction::native_into(action),
982                                 }
983                         },
984                         nativeMessageSendEvent::PaymentFailureNetworkUpdate {mut update, } => {
985                                 MessageSendEvent::PaymentFailureNetworkUpdate {
986                                         update: crate::ln::msgs::HTLCFailChannelUpdate::native_into(update),
987                                 }
988                         },
989                         nativeMessageSendEvent::SendChannelRangeQuery {mut node_id, mut msg, } => {
990                                 MessageSendEvent::SendChannelRangeQuery {
991                                         node_id: crate::c_types::PublicKey::from_rust(&node_id),
992                                         msg: crate::ln::msgs::QueryChannelRange { inner: Box::into_raw(Box::new(msg)), is_owned: true },
993                                 }
994                         },
995                         nativeMessageSendEvent::SendShortIdsQuery {mut node_id, mut msg, } => {
996                                 MessageSendEvent::SendShortIdsQuery {
997                                         node_id: crate::c_types::PublicKey::from_rust(&node_id),
998                                         msg: crate::ln::msgs::QueryShortChannelIds { inner: Box::into_raw(Box::new(msg)), is_owned: true },
999                                 }
1000                         },
1001                         nativeMessageSendEvent::SendReplyChannelRange {mut node_id, mut msg, } => {
1002                                 MessageSendEvent::SendReplyChannelRange {
1003                                         node_id: crate::c_types::PublicKey::from_rust(&node_id),
1004                                         msg: crate::ln::msgs::ReplyChannelRange { inner: Box::into_raw(Box::new(msg)), is_owned: true },
1005                                 }
1006                         },
1007                 }
1008         }
1009 }
1010 /// Frees any resources used by the MessageSendEvent
1011 #[no_mangle]
1012 pub extern "C" fn MessageSendEvent_free(this_ptr: MessageSendEvent) { }
1013 /// Creates a copy of the MessageSendEvent
1014 #[no_mangle]
1015 pub extern "C" fn MessageSendEvent_clone(orig: &MessageSendEvent) -> MessageSendEvent {
1016         orig.clone()
1017 }
1018 /// A trait indicating an object may generate message send events
1019 #[repr(C)]
1020 pub struct MessageSendEventsProvider {
1021         /// An opaque pointer which is passed to your function implementations as an argument.
1022         /// This has no meaning in the LDK, and can be NULL or any other value.
1023         pub this_arg: *mut c_void,
1024         /// Gets the list of pending events which were generated by previous actions, clearing the list
1025         /// in the process.
1026         #[must_use]
1027         pub get_and_clear_pending_msg_events: extern "C" fn (this_arg: *const c_void) -> crate::c_types::derived::CVec_MessageSendEventZ,
1028         /// Frees any resources associated with this object given its this_arg pointer.
1029         /// Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed.
1030         pub free: Option<extern "C" fn(this_arg: *mut c_void)>,
1031 }
1032
1033 use lightning::util::events::MessageSendEventsProvider as rustMessageSendEventsProvider;
1034 impl rustMessageSendEventsProvider for MessageSendEventsProvider {
1035         fn get_and_clear_pending_msg_events(&self) -> Vec<lightning::util::events::MessageSendEvent> {
1036                 let mut ret = (self.get_and_clear_pending_msg_events)(self.this_arg);
1037                 let mut local_ret = Vec::new(); for mut item in ret.into_rust().drain(..) { local_ret.push( { item.into_native() }); };
1038                 local_ret
1039         }
1040 }
1041
1042 // We're essentially a pointer already, or at least a set of pointers, so allow us to be used
1043 // directly as a Deref trait in higher-level structs:
1044 impl std::ops::Deref for MessageSendEventsProvider {
1045         type Target = Self;
1046         fn deref(&self) -> &Self {
1047                 self
1048         }
1049 }
1050 /// Calls the free function if one is set
1051 #[no_mangle]
1052 pub extern "C" fn MessageSendEventsProvider_free(this_ptr: MessageSendEventsProvider) { }
1053 impl Drop for MessageSendEventsProvider {
1054         fn drop(&mut self) {
1055                 if let Some(f) = self.free {
1056                         f(self.this_arg);
1057                 }
1058         }
1059 }
1060 /// A trait indicating an object may generate events
1061 #[repr(C)]
1062 pub struct EventsProvider {
1063         /// An opaque pointer which is passed to your function implementations as an argument.
1064         /// This has no meaning in the LDK, and can be NULL or any other value.
1065         pub this_arg: *mut c_void,
1066         /// Gets the list of pending events which were generated by previous actions, clearing the list
1067         /// in the process.
1068         #[must_use]
1069         pub get_and_clear_pending_events: extern "C" fn (this_arg: *const c_void) -> crate::c_types::derived::CVec_EventZ,
1070         /// Frees any resources associated with this object given its this_arg pointer.
1071         /// Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed.
1072         pub free: Option<extern "C" fn(this_arg: *mut c_void)>,
1073 }
1074
1075 use lightning::util::events::EventsProvider as rustEventsProvider;
1076 impl rustEventsProvider for EventsProvider {
1077         fn get_and_clear_pending_events(&self) -> Vec<lightning::util::events::Event> {
1078                 let mut ret = (self.get_and_clear_pending_events)(self.this_arg);
1079                 let mut local_ret = Vec::new(); for mut item in ret.into_rust().drain(..) { local_ret.push( { item.into_native() }); };
1080                 local_ret
1081         }
1082 }
1083
1084 // We're essentially a pointer already, or at least a set of pointers, so allow us to be used
1085 // directly as a Deref trait in higher-level structs:
1086 impl std::ops::Deref for EventsProvider {
1087         type Target = Self;
1088         fn deref(&self) -> &Self {
1089                 self
1090         }
1091 }
1092 /// Calls the free function if one is set
1093 #[no_mangle]
1094 pub extern "C" fn EventsProvider_free(this_ptr: EventsProvider) { }
1095 impl Drop for EventsProvider {
1096         fn drop(&mut self) {
1097                 if let Some(f) = self.free {
1098                         f(self.this_arg);
1099                 }
1100         }
1101 }