BDR: Linearizing secp256k1 deps
[rust-lightning] / lightning / src / util / events.rs
index 2c00a133575d60d9923f1e9afb0501b9cc4fa706..76ec20209412a8ddc4865aa931c3265a5275f60e 100644 (file)
@@ -13,7 +13,7 @@ use util::ser::{Writeable, Writer, MaybeReadable, Readable};
 
 use bitcoin::blockdata::script::Script;
 
-use secp256k1::key::PublicKey;
+use bitcoin::secp256k1::key::PublicKey;
 
 use std::time::Duration;
 
@@ -51,10 +51,14 @@ pub enum Event {
        },
        /// 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 must call
-       /// ChannelManager::fail_htlc_backwards to free up resources for this HTLC.
+       /// Note that if the preimage is not known or the amount paid is incorrect, you should call
+       /// ChannelManager::fail_htlc_backwards to free up resources for this HTLC and avoid
+       /// network congestion.
        /// The amount paid should be considered 'incorrect' when it is less than or more than twice
        /// the amount expected.
+       /// If you fail to call either ChannelManager::claim_funds or
+       /// ChannelManager::fail_htlc_backwards within the HTLC's timeout, the HTLC will be
+       /// automatically failed.
        PaymentReceived {
                /// The hash for which the preimage should be handed to the ChannelManager.
                payment_hash: PaymentHash,
@@ -96,6 +100,8 @@ pub enum Event {
                rejected_by_dest: bool,
 #[cfg(test)]
                error_code: Option<u16>,
+#[cfg(test)]
+               error_data: Option<Vec<u8>>,
        },
        /// Used to indicate that ChannelManager::process_pending_htlc_forwards should be called at a
        /// time in the future.
@@ -142,12 +148,16 @@ impl Writeable for Event {
                        &Event::PaymentFailed { ref payment_hash, ref rejected_by_dest,
                                #[cfg(test)]
                                ref error_code,
+                               #[cfg(test)]
+                               ref error_data,
                        } => {
                                4u8.write(writer)?;
                                payment_hash.write(writer)?;
                                rejected_by_dest.write(writer)?;
                                #[cfg(test)]
                                error_code.write(writer)?;
+                               #[cfg(test)]
+                               error_data.write(writer)?;
                        },
                        &Event::PendingHTLCsForwardable { time_forwardable: _ } => {
                                5u8.write(writer)?;
@@ -186,6 +196,8 @@ impl MaybeReadable for Event {
                                        rejected_by_dest: Readable::read(reader)?,
                                        #[cfg(test)]
                                        error_code: Readable::read(reader)?,
+                                       #[cfg(test)]
+                                       error_data: Readable::read(reader)?,
                                })),
                        5u8 => Ok(Some(Event::PendingHTLCsForwardable {
                                        time_forwardable: Duration::from_secs(0)