X-Git-Url: http://git.bitcoin.ninja/index.cgi?p=ldk-c-bindings;a=blobdiff_plain;f=lightning-c-bindings%2Fsrc%2Futil%2Fevents.rs;h=295878e332524ae59a98ab82d3bcb30e2642c2ab;hp=3ec8def633d01bd28e3391e92ef19697ca73019a;hb=933eac0670cad94354d73ef144cbaf2c0e81be50;hpb=04fcb2d0d013cfb63ed656de156f0659f1b1411e diff --git a/lightning-c-bindings/src/util/events.rs b/lightning-c-bindings/src/util/events.rs index 3ec8def..295878e 100644 --- a/lightning-c-bindings/src/util/events.rs +++ b/lightning-c-bindings/src/util/events.rs @@ -1,3 +1,11 @@ +// This file is Copyright its original authors, visible in version control +// history and in the source files from which this was generated. +// +// This file is licensed under the license available in the LICENSE or LICENSE.md +// file in the root of this repository or, if no such file exists, the same +// license as that which applies to the original source files from which this +// source was automatically generated. + //! Events are returned from various bits in the library which indicate some action must be taken //! by the client. //! @@ -34,16 +42,6 @@ pub enum Event { /// The value passed in to ChannelManager::create_channel user_channel_id: u64, }, - /// Used to indicate that the client may now broadcast the funding transaction it created for a - /// channel. Broadcasting such a transaction prior to this event may lead to our counterparty - /// trivially stealing all funds in the funding transaction! - FundingBroadcastSafe { - /// The output, which was passed to ChannelManager::funding_transaction_generated, which is - /// now safe to broadcast. - funding_txo: crate::chain::transaction::OutPoint, - /// The value passed in to ChannelManager::create_channel - user_channel_id: u64, - }, /// Indicates we've received money! Just gotta dig out that payment preimage and feed it to /// ChannelManager::claim_funds to get it.... /// Note that if the preimage is not known or the amount paid is incorrect, you should call @@ -129,14 +127,6 @@ impl Event { user_channel_id: user_channel_id_nonref, } }, - Event::FundingBroadcastSafe {ref funding_txo, ref user_channel_id, } => { - let mut funding_txo_nonref = (*funding_txo).clone(); - let mut user_channel_id_nonref = (*user_channel_id).clone(); - nativeEvent::FundingBroadcastSafe { - funding_txo: *unsafe { Box::from_raw(funding_txo_nonref.take_inner()) }, - user_channel_id: user_channel_id_nonref, - } - }, Event::PaymentReceived {ref payment_hash, ref payment_secret, ref amt, } => { let mut payment_hash_nonref = (*payment_hash).clone(); let mut payment_secret_nonref = (*payment_secret).clone(); @@ -188,12 +178,6 @@ impl Event { user_channel_id: user_channel_id, } }, - Event::FundingBroadcastSafe {mut funding_txo, mut user_channel_id, } => { - nativeEvent::FundingBroadcastSafe { - funding_txo: *unsafe { Box::from_raw(funding_txo.take_inner()) }, - user_channel_id: user_channel_id, - } - }, Event::PaymentReceived {mut payment_hash, mut payment_secret, mut amt, } => { let mut local_payment_secret = if payment_secret.data == [0; 32] { None } else { Some( { ::lightning::ln::channelmanager::PaymentSecret(payment_secret.data) }) }; nativeEvent::PaymentReceived { @@ -241,14 +225,6 @@ impl Event { user_channel_id: user_channel_id_nonref, } }, - nativeEvent::FundingBroadcastSafe {ref funding_txo, ref user_channel_id, } => { - let mut funding_txo_nonref = (*funding_txo).clone(); - let mut user_channel_id_nonref = (*user_channel_id).clone(); - Event::FundingBroadcastSafe { - funding_txo: crate::chain::transaction::OutPoint { inner: Box::into_raw(Box::new(funding_txo_nonref)), is_owned: true }, - user_channel_id: user_channel_id_nonref, - } - }, nativeEvent::PaymentReceived {ref payment_hash, ref payment_secret, ref amt, } => { let mut payment_hash_nonref = (*payment_hash).clone(); let mut payment_secret_nonref = (*payment_secret).clone(); @@ -300,12 +276,6 @@ impl Event { user_channel_id: user_channel_id, } }, - nativeEvent::FundingBroadcastSafe {mut funding_txo, mut user_channel_id, } => { - Event::FundingBroadcastSafe { - funding_txo: crate::chain::transaction::OutPoint { inner: Box::into_raw(Box::new(funding_txo)), is_owned: true }, - user_channel_id: user_channel_id, - } - }, nativeEvent::PaymentReceived {mut payment_hash, mut payment_secret, mut amt, } => { 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 } } }; Event::PaymentReceived { @@ -491,6 +461,14 @@ pub enum MessageSendEvent { /// The query_short_channel_ids which should be sent. msg: crate::ln::msgs::QueryShortChannelIds, }, + /// Sends a reply to a channel range query. This may be one of several SendReplyChannelRange events + /// emitted during processing of the query. + SendReplyChannelRange { + /// The node_id of this message recipient + node_id: crate::c_types::PublicKey, + /// The reply_channel_range which should be sent. + msg: crate::ln::msgs::ReplyChannelRange, + }, } use lightning::util::events::MessageSendEvent as nativeMessageSendEvent; impl MessageSendEvent { @@ -635,6 +613,14 @@ impl MessageSendEvent { msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) }, } }, + MessageSendEvent::SendReplyChannelRange {ref node_id, ref msg, } => { + let mut node_id_nonref = (*node_id).clone(); + let mut msg_nonref = (*msg).clone(); + nativeMessageSendEvent::SendReplyChannelRange { + node_id: node_id_nonref.into_rust(), + msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) }, + } + }, } } #[allow(unused)] @@ -745,6 +731,12 @@ impl MessageSendEvent { msg: *unsafe { Box::from_raw(msg.take_inner()) }, } }, + MessageSendEvent::SendReplyChannelRange {mut node_id, mut msg, } => { + nativeMessageSendEvent::SendReplyChannelRange { + node_id: node_id.into_rust(), + msg: *unsafe { Box::from_raw(msg.take_inner()) }, + } + }, } } #[allow(unused)] @@ -888,6 +880,14 @@ impl MessageSendEvent { msg: crate::ln::msgs::QueryShortChannelIds { inner: Box::into_raw(Box::new(msg_nonref)), is_owned: true }, } }, + nativeMessageSendEvent::SendReplyChannelRange {ref node_id, ref msg, } => { + let mut node_id_nonref = (*node_id).clone(); + let mut msg_nonref = (*msg).clone(); + MessageSendEvent::SendReplyChannelRange { + node_id: crate::c_types::PublicKey::from_rust(&node_id_nonref), + msg: crate::ln::msgs::ReplyChannelRange { inner: Box::into_raw(Box::new(msg_nonref)), is_owned: true }, + } + }, } } #[allow(unused)] @@ -998,6 +998,12 @@ impl MessageSendEvent { msg: crate::ln::msgs::QueryShortChannelIds { inner: Box::into_raw(Box::new(msg)), is_owned: true }, } }, + nativeMessageSendEvent::SendReplyChannelRange {mut node_id, mut msg, } => { + MessageSendEvent::SendReplyChannelRange { + node_id: crate::c_types::PublicKey::from_rust(&node_id), + msg: crate::ln::msgs::ReplyChannelRange { inner: Box::into_raw(Box::new(msg)), is_owned: true }, + } + }, } } } @@ -1019,8 +1025,8 @@ pub struct MessageSendEventsProvider { /// in the process. #[must_use] pub get_and_clear_pending_msg_events: extern "C" fn (this_arg: *const c_void) -> crate::c_types::derived::CVec_MessageSendEventZ, -/// Frees any resources associated with this object given its this_arg pointer. -/// Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. + /// Frees any resources associated with this object given its this_arg pointer. + /// Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. pub free: Option, } @@ -1061,8 +1067,8 @@ pub struct EventsProvider { /// in the process. #[must_use] pub get_and_clear_pending_events: extern "C" fn (this_arg: *const c_void) -> crate::c_types::derived::CVec_EventZ, -/// Frees any resources associated with this object given its this_arg pointer. -/// Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. + /// Frees any resources associated with this object given its this_arg pointer. + /// Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. pub free: Option, }