From e9f9cda986a37a6d7d84f9f5856d06b477a2374f Mon Sep 17 00:00:00 2001 From: Matt Corallo Date: Wed, 4 Apr 2018 11:44:33 -0400 Subject: [PATCH] impl more message encodings --- src/ln/msgs.rs | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/ln/msgs.rs b/src/ln/msgs.rs index 5939c09b1..c48e05681 100644 --- a/src/ln/msgs.rs +++ b/src/ln/msgs.rs @@ -746,7 +746,11 @@ impl MsgDecodable for Shutdown { } impl MsgEncodable for Shutdown { fn encode(&self) -> Vec { - unimplemented!(); + let mut res = Vec::with_capacity(32 + 2 + self.scriptpubkey.len()); + res.extend_from_slice(&serialize(&self.channel_id).unwrap()); + res.extend_from_slice(&byte_utils::be16_to_array(self.scriptpubkey.len() as u16)); + res.extend_from_slice(&self.scriptpubkey[..]); + res } } @@ -765,7 +769,12 @@ impl MsgDecodable for ClosingSigned { } impl MsgEncodable for ClosingSigned { fn encode(&self) -> Vec { - unimplemented!(); + let mut res = Vec::with_capacity(32+8+64); + res.extend_from_slice(&serialize(&self.channel_id).unwrap()); + res.extend_from_slice(&byte_utils::be64_to_array(self.fee_satoshis)); + let secp_ctx = Secp256k1::without_caps(); + res.extend_from_slice(&self.signature.serialize_compact(&secp_ctx)); + res } } -- 2.39.5