Skip to content

Commit f551634

Browse files
committed
Serialize blinded forwards and receives in Trampoline onions.
1 parent 25fffeb commit f551634

File tree

1 file changed

+38
-1
lines changed

1 file changed

+38
-1
lines changed

lightning/src/ln/msgs.rs

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1768,6 +1768,19 @@ mod fuzzy_internal_msgs {
17681768
outgoing_cltv_value: u32,
17691769
/// The node id to which the trampoline node must find a route
17701770
outgoing_node_id: PublicKey,
1771+
},
1772+
BlindedForward {
1773+
encrypted_tlvs: Vec<u8>,
1774+
intro_node_blinding_point: Option<PublicKey>,
1775+
},
1776+
BlindedReceive {
1777+
sender_intended_htlc_amt_msat: u64,
1778+
total_msat: u64,
1779+
cltv_expiry_height: u32,
1780+
encrypted_tlvs: Vec<u8>,
1781+
intro_node_blinding_point: Option<PublicKey>, // Set if the introduction node of the blinded path is the final node
1782+
keysend_preimage: Option<PaymentPreimage>,
1783+
custom_tlvs: Vec<(u64, Vec<u8>)>,
17711784
}
17721785
}
17731786

@@ -2673,7 +2686,31 @@ impl Writeable for OutboundTrampolinePayload {
26732686
(4, HighZeroBytesDroppedBigSize(*outgoing_cltv_value), required),
26742687
(14, outgoing_node_id, required)
26752688
});
2676-
}
2689+
},
2690+
Self::BlindedForward { encrypted_tlvs, intro_node_blinding_point } => {
2691+
_encode_varint_length_prefixed_tlv!(w, {
2692+
(10, *encrypted_tlvs, required_vec),
2693+
(12, intro_node_blinding_point, option)
2694+
});
2695+
},
2696+
Self::BlindedReceive {
2697+
sender_intended_htlc_amt_msat, total_msat, cltv_expiry_height, encrypted_tlvs,
2698+
intro_node_blinding_point, keysend_preimage, ref custom_tlvs,
2699+
} => {
2700+
// We need to update [`ln::outbound_payment::RecipientOnionFields::with_custom_tlvs`]
2701+
// to reject any reserved types in the experimental range if new ones are ever
2702+
// standardized.
2703+
let keysend_tlv = keysend_preimage.map(|preimage| (5482373484, preimage.encode()));
2704+
let mut custom_tlvs: Vec<&(u64, Vec<u8>)> = custom_tlvs.iter().chain(keysend_tlv.iter()).collect();
2705+
custom_tlvs.sort_unstable_by_key(|(typ, _)| *typ);
2706+
_encode_varint_length_prefixed_tlv!(w, {
2707+
(2, HighZeroBytesDroppedBigSize(*sender_intended_htlc_amt_msat), required),
2708+
(4, HighZeroBytesDroppedBigSize(*cltv_expiry_height), required),
2709+
(10, *encrypted_tlvs, required_vec),
2710+
(12, intro_node_blinding_point, option),
2711+
(18, HighZeroBytesDroppedBigSize(*total_msat), required)
2712+
}, custom_tlvs.iter());
2713+
},
26772714
}
26782715
Ok(())
26792716
}

0 commit comments

Comments
 (0)