From: Matt Corallo Date: Wed, 4 Apr 2018 15:44:33 +0000 (-0400) Subject: impl more message encodings X-Git-Tag: v0.0.12~412^2~4 X-Git-Url: http://git.bitcoin.ninja/?a=commitdiff_plain;h=e9f9cda986a37a6d7d84f9f5856d06b477a2374f;p=rust-lightning impl more message encodings --- 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 } }