Skip to content

Commit 3feb4a6

Browse files
committed
f - add accessor method for RecipientOnionFields::custom_tlvs
1 parent 1ba97fb commit 3feb4a6

File tree

1 file changed

+20
-12
lines changed

1 file changed

+20
-12
lines changed

lightning/src/ln/outbound_payment.rs

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -431,14 +431,7 @@ pub struct RecipientOnionFields {
431431
/// [`Self::payment_secret`] and while nearly all lightning senders support secrets, metadata
432432
/// may not be supported as universally.
433433
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.
442435
pub(super) custom_tlvs: Option<Vec<(u64, Vec<u8>)>>,
443436
}
444437

@@ -465,10 +458,11 @@ impl RecipientOnionFields {
465458
Self { payment_secret: None, payment_metadata: None, custom_tlvs: None }
466459
}
467460

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.
472466
pub fn with_custom_tlvs(mut self, custom_tlvs: Vec<(u64, Vec<u8>)>) -> Result<Self, ()> {
473467
let mut prev_type = None;
474468
for (typ, _) in custom_tlvs.iter() {
@@ -483,6 +477,20 @@ impl RecipientOnionFields {
483477
Ok(self)
484478
}
485479

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+
486494
/// When we have received some HTLC(s) towards an MPP payment, as we receive further HTLC(s) we
487495
/// have to make sure that some fields match exactly across the parts. For those that aren't
488496
/// required to match, if they don't match we should remove them so as to not expose data

0 commit comments

Comments
 (0)