Handle sending and receiving warning messages
[rust-lightning] / lightning / src / ln / wire.rs
index d3cc257f5a6b18cb1776475b4fec69949521e1d6..2c77fd46b8d92f8730e19d65448665f2fd86c710 100644 (file)
@@ -35,6 +35,7 @@ pub trait CustomMessageReader {
 pub(crate) enum Message<T> where T: core::fmt::Debug + Type {
        Init(msgs::Init),
        Error(msgs::ErrorMessage),
+       Warning(msgs::WarningMessage),
        Ping(msgs::Ping),
        Pong(msgs::Pong),
        OpenChannel(msgs::OpenChannel),
@@ -74,6 +75,7 @@ impl<T> Message<T> where T: core::fmt::Debug + Type {
                match self {
                        &Message::Init(ref msg) => msg.type_id(),
                        &Message::Error(ref msg) => msg.type_id(),
+                       &Message::Warning(ref msg) => msg.type_id(),
                        &Message::Ping(ref msg) => msg.type_id(),
                        &Message::Pong(ref msg) => msg.type_id(),
                        &Message::OpenChannel(ref msg) => msg.type_id(),
@@ -133,6 +135,9 @@ where
                msgs::ErrorMessage::TYPE => {
                        Ok(Message::Error(Readable::read(buffer)?))
                },
+               msgs::WarningMessage::TYPE => {
+                       Ok(Message::Warning(Readable::read(buffer)?))
+               },
                msgs::Ping::TYPE => {
                        Ok(Message::Ping(Readable::read(buffer)?))
                },
@@ -264,6 +269,10 @@ impl Encode for msgs::ErrorMessage {
        const TYPE: u16 = 17;
 }
 
+impl Encode for msgs::WarningMessage {
+       const TYPE: u16 = 1;
+}
+
 impl Encode for msgs::Ping {
        const TYPE: u16 = 18;
 }