@@ -431,14 +431,7 @@ pub struct RecipientOnionFields {
431
431
/// [`Self::payment_secret`] and while nearly all lightning senders support secrets, metadata
432
432
/// may not be supported as universally.
433
433
pub payment_metadata : Option < Vec < u8 > > ,
434
- /// Custom TLVs allow sending extra application-specific data with a payment. They provide
435
- /// additional flexibility on top of payment metadata, as while other implementations may
436
- /// require payment metadata to reflect metadata provided in an invoice, custom TLVs
437
- /// do not have this restriction.
438
- ///
439
- /// Note that the if this field is `Some`, it will contain properly ordered TLVs, each
440
- /// represented by a `(u64, Vec<u8>)` for its type number and serialized value respectively.
441
- /// This is validated when setting this field using [`Self::with_custom_tlvs`].
434
+ /// See [`Self::custom_tlvs`] for more info.
442
435
pub ( super ) custom_tlvs : Option < Vec < ( u64 , Vec < u8 > ) > > ,
443
436
}
444
437
@@ -465,10 +458,11 @@ impl RecipientOnionFields {
465
458
Self { payment_secret : None , payment_metadata : None , custom_tlvs : None }
466
459
}
467
460
468
- /// Creates a new [`RecipientOnionFields`], setting `custom_tlvs`. Each TLV is provided as a
469
- /// `(u64, Vec<u8>)` for the type number and serialized value respectively. TLV type numbers
470
- /// must be unique, in increasing order, and within the range reserved for custom types, i.e.
471
- /// >= 2^16, otherwise this method will return `Err(())`.
461
+ /// Creates a new [`RecipientOnionFields`] from an existing one, adding custom TLVs. Each
462
+ /// TLV is provided as a `(u64, Vec<u8>)` for the type number and serialized value
463
+ /// respectively. TLV type numbers must be unique, in increasing order, and within the range
464
+ /// reserved for custom types, i.e. >= 2^16, otherwise this method will return `Err(())`.
465
+ /// See [`Self::custom_tlvs`] for more info.
472
466
pub fn with_custom_tlvs ( mut self , custom_tlvs : Vec < ( u64 , Vec < u8 > ) > ) -> Result < Self , ( ) > {
473
467
let mut prev_type = None ;
474
468
for ( typ, _) in custom_tlvs. iter ( ) {
@@ -483,6 +477,20 @@ impl RecipientOnionFields {
483
477
Ok ( self )
484
478
}
485
479
480
+ /// Gets the custom TLVs that will be sent or have been received.
481
+ ///
482
+ /// Custom TLVs allow sending extra application-specific data with a payment. They provide
483
+ /// additional flexibility on top of payment metadata, as while other implementations may
484
+ /// require `payment_metadata` to reflect metadata provided in an invoice, custom TLVs
485
+ /// do not have this restriction.
486
+ ///
487
+ /// Note that if this field is `Some`, it will contain properly ordered TLVs, each
488
+ /// represented by a `(u64, Vec<u8>)` for its type number and serialized value respectively.
489
+ /// This is validated when setting this field using [`Self::with_custom_tlvs`].
490
+ pub fn custom_tlvs ( & self ) -> & Option < Vec < ( u64 , Vec < u8 > ) > > {
491
+ & self . custom_tlvs
492
+ }
493
+
486
494
/// When we have received some HTLC(s) towards an MPP payment, as we receive further HTLC(s) we
487
495
/// have to make sure that some fields match exactly across the parts. For those that aren't
488
496
/// required to match, if they don't match we should remove them so as to not expose data
0 commit comments