1 // This file is Copyright its original authors, visible in version control
2 // history and in the source files from which this was generated.
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.
9 //! Events are returned from various bits in the library which indicate some action must be taken
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
16 use std::str::FromStr;
18 use bitcoin::hashes::Hash;
19 use crate::c_types::*;
21 /// An Event which you should probably take some action in response to.
23 /// Note that while Writeable and Readable are implemented for Event, you probably shouldn't use
24 /// them directly as they don't round-trip exactly (for example FundingGenerationReady is never
25 /// written as it makes no sense to respond to it after reconnecting to peers).
30 /// Used to indicate that the client should generate a funding transaction with the given
31 /// parameters and then call ChannelManager::funding_transaction_generated.
32 /// Generated in ChannelManager message handling.
33 /// Note that *all inputs* in the funding transaction must spend SegWit outputs or your
34 /// counterparty can steal your funds!
35 FundingGenerationReady {
36 /// The random channel_id we picked which you'll need to pass into
37 /// ChannelManager::funding_transaction_generated.
38 temporary_channel_id: crate::c_types::ThirtyTwoBytes,
39 /// The value, in satoshis, that the output should have.
40 channel_value_satoshis: u64,
41 /// The script which should be used in the transaction output.
42 output_script: crate::c_types::derived::CVec_u8Z,
43 /// The value passed in to ChannelManager::create_channel
46 /// Indicates we've received money! Just gotta dig out that payment preimage and feed it to
47 /// ChannelManager::claim_funds to get it....
48 /// Note that if the preimage is not known or the amount paid is incorrect, you should call
49 /// ChannelManager::fail_htlc_backwards to free up resources for this HTLC and avoid
50 /// network congestion.
51 /// The amount paid should be considered 'incorrect' when it is less than or more than twice
52 /// the amount expected.
53 /// If you fail to call either ChannelManager::claim_funds or
54 /// ChannelManager::fail_htlc_backwards within the HTLC's timeout, the HTLC will be
55 /// automatically failed.
57 /// The hash for which the preimage should be handed to the ChannelManager.
58 payment_hash: crate::c_types::ThirtyTwoBytes,
59 /// The preimage to the payment_hash, if the payment hash (and secret) were fetched via
60 /// [`ChannelManager::create_inbound_payment`]. If provided, this can be handed directly to
61 /// [`ChannelManager::claim_funds`].
63 /// [`ChannelManager::create_inbound_payment`]: crate::ln::channelmanager::ChannelManager::create_inbound_payment
64 /// [`ChannelManager::claim_funds`]: crate::ln::channelmanager::ChannelManager::claim_funds
65 payment_preimage: crate::c_types::ThirtyTwoBytes,
66 /// The \"payment secret\". This authenticates the sender to the recipient, preventing a
67 /// number of deanonymization attacks during the routing process.
68 /// It is provided here for your reference, however its accuracy is enforced directly by
69 /// [`ChannelManager`] using the values you previously provided to
70 /// [`ChannelManager::create_inbound_payment`] or
71 /// [`ChannelManager::create_inbound_payment_for_hash`].
73 /// [`ChannelManager`]: crate::ln::channelmanager::ChannelManager
74 /// [`ChannelManager::create_inbound_payment`]: crate::ln::channelmanager::ChannelManager::create_inbound_payment
75 /// [`ChannelManager::create_inbound_payment_for_hash`]: crate::ln::channelmanager::ChannelManager::create_inbound_payment_for_hash
76 payment_secret: crate::c_types::ThirtyTwoBytes,
77 /// The value, in thousandths of a satoshi, that this payment is for. Note that you must
78 /// compare this to the expected value before accepting the payment (as otherwise you are
79 /// providing proof-of-payment for less than the value you expected!).
81 /// This is the `user_payment_id` which was provided to
82 /// [`ChannelManager::create_inbound_payment_for_hash`] or
83 /// [`ChannelManager::create_inbound_payment`]. It has no meaning inside of LDK and is
84 /// simply copied here. It may be used to correlate PaymentReceived events with invoice
85 /// metadata stored elsewhere.
87 /// [`ChannelManager::create_inbound_payment`]: crate::ln::channelmanager::ChannelManager::create_inbound_payment
88 /// [`ChannelManager::create_inbound_payment_for_hash`]: crate::ln::channelmanager::ChannelManager::create_inbound_payment_for_hash
91 /// Indicates an outbound payment we made succeeded (ie it made it all the way to its target
92 /// and we got back the payment preimage for it).
93 /// Note that duplicative PaymentSent Events may be generated - it is your responsibility to
94 /// deduplicate them by payment_preimage (which MUST be unique)!
96 /// The preimage to the hash given to ChannelManager::send_payment.
97 /// Note that this serves as a payment receipt, if you wish to have such a thing, you must
99 payment_preimage: crate::c_types::ThirtyTwoBytes,
101 /// Indicates an outbound payment we made failed. Probably some intermediary node dropped
102 /// something. You may wish to retry with a different route.
103 /// Note that duplicative PaymentFailed Events may be generated - it is your responsibility to
104 /// deduplicate them by payment_hash (which MUST be unique)!
106 /// The hash which was given to ChannelManager::send_payment.
107 payment_hash: crate::c_types::ThirtyTwoBytes,
108 /// Indicates the payment was rejected for some reason by the recipient. This implies that
109 /// the payment has failed, not just the route in question. If this is not set, you may
110 /// retry the payment via a different route.
111 rejected_by_dest: bool,
113 /// Used to indicate that ChannelManager::process_pending_htlc_forwards should be called at a
114 /// time in the future.
115 PendingHTLCsForwardable {
116 /// The minimum amount of time that should be waited prior to calling
117 /// process_pending_htlc_forwards. To increase the effort required to correlate payments,
118 /// you should wait a random amount of time in roughly the range (now + time_forwardable,
119 /// now + 5*time_forwardable).
120 time_forwardable: u64,
122 /// Used to indicate that an output was generated on-chain which you should know how to spend.
123 /// Such an output will *not* ever be spent by rust-lightning, and are not at risk of your
124 /// counterparty spending them due to some kind of timeout. Thus, you need to store them
125 /// somewhere and spend them when you create on-chain transactions.
127 /// The outputs which you should store as spendable by you.
128 outputs: crate::c_types::derived::CVec_SpendableOutputDescriptorZ,
131 use lightning::util::events::Event as nativeEvent;
134 pub(crate) fn to_native(&self) -> nativeEvent {
136 Event::FundingGenerationReady {ref temporary_channel_id, ref channel_value_satoshis, ref output_script, ref user_channel_id, } => {
137 let mut temporary_channel_id_nonref = (*temporary_channel_id).clone();
138 let mut channel_value_satoshis_nonref = (*channel_value_satoshis).clone();
139 let mut output_script_nonref = (*output_script).clone();
140 let mut user_channel_id_nonref = (*user_channel_id).clone();
141 nativeEvent::FundingGenerationReady {
142 temporary_channel_id: temporary_channel_id_nonref.data,
143 channel_value_satoshis: channel_value_satoshis_nonref,
144 output_script: ::bitcoin::blockdata::script::Script::from(output_script_nonref.into_rust()),
145 user_channel_id: user_channel_id_nonref,
148 Event::PaymentReceived {ref payment_hash, ref payment_preimage, ref payment_secret, ref amt, ref user_payment_id, } => {
149 let mut payment_hash_nonref = (*payment_hash).clone();
150 let mut payment_preimage_nonref = (*payment_preimage).clone();
151 let mut local_payment_preimage_nonref = if payment_preimage_nonref.data == [0; 32] { None } else { Some( { ::lightning::ln::PaymentPreimage(payment_preimage_nonref.data) }) };
152 let mut payment_secret_nonref = (*payment_secret).clone();
153 let mut amt_nonref = (*amt).clone();
154 let mut user_payment_id_nonref = (*user_payment_id).clone();
155 nativeEvent::PaymentReceived {
156 payment_hash: ::lightning::ln::PaymentHash(payment_hash_nonref.data),
157 payment_preimage: local_payment_preimage_nonref,
158 payment_secret: ::lightning::ln::PaymentSecret(payment_secret_nonref.data),
160 user_payment_id: user_payment_id_nonref,
163 Event::PaymentSent {ref payment_preimage, } => {
164 let mut payment_preimage_nonref = (*payment_preimage).clone();
165 nativeEvent::PaymentSent {
166 payment_preimage: ::lightning::ln::PaymentPreimage(payment_preimage_nonref.data),
169 Event::PaymentFailed {ref payment_hash, ref rejected_by_dest, } => {
170 let mut payment_hash_nonref = (*payment_hash).clone();
171 let mut rejected_by_dest_nonref = (*rejected_by_dest).clone();
172 nativeEvent::PaymentFailed {
173 payment_hash: ::lightning::ln::PaymentHash(payment_hash_nonref.data),
174 rejected_by_dest: rejected_by_dest_nonref,
177 Event::PendingHTLCsForwardable {ref time_forwardable, } => {
178 let mut time_forwardable_nonref = (*time_forwardable).clone();
179 nativeEvent::PendingHTLCsForwardable {
180 time_forwardable: std::time::Duration::from_secs(time_forwardable_nonref),
183 Event::SpendableOutputs {ref outputs, } => {
184 let mut outputs_nonref = (*outputs).clone();
185 let mut local_outputs_nonref = Vec::new(); for mut item in outputs_nonref.into_rust().drain(..) { local_outputs_nonref.push( { item.into_native() }); };
186 nativeEvent::SpendableOutputs {
187 outputs: local_outputs_nonref,
193 pub(crate) fn into_native(self) -> nativeEvent {
195 Event::FundingGenerationReady {mut temporary_channel_id, mut channel_value_satoshis, mut output_script, mut user_channel_id, } => {
196 nativeEvent::FundingGenerationReady {
197 temporary_channel_id: temporary_channel_id.data,
198 channel_value_satoshis: channel_value_satoshis,
199 output_script: ::bitcoin::blockdata::script::Script::from(output_script.into_rust()),
200 user_channel_id: user_channel_id,
203 Event::PaymentReceived {mut payment_hash, mut payment_preimage, mut payment_secret, mut amt, mut user_payment_id, } => {
204 let mut local_payment_preimage = if payment_preimage.data == [0; 32] { None } else { Some( { ::lightning::ln::PaymentPreimage(payment_preimage.data) }) };
205 nativeEvent::PaymentReceived {
206 payment_hash: ::lightning::ln::PaymentHash(payment_hash.data),
207 payment_preimage: local_payment_preimage,
208 payment_secret: ::lightning::ln::PaymentSecret(payment_secret.data),
210 user_payment_id: user_payment_id,
213 Event::PaymentSent {mut payment_preimage, } => {
214 nativeEvent::PaymentSent {
215 payment_preimage: ::lightning::ln::PaymentPreimage(payment_preimage.data),
218 Event::PaymentFailed {mut payment_hash, mut rejected_by_dest, } => {
219 nativeEvent::PaymentFailed {
220 payment_hash: ::lightning::ln::PaymentHash(payment_hash.data),
221 rejected_by_dest: rejected_by_dest,
224 Event::PendingHTLCsForwardable {mut time_forwardable, } => {
225 nativeEvent::PendingHTLCsForwardable {
226 time_forwardable: std::time::Duration::from_secs(time_forwardable),
229 Event::SpendableOutputs {mut outputs, } => {
230 let mut local_outputs = Vec::new(); for mut item in outputs.into_rust().drain(..) { local_outputs.push( { item.into_native() }); };
231 nativeEvent::SpendableOutputs {
232 outputs: local_outputs,
238 pub(crate) fn from_native(native: &nativeEvent) -> Self {
240 nativeEvent::FundingGenerationReady {ref temporary_channel_id, ref channel_value_satoshis, ref output_script, ref user_channel_id, } => {
241 let mut temporary_channel_id_nonref = (*temporary_channel_id).clone();
242 let mut channel_value_satoshis_nonref = (*channel_value_satoshis).clone();
243 let mut output_script_nonref = (*output_script).clone();
244 let mut user_channel_id_nonref = (*user_channel_id).clone();
245 Event::FundingGenerationReady {
246 temporary_channel_id: crate::c_types::ThirtyTwoBytes { data: temporary_channel_id_nonref },
247 channel_value_satoshis: channel_value_satoshis_nonref,
248 output_script: output_script_nonref.into_bytes().into(),
249 user_channel_id: user_channel_id_nonref,
252 nativeEvent::PaymentReceived {ref payment_hash, ref payment_preimage, ref payment_secret, ref amt, ref user_payment_id, } => {
253 let mut payment_hash_nonref = (*payment_hash).clone();
254 let mut payment_preimage_nonref = (*payment_preimage).clone();
255 let mut local_payment_preimage_nonref = if payment_preimage_nonref.is_none() { crate::c_types::ThirtyTwoBytes::null() } else { { crate::c_types::ThirtyTwoBytes { data: (payment_preimage_nonref.unwrap()).0 } } };
256 let mut payment_secret_nonref = (*payment_secret).clone();
257 let mut amt_nonref = (*amt).clone();
258 let mut user_payment_id_nonref = (*user_payment_id).clone();
259 Event::PaymentReceived {
260 payment_hash: crate::c_types::ThirtyTwoBytes { data: payment_hash_nonref.0 },
261 payment_preimage: local_payment_preimage_nonref,
262 payment_secret: crate::c_types::ThirtyTwoBytes { data: payment_secret_nonref.0 },
264 user_payment_id: user_payment_id_nonref,
267 nativeEvent::PaymentSent {ref payment_preimage, } => {
268 let mut payment_preimage_nonref = (*payment_preimage).clone();
270 payment_preimage: crate::c_types::ThirtyTwoBytes { data: payment_preimage_nonref.0 },
273 nativeEvent::PaymentFailed {ref payment_hash, ref rejected_by_dest, } => {
274 let mut payment_hash_nonref = (*payment_hash).clone();
275 let mut rejected_by_dest_nonref = (*rejected_by_dest).clone();
276 Event::PaymentFailed {
277 payment_hash: crate::c_types::ThirtyTwoBytes { data: payment_hash_nonref.0 },
278 rejected_by_dest: rejected_by_dest_nonref,
281 nativeEvent::PendingHTLCsForwardable {ref time_forwardable, } => {
282 let mut time_forwardable_nonref = (*time_forwardable).clone();
283 Event::PendingHTLCsForwardable {
284 time_forwardable: time_forwardable_nonref.as_secs(),
287 nativeEvent::SpendableOutputs {ref outputs, } => {
288 let mut outputs_nonref = (*outputs).clone();
289 let mut local_outputs_nonref = Vec::new(); for mut item in outputs_nonref.drain(..) { local_outputs_nonref.push( { crate::lightning::chain::keysinterface::SpendableOutputDescriptor::native_into(item) }); };
290 Event::SpendableOutputs {
291 outputs: local_outputs_nonref.into(),
297 pub(crate) fn native_into(native: nativeEvent) -> Self {
299 nativeEvent::FundingGenerationReady {mut temporary_channel_id, mut channel_value_satoshis, mut output_script, mut user_channel_id, } => {
300 Event::FundingGenerationReady {
301 temporary_channel_id: crate::c_types::ThirtyTwoBytes { data: temporary_channel_id },
302 channel_value_satoshis: channel_value_satoshis,
303 output_script: output_script.into_bytes().into(),
304 user_channel_id: user_channel_id,
307 nativeEvent::PaymentReceived {mut payment_hash, mut payment_preimage, mut payment_secret, mut amt, mut user_payment_id, } => {
308 let mut local_payment_preimage = if payment_preimage.is_none() { crate::c_types::ThirtyTwoBytes::null() } else { { crate::c_types::ThirtyTwoBytes { data: (payment_preimage.unwrap()).0 } } };
309 Event::PaymentReceived {
310 payment_hash: crate::c_types::ThirtyTwoBytes { data: payment_hash.0 },
311 payment_preimage: local_payment_preimage,
312 payment_secret: crate::c_types::ThirtyTwoBytes { data: payment_secret.0 },
314 user_payment_id: user_payment_id,
317 nativeEvent::PaymentSent {mut payment_preimage, } => {
319 payment_preimage: crate::c_types::ThirtyTwoBytes { data: payment_preimage.0 },
322 nativeEvent::PaymentFailed {mut payment_hash, mut rejected_by_dest, } => {
323 Event::PaymentFailed {
324 payment_hash: crate::c_types::ThirtyTwoBytes { data: payment_hash.0 },
325 rejected_by_dest: rejected_by_dest,
328 nativeEvent::PendingHTLCsForwardable {mut time_forwardable, } => {
329 Event::PendingHTLCsForwardable {
330 time_forwardable: time_forwardable.as_secs(),
333 nativeEvent::SpendableOutputs {mut outputs, } => {
334 let mut local_outputs = Vec::new(); for mut item in outputs.drain(..) { local_outputs.push( { crate::lightning::chain::keysinterface::SpendableOutputDescriptor::native_into(item) }); };
335 Event::SpendableOutputs {
336 outputs: local_outputs.into(),
342 /// Frees any resources used by the Event
344 pub extern "C" fn Event_free(this_ptr: Event) { }
345 /// Creates a copy of the Event
347 pub extern "C" fn Event_clone(orig: &Event) -> Event {
351 /// Serialize the Event object into a byte array which can be read by Event_read
352 pub extern "C" fn Event_write(obj: &Event) -> crate::c_types::derived::CVec_u8Z {
353 crate::c_types::serialize_obj(&unsafe { &*obj }.to_native())
355 /// An event generated by ChannelManager which indicates a message should be sent to a peer (or
356 /// broadcast to most peers).
357 /// These events are handled by PeerManager::process_events if you are using a PeerManager.
361 pub enum MessageSendEvent {
362 /// Used to indicate that we've accepted a channel open and should send the accept_channel
363 /// message provided to the given peer.
365 /// The node_id of the node which should receive this message
366 node_id: crate::c_types::PublicKey,
367 /// The message which should be sent.
368 msg: crate::lightning::ln::msgs::AcceptChannel,
370 /// Used to indicate that we've initiated a channel open and should send the open_channel
371 /// message provided to the given peer.
373 /// The node_id of the node which should receive this message
374 node_id: crate::c_types::PublicKey,
375 /// The message which should be sent.
376 msg: crate::lightning::ln::msgs::OpenChannel,
378 /// Used to indicate that a funding_created message should be sent to the peer with the given node_id.
380 /// The node_id of the node which should receive this message
381 node_id: crate::c_types::PublicKey,
382 /// The message which should be sent.
383 msg: crate::lightning::ln::msgs::FundingCreated,
385 /// Used to indicate that a funding_signed message should be sent to the peer with the given node_id.
387 /// The node_id of the node which should receive this message
388 node_id: crate::c_types::PublicKey,
389 /// The message which should be sent.
390 msg: crate::lightning::ln::msgs::FundingSigned,
392 /// Used to indicate that a funding_locked message should be sent to the peer with the given node_id.
394 /// The node_id of the node which should receive these message(s)
395 node_id: crate::c_types::PublicKey,
396 /// The funding_locked message which should be sent.
397 msg: crate::lightning::ln::msgs::FundingLocked,
399 /// Used to indicate that an announcement_signatures message should be sent to the peer with the given node_id.
400 SendAnnouncementSignatures {
401 /// The node_id of the node which should receive these message(s)
402 node_id: crate::c_types::PublicKey,
403 /// The announcement_signatures message which should be sent.
404 msg: crate::lightning::ln::msgs::AnnouncementSignatures,
406 /// Used to indicate that a series of HTLC update messages, as well as a commitment_signed
407 /// message should be sent to the peer with the given node_id.
409 /// The node_id of the node which should receive these message(s)
410 node_id: crate::c_types::PublicKey,
411 /// The update messages which should be sent. ALL messages in the struct should be sent!
412 updates: crate::lightning::ln::msgs::CommitmentUpdate,
414 /// Used to indicate that a revoke_and_ack message should be sent to the peer with the given node_id.
416 /// The node_id of the node which should receive this message
417 node_id: crate::c_types::PublicKey,
418 /// The message which should be sent.
419 msg: crate::lightning::ln::msgs::RevokeAndACK,
421 /// Used to indicate that a closing_signed message should be sent to the peer with the given node_id.
423 /// The node_id of the node which should receive this message
424 node_id: crate::c_types::PublicKey,
425 /// The message which should be sent.
426 msg: crate::lightning::ln::msgs::ClosingSigned,
428 /// Used to indicate that a shutdown message should be sent to the peer with the given node_id.
430 /// The node_id of the node which should receive this message
431 node_id: crate::c_types::PublicKey,
432 /// The message which should be sent.
433 msg: crate::lightning::ln::msgs::Shutdown,
435 /// Used to indicate that a channel_reestablish message should be sent to the peer with the given node_id.
436 SendChannelReestablish {
437 /// The node_id of the node which should receive this message
438 node_id: crate::c_types::PublicKey,
439 /// The message which should be sent.
440 msg: crate::lightning::ln::msgs::ChannelReestablish,
442 /// Used to indicate that a channel_announcement and channel_update should be broadcast to all
443 /// peers (except the peer with node_id either msg.contents.node_id_1 or msg.contents.node_id_2).
445 /// Note that after doing so, you very likely (unless you did so very recently) want to call
446 /// ChannelManager::broadcast_node_announcement to trigger a BroadcastNodeAnnouncement event.
447 /// This ensures that any nodes which see our channel_announcement also have a relevant
448 /// node_announcement, including relevant feature flags which may be important for routing
449 /// through or to us.
450 BroadcastChannelAnnouncement {
451 /// The channel_announcement which should be sent.
452 msg: crate::lightning::ln::msgs::ChannelAnnouncement,
453 /// The followup channel_update which should be sent.
454 update_msg: crate::lightning::ln::msgs::ChannelUpdate,
456 /// Used to indicate that a node_announcement should be broadcast to all peers.
457 BroadcastNodeAnnouncement {
458 /// The node_announcement which should be sent.
459 msg: crate::lightning::ln::msgs::NodeAnnouncement,
461 /// Used to indicate that a channel_update should be broadcast to all peers.
462 BroadcastChannelUpdate {
463 /// The channel_update which should be sent.
464 msg: crate::lightning::ln::msgs::ChannelUpdate,
466 /// Broadcast an error downstream to be handled
468 /// The node_id of the node which should receive this message
469 node_id: crate::c_types::PublicKey,
470 /// The action which should be taken.
471 action: crate::lightning::ln::msgs::ErrorAction,
473 /// When a payment fails we may receive updates back from the hop where it failed. In such
474 /// cases this event is generated so that we can inform the network graph of this information.
475 PaymentFailureNetworkUpdate {
476 /// The channel/node update which should be sent to NetGraphMsgHandler
477 update: crate::lightning::ln::msgs::HTLCFailChannelUpdate,
479 /// Query a peer for channels with funding transaction UTXOs in a block range.
480 SendChannelRangeQuery {
481 /// The node_id of this message recipient
482 node_id: crate::c_types::PublicKey,
483 /// The query_channel_range which should be sent.
484 msg: crate::lightning::ln::msgs::QueryChannelRange,
486 /// Request routing gossip messages from a peer for a list of channels identified by
487 /// their short_channel_ids.
489 /// The node_id of this message recipient
490 node_id: crate::c_types::PublicKey,
491 /// The query_short_channel_ids which should be sent.
492 msg: crate::lightning::ln::msgs::QueryShortChannelIds,
494 /// Sends a reply to a channel range query. This may be one of several SendReplyChannelRange events
495 /// emitted during processing of the query.
496 SendReplyChannelRange {
497 /// The node_id of this message recipient
498 node_id: crate::c_types::PublicKey,
499 /// The reply_channel_range which should be sent.
500 msg: crate::lightning::ln::msgs::ReplyChannelRange,
503 use lightning::util::events::MessageSendEvent as nativeMessageSendEvent;
504 impl MessageSendEvent {
506 pub(crate) fn to_native(&self) -> nativeMessageSendEvent {
508 MessageSendEvent::SendAcceptChannel {ref node_id, ref msg, } => {
509 let mut node_id_nonref = (*node_id).clone();
510 let mut msg_nonref = (*msg).clone();
511 nativeMessageSendEvent::SendAcceptChannel {
512 node_id: node_id_nonref.into_rust(),
513 msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) },
516 MessageSendEvent::SendOpenChannel {ref node_id, ref msg, } => {
517 let mut node_id_nonref = (*node_id).clone();
518 let mut msg_nonref = (*msg).clone();
519 nativeMessageSendEvent::SendOpenChannel {
520 node_id: node_id_nonref.into_rust(),
521 msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) },
524 MessageSendEvent::SendFundingCreated {ref node_id, ref msg, } => {
525 let mut node_id_nonref = (*node_id).clone();
526 let mut msg_nonref = (*msg).clone();
527 nativeMessageSendEvent::SendFundingCreated {
528 node_id: node_id_nonref.into_rust(),
529 msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) },
532 MessageSendEvent::SendFundingSigned {ref node_id, ref msg, } => {
533 let mut node_id_nonref = (*node_id).clone();
534 let mut msg_nonref = (*msg).clone();
535 nativeMessageSendEvent::SendFundingSigned {
536 node_id: node_id_nonref.into_rust(),
537 msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) },
540 MessageSendEvent::SendFundingLocked {ref node_id, ref msg, } => {
541 let mut node_id_nonref = (*node_id).clone();
542 let mut msg_nonref = (*msg).clone();
543 nativeMessageSendEvent::SendFundingLocked {
544 node_id: node_id_nonref.into_rust(),
545 msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) },
548 MessageSendEvent::SendAnnouncementSignatures {ref node_id, ref msg, } => {
549 let mut node_id_nonref = (*node_id).clone();
550 let mut msg_nonref = (*msg).clone();
551 nativeMessageSendEvent::SendAnnouncementSignatures {
552 node_id: node_id_nonref.into_rust(),
553 msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) },
556 MessageSendEvent::UpdateHTLCs {ref node_id, ref updates, } => {
557 let mut node_id_nonref = (*node_id).clone();
558 let mut updates_nonref = (*updates).clone();
559 nativeMessageSendEvent::UpdateHTLCs {
560 node_id: node_id_nonref.into_rust(),
561 updates: *unsafe { Box::from_raw(updates_nonref.take_inner()) },
564 MessageSendEvent::SendRevokeAndACK {ref node_id, ref msg, } => {
565 let mut node_id_nonref = (*node_id).clone();
566 let mut msg_nonref = (*msg).clone();
567 nativeMessageSendEvent::SendRevokeAndACK {
568 node_id: node_id_nonref.into_rust(),
569 msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) },
572 MessageSendEvent::SendClosingSigned {ref node_id, ref msg, } => {
573 let mut node_id_nonref = (*node_id).clone();
574 let mut msg_nonref = (*msg).clone();
575 nativeMessageSendEvent::SendClosingSigned {
576 node_id: node_id_nonref.into_rust(),
577 msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) },
580 MessageSendEvent::SendShutdown {ref node_id, ref msg, } => {
581 let mut node_id_nonref = (*node_id).clone();
582 let mut msg_nonref = (*msg).clone();
583 nativeMessageSendEvent::SendShutdown {
584 node_id: node_id_nonref.into_rust(),
585 msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) },
588 MessageSendEvent::SendChannelReestablish {ref node_id, ref msg, } => {
589 let mut node_id_nonref = (*node_id).clone();
590 let mut msg_nonref = (*msg).clone();
591 nativeMessageSendEvent::SendChannelReestablish {
592 node_id: node_id_nonref.into_rust(),
593 msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) },
596 MessageSendEvent::BroadcastChannelAnnouncement {ref msg, ref update_msg, } => {
597 let mut msg_nonref = (*msg).clone();
598 let mut update_msg_nonref = (*update_msg).clone();
599 nativeMessageSendEvent::BroadcastChannelAnnouncement {
600 msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) },
601 update_msg: *unsafe { Box::from_raw(update_msg_nonref.take_inner()) },
604 MessageSendEvent::BroadcastNodeAnnouncement {ref msg, } => {
605 let mut msg_nonref = (*msg).clone();
606 nativeMessageSendEvent::BroadcastNodeAnnouncement {
607 msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) },
610 MessageSendEvent::BroadcastChannelUpdate {ref msg, } => {
611 let mut msg_nonref = (*msg).clone();
612 nativeMessageSendEvent::BroadcastChannelUpdate {
613 msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) },
616 MessageSendEvent::HandleError {ref node_id, ref action, } => {
617 let mut node_id_nonref = (*node_id).clone();
618 let mut action_nonref = (*action).clone();
619 nativeMessageSendEvent::HandleError {
620 node_id: node_id_nonref.into_rust(),
621 action: action_nonref.into_native(),
624 MessageSendEvent::PaymentFailureNetworkUpdate {ref update, } => {
625 let mut update_nonref = (*update).clone();
626 nativeMessageSendEvent::PaymentFailureNetworkUpdate {
627 update: update_nonref.into_native(),
630 MessageSendEvent::SendChannelRangeQuery {ref node_id, ref msg, } => {
631 let mut node_id_nonref = (*node_id).clone();
632 let mut msg_nonref = (*msg).clone();
633 nativeMessageSendEvent::SendChannelRangeQuery {
634 node_id: node_id_nonref.into_rust(),
635 msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) },
638 MessageSendEvent::SendShortIdsQuery {ref node_id, ref msg, } => {
639 let mut node_id_nonref = (*node_id).clone();
640 let mut msg_nonref = (*msg).clone();
641 nativeMessageSendEvent::SendShortIdsQuery {
642 node_id: node_id_nonref.into_rust(),
643 msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) },
646 MessageSendEvent::SendReplyChannelRange {ref node_id, ref msg, } => {
647 let mut node_id_nonref = (*node_id).clone();
648 let mut msg_nonref = (*msg).clone();
649 nativeMessageSendEvent::SendReplyChannelRange {
650 node_id: node_id_nonref.into_rust(),
651 msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) },
657 pub(crate) fn into_native(self) -> nativeMessageSendEvent {
659 MessageSendEvent::SendAcceptChannel {mut node_id, mut msg, } => {
660 nativeMessageSendEvent::SendAcceptChannel {
661 node_id: node_id.into_rust(),
662 msg: *unsafe { Box::from_raw(msg.take_inner()) },
665 MessageSendEvent::SendOpenChannel {mut node_id, mut msg, } => {
666 nativeMessageSendEvent::SendOpenChannel {
667 node_id: node_id.into_rust(),
668 msg: *unsafe { Box::from_raw(msg.take_inner()) },
671 MessageSendEvent::SendFundingCreated {mut node_id, mut msg, } => {
672 nativeMessageSendEvent::SendFundingCreated {
673 node_id: node_id.into_rust(),
674 msg: *unsafe { Box::from_raw(msg.take_inner()) },
677 MessageSendEvent::SendFundingSigned {mut node_id, mut msg, } => {
678 nativeMessageSendEvent::SendFundingSigned {
679 node_id: node_id.into_rust(),
680 msg: *unsafe { Box::from_raw(msg.take_inner()) },
683 MessageSendEvent::SendFundingLocked {mut node_id, mut msg, } => {
684 nativeMessageSendEvent::SendFundingLocked {
685 node_id: node_id.into_rust(),
686 msg: *unsafe { Box::from_raw(msg.take_inner()) },
689 MessageSendEvent::SendAnnouncementSignatures {mut node_id, mut msg, } => {
690 nativeMessageSendEvent::SendAnnouncementSignatures {
691 node_id: node_id.into_rust(),
692 msg: *unsafe { Box::from_raw(msg.take_inner()) },
695 MessageSendEvent::UpdateHTLCs {mut node_id, mut updates, } => {
696 nativeMessageSendEvent::UpdateHTLCs {
697 node_id: node_id.into_rust(),
698 updates: *unsafe { Box::from_raw(updates.take_inner()) },
701 MessageSendEvent::SendRevokeAndACK {mut node_id, mut msg, } => {
702 nativeMessageSendEvent::SendRevokeAndACK {
703 node_id: node_id.into_rust(),
704 msg: *unsafe { Box::from_raw(msg.take_inner()) },
707 MessageSendEvent::SendClosingSigned {mut node_id, mut msg, } => {
708 nativeMessageSendEvent::SendClosingSigned {
709 node_id: node_id.into_rust(),
710 msg: *unsafe { Box::from_raw(msg.take_inner()) },
713 MessageSendEvent::SendShutdown {mut node_id, mut msg, } => {
714 nativeMessageSendEvent::SendShutdown {
715 node_id: node_id.into_rust(),
716 msg: *unsafe { Box::from_raw(msg.take_inner()) },
719 MessageSendEvent::SendChannelReestablish {mut node_id, mut msg, } => {
720 nativeMessageSendEvent::SendChannelReestablish {
721 node_id: node_id.into_rust(),
722 msg: *unsafe { Box::from_raw(msg.take_inner()) },
725 MessageSendEvent::BroadcastChannelAnnouncement {mut msg, mut update_msg, } => {
726 nativeMessageSendEvent::BroadcastChannelAnnouncement {
727 msg: *unsafe { Box::from_raw(msg.take_inner()) },
728 update_msg: *unsafe { Box::from_raw(update_msg.take_inner()) },
731 MessageSendEvent::BroadcastNodeAnnouncement {mut msg, } => {
732 nativeMessageSendEvent::BroadcastNodeAnnouncement {
733 msg: *unsafe { Box::from_raw(msg.take_inner()) },
736 MessageSendEvent::BroadcastChannelUpdate {mut msg, } => {
737 nativeMessageSendEvent::BroadcastChannelUpdate {
738 msg: *unsafe { Box::from_raw(msg.take_inner()) },
741 MessageSendEvent::HandleError {mut node_id, mut action, } => {
742 nativeMessageSendEvent::HandleError {
743 node_id: node_id.into_rust(),
744 action: action.into_native(),
747 MessageSendEvent::PaymentFailureNetworkUpdate {mut update, } => {
748 nativeMessageSendEvent::PaymentFailureNetworkUpdate {
749 update: update.into_native(),
752 MessageSendEvent::SendChannelRangeQuery {mut node_id, mut msg, } => {
753 nativeMessageSendEvent::SendChannelRangeQuery {
754 node_id: node_id.into_rust(),
755 msg: *unsafe { Box::from_raw(msg.take_inner()) },
758 MessageSendEvent::SendShortIdsQuery {mut node_id, mut msg, } => {
759 nativeMessageSendEvent::SendShortIdsQuery {
760 node_id: node_id.into_rust(),
761 msg: *unsafe { Box::from_raw(msg.take_inner()) },
764 MessageSendEvent::SendReplyChannelRange {mut node_id, mut msg, } => {
765 nativeMessageSendEvent::SendReplyChannelRange {
766 node_id: node_id.into_rust(),
767 msg: *unsafe { Box::from_raw(msg.take_inner()) },
773 pub(crate) fn from_native(native: &nativeMessageSendEvent) -> Self {
775 nativeMessageSendEvent::SendAcceptChannel {ref node_id, ref msg, } => {
776 let mut node_id_nonref = (*node_id).clone();
777 let mut msg_nonref = (*msg).clone();
778 MessageSendEvent::SendAcceptChannel {
779 node_id: crate::c_types::PublicKey::from_rust(&node_id_nonref),
780 msg: crate::lightning::ln::msgs::AcceptChannel { inner: Box::into_raw(Box::new(msg_nonref)), is_owned: true },
783 nativeMessageSendEvent::SendOpenChannel {ref node_id, ref msg, } => {
784 let mut node_id_nonref = (*node_id).clone();
785 let mut msg_nonref = (*msg).clone();
786 MessageSendEvent::SendOpenChannel {
787 node_id: crate::c_types::PublicKey::from_rust(&node_id_nonref),
788 msg: crate::lightning::ln::msgs::OpenChannel { inner: Box::into_raw(Box::new(msg_nonref)), is_owned: true },
791 nativeMessageSendEvent::SendFundingCreated {ref node_id, ref msg, } => {
792 let mut node_id_nonref = (*node_id).clone();
793 let mut msg_nonref = (*msg).clone();
794 MessageSendEvent::SendFundingCreated {
795 node_id: crate::c_types::PublicKey::from_rust(&node_id_nonref),
796 msg: crate::lightning::ln::msgs::FundingCreated { inner: Box::into_raw(Box::new(msg_nonref)), is_owned: true },
799 nativeMessageSendEvent::SendFundingSigned {ref node_id, ref msg, } => {
800 let mut node_id_nonref = (*node_id).clone();
801 let mut msg_nonref = (*msg).clone();
802 MessageSendEvent::SendFundingSigned {
803 node_id: crate::c_types::PublicKey::from_rust(&node_id_nonref),
804 msg: crate::lightning::ln::msgs::FundingSigned { inner: Box::into_raw(Box::new(msg_nonref)), is_owned: true },
807 nativeMessageSendEvent::SendFundingLocked {ref node_id, ref msg, } => {
808 let mut node_id_nonref = (*node_id).clone();
809 let mut msg_nonref = (*msg).clone();
810 MessageSendEvent::SendFundingLocked {
811 node_id: crate::c_types::PublicKey::from_rust(&node_id_nonref),
812 msg: crate::lightning::ln::msgs::FundingLocked { inner: Box::into_raw(Box::new(msg_nonref)), is_owned: true },
815 nativeMessageSendEvent::SendAnnouncementSignatures {ref node_id, ref msg, } => {
816 let mut node_id_nonref = (*node_id).clone();
817 let mut msg_nonref = (*msg).clone();
818 MessageSendEvent::SendAnnouncementSignatures {
819 node_id: crate::c_types::PublicKey::from_rust(&node_id_nonref),
820 msg: crate::lightning::ln::msgs::AnnouncementSignatures { inner: Box::into_raw(Box::new(msg_nonref)), is_owned: true },
823 nativeMessageSendEvent::UpdateHTLCs {ref node_id, ref updates, } => {
824 let mut node_id_nonref = (*node_id).clone();
825 let mut updates_nonref = (*updates).clone();
826 MessageSendEvent::UpdateHTLCs {
827 node_id: crate::c_types::PublicKey::from_rust(&node_id_nonref),
828 updates: crate::lightning::ln::msgs::CommitmentUpdate { inner: Box::into_raw(Box::new(updates_nonref)), is_owned: true },
831 nativeMessageSendEvent::SendRevokeAndACK {ref node_id, ref msg, } => {
832 let mut node_id_nonref = (*node_id).clone();
833 let mut msg_nonref = (*msg).clone();
834 MessageSendEvent::SendRevokeAndACK {
835 node_id: crate::c_types::PublicKey::from_rust(&node_id_nonref),
836 msg: crate::lightning::ln::msgs::RevokeAndACK { inner: Box::into_raw(Box::new(msg_nonref)), is_owned: true },
839 nativeMessageSendEvent::SendClosingSigned {ref node_id, ref msg, } => {
840 let mut node_id_nonref = (*node_id).clone();
841 let mut msg_nonref = (*msg).clone();
842 MessageSendEvent::SendClosingSigned {
843 node_id: crate::c_types::PublicKey::from_rust(&node_id_nonref),
844 msg: crate::lightning::ln::msgs::ClosingSigned { inner: Box::into_raw(Box::new(msg_nonref)), is_owned: true },
847 nativeMessageSendEvent::SendShutdown {ref node_id, ref msg, } => {
848 let mut node_id_nonref = (*node_id).clone();
849 let mut msg_nonref = (*msg).clone();
850 MessageSendEvent::SendShutdown {
851 node_id: crate::c_types::PublicKey::from_rust(&node_id_nonref),
852 msg: crate::lightning::ln::msgs::Shutdown { inner: Box::into_raw(Box::new(msg_nonref)), is_owned: true },
855 nativeMessageSendEvent::SendChannelReestablish {ref node_id, ref msg, } => {
856 let mut node_id_nonref = (*node_id).clone();
857 let mut msg_nonref = (*msg).clone();
858 MessageSendEvent::SendChannelReestablish {
859 node_id: crate::c_types::PublicKey::from_rust(&node_id_nonref),
860 msg: crate::lightning::ln::msgs::ChannelReestablish { inner: Box::into_raw(Box::new(msg_nonref)), is_owned: true },
863 nativeMessageSendEvent::BroadcastChannelAnnouncement {ref msg, ref update_msg, } => {
864 let mut msg_nonref = (*msg).clone();
865 let mut update_msg_nonref = (*update_msg).clone();
866 MessageSendEvent::BroadcastChannelAnnouncement {
867 msg: crate::lightning::ln::msgs::ChannelAnnouncement { inner: Box::into_raw(Box::new(msg_nonref)), is_owned: true },
868 update_msg: crate::lightning::ln::msgs::ChannelUpdate { inner: Box::into_raw(Box::new(update_msg_nonref)), is_owned: true },
871 nativeMessageSendEvent::BroadcastNodeAnnouncement {ref msg, } => {
872 let mut msg_nonref = (*msg).clone();
873 MessageSendEvent::BroadcastNodeAnnouncement {
874 msg: crate::lightning::ln::msgs::NodeAnnouncement { inner: Box::into_raw(Box::new(msg_nonref)), is_owned: true },
877 nativeMessageSendEvent::BroadcastChannelUpdate {ref msg, } => {
878 let mut msg_nonref = (*msg).clone();
879 MessageSendEvent::BroadcastChannelUpdate {
880 msg: crate::lightning::ln::msgs::ChannelUpdate { inner: Box::into_raw(Box::new(msg_nonref)), is_owned: true },
883 nativeMessageSendEvent::HandleError {ref node_id, ref action, } => {
884 let mut node_id_nonref = (*node_id).clone();
885 let mut action_nonref = (*action).clone();
886 MessageSendEvent::HandleError {
887 node_id: crate::c_types::PublicKey::from_rust(&node_id_nonref),
888 action: crate::lightning::ln::msgs::ErrorAction::native_into(action_nonref),
891 nativeMessageSendEvent::PaymentFailureNetworkUpdate {ref update, } => {
892 let mut update_nonref = (*update).clone();
893 MessageSendEvent::PaymentFailureNetworkUpdate {
894 update: crate::lightning::ln::msgs::HTLCFailChannelUpdate::native_into(update_nonref),
897 nativeMessageSendEvent::SendChannelRangeQuery {ref node_id, ref msg, } => {
898 let mut node_id_nonref = (*node_id).clone();
899 let mut msg_nonref = (*msg).clone();
900 MessageSendEvent::SendChannelRangeQuery {
901 node_id: crate::c_types::PublicKey::from_rust(&node_id_nonref),
902 msg: crate::lightning::ln::msgs::QueryChannelRange { inner: Box::into_raw(Box::new(msg_nonref)), is_owned: true },
905 nativeMessageSendEvent::SendShortIdsQuery {ref node_id, ref msg, } => {
906 let mut node_id_nonref = (*node_id).clone();
907 let mut msg_nonref = (*msg).clone();
908 MessageSendEvent::SendShortIdsQuery {
909 node_id: crate::c_types::PublicKey::from_rust(&node_id_nonref),
910 msg: crate::lightning::ln::msgs::QueryShortChannelIds { inner: Box::into_raw(Box::new(msg_nonref)), is_owned: true },
913 nativeMessageSendEvent::SendReplyChannelRange {ref node_id, ref msg, } => {
914 let mut node_id_nonref = (*node_id).clone();
915 let mut msg_nonref = (*msg).clone();
916 MessageSendEvent::SendReplyChannelRange {
917 node_id: crate::c_types::PublicKey::from_rust(&node_id_nonref),
918 msg: crate::lightning::ln::msgs::ReplyChannelRange { inner: Box::into_raw(Box::new(msg_nonref)), is_owned: true },
924 pub(crate) fn native_into(native: nativeMessageSendEvent) -> Self {
926 nativeMessageSendEvent::SendAcceptChannel {mut node_id, mut msg, } => {
927 MessageSendEvent::SendAcceptChannel {
928 node_id: crate::c_types::PublicKey::from_rust(&node_id),
929 msg: crate::lightning::ln::msgs::AcceptChannel { inner: Box::into_raw(Box::new(msg)), is_owned: true },
932 nativeMessageSendEvent::SendOpenChannel {mut node_id, mut msg, } => {
933 MessageSendEvent::SendOpenChannel {
934 node_id: crate::c_types::PublicKey::from_rust(&node_id),
935 msg: crate::lightning::ln::msgs::OpenChannel { inner: Box::into_raw(Box::new(msg)), is_owned: true },
938 nativeMessageSendEvent::SendFundingCreated {mut node_id, mut msg, } => {
939 MessageSendEvent::SendFundingCreated {
940 node_id: crate::c_types::PublicKey::from_rust(&node_id),
941 msg: crate::lightning::ln::msgs::FundingCreated { inner: Box::into_raw(Box::new(msg)), is_owned: true },
944 nativeMessageSendEvent::SendFundingSigned {mut node_id, mut msg, } => {
945 MessageSendEvent::SendFundingSigned {
946 node_id: crate::c_types::PublicKey::from_rust(&node_id),
947 msg: crate::lightning::ln::msgs::FundingSigned { inner: Box::into_raw(Box::new(msg)), is_owned: true },
950 nativeMessageSendEvent::SendFundingLocked {mut node_id, mut msg, } => {
951 MessageSendEvent::SendFundingLocked {
952 node_id: crate::c_types::PublicKey::from_rust(&node_id),
953 msg: crate::lightning::ln::msgs::FundingLocked { inner: Box::into_raw(Box::new(msg)), is_owned: true },
956 nativeMessageSendEvent::SendAnnouncementSignatures {mut node_id, mut msg, } => {
957 MessageSendEvent::SendAnnouncementSignatures {
958 node_id: crate::c_types::PublicKey::from_rust(&node_id),
959 msg: crate::lightning::ln::msgs::AnnouncementSignatures { inner: Box::into_raw(Box::new(msg)), is_owned: true },
962 nativeMessageSendEvent::UpdateHTLCs {mut node_id, mut updates, } => {
963 MessageSendEvent::UpdateHTLCs {
964 node_id: crate::c_types::PublicKey::from_rust(&node_id),
965 updates: crate::lightning::ln::msgs::CommitmentUpdate { inner: Box::into_raw(Box::new(updates)), is_owned: true },
968 nativeMessageSendEvent::SendRevokeAndACK {mut node_id, mut msg, } => {
969 MessageSendEvent::SendRevokeAndACK {
970 node_id: crate::c_types::PublicKey::from_rust(&node_id),
971 msg: crate::lightning::ln::msgs::RevokeAndACK { inner: Box::into_raw(Box::new(msg)), is_owned: true },
974 nativeMessageSendEvent::SendClosingSigned {mut node_id, mut msg, } => {
975 MessageSendEvent::SendClosingSigned {
976 node_id: crate::c_types::PublicKey::from_rust(&node_id),
977 msg: crate::lightning::ln::msgs::ClosingSigned { inner: Box::into_raw(Box::new(msg)), is_owned: true },
980 nativeMessageSendEvent::SendShutdown {mut node_id, mut msg, } => {
981 MessageSendEvent::SendShutdown {
982 node_id: crate::c_types::PublicKey::from_rust(&node_id),
983 msg: crate::lightning::ln::msgs::Shutdown { inner: Box::into_raw(Box::new(msg)), is_owned: true },
986 nativeMessageSendEvent::SendChannelReestablish {mut node_id, mut msg, } => {
987 MessageSendEvent::SendChannelReestablish {
988 node_id: crate::c_types::PublicKey::from_rust(&node_id),
989 msg: crate::lightning::ln::msgs::ChannelReestablish { inner: Box::into_raw(Box::new(msg)), is_owned: true },
992 nativeMessageSendEvent::BroadcastChannelAnnouncement {mut msg, mut update_msg, } => {
993 MessageSendEvent::BroadcastChannelAnnouncement {
994 msg: crate::lightning::ln::msgs::ChannelAnnouncement { inner: Box::into_raw(Box::new(msg)), is_owned: true },
995 update_msg: crate::lightning::ln::msgs::ChannelUpdate { inner: Box::into_raw(Box::new(update_msg)), is_owned: true },
998 nativeMessageSendEvent::BroadcastNodeAnnouncement {mut msg, } => {
999 MessageSendEvent::BroadcastNodeAnnouncement {
1000 msg: crate::lightning::ln::msgs::NodeAnnouncement { inner: Box::into_raw(Box::new(msg)), is_owned: true },
1003 nativeMessageSendEvent::BroadcastChannelUpdate {mut msg, } => {
1004 MessageSendEvent::BroadcastChannelUpdate {
1005 msg: crate::lightning::ln::msgs::ChannelUpdate { inner: Box::into_raw(Box::new(msg)), is_owned: true },
1008 nativeMessageSendEvent::HandleError {mut node_id, mut action, } => {
1009 MessageSendEvent::HandleError {
1010 node_id: crate::c_types::PublicKey::from_rust(&node_id),
1011 action: crate::lightning::ln::msgs::ErrorAction::native_into(action),
1014 nativeMessageSendEvent::PaymentFailureNetworkUpdate {mut update, } => {
1015 MessageSendEvent::PaymentFailureNetworkUpdate {
1016 update: crate::lightning::ln::msgs::HTLCFailChannelUpdate::native_into(update),
1019 nativeMessageSendEvent::SendChannelRangeQuery {mut node_id, mut msg, } => {
1020 MessageSendEvent::SendChannelRangeQuery {
1021 node_id: crate::c_types::PublicKey::from_rust(&node_id),
1022 msg: crate::lightning::ln::msgs::QueryChannelRange { inner: Box::into_raw(Box::new(msg)), is_owned: true },
1025 nativeMessageSendEvent::SendShortIdsQuery {mut node_id, mut msg, } => {
1026 MessageSendEvent::SendShortIdsQuery {
1027 node_id: crate::c_types::PublicKey::from_rust(&node_id),
1028 msg: crate::lightning::ln::msgs::QueryShortChannelIds { inner: Box::into_raw(Box::new(msg)), is_owned: true },
1031 nativeMessageSendEvent::SendReplyChannelRange {mut node_id, mut msg, } => {
1032 MessageSendEvent::SendReplyChannelRange {
1033 node_id: crate::c_types::PublicKey::from_rust(&node_id),
1034 msg: crate::lightning::ln::msgs::ReplyChannelRange { inner: Box::into_raw(Box::new(msg)), is_owned: true },
1040 /// Frees any resources used by the MessageSendEvent
1042 pub extern "C" fn MessageSendEvent_free(this_ptr: MessageSendEvent) { }
1043 /// Creates a copy of the MessageSendEvent
1045 pub extern "C" fn MessageSendEvent_clone(orig: &MessageSendEvent) -> MessageSendEvent {
1048 /// A trait indicating an object may generate message send events
1050 pub struct MessageSendEventsProvider {
1051 /// An opaque pointer which is passed to your function implementations as an argument.
1052 /// This has no meaning in the LDK, and can be NULL or any other value.
1053 pub this_arg: *mut c_void,
1054 /// Gets the list of pending events which were generated by previous actions, clearing the list
1057 pub get_and_clear_pending_msg_events: extern "C" fn (this_arg: *const c_void) -> crate::c_types::derived::CVec_MessageSendEventZ,
1058 /// Frees any resources associated with this object given its this_arg pointer.
1059 /// Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed.
1060 pub free: Option<extern "C" fn(this_arg: *mut c_void)>,
1063 use lightning::util::events::MessageSendEventsProvider as rustMessageSendEventsProvider;
1064 impl rustMessageSendEventsProvider for MessageSendEventsProvider {
1065 fn get_and_clear_pending_msg_events(&self) -> Vec<lightning::util::events::MessageSendEvent> {
1066 let mut ret = (self.get_and_clear_pending_msg_events)(self.this_arg);
1067 let mut local_ret = Vec::new(); for mut item in ret.into_rust().drain(..) { local_ret.push( { item.into_native() }); };
1072 // We're essentially a pointer already, or at least a set of pointers, so allow us to be used
1073 // directly as a Deref trait in higher-level structs:
1074 impl std::ops::Deref for MessageSendEventsProvider {
1076 fn deref(&self) -> &Self {
1080 /// Calls the free function if one is set
1082 pub extern "C" fn MessageSendEventsProvider_free(this_ptr: MessageSendEventsProvider) { }
1083 impl Drop for MessageSendEventsProvider {
1084 fn drop(&mut self) {
1085 if let Some(f) = self.free {
1090 /// A trait indicating an object may generate events
1092 pub struct EventsProvider {
1093 /// An opaque pointer which is passed to your function implementations as an argument.
1094 /// This has no meaning in the LDK, and can be NULL or any other value.
1095 pub this_arg: *mut c_void,
1096 /// Gets the list of pending events which were generated by previous actions, clearing the list
1099 pub get_and_clear_pending_events: extern "C" fn (this_arg: *const c_void) -> crate::c_types::derived::CVec_EventZ,
1100 /// Frees any resources associated with this object given its this_arg pointer.
1101 /// Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed.
1102 pub free: Option<extern "C" fn(this_arg: *mut c_void)>,
1105 use lightning::util::events::EventsProvider as rustEventsProvider;
1106 impl rustEventsProvider for EventsProvider {
1107 fn get_and_clear_pending_events(&self) -> Vec<lightning::util::events::Event> {
1108 let mut ret = (self.get_and_clear_pending_events)(self.this_arg);
1109 let mut local_ret = Vec::new(); for mut item in ret.into_rust().drain(..) { local_ret.push( { item.into_native() }); };
1114 // We're essentially a pointer already, or at least a set of pointers, so allow us to be used
1115 // directly as a Deref trait in higher-level structs:
1116 impl std::ops::Deref for EventsProvider {
1118 fn deref(&self) -> &Self {
1122 /// Calls the free function if one is set
1124 pub extern "C" fn EventsProvider_free(this_ptr: EventsProvider) { }
1125 impl Drop for EventsProvider {
1126 fn drop(&mut self) {
1127 if let Some(f) = self.free {