@@ -471,9 +471,9 @@ pub enum RetryableSendFailure {
471
471
/// [`Event::PaymentSent`]: crate::events::Event::PaymentSent
472
472
/// [`Event::PaymentFailed`]: crate::events::Event::PaymentFailed
473
473
DuplicatePayment ,
474
- /// The [`RecipientOnionFields::payment_metadata`], [`RecipientOnionFields::custom_tlvs `], or
475
- /// [`BlindedPaymentPath`]s provided are too large and caused us to exceed the maximum onion
476
- /// packet size of 1300 bytes.
474
+ /// The [`RecipientOnionFields::payment_metadata`], [`RecipientOnionFields::sender_custom_tlvs `],
475
+ /// [`RecipientOnionFields::user_custom_tlvs`] or [` BlindedPaymentPath`]s provided are too large
476
+ /// and caused us to exceed the maximum onion packet size of 1300 bytes.
477
477
///
478
478
/// [`BlindedPaymentPath`]: crate::blinded_path::payment::BlindedPaymentPath
479
479
OnionPacketSizeExceeded ,
@@ -614,9 +614,9 @@ pub struct RecipientOnionFields {
614
614
/// [`Self::payment_secret`] and while nearly all lightning senders support secrets, metadata
615
615
/// may not be supported as universally.
616
616
pub payment_metadata : Option < Vec < u8 > > ,
617
- /// See [`Self::custom_tlvs `] for more info.
617
+ /// See [`Self::sender_custom_tlvs `] for more info.
618
618
pub ( super ) sender_custom_tlvs : Vec < ( u64 , Vec < u8 > ) > ,
619
- /// Custom Tlvs sent by user to themself .
619
+ /// See [`Self::user_custom_tlvs`] for more info .
620
620
pub ( super ) user_custom_tlvs : Vec < u8 >
621
621
}
622
622
@@ -647,15 +647,15 @@ impl RecipientOnionFields {
647
647
Self { payment_secret : None , payment_metadata : None , sender_custom_tlvs : Vec :: new ( ) , user_custom_tlvs : Vec :: new ( ) }
648
648
}
649
649
650
- /// Creates a new [`RecipientOnionFields`] from an existing one, adding custom TLVs. Each
651
- /// TLV is provided as a `(u64, Vec<u8>)` for the type number and serialized value
650
+ /// Creates a new [`RecipientOnionFields`] from an existing one, adding sender custom TLVs.
651
+ /// Each TLV is provided as a `(u64, Vec<u8>)` for the type number and serialized value
652
652
/// respectively. TLV type numbers must be unique and within the range
653
653
/// reserved for custom types, i.e. >= 2^16, otherwise this method will return `Err(())`.
654
654
///
655
655
/// This method will also error for types in the experimental range which have been
656
656
/// standardized within the protocol, which only includes 5482373484 (keysend) for now.
657
657
///
658
- /// See [`Self::custom_tlvs `] for more info.
658
+ /// See [`Self::sender_custom_tlvs `] for more info.
659
659
pub fn with_sender_custom_tlvs ( mut self , mut sender_custom_tlvs : Vec < ( u64 , Vec < u8 > ) > ) -> Result < Self , ( ) > {
660
660
sender_custom_tlvs. sort_unstable_by_key ( |( typ, _) | * typ) ;
661
661
let mut prev_type = None ;
@@ -674,36 +674,72 @@ impl RecipientOnionFields {
674
674
Ok ( self )
675
675
}
676
676
677
- /// Gets the custom TLVs that will be sent or have been received .
677
+ /// Creates a new [`RecipientOnionFields`] from an existing one, adding user custom TLVs .
678
678
///
679
- /// Custom TLVs allow sending extra application-specific data with a payment. They provide
680
- /// additional flexibility on top of payment metadata, as while other implementations may
681
- /// require `payment_metadata` to reflect metadata provided in an invoice, custom TLVs
682
- /// do not have this restriction.
679
+ /// See [`Self::user_custom_tlvs`] for more info.
680
+ pub fn with_user_custom_tlvs ( mut self , custom_tlvs : Vec < u8 > ) -> Self {
681
+ self . user_custom_tlvs = custom_tlvs;
682
+ self
683
+ }
684
+
685
+ /// Gets the sender custom TLVs that will be sent or have been received.
686
+ ///
687
+ /// Sender custom TLVs allow sending extra application-specific data with a payment.
688
+ /// They provide additional flexibility on top of payment metadata, as while other
689
+ /// implementations may require `payment_metadata` to reflect metadata provided in
690
+ /// an invoice, custom TLVs do not have this restriction.
683
691
///
684
692
/// Note that if this field is non-empty, it will contain strictly increasing TLVs, each
685
693
/// represented by a `(u64, Vec<u8>)` for its type number and serialized value respectively.
686
- /// This is validated when setting this field using [`Self::with_custom_tlvs `].
694
+ /// This is validated when setting this field using [`Self::with_sender_custom_tlvs `].
687
695
#[ cfg( not( c_bindings) ) ]
688
696
pub fn sender_custom_tlvs ( & self ) -> & Vec < ( u64 , Vec < u8 > ) > {
689
697
& self . sender_custom_tlvs
690
698
}
691
699
692
- /// Gets the custom TLVs that will be sent or have been received.
700
+ /// Gets the sender custom TLVs that will be sent or have been received.
693
701
///
694
- /// Custom TLVs allow sending extra application-specific data with a payment. They provide
695
- /// additional flexibility on top of payment metadata, as while other implementations may
696
- /// require `payment_metadata` to reflect metadata provided in an invoice, custom TLVs
697
- /// do not have this restriction.
702
+ /// Sender custom TLVs allow sending extra application-specific data with a payment.
703
+ /// They provide additional flexibility on top of payment metadata, as while other
704
+ /// implementations may require `payment_metadata` to reflect metadata provided in
705
+ /// an invoice, custom TLVs do not have this restriction.
698
706
///
699
707
/// Note that if this field is non-empty, it will contain strictly increasing TLVs, each
700
708
/// represented by a `(u64, Vec<u8>)` for its type number and serialized value respectively.
701
- /// This is validated when setting this field using [`Self::with_custom_tlvs `].
709
+ /// This is validated when setting this field using [`Self::with_sender_custom_tlvs `].
702
710
#[ cfg( c_bindings) ]
703
711
pub fn sender_custom_tlvs ( & self ) -> Vec < ( u64 , Vec < u8 > ) > {
704
712
self . sender_custom_tlvs . clone ( )
705
713
}
706
714
715
+ /// Gets the user custom TLVs that will be sent or have been received.
716
+ ///
717
+ /// User custom TLVs allow receiving back extra application-specific
718
+ /// data that was set by the receiver in the Blinded Path used by the sender
719
+ /// to reach them.
720
+ ///
721
+ /// This provides additional flexibility to users by enabling them to include
722
+ /// extra data they want to receive back, which can be used for authentication
723
+ /// or other purposes.
724
+ #[ cfg( not( c_bindings) ) ]
725
+ pub fn user_custom_tlvs ( & self ) -> & Vec < u8 > {
726
+ & self . user_custom_tlvs
727
+ }
728
+
729
+ /// Gets the user custom TLVs that will be sent or have been received.
730
+ ///
731
+ /// User custom TLVs allow receiving back extra application-specific
732
+ /// data that was set by the receiver in the Blinded Path used by the sender
733
+ /// to reach them.
734
+ ///
735
+ /// This provides additional flexibility to users by enabling them to include
736
+ /// extra data they want to receive back, which can be used for authentication
737
+ /// or other purposes.
738
+ #[ cfg( c_bindings) ]
739
+ pub fn user_custom_tlvs ( & self ) -> Vec < u8 > {
740
+ self . user_custom_tlvs . clone ( )
741
+ }
742
+
707
743
/// When we have received some HTLC(s) towards an MPP payment, as we receive further HTLC(s) we
708
744
/// have to make sure that some fields match exactly across the parts. For those that aren't
709
745
/// required to match, if they don't match we should remove them so as to not expose data
0 commit comments