X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=lightning%2Fsrc%2Fln%2Fmsgs.rs;h=b2825df4a9cdd606389c5cbfad640d607ba78b5f;hb=9f4dcd0bd55bd22d418bcee162d529d2953efc0d;hp=3bc4483aaa552a618c6df63a126edcad6e8d2705;hpb=e9ff38fbb26d2ded561ba69aa3c8231fc3f60d70;p=rust-lightning diff --git a/lightning/src/ln/msgs.rs b/lightning/src/ln/msgs.rs index 3bc4483a..b2825df4 100644 --- a/lightning/src/ln/msgs.rs +++ b/lightning/src/ln/msgs.rs @@ -28,8 +28,8 @@ use bitcoin::blockdata::constants::ChainHash; use bitcoin::secp256k1::PublicKey; use bitcoin::secp256k1::ecdsa::Signature; use bitcoin::{secp256k1, Witness}; -use bitcoin::blockdata::script::Script; -use bitcoin::hash_types::{Txid, BlockHash}; +use bitcoin::blockdata::script::ScriptBuf; +use bitcoin::hash_types::Txid; use crate::blinded_path::payment::ReceiveTlvs; use crate::ln::{ChannelId, PaymentPreimage, PaymentHash, PaymentSecret}; @@ -48,10 +48,11 @@ use core::ops::Deref; use core::str::FromStr; #[cfg(feature = "std")] use std::net::SocketAddr; +use core::fmt::Display; use crate::io::{self, Cursor, Read}; use crate::io_extras::read_to_end; -use crate::events::{MessageSendEventsProvider, OnionMessageProvider}; +use crate::events::MessageSendEventsProvider; use crate::util::chacha20poly1305rfc::ChaChaPolyReadAdapter; use crate::util::logger; use crate::util::ser::{LengthReadable, LengthReadableArgs, Readable, ReadableArgs, Writeable, Writer, WithoutLength, FixedLengthReader, HighZeroBytesDroppedBigSize, Hostname, TransactionU16LenLimited, BigSize}; @@ -64,11 +65,11 @@ pub(crate) const MAX_VALUE_MSAT: u64 = 21_000_000_0000_0000_000; #[cfg(taproot)] /// A partial signature that also contains the Musig2 nonce its signer used -#[derive(Clone, Debug, PartialEq, Eq)] +#[derive(Clone, Debug, Hash, PartialEq, Eq)] pub struct PartialSignatureWithNonce(pub musig2::types::PartialSignature, pub musig2::types::PublicNonce); /// An error in decoding a message or struct. -#[derive(Clone, Debug, PartialEq, Eq)] +#[derive(Clone, Debug, Hash, PartialEq, Eq)] pub enum DecodeError { /// A version byte specified something we don't know how to handle. /// @@ -95,7 +96,7 @@ pub enum DecodeError { /// An [`init`] message to be sent to or received from a peer. /// /// [`init`]: https://github.com/lightning/bolts/blob/master/01-messaging.md#the-init-message -#[derive(Clone, Debug, PartialEq, Eq)] +#[derive(Clone, Debug, Hash, PartialEq, Eq)] pub struct Init { /// The relevant features which the sender supports. pub features: InitFeatures, @@ -115,7 +116,7 @@ pub struct Init { /// An [`error`] message to be sent to or received from a peer. /// /// [`error`]: https://github.com/lightning/bolts/blob/master/01-messaging.md#the-error-and-warning-messages -#[derive(Clone, Debug, PartialEq, Eq)] +#[derive(Clone, Debug, Hash, PartialEq, Eq)] pub struct ErrorMessage { /// The channel ID involved in the error. /// @@ -133,7 +134,7 @@ pub struct ErrorMessage { /// A [`warning`] message to be sent to or received from a peer. /// /// [`warning`]: https://github.com/lightning/bolts/blob/master/01-messaging.md#the-error-and-warning-messages -#[derive(Clone, Debug, PartialEq, Eq)] +#[derive(Clone, Debug, Hash, PartialEq, Eq)] pub struct WarningMessage { /// The channel ID involved in the warning. /// @@ -150,7 +151,7 @@ pub struct WarningMessage { /// A [`ping`] message to be sent to or received from a peer. /// /// [`ping`]: https://github.com/lightning/bolts/blob/master/01-messaging.md#the-ping-and-pong-messages -#[derive(Clone, Debug, PartialEq, Eq)] +#[derive(Clone, Debug, Hash, PartialEq, Eq)] pub struct Ping { /// The desired response length. pub ponglen: u16, @@ -163,7 +164,7 @@ pub struct Ping { /// A [`pong`] message to be sent to or received from a peer. /// /// [`pong`]: https://github.com/lightning/bolts/blob/master/01-messaging.md#the-ping-and-pong-messages -#[derive(Clone, Debug, PartialEq, Eq)] +#[derive(Clone, Debug, Hash, PartialEq, Eq)] pub struct Pong { /// The pong packet size. /// @@ -176,10 +177,10 @@ pub struct Pong { /// Used in V1 channel establishment /// /// [`open_channel`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#the-open_channel-message -#[derive(Clone, Debug, PartialEq, Eq)] +#[derive(Clone, Debug, Hash, PartialEq, Eq)] pub struct OpenChannel { /// The genesis hash of the blockchain where the channel is to be opened - pub chain_hash: BlockHash, + pub chain_hash: ChainHash, /// A temporary channel ID, until the funding outpoint is announced pub temporary_channel_id: ChannelId, /// The channel value @@ -217,7 +218,7 @@ pub struct OpenChannel { /// The channel flags to be used pub channel_flags: u8, /// A request to pre-set the to-sender output's `scriptPubkey` for when we collaboratively close - pub shutdown_scriptpubkey: Option