@@ -17,7 +17,9 @@ use super::async_payments::AsyncPaymentsMessage;
1717use super :: dns_resolution:: DNSResolverMessage ;
1818use super :: messenger:: CustomOnionMessageHandler ;
1919use super :: offers:: OffersMessage ;
20- use crate :: blinded_path:: message:: { BlindedMessagePath , ForwardTlvs , NextMessageHop , ReceiveTlvs } ;
20+ use crate :: blinded_path:: message:: {
21+ BlindedMessagePath , DummyTlv , ForwardTlvs , NextMessageHop , ReceiveTlvs , UnauthenticatedDummyTlv ,
22+ } ;
2123use crate :: crypto:: streams:: { ChaChaPolyReadAdapter , ChaChaPolyWriteAdapter } ;
2224use crate :: ln:: msgs:: DecodeError ;
2325use crate :: ln:: onion_utils;
@@ -111,6 +113,8 @@ impl LengthReadable for Packet {
111113pub ( super ) enum Payload < T : OnionMessageContents > {
112114 /// This payload is for an intermediate hop.
113115 Forward ( ForwardControlTlvs ) ,
116+ /// This payload is dummy, and is inteded to be peeled.
117+ Dummy ( DummyControlTlvs ) ,
114118 /// This payload is for the final hop.
115119 Receive { control_tlvs : ReceiveControlTlvs , reply_path : Option < BlindedMessagePath > , message : T } ,
116120}
@@ -204,6 +208,11 @@ pub(super) enum ForwardControlTlvs {
204208 Unblinded ( ForwardTlvs ) ,
205209}
206210
211+ pub ( super ) enum DummyControlTlvs {
212+ /// See [`ForwardControlTlvs::Unblinded`]
213+ Unblinded ( DummyTlv ) ,
214+ }
215+
207216/// Receive control TLVs in their blinded and unblinded form.
208217pub ( super ) enum ReceiveControlTlvs {
209218 /// See [`ForwardControlTlvs::Blinded`].
@@ -234,6 +243,10 @@ impl<T: OnionMessageContents> Writeable for (Payload<T>, [u8; 32]) {
234243 let write_adapter = ChaChaPolyWriteAdapter :: new ( self . 1 , & control_tlvs) ;
235244 _encode_varint_length_prefixed_tlv ! ( w, { ( 4 , write_adapter, required) } )
236245 } ,
246+ Payload :: Dummy ( DummyControlTlvs :: Unblinded ( control_tlvs) ) => {
247+ let write_adapter = ChaChaPolyWriteAdapter :: new ( self . 1 , & control_tlvs) ;
248+ _encode_varint_length_prefixed_tlv ! ( w, { ( 4 , write_adapter, required) } )
249+ } ,
237250 Payload :: Receive {
238251 control_tlvs : ReceiveControlTlvs :: Unblinded ( control_tlvs) ,
239252 reply_path,
@@ -310,6 +323,9 @@ impl<H: CustomOnionMessageHandler + ?Sized, L: Logger + ?Sized> ReadableArgs<(Sh
310323 }
311324 Ok ( Payload :: Forward ( ForwardControlTlvs :: Unblinded ( tlvs) ) )
312325 } ,
326+ Some ( ChaChaPolyReadAdapter { readable : ControlTlvs :: Dummy ( tlvs) } ) => {
327+ Ok ( Payload :: Dummy ( DummyControlTlvs :: Unblinded ( tlvs) ) )
328+ } ,
313329 Some ( ChaChaPolyReadAdapter { readable : ControlTlvs :: Receive ( tlvs) } ) => {
314330 Ok ( Payload :: Receive {
315331 control_tlvs : ReceiveControlTlvs :: Unblinded ( tlvs) ,
@@ -328,6 +344,8 @@ impl<H: CustomOnionMessageHandler + ?Sized, L: Logger + ?Sized> ReadableArgs<(Sh
328344pub ( crate ) enum ControlTlvs {
329345 /// This onion message is intended to be forwarded.
330346 Forward ( ForwardTlvs ) ,
347+ /// This onion message is a dummy, and is intended to be peeled.
348+ Dummy ( DummyTlv ) ,
331349 /// This onion message is intended to be received.
332350 Receive ( ReceiveTlvs ) ,
333351}
@@ -343,6 +361,7 @@ impl Readable for ControlTlvs {
343361 ( 4 , next_node_id, option) ,
344362 ( 8 , next_blinding_override, option) ,
345363 ( 65537 , context, option) ,
364+ ( 65539 , authentication, option) ,
346365 } ) ;
347366
348367 let next_hop = match ( short_channel_id, next_node_id) {
@@ -363,7 +382,10 @@ impl Readable for ControlTlvs {
363382 } else if valid_recv_fmt {
364383 ControlTlvs :: Receive ( ReceiveTlvs { context } )
365384 } else {
366- return Err ( DecodeError :: InvalidValue ) ;
385+ ControlTlvs :: Dummy ( DummyTlv {
386+ dummy_tlv : UnauthenticatedDummyTlv { } ,
387+ authentication : authentication. ok_or ( DecodeError :: InvalidValue ) ?,
388+ } )
367389 } ;
368390
369391 Ok ( payload_fmt)
@@ -374,6 +396,7 @@ impl Writeable for ControlTlvs {
374396 fn write < W : Writer > ( & self , w : & mut W ) -> Result < ( ) , io:: Error > {
375397 match self {
376398 Self :: Forward ( tlvs) => tlvs. write ( w) ,
399+ Self :: Dummy ( tlvs) => tlvs. write ( w) ,
377400 Self :: Receive ( tlvs) => tlvs. write ( w) ,
378401 }
379402 }
0 commit comments