X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=lightning-c-bindings%2Fsrc%2Flightning%2Futil%2Fevents.rs;h=7961f623bbc456c5ab50b8398cc3ddd0feca46fa;hb=033f4f3b2750dcd5afc8b158d7474242b29b24f3;hp=2aea6ac993cc766a7e9252f1504b85a33a40ae96;hpb=3eda14ff27fcb12a0d8c8b1130af95f5f4daeccb;p=ldk-c-bindings diff --git a/lightning-c-bindings/src/lightning/util/events.rs b/lightning-c-bindings/src/lightning/util/events.rs index 2aea6ac..7961f62 100644 --- a/lightning-c-bindings/src/lightning/util/events.rs +++ b/lightning-c-bindings/src/lightning/util/events.rs @@ -115,7 +115,8 @@ pub enum Event { /// now + 5*time_forwardable). time_forwardable: u64, }, - /// Used to indicate that an output was generated on-chain which you should know how to spend. + /// Used to indicate that an output which you should know how to spend was confirmed on chain + /// and is now spendable. /// Such an output will *not* ever be spent by rust-lightning, and are not at risk of your /// counterparty spending them due to some kind of timeout. Thus, you need to store them /// somewhere and spend them when you create on-chain transactions. @@ -459,6 +460,15 @@ pub enum MessageSendEvent { /// The channel_update which should be sent. msg: crate::lightning::ln::msgs::ChannelUpdate, }, + /// Used to indicate that a channel_update should be sent to a single peer. + /// In contrast to [`Self::BroadcastChannelUpdate`], this is used when the channel is a + /// private channel and we shouldn't be informing all of our peers of channel parameters. + SendChannelUpdate { + /// The node_id of the node which should receive this message + node_id: crate::c_types::PublicKey, + /// The channel_update which should be sent. + msg: crate::lightning::ln::msgs::ChannelUpdate, + }, /// Broadcast an error downstream to be handled HandleError { /// The node_id of the node which should receive this message @@ -609,6 +619,14 @@ impl MessageSendEvent { msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) }, } }, + MessageSendEvent::SendChannelUpdate {ref node_id, ref msg, } => { + let mut node_id_nonref = (*node_id).clone(); + let mut msg_nonref = (*msg).clone(); + nativeMessageSendEvent::SendChannelUpdate { + node_id: node_id_nonref.into_rust(), + msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) }, + } + }, MessageSendEvent::HandleError {ref node_id, ref action, } => { let mut node_id_nonref = (*node_id).clone(); let mut action_nonref = (*action).clone(); @@ -734,6 +752,12 @@ impl MessageSendEvent { msg: *unsafe { Box::from_raw(msg.take_inner()) }, } }, + MessageSendEvent::SendChannelUpdate {mut node_id, mut msg, } => { + nativeMessageSendEvent::SendChannelUpdate { + node_id: node_id.into_rust(), + msg: *unsafe { Box::from_raw(msg.take_inner()) }, + } + }, MessageSendEvent::HandleError {mut node_id, mut action, } => { nativeMessageSendEvent::HandleError { node_id: node_id.into_rust(), @@ -876,6 +900,14 @@ impl MessageSendEvent { msg: crate::lightning::ln::msgs::ChannelUpdate { inner: Box::into_raw(Box::new(msg_nonref)), is_owned: true }, } }, + nativeMessageSendEvent::SendChannelUpdate {ref node_id, ref msg, } => { + let mut node_id_nonref = (*node_id).clone(); + let mut msg_nonref = (*msg).clone(); + MessageSendEvent::SendChannelUpdate { + node_id: crate::c_types::PublicKey::from_rust(&node_id_nonref), + msg: crate::lightning::ln::msgs::ChannelUpdate { inner: Box::into_raw(Box::new(msg_nonref)), is_owned: true }, + } + }, nativeMessageSendEvent::HandleError {ref node_id, ref action, } => { let mut node_id_nonref = (*node_id).clone(); let mut action_nonref = (*action).clone(); @@ -1001,6 +1033,12 @@ impl MessageSendEvent { msg: crate::lightning::ln::msgs::ChannelUpdate { inner: Box::into_raw(Box::new(msg)), is_owned: true }, } }, + nativeMessageSendEvent::SendChannelUpdate {mut node_id, mut msg, } => { + MessageSendEvent::SendChannelUpdate { + node_id: crate::c_types::PublicKey::from_rust(&node_id), + msg: crate::lightning::ln::msgs::ChannelUpdate { inner: Box::into_raw(Box::new(msg)), is_owned: true }, + } + }, nativeMessageSendEvent::HandleError {mut node_id, mut action, } => { MessageSendEvent::HandleError { node_id: crate::c_types::PublicKey::from_rust(&node_id), @@ -1055,6 +1093,8 @@ pub struct MessageSendEventsProvider { /// 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, } +unsafe impl Send for MessageSendEventsProvider {} +unsafe impl Sync for MessageSendEventsProvider {} use lightning::util::events::MessageSendEventsProvider as rustMessageSendEventsProvider; impl rustMessageSendEventsProvider for MessageSendEventsProvider { @@ -1122,6 +1162,8 @@ pub struct EventsProvider { /// 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, } +unsafe impl Send for EventsProvider {} +unsafe impl Sync for EventsProvider {} use lightning::util::events::EventsProvider as rustEventsProvider; /// Calls the free function if one is set @@ -1148,6 +1190,8 @@ pub struct EventHandler { /// 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, } +unsafe impl Send for EventHandler {} +unsafe impl Sync for EventHandler {} use lightning::util::events::EventHandler as rustEventHandler; impl rustEventHandler for EventHandler {