features: advertise wumbo channels as supported
[rust-lightning] / lightning / src / util / events.rs
index a4a733c8e503eff05212d6570ada728a4cb95c1e..ea50398b5e54ad2d2d1c691dadd31b0f3fe341fb 100644 (file)
@@ -17,6 +17,7 @@
 use chain::keysinterface::SpendableOutputDescriptor;
 use ln::channelmanager::PaymentId;
 use ln::channel::FUNDING_CONF_DEADLINE_BLOCKS;
+use ln::features::ChannelTypeFeatures;
 use ln::msgs;
 use ln::msgs::DecodeError;
 use ln::{PaymentPreimage, PaymentHash, PaymentSecret};
@@ -29,7 +30,6 @@ use bitcoin::blockdata::script::Script;
 use bitcoin::hashes::Hash;
 use bitcoin::hashes::sha256::Hash as Sha256;
 use bitcoin::secp256k1::key::PublicKey;
-
 use io;
 use prelude::*;
 use core::time::Duration;
@@ -236,7 +236,7 @@ pub enum Event {
        /// Note that this does *not* indicate that all paths for an MPP payment have failed, see
        /// [`Event::PaymentFailed`] and [`all_paths_failed`].
        ///
-       /// [`all_paths_failed`]: Self::all_paths_failed
+       /// [`all_paths_failed`]: Self::PaymentPathFailed::all_paths_failed
        PaymentPathFailed {
                /// The id returned by [`ChannelManager::send_payment`] and used with
                /// [`ChannelManager::retry_payment`] and [`ChannelManager::abandon_payment`].
@@ -366,11 +366,15 @@ pub enum Event {
                /// The channel_id of the channel which has been closed. Note that on-chain transactions
                /// resolving the channel are likely still awaiting confirmation.
                channel_id: [u8; 32],
-               /// The `user_channel_id` value passed in to [`ChannelManager::create_channel`], or 0 for
-               /// an inbound channel. This will always be zero for objects serialized with LDK versions
-               /// prior to 0.0.102.
+               /// The `user_channel_id` value passed in to [`ChannelManager::create_channel`] for outbound
+               /// channels, or to [`ChannelManager::accept_inbound_channel`] for inbound channels if
+               /// [`UserConfig::manually_accept_inbound_channels`] config flag is set to true. Otherwise
+               /// `user_channel_id` will be 0 for an inbound channel.
+               /// This will always be zero for objects serialized with LDK versions prior to 0.0.102.
                ///
                /// [`ChannelManager::create_channel`]: crate::ln::channelmanager::ChannelManager::create_channel
+               /// [`ChannelManager::accept_inbound_channel`]: crate::ln::channelmanager::ChannelManager::accept_inbound_channel
+               /// [`UserConfig::manually_accept_inbound_channels`]: crate::util::config::UserConfig::manually_accept_inbound_channels
                user_channel_id: u64,
                /// The reason the channel was closed.
                reason: ClosureReason
@@ -403,6 +407,44 @@ pub enum Event {
                /// May contain a closed channel if the HTLC sent along the path was fulfilled on chain.
                path: Vec<RouteHop>,
        },
+       /// Indicates a request to open a new channel by a peer.
+       ///
+       /// To accept the request, call [`ChannelManager::accept_inbound_channel`]. To reject the
+       /// request, call [`ChannelManager::force_close_channel`].
+       ///
+       /// The event is only triggered when a new open channel request is received and the
+       /// [`UserConfig::manually_accept_inbound_channels`] config flag is set to true.
+       ///
+       /// [`ChannelManager::accept_inbound_channel`]: crate::ln::channelmanager::ChannelManager::accept_inbound_channel
+       /// [`ChannelManager::force_close_channel`]: crate::ln::channelmanager::ChannelManager::force_close_channel
+       /// [`UserConfig::manually_accept_inbound_channels`]: crate::util::config::UserConfig::manually_accept_inbound_channels
+       OpenChannelRequest {
+               /// The temporary channel ID of the channel requested to be opened.
+               ///
+               /// When responding to the request, the `temporary_channel_id` should be passed
+               /// back to the ChannelManager with [`ChannelManager::accept_inbound_channel`] to accept,
+               /// or to [`ChannelManager::force_close_channel`] to reject.
+               ///
+               /// [`ChannelManager::accept_inbound_channel`]: crate::ln::channelmanager::ChannelManager::accept_inbound_channel
+               /// [`ChannelManager::force_close_channel`]: crate::ln::channelmanager::ChannelManager::force_close_channel
+               temporary_channel_id: [u8; 32],
+               /// The node_id of the counterparty requesting to open the channel.
+               counterparty_node_id: PublicKey,
+               /// The channel value of the requested channel.
+               funding_satoshis: u64,
+               /// Our starting balance in the channel if the request is accepted, in milli-satoshi.
+               push_msat: u64,
+               /// The features that this channel will operate with. If you reject the channel, a
+               /// well-behaved counterparty may automatically re-attempt the channel with a new set of
+               /// feature flags.
+               ///
+               /// Note that if [`ChannelTypeFeatures::supports_scid_privacy`] returns true on this type,
+               /// the resulting [`ChannelManager`] will not be readable by versions of LDK prior to
+               /// 0.0.106.
+               ///
+               /// [`ChannelManager`]: crate::ln::channelmanager::ChannelManager
+               channel_type: ChannelTypeFeatures,
+       },
 }
 
 impl Writeable for Event {
@@ -515,6 +557,11 @@ impl Writeable for Event {
                                        (2, payment_hash, required),
                                })
                        },
+                       &Event::OpenChannelRequest { .. } => {
+                               17u8.write(writer)?;
+                               // We never write the OpenChannelRequest events as, upon disconnection, peers
+                               // drop any channels which have not yet exchanged funding_signed.
+                       },
                        // Note that, going forward, all new events must only write data inside of
                        // `write_tlv_fields`. Versions 0.0.101+ will ignore odd-numbered events that write
                        // data via `write_tlv_fields`.
@@ -707,6 +754,10 @@ impl MaybeReadable for Event {
                                };
                                f()
                        },
+                       17u8 => {
+                               // Value 17 is used for `Event::OpenChannelRequest`.
+                               Ok(None)
+                       },
                        // Versions prior to 0.0.100 did not ignore odd types, instead returning InvalidValue.
                        // Version 0.0.100 failed to properly ignore odd types, possibly resulting in corrupt
                        // reads.
@@ -873,7 +924,15 @@ pub enum MessageSendEvent {
                node_id: PublicKey,
                /// The reply_channel_range which should be sent.
                msg: msgs::ReplyChannelRange,
-       }
+       },
+       /// Sends a timestamp filter for inbound gossip. This should be sent on each new connection to
+       /// enable receiving gossip messages from the peer.
+       SendGossipTimestampFilter {
+               /// The node_id of this message recipient
+               node_id: PublicKey,
+               /// The gossip_timestamp_filter which should be sent.
+               msg: msgs::GossipTimestampFilter,
+       },
 }
 
 /// A trait indicating an object may generate message send events