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
17 use bitcoin::hashes::Hash;
18 use crate::c_types::*;
20 /// An Event which you should probably take some action in response to.
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).
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
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.
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!).
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)!
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
81 payment_preimage: crate::c_types::ThirtyTwoBytes,
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)!
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,
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,
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.
109 /// The outputs which you should store as spendable by you.
110 outputs: crate::c_types::derived::CVec_SpendableOutputDescriptorZ,
113 use lightning::util::events::Event as nativeEvent;
116 pub(crate) fn to_native(&self) -> nativeEvent {
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,
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,
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),
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,
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),
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,
171 pub(crate) fn into_native(self) -> nativeEvent {
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,
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,
189 Event::PaymentSent {mut payment_preimage, } => {
190 nativeEvent::PaymentSent {
191 payment_preimage: ::lightning::ln::channelmanager::PaymentPreimage(payment_preimage.data),
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,
200 Event::PendingHTLCsForwardable {mut time_forwardable, } => {
201 nativeEvent::PendingHTLCsForwardable {
202 time_forwardable: std::time::Duration::from_secs(time_forwardable),
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,
214 pub(crate) fn from_native(native: &nativeEvent) -> Self {
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,
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,
239 nativeEvent::PaymentSent {ref payment_preimage, } => {
240 let mut payment_preimage_nonref = (*payment_preimage).clone();
242 payment_preimage: crate::c_types::ThirtyTwoBytes { data: payment_preimage_nonref.0 },
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,
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(),
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(),
269 pub(crate) fn native_into(native: nativeEvent) -> Self {
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,
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,
287 nativeEvent::PaymentSent {mut payment_preimage, } => {
289 payment_preimage: crate::c_types::ThirtyTwoBytes { data: payment_preimage.0 },
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,
298 nativeEvent::PendingHTLCsForwardable {mut time_forwardable, } => {
299 Event::PendingHTLCsForwardable {
300 time_forwardable: time_forwardable.as_secs(),
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(),
312 /// Frees any resources used by the Event
314 pub extern "C" fn Event_free(this_ptr: Event) { }
315 /// Creates a copy of the Event
317 pub extern "C" fn Event_clone(orig: &Event) -> Event {
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())
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.
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.
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,
340 /// Used to indicate that we've initiated a channel open and should send the open_channel
341 /// message provided to the given peer.
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,
348 /// Used to indicate that a funding_created message should be sent to the peer with the given node_id.
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,
355 /// Used to indicate that a funding_signed message should be sent to the peer with the given node_id.
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,
362 /// Used to indicate that a funding_locked message should be sent to the peer with the given node_id.
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,
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,
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.
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,
384 /// Used to indicate that a revoke_and_ack message should be sent to the peer with the given node_id.
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,
391 /// Used to indicate that a closing_signed message should be sent to the peer with the given node_id.
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,
398 /// Used to indicate that a shutdown message should be sent to the peer with the given node_id.
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,
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,
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).
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,
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,
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,
436 /// Broadcast an error downstream to be handled
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,
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,
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,
456 /// Request routing gossip messages from a peer for a list of channels identified by
457 /// their short_channel_ids.
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,
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,
473 use lightning::util::events::MessageSendEvent as nativeMessageSendEvent;
474 impl MessageSendEvent {
476 pub(crate) fn to_native(&self) -> nativeMessageSendEvent {
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()) },
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()) },
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()) },
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()) },
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()) },
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()) },
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()) },
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()) },
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()) },
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()) },
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()) },
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()) },
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()) },
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()) },
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(),
594 MessageSendEvent::PaymentFailureNetworkUpdate {ref update, } => {
595 let mut update_nonref = (*update).clone();
596 nativeMessageSendEvent::PaymentFailureNetworkUpdate {
597 update: update_nonref.into_native(),
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()) },
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()) },
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()) },
627 pub(crate) fn into_native(self) -> nativeMessageSendEvent {
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()) },
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()) },
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()) },
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()) },
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()) },
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()) },
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()) },
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()) },
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()) },
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()) },
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()) },
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()) },
701 MessageSendEvent::BroadcastNodeAnnouncement {mut msg, } => {
702 nativeMessageSendEvent::BroadcastNodeAnnouncement {
703 msg: *unsafe { Box::from_raw(msg.take_inner()) },
706 MessageSendEvent::BroadcastChannelUpdate {mut msg, } => {
707 nativeMessageSendEvent::BroadcastChannelUpdate {
708 msg: *unsafe { Box::from_raw(msg.take_inner()) },
711 MessageSendEvent::HandleError {mut node_id, mut action, } => {
712 nativeMessageSendEvent::HandleError {
713 node_id: node_id.into_rust(),
714 action: action.into_native(),
717 MessageSendEvent::PaymentFailureNetworkUpdate {mut update, } => {
718 nativeMessageSendEvent::PaymentFailureNetworkUpdate {
719 update: update.into_native(),
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()) },
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()) },
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()) },
743 pub(crate) fn from_native(native: &nativeMessageSendEvent) -> Self {
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 },
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 },
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 },
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 },
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 },
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 },
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 },
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 },
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 },
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 },
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 },
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 },
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 },
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 },
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),
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),
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 },
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 },
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 },
894 pub(crate) fn native_into(native: nativeMessageSendEvent) -> Self {
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 },
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 },
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 },
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 },
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 },
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 },
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 },
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 },
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 },
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 },
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 },
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 },
968 nativeMessageSendEvent::BroadcastNodeAnnouncement {mut msg, } => {
969 MessageSendEvent::BroadcastNodeAnnouncement {
970 msg: crate::ln::msgs::NodeAnnouncement { inner: Box::into_raw(Box::new(msg)), is_owned: true },
973 nativeMessageSendEvent::BroadcastChannelUpdate {mut msg, } => {
974 MessageSendEvent::BroadcastChannelUpdate {
975 msg: crate::ln::msgs::ChannelUpdate { inner: Box::into_raw(Box::new(msg)), is_owned: true },
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),
984 nativeMessageSendEvent::PaymentFailureNetworkUpdate {mut update, } => {
985 MessageSendEvent::PaymentFailureNetworkUpdate {
986 update: crate::ln::msgs::HTLCFailChannelUpdate::native_into(update),
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 },
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 },
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 },
1010 /// Frees any resources used by the MessageSendEvent
1012 pub extern "C" fn MessageSendEvent_free(this_ptr: MessageSendEvent) { }
1013 /// Creates a copy of the MessageSendEvent
1015 pub extern "C" fn MessageSendEvent_clone(orig: &MessageSendEvent) -> MessageSendEvent {
1018 /// A trait indicating an object may generate message send events
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
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)>,
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() }); };
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 {
1046 fn deref(&self) -> &Self {
1050 /// Calls the free function if one is set
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 {
1060 /// A trait indicating an object may generate events
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
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)>,
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() }); };
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 {
1088 fn deref(&self) -> &Self {
1092 /// Calls the free function if one is set
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 {