@@ -17,7 +17,10 @@ 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 ,
22+ UnauthenticatedDummyTlv ,
23+ } ;
2124use crate :: crypto:: streams:: { ChaChaPolyReadAdapter , ChaChaPolyWriteAdapter } ;
2225use crate :: ln:: msgs:: DecodeError ;
2326use crate :: ln:: onion_utils;
@@ -111,6 +114,8 @@ impl LengthReadable for Packet {
111114pub ( super ) enum Payload < T : OnionMessageContents > {
112115 /// This payload is for an intermediate hop.
113116 Forward ( ForwardControlTlvs ) ,
117+ /// This payload is dummy, and is inteded to be peeled.
118+ Dummy ( DummyControlTlvs ) ,
114119 /// This payload is for the final hop.
115120 Receive { control_tlvs : ReceiveControlTlvs , reply_path : Option < BlindedMessagePath > , message : T } ,
116121}
@@ -204,6 +209,11 @@ pub(super) enum ForwardControlTlvs {
204209 Unblinded ( ForwardTlvs ) ,
205210}
206211
212+ pub ( super ) enum DummyControlTlvs {
213+ /// See [`ForwardControlTlvs::Unblinded`]
214+ Unblinded ( DummyTlv ) ,
215+ }
216+
207217/// Receive control TLVs in their blinded and unblinded form.
208218pub ( super ) enum ReceiveControlTlvs {
209219 /// See [`ForwardControlTlvs::Blinded`].
@@ -234,6 +244,10 @@ impl<T: OnionMessageContents> Writeable for (Payload<T>, [u8; 32]) {
234244 let write_adapter = ChaChaPolyWriteAdapter :: new ( self . 1 , & control_tlvs) ;
235245 _encode_varint_length_prefixed_tlv ! ( w, { ( 4 , write_adapter, required) } )
236246 } ,
247+ Payload :: Dummy ( DummyControlTlvs :: Unblinded ( control_tlvs) ) => {
248+ let write_adapter = ChaChaPolyWriteAdapter :: new ( self . 1 , & control_tlvs) ;
249+ _encode_varint_length_prefixed_tlv ! ( w, { ( 4 , write_adapter, required) } )
250+ } ,
237251 Payload :: Receive {
238252 control_tlvs : ReceiveControlTlvs :: Unblinded ( control_tlvs) ,
239253 reply_path,
@@ -310,6 +324,9 @@ impl<H: CustomOnionMessageHandler + ?Sized, L: Logger + ?Sized> ReadableArgs<(Sh
310324 }
311325 Ok ( Payload :: Forward ( ForwardControlTlvs :: Unblinded ( tlvs) ) )
312326 } ,
327+ Some ( ChaChaPolyReadAdapter { readable : ControlTlvs :: Dummy ( tlvs) } ) => {
328+ Ok ( Payload :: Dummy ( DummyControlTlvs :: Unblinded ( tlvs) ) )
329+ } ,
313330 Some ( ChaChaPolyReadAdapter { readable : ControlTlvs :: Receive ( tlvs) } ) => {
314331 Ok ( Payload :: Receive {
315332 control_tlvs : ReceiveControlTlvs :: Unblinded ( tlvs) ,
@@ -328,6 +345,8 @@ impl<H: CustomOnionMessageHandler + ?Sized, L: Logger + ?Sized> ReadableArgs<(Sh
328345pub ( crate ) enum ControlTlvs {
329346 /// This onion message is intended to be forwarded.
330347 Forward ( ForwardTlvs ) ,
348+ /// This onion message is a dummy, and is intended to be peeled.
349+ Dummy ( DummyTlv ) ,
331350 /// This onion message is intended to be received.
332351 Receive ( ReceiveTlvs ) ,
333352}
@@ -343,6 +362,7 @@ impl Readable for ControlTlvs {
343362 ( 4 , next_node_id, option) ,
344363 ( 8 , next_blinding_override, option) ,
345364 ( 65537 , context, option) ,
365+ ( 65539 , authentication, option) ,
346366 } ) ;
347367
348368 let next_hop = match ( short_channel_id, next_node_id) {
@@ -363,7 +383,10 @@ impl Readable for ControlTlvs {
363383 } else if valid_recv_fmt {
364384 ControlTlvs :: Receive ( ReceiveTlvs { context } )
365385 } else {
366- return Err ( DecodeError :: InvalidValue ) ;
386+ ControlTlvs :: Dummy ( DummyTlv {
387+ dummy_tlv : UnauthenticatedDummyTlv { } ,
388+ authentication : authentication. ok_or ( DecodeError :: InvalidValue ) ?,
389+ } )
367390 } ;
368391
369392 Ok ( payload_fmt)
@@ -374,6 +397,7 @@ impl Writeable for ControlTlvs {
374397 fn write < W : Writer > ( & self , w : & mut W ) -> Result < ( ) , io:: Error > {
375398 match self {
376399 Self :: Forward ( tlvs) => tlvs. write ( w) ,
400+ Self :: Dummy ( tlvs) => tlvs. write ( w) ,
377401 Self :: Receive ( tlvs) => tlvs. write ( w) ,
378402 }
379403 }
0 commit comments