Skip to content

Commit 285b9e6

Browse files
committed
Implement Writeable for TrampolineForwardTlvs
We will need the ability to serialize blinded Trampoline forwards to construct their encrypted TLV data and for unit tests.
1 parent d410ae0 commit 285b9e6

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

lightning/src/blinded_path/payment.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -514,6 +514,24 @@ impl Writeable for ForwardTlvs {
514514
}
515515
}
516516

517+
#[cfg(trampoline)]
518+
impl Writeable for TrampolineForwardTlvs {
519+
fn write<W: Writer>(&self, w: &mut W) -> Result<(), io::Error> {
520+
let features_opt = if self.features == BlindedHopFeatures::empty() {
521+
None
522+
} else {
523+
Some(WithoutLength(&self.features))
524+
};
525+
encode_tlv_stream!(w, {
526+
(4, self.next_trampoline, required),
527+
(10, self.payment_relay, required),
528+
(12, self.payment_constraints, required),
529+
(14, features_opt, option)
530+
});
531+
Ok(())
532+
}
533+
}
534+
517535
impl Writeable for ReceiveTlvs {
518536
fn write<W: Writer>(&self, w: &mut W) -> Result<(), io::Error> {
519537
encode_tlv_stream!(w, {

0 commit comments

Comments
 (0)