Move accept_channel checks into `ChannelContext::do_accept_channel_checks`
[rust-lightning] / lightning / src / events / mod.rs
index d6d2da936e42927355be35c4a2453715521614d7..a1d1b3aa572470bda0bf984a7f07380648ad8e1a 100644 (file)
@@ -280,7 +280,21 @@ pub enum ClosureReason {
        /// Closure generated from [`ChannelManager::force_close_channel`], called by the user.
        ///
        /// [`ChannelManager::force_close_channel`]: crate::ln::channelmanager::ChannelManager::force_close_channel.
-       HolderForceClosed,
+       HolderForceClosed {
+               /// Whether or not the latest transaction was broadcasted when the channel was force
+               /// closed.
+               ///
+               /// Channels closed using [`ChannelManager::force_close_broadcasting_latest_txn`] will have
+               /// this field set to true, whereas channels closed using [`ChannelManager::force_close_without_broadcasting_txn`]
+               /// or force-closed prior to being funded will have this field set to false.
+               ///
+               /// This will be `None` for objects generated or written by LDK 0.0.123 and
+               /// earlier.
+               ///
+               /// [`ChannelManager::force_close_broadcasting_latest_txn`]: crate::ln::channelmanager::ChannelManager::force_close_broadcasting_latest_txn.
+               /// [`ChannelManager::force_close_without_broadcasting_txn`]: crate::ln::channelmanager::ChannelManager::force_close_without_broadcasting_txn.
+               broadcasted_latest_txn: Option<bool>
+       },
        /// The channel was closed after negotiating a cooperative close and we've now broadcasted
        /// the cooperative close transaction. Note the shutdown may have been initiated by us.
        ///
@@ -357,7 +371,14 @@ impl core::fmt::Display for ClosureReason {
                        ClosureReason::CounterpartyForceClosed { peer_msg } => {
                                f.write_fmt(format_args!("counterparty force-closed with message: {}", peer_msg))
                        },
-                       ClosureReason::HolderForceClosed => f.write_str("user force-closed the channel"),
+                       ClosureReason::HolderForceClosed { broadcasted_latest_txn } => {
+                               f.write_str("user force-closed the channel")?;
+                               if let Some(brodcasted) = broadcasted_latest_txn {
+                                       write!(f, " and {} the latest transaction", if *brodcasted { "broadcasted" } else { "elected not to broadcast" })
+                               } else {
+                                       Ok(())
+                               }
+                       },
                        ClosureReason::LegacyCooperativeClosure => f.write_str("the channel was cooperatively closed"),
                        ClosureReason::CounterpartyInitiatedCooperativeClosure => f.write_str("the channel was cooperatively closed by our peer"),
                        ClosureReason::LocallyInitiatedCooperativeClosure => f.write_str("the channel was cooperatively closed by us"),
@@ -384,7 +405,7 @@ impl core::fmt::Display for ClosureReason {
 impl_writeable_tlv_based_enum_upgradable!(ClosureReason,
        (0, CounterpartyForceClosed) => { (1, peer_msg, required) },
        (1, FundingTimedOut) => {},
-       (2, HolderForceClosed) => {},
+       (2, HolderForceClosed) => { (1, broadcasted_latest_txn, option) },
        (6, CommitmentTxConfirmed) => {},
        (4, LegacyCooperativeClosure) => {},
        (8, ProcessingError) => { (1, err, required) },
@@ -720,8 +741,16 @@ pub enum Event {
        /// Indicates a [`Bolt12Invoice`] in response to an [`InvoiceRequest`] or a [`Refund`] was
        /// received.
        ///
+       /// This event will only be generated if [`UserConfig::manually_handle_bolt12_invoices`] is set.
+       /// Use [`ChannelManager::send_payment_for_bolt12_invoice`] to pay the invoice or
+       /// [`ChannelManager::abandon_payment`] to abandon the associated payment. See those docs for
+       /// further details.
+       ///
        /// [`InvoiceRequest`]: crate::offers::invoice_request::InvoiceRequest
        /// [`Refund`]: crate::offers::refund::Refund
+       /// [`UserConfig::manually_handle_bolt12_invoices`]: crate::util::config::UserConfig::manually_handle_bolt12_invoices
+       /// [`ChannelManager::send_payment_for_bolt12_invoice`]: crate::ln::channelmanager::ChannelManager::send_payment_for_bolt12_invoice
+       /// [`ChannelManager::abandon_payment`]: crate::ln::channelmanager::ChannelManager::abandon_payment
        InvoiceReceived {
                /// The `payment_id` associated with payment for the invoice.
                payment_id: PaymentId,