@@ -325,6 +325,15 @@ pub struct UnauthenticatedReceiveTlvs {
325325 	pub  payment_constraints :  PaymentConstraints , 
326326	/// Context for the receiver of this payment. 
327327 	pub  payment_context :  PaymentContext , 
328+ 	/// Custom data set by the user. And is returned back when the blinded path is used. 
329+  	/// 
330+  	/// ## Note on Forward Compatibility: 
331+  	/// Users can encode any kind of data into the `Vec<u8>` bytes here. However, they should ensure 
332+  	/// that the data is structured in a forward-compatible manner. This is especially important as 
333+  	/// `ReceiveTlvs` created in one version of the software may still appear in payments received 
334+  	/// shortly after a software upgrade. Proper forward compatibility helps prevent data loss or 
335+  	/// misinterpretation in future versions. 
336+  	pub  custom_data :  Option < Vec < u8 > > , 
328337} 
329338
330339impl  UnauthenticatedReceiveTlvs  { 
@@ -490,6 +499,7 @@ impl Writeable for ReceiveTlvs {
490499			( 65536 ,  self . tlvs. payment_secret,  required) , 
491500			( 65537 ,  self . tlvs. payment_context,  required) , 
492501			( 65539 ,  self . authentication,  required) , 
502+ 			( 65541 ,  self . tlvs. custom_data,  required) 
493503		} ) ; 
494504		Ok ( ( ) ) 
495505	} 
@@ -501,6 +511,7 @@ impl Writeable for UnauthenticatedReceiveTlvs {
501511			( 12 ,  self . payment_constraints,  required) , 
502512			( 65536 ,  self . payment_secret,  required) , 
503513			( 65537 ,  self . payment_context,  required) , 
514+ 			( 65541 ,  self . custom_data,  ( default_value,  Vec :: new( ) ) ) , 
504515		} ) ; 
505516		Ok ( ( ) ) 
506517	} 
@@ -529,6 +540,7 @@ impl Readable for BlindedPaymentTlvs {
529540			( 65536 ,  payment_secret,  option) , 
530541			( 65537 ,  payment_context,  option) , 
531542			( 65539 ,  authentication,  option) , 
543+ 			( 65541 ,  custom_data,  option) 
532544		} ) ; 
533545		let  _padding:  Option < utils:: Padding >  = _padding; 
534546
@@ -552,6 +564,7 @@ impl Readable for BlindedPaymentTlvs {
552564					payment_secret :  payment_secret. ok_or ( DecodeError :: InvalidValue ) ?, 
553565					payment_constraints :  payment_constraints. 0 . unwrap ( ) , 
554566					payment_context :  payment_context. ok_or ( DecodeError :: InvalidValue ) ?, 
567+ 					custom_data :  custom_data. ok_or ( DecodeError :: InvalidValue ) ?, 
555568				} , 
556569				authentication :  authentication. ok_or ( DecodeError :: InvalidValue ) ?, 
557570			} ) ) 
@@ -794,6 +807,7 @@ mod tests {
794807			payment_secret :  PaymentSecret ( [ 0 ;  32 ] ) , 
795808			payment_constraints :  PaymentConstraints  {  max_cltv_expiry :  0 ,  htlc_minimum_msat :  1  } , 
796809			payment_context :  PaymentContext :: Bolt12Refund ( Bolt12RefundContext  { } ) , 
810+ 			custom_data :  None , 
797811		} ; 
798812		let  htlc_maximum_msat = 100_000 ; 
799813		let  blinded_payinfo =
@@ -812,6 +826,7 @@ mod tests {
812826			payment_secret :  PaymentSecret ( [ 0 ;  32 ] ) , 
813827			payment_constraints :  PaymentConstraints  {  max_cltv_expiry :  0 ,  htlc_minimum_msat :  1  } , 
814828			payment_context :  PaymentContext :: Bolt12Refund ( Bolt12RefundContext  { } ) , 
829+ 			custom_data :  None , 
815830		} ; 
816831		let  blinded_payinfo =
817832			super :: compute_payinfo ( & [ ] ,  & recv_tlvs,  4242 ,  TEST_FINAL_CLTV  as  u16 ) . unwrap ( ) ; 
@@ -869,6 +884,7 @@ mod tests {
869884			payment_secret :  PaymentSecret ( [ 0 ;  32 ] ) , 
870885			payment_constraints :  PaymentConstraints  {  max_cltv_expiry :  0 ,  htlc_minimum_msat :  3  } , 
871886			payment_context :  PaymentContext :: Bolt12Refund ( Bolt12RefundContext  { } ) , 
887+ 			custom_data :  None , 
872888		} ; 
873889		let  htlc_maximum_msat = 100_000 ; 
874890		let  blinded_payinfo = super :: compute_payinfo ( 
@@ -928,6 +944,7 @@ mod tests {
928944			payment_secret :  PaymentSecret ( [ 0 ;  32 ] ) , 
929945			payment_constraints :  PaymentConstraints  {  max_cltv_expiry :  0 ,  htlc_minimum_msat :  1  } , 
930946			payment_context :  PaymentContext :: Bolt12Refund ( Bolt12RefundContext  { } ) , 
947+ 			custom_data :  None , 
931948		} ; 
932949		let  htlc_minimum_msat = 3798 ; 
933950		assert ! ( super :: compute_payinfo( 
@@ -997,6 +1014,7 @@ mod tests {
9971014			payment_secret :  PaymentSecret ( [ 0 ;  32 ] ) , 
9981015			payment_constraints :  PaymentConstraints  {  max_cltv_expiry :  0 ,  htlc_minimum_msat :  1  } , 
9991016			payment_context :  PaymentContext :: Bolt12Refund ( Bolt12RefundContext  { } ) , 
1017+ 			custom_data :  None , 
10001018		} ; 
10011019
10021020		let  blinded_payinfo = super :: compute_payinfo ( 
0 commit comments