Merge pull request #2441 from arik-so/2023-07-taproot-signer-wrapped
[rust-lightning] / lightning / src / events / mod.rs
index 77bf2f265fad9dafdec281b1fc410ccb89229a12..28313046433151bdb566beb5a2974bdd1d469908 100644 (file)
@@ -544,6 +544,11 @@ pub enum Event {
        /// payment is no longer retryable, due either to the [`Retry`] provided or
        /// [`ChannelManager::abandon_payment`] having been called for the corresponding payment.
        ///
+       /// In exceedingly rare cases, it is possible that an [`Event::PaymentFailed`] is generated for
+       /// a payment after an [`Event::PaymentSent`] event for this same payment has already been
+       /// received and processed. In this case, the [`Event::PaymentFailed`] event MUST be ignored,
+       /// and the payment MUST be treated as having succeeded.
+       ///
        /// [`Retry`]: crate::ln::channelmanager::Retry
        /// [`ChannelManager::abandon_payment`]: crate::ln::channelmanager::ChannelManager::abandon_payment
        PaymentFailed {
@@ -710,6 +715,10 @@ pub enum Event {
        SpendableOutputs {
                /// The outputs which you should store as spendable by you.
                outputs: Vec<SpendableOutputDescriptor>,
+               /// The `channel_id` indicating which channel the spendable outputs belong to.
+               ///
+               /// This will always be `Some` for events generated by LDK versions 0.0.117 and above.
+               channel_id: Option<[u8; 32]>,
        },
        /// This event is generated when a payment has been successfully forwarded through us and a
        /// forwarding fee earned.
@@ -995,10 +1004,11 @@ impl Writeable for Event {
                                // Note that we now ignore these on the read end as we'll re-generate them in
                                // ChannelManager, we write them here only for backwards compatibility.
                        },
-                       &Event::SpendableOutputs { ref outputs } => {
+                       &Event::SpendableOutputs { ref outputs, channel_id } => {
                                5u8.write(writer)?;
                                write_tlv_fields!(writer, {
                                        (0, WithoutLength(outputs), required),
+                                       (1, channel_id, option),
                                });
                        },
                        &Event::HTLCIntercepted { requested_next_hop_scid, payment_hash, inbound_amount_msat, expected_outbound_amount_msat, intercept_id } => {
@@ -1269,10 +1279,12 @@ impl MaybeReadable for Event {
                        5u8 => {
                                let f = || {
                                        let mut outputs = WithoutLength(Vec::new());
+                                       let mut channel_id: Option<[u8; 32]> = None;
                                        read_tlv_fields!(reader, {
                                                (0, outputs, required),
+                                               (1, channel_id, option),
                                        });
-                                       Ok(Some(Event::SpendableOutputs { outputs: outputs.0 }))
+                                       Ok(Some(Event::SpendableOutputs { outputs: outputs.0, channel_id }))
                                };
                                f()
                        },
@@ -1546,6 +1558,7 @@ impl MaybeReadable for Event {
 /// broadcast to most peers).
 /// These events are handled by PeerManager::process_events if you are using a PeerManager.
 #[derive(Clone, Debug)]
+#[cfg_attr(test, derive(PartialEq))]
 pub enum MessageSendEvent {
        /// Used to indicate that we've accepted a channel open and should send the accept_channel
        /// message provided to the given peer.