@@ -65,7 +65,6 @@ impl Writeable for ForwardTlvs {
6565 NextMessageHop :: NodeId ( pubkey) => ( Some ( pubkey) , None ) ,
6666 NextMessageHop :: ShortChannelId ( scid) => ( None , Some ( scid) ) ,
6767 } ;
68- // TODO: write padding
6968 encode_tlv_stream ! ( writer, {
7069 ( 2 , short_channel_id, option) ,
7170 ( 4 , next_node_id, option) ,
@@ -77,7 +76,6 @@ impl Writeable for ForwardTlvs {
7776
7877impl Writeable for ReceiveTlvs {
7978 fn write < W : Writer > ( & self , writer : & mut W ) -> Result < ( ) , io:: Error > {
80- // TODO: write padding
8179 encode_tlv_stream ! ( writer, {
8280 ( 65537 , self . context, option) ,
8381 } ) ;
@@ -138,17 +136,25 @@ pub(super) fn blinded_hops<T: secp256k1::Signing + secp256k1::Verification>(
138136) -> Result < Vec < BlindedHop > , secp256k1:: Error > {
139137 let pks = intermediate_nodes. iter ( ) . map ( |node| & node. node_id )
140138 . chain ( core:: iter:: once ( & recipient_node_id) ) ;
141- let tlvs = pks. clone ( )
139+ let tlvs: Vec < ControlTlvs > = pks. clone ( )
142140 . skip ( 1 ) // The first node's TLVs contains the next node's pubkey
143141 . zip ( intermediate_nodes. iter ( ) . map ( |node| node. short_channel_id ) )
144142 . map ( |( pubkey, scid) | match scid {
145143 Some ( scid) => NextMessageHop :: ShortChannelId ( scid) ,
146144 None => NextMessageHop :: NodeId ( * pubkey) ,
147145 } )
148146 . map ( |next_hop| ControlTlvs :: Forward ( ForwardTlvs { next_hop, next_blinding_override : None } ) )
149- . chain ( core:: iter:: once ( ControlTlvs :: Receive ( ReceiveTlvs { context : Some ( context) } ) ) ) ;
147+ . chain ( core:: iter:: once ( ControlTlvs :: Receive ( ReceiveTlvs { context : Some ( context) } ) ) )
148+ . collect ( ) ;
150149
151- utils:: construct_blinded_hops ( secp_ctx, pks, tlvs, session_priv)
150+ let max_length = tlvs. iter ( )
151+ . max_by_key ( |c| c. serialized_length ( ) )
152+ . map ( |c| c. serialized_length ( ) )
153+ . unwrap_or ( 0 ) ;
154+
155+ let length_tlvs = tlvs. into_iter ( ) . map ( move |tlv| ( max_length, tlv) ) ;
156+
157+ utils:: construct_blinded_hops ( secp_ctx, pks, length_tlvs, session_priv)
152158}
153159
154160// Advance the blinded onion message path by one hop, so make the second hop into the new
0 commit comments