Skip to content

Commit 32c69a3

Browse files
committed
Avoid ref to a Vec when accessing custom onion TLVs
The bindings can't easily return a reference to a `Vec`, so we instead split the implementation into vec/slice depending on the `c_bindings` flag.
1 parent f5079b0 commit 32c69a3

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

lightning/src/ln/outbound_payment.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -573,10 +573,26 @@ impl RecipientOnionFields {
573573
/// Note that if this field is non-empty, it will contain strictly increasing TLVs, each
574574
/// represented by a `(u64, Vec<u8>)` for its type number and serialized value respectively.
575575
/// This is validated when setting this field using [`Self::with_custom_tlvs`].
576+
#[cfg(not(c_bindings))]
576577
pub fn custom_tlvs(&self) -> &Vec<(u64, Vec<u8>)> {
577578
&self.custom_tlvs
578579
}
579580

581+
/// Gets the custom TLVs that will be sent or have been received.
582+
///
583+
/// Custom TLVs allow sending extra application-specific data with a payment. They provide
584+
/// additional flexibility on top of payment metadata, as while other implementations may
585+
/// require `payment_metadata` to reflect metadata provided in an invoice, custom TLVs
586+
/// do not have this restriction.
587+
///
588+
/// Note that if this field is non-empty, it will contain strictly increasing TLVs, each
589+
/// represented by a `(u64, Vec<u8>)` for its type number and serialized value respectively.
590+
/// This is validated when setting this field using [`Self::with_custom_tlvs`].
591+
#[cfg(c_bindings)]
592+
pub fn custom_tlvs(&self) -> Vec<(u64, Vec<u8>)> {
593+
self.custom_tlvs.clone()
594+
}
595+
580596
/// When we have received some HTLC(s) towards an MPP payment, as we receive further HTLC(s) we
581597
/// have to make sure that some fields match exactly across the parts. For those that aren't
582598
/// required to match, if they don't match we should remove them so as to not expose data

0 commit comments

Comments
 (0)