@@ -12,7 +12,9 @@ use crate::prelude::*;
1212use crate :: ln:: msgs;
1313use crate :: ln:: msgs:: LightningError ;
1414use crate :: ln:: wire;
15+ use crate :: ln:: wire:: Type ;
1516use crate :: sign:: { NodeSigner , Recipient } ;
17+ use crate :: util:: ser:: Writeable ;
1618
1719use bitcoin:: hashes:: sha256:: Hash as Sha256 ;
1820use bitcoin:: hashes:: { Hash , HashEngine } ;
@@ -565,12 +567,14 @@ impl PeerChannelEncryptor {
565567 /// Encrypts the given message, returning the encrypted version.
566568 /// panics if the length of `message`, once encoded, is greater than 65535 or if the Noise
567569 /// handshake has not finished.
568- pub fn encrypt_message < M : wire:: Type > ( & mut self , message : & M ) -> Vec < u8 > {
570+ pub fn encrypt_message < T : wire:: Type > ( & mut self , message : wire :: Message < T > ) -> Vec < u8 > {
569571 // Allocate a buffer with 2KB, fitting most common messages. Reserve the first 16+2 bytes
570572 // for the 2-byte message type prefix and its MAC.
571573 let mut res = VecWriter ( Vec :: with_capacity ( MSG_BUF_ALLOC_SIZE ) ) ;
572574 res. 0 . resize ( 16 + 2 , 0 ) ;
573- wire:: write ( message, & mut res) . expect ( "In-memory messages must never fail to serialize" ) ;
575+
576+ message. type_id ( ) . write ( & mut res) . expect ( "In-memory messages must never fail to serialize" ) ;
577+ message. write ( & mut res) . expect ( "In-memory messages must never fail to serialize" ) ;
574578
575579 self . encrypt_message_with_header_0s ( & mut res. 0 ) ;
576580 res. 0
0 commit comments