Merge pull request #307 from dongcarl/2019-02-derive-partialeq
[rust-lightning] / src / ln / msgs.rs
index 4c6524afbe62aa04cb9bda89d937578c4fbc19f4..f00dc34a50024a48d36c9a0ebf3c0dc695567f3b 100644 (file)
@@ -8,7 +8,7 @@
 //!
 //! Note that if you go with such an architecture (instead of passing raw socket events to a
 //! non-internet-facing system) you trust the frontend internet-facing system to not lie about the
-//! source node_id of the mssage, however this does allow you to significantly reduce bandwidth
+//! source node_id of the message, however this does allow you to significantly reduce bandwidth
 //! between the systems as routing messages can represent a significant chunk of bandwidth usage
 //! (especially for non-channel-publicly-announcing nodes). As an alternate design which avoids
 //! this issue, if you have sufficient bidirectional bandwidth between your systems, you may send
@@ -16,7 +16,7 @@
 //! track the network on the less-secure system.
 
 use secp256k1::key::PublicKey;
-use secp256k1::{Secp256k1, Signature};
+use secp256k1::Signature;
 use secp256k1;
 use bitcoin::util::hash::Sha256dHash;
 use bitcoin::blockdata::script::Script;
@@ -337,25 +337,25 @@ pub struct AnnouncementSignatures {
 /// An address which can be used to connect to a remote peer
 #[derive(PartialEq, Clone)]
 pub enum NetAddress {
-       /// An IPv4 address/port on which the peer is listenting.
+       /// An IPv4 address/port on which the peer is listening.
        IPv4 {
                /// The 4-byte IPv4 address
                addr: [u8; 4],
-               /// The port on which the node is listenting
+               /// The port on which the node is listening
                port: u16,
        },
-       /// An IPv6 address/port on which the peer is listenting.
+       /// An IPv6 address/port on which the peer is listening.
        IPv6 {
                /// The 16-byte IPv6 address
                addr: [u8; 16],
-               /// The port on which the node is listenting
+               /// The port on which the node is listening
                port: u16,
        },
        /// An old-style Tor onion address/port on which the peer is listening.
        OnionV2 {
                /// The bytes (usually encoded in base32 with ".onion" appended)
                addr: [u8; 10],
-               /// The port on which the node is listenting
+               /// The port on which the node is listening
                port: u16,
        },
        /// A new-style Tor onion address/port on which the peer is listening.
@@ -368,7 +368,7 @@ pub enum NetAddress {
                checksum: u16,
                /// The version byte, as defined by the Tor Onion v3 spec.
                version: u8,
-               /// The port on which the node is listenting
+               /// The port on which the node is listening
                port: u16,
        },
 }
@@ -555,12 +555,18 @@ pub struct HandleError { //TODO: rename me
 /// transaction updates if they were pending.
 #[derive(PartialEq, Clone)]
 pub struct CommitmentUpdate {
-       pub(crate) update_add_htlcs: Vec<UpdateAddHTLC>,
-       pub(crate) update_fulfill_htlcs: Vec<UpdateFulfillHTLC>,
-       pub(crate) update_fail_htlcs: Vec<UpdateFailHTLC>,
-       pub(crate) update_fail_malformed_htlcs: Vec<UpdateFailMalformedHTLC>,
-       pub(crate) update_fee: Option<UpdateFee>,
-       pub(crate) commitment_signed: CommitmentSigned,
+       /// update_add_htlc messages which should be sent
+       pub update_add_htlcs: Vec<UpdateAddHTLC>,
+       /// update_fulfill_htlc messages which should be sent
+       pub update_fulfill_htlcs: Vec<UpdateFulfillHTLC>,
+       /// update_fail_htlc messages which should be sent
+       pub update_fail_htlcs: Vec<UpdateFailHTLC>,
+       /// update_fail_malformed_htlc messages which should be sent
+       pub update_fail_malformed_htlcs: Vec<UpdateFailMalformedHTLC>,
+       /// An update_fee message which should be sent
+       pub update_fee: Option<UpdateFee>,
+       /// Finally, the commitment_signed message which should be sent
+       pub commitment_signed: CommitmentSigned,
 }
 
 /// The information we received from a peer along the route of a payment we originated. This is
@@ -1024,7 +1030,7 @@ impl<R: Read> Readable<R> for OnionPacket {
                        public_key: {
                                let mut buf = [0u8;33];
                                r.read_exact(&mut buf)?;
-                               PublicKey::from_slice(&Secp256k1::without_caps(), &buf)
+                               PublicKey::from_slice(&buf)
                        },
                        hop_data: Readable::read(r)?,
                        hmac: Readable::read(r)?,
@@ -1407,7 +1413,7 @@ mod tests {
        fn encoding_channel_reestablish_with_secret() {
                let public_key = {
                        let secp_ctx = Secp256k1::new();
-                       PublicKey::from_secret_key(&secp_ctx, &SecretKey::from_slice(&secp_ctx, &hex::decode("0101010101010101010101010101010101010101010101010101010101010101").unwrap()[..]).unwrap())
+                       PublicKey::from_secret_key(&secp_ctx, &SecretKey::from_slice(&hex::decode("0101010101010101010101010101010101010101010101010101010101010101").unwrap()[..]).unwrap())
                };
 
                let cr = msgs::ChannelReestablish {