Skip to content

Commit b845c1a

Browse files
committed
Implement Writeable for TrampolineForwardTlvs
We will need the ability to serialize blinded Trampoline forwards to construct their encrypted TLV data from its unencrypted state using `construct_blinded_hops`, which initially we only do in unit tests.
1 parent 77012c0 commit b845c1a

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

lightning/src/blinded_path/payment.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -512,6 +512,23 @@ impl Writeable for ForwardTlvs {
512512
}
513513
}
514514

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

0 commit comments

Comments
 (0)