@@ -325,6 +325,15 @@ pub struct UnauthenticatedReceiveTlvs {
325
325
pub payment_constraints : PaymentConstraints ,
326
326
/// Context for the receiver of this payment.
327
327
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 > > ,
328
337
}
329
338
330
339
impl UnauthenticatedReceiveTlvs {
@@ -490,6 +499,7 @@ impl Writeable for ReceiveTlvs {
490
499
( 65536 , self . tlvs. payment_secret, required) ,
491
500
( 65537 , self . tlvs. payment_context, required) ,
492
501
( 65539 , self . authentication, required) ,
502
+ ( 65541 , self . tlvs. custom_data, required)
493
503
} ) ;
494
504
Ok ( ( ) )
495
505
}
@@ -501,6 +511,7 @@ impl Writeable for UnauthenticatedReceiveTlvs {
501
511
( 12 , self . payment_constraints, required) ,
502
512
( 65536 , self . payment_secret, required) ,
503
513
( 65537 , self . payment_context, required) ,
514
+ ( 65541 , self . custom_data, ( default_value, Vec :: new( ) ) ) ,
504
515
} ) ;
505
516
Ok ( ( ) )
506
517
}
@@ -529,6 +540,7 @@ impl Readable for BlindedPaymentTlvs {
529
540
( 65536 , payment_secret, option) ,
530
541
( 65537 , payment_context, option) ,
531
542
( 65539 , authentication, option) ,
543
+ ( 65541 , custom_data, option)
532
544
} ) ;
533
545
let _padding: Option < utils:: Padding > = _padding;
534
546
@@ -552,6 +564,7 @@ impl Readable for BlindedPaymentTlvs {
552
564
payment_secret : payment_secret. ok_or ( DecodeError :: InvalidValue ) ?,
553
565
payment_constraints : payment_constraints. 0 . unwrap ( ) ,
554
566
payment_context : payment_context. ok_or ( DecodeError :: InvalidValue ) ?,
567
+ custom_data : custom_data. ok_or ( DecodeError :: InvalidValue ) ?,
555
568
} ,
556
569
authentication : authentication. ok_or ( DecodeError :: InvalidValue ) ?,
557
570
} ) )
@@ -794,6 +807,7 @@ mod tests {
794
807
payment_secret : PaymentSecret ( [ 0 ; 32 ] ) ,
795
808
payment_constraints : PaymentConstraints { max_cltv_expiry : 0 , htlc_minimum_msat : 1 } ,
796
809
payment_context : PaymentContext :: Bolt12Refund ( Bolt12RefundContext { } ) ,
810
+ custom_data : None ,
797
811
} ;
798
812
let htlc_maximum_msat = 100_000 ;
799
813
let blinded_payinfo =
@@ -812,6 +826,7 @@ mod tests {
812
826
payment_secret : PaymentSecret ( [ 0 ; 32 ] ) ,
813
827
payment_constraints : PaymentConstraints { max_cltv_expiry : 0 , htlc_minimum_msat : 1 } ,
814
828
payment_context : PaymentContext :: Bolt12Refund ( Bolt12RefundContext { } ) ,
829
+ custom_data : None ,
815
830
} ;
816
831
let blinded_payinfo =
817
832
super :: compute_payinfo ( & [ ] , & recv_tlvs, 4242 , TEST_FINAL_CLTV as u16 ) . unwrap ( ) ;
@@ -869,6 +884,7 @@ mod tests {
869
884
payment_secret : PaymentSecret ( [ 0 ; 32 ] ) ,
870
885
payment_constraints : PaymentConstraints { max_cltv_expiry : 0 , htlc_minimum_msat : 3 } ,
871
886
payment_context : PaymentContext :: Bolt12Refund ( Bolt12RefundContext { } ) ,
887
+ custom_data : None ,
872
888
} ;
873
889
let htlc_maximum_msat = 100_000 ;
874
890
let blinded_payinfo = super :: compute_payinfo (
@@ -928,6 +944,7 @@ mod tests {
928
944
payment_secret : PaymentSecret ( [ 0 ; 32 ] ) ,
929
945
payment_constraints : PaymentConstraints { max_cltv_expiry : 0 , htlc_minimum_msat : 1 } ,
930
946
payment_context : PaymentContext :: Bolt12Refund ( Bolt12RefundContext { } ) ,
947
+ custom_data : None ,
931
948
} ;
932
949
let htlc_minimum_msat = 3798 ;
933
950
assert ! ( super :: compute_payinfo(
@@ -997,6 +1014,7 @@ mod tests {
997
1014
payment_secret : PaymentSecret ( [ 0 ; 32 ] ) ,
998
1015
payment_constraints : PaymentConstraints { max_cltv_expiry : 0 , htlc_minimum_msat : 1 } ,
999
1016
payment_context : PaymentContext :: Bolt12Refund ( Bolt12RefundContext { } ) ,
1017
+ custom_data : None ,
1000
1018
} ;
1001
1019
1002
1020
let blinded_payinfo = super :: compute_payinfo (
0 commit comments