Skip to content

Commit 3793002

Browse files
committed
Serialize blinded forwards and receives in Trampoline onions.
1 parent 07f3380 commit 3793002

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

@@ -2665,7 +2678,31 @@ impl Writeable for OutboundTrampolinePayload {
26652678
(4, HighZeroBytesDroppedBigSize(*outgoing_cltv_value), required),
26662679
(14, outgoing_node_id, required)
26672680
});
2668-
}
2681+
},
2682+
Self::BlindedForward { encrypted_tlvs, intro_node_blinding_point } => {
2683+
_encode_varint_length_prefixed_tlv!(w, {
2684+
(10, *encrypted_tlvs, required_vec),
2685+
(12, intro_node_blinding_point, option)
2686+
});
2687+
},
2688+
Self::BlindedReceive {
2689+
sender_intended_htlc_amt_msat, total_msat, cltv_expiry_height, encrypted_tlvs,
2690+
intro_node_blinding_point, keysend_preimage, ref custom_tlvs,
2691+
} => {
2692+
// We need to update [`ln::outbound_payment::RecipientOnionFields::with_custom_tlvs`]
2693+
// to reject any reserved types in the experimental range if new ones are ever
2694+
// standardized.
2695+
let keysend_tlv = keysend_preimage.map(|preimage| (5482373484, preimage.encode()));
2696+
let mut custom_tlvs: Vec<&(u64, Vec<u8>)> = custom_tlvs.iter().chain(keysend_tlv.iter()).collect();
2697+
custom_tlvs.sort_unstable_by_key(|(typ, _)| *typ);
2698+
_encode_varint_length_prefixed_tlv!(w, {
2699+
(2, HighZeroBytesDroppedBigSize(*sender_intended_htlc_amt_msat), required),
2700+
(4, HighZeroBytesDroppedBigSize(*cltv_expiry_height), required),
2701+
(10, *encrypted_tlvs, required_vec),
2702+
(12, intro_node_blinding_point, option),
2703+
(18, HighZeroBytesDroppedBigSize(*total_msat), required)
2704+
}, custom_tlvs.iter());
2705+
},
26692706
}
26702707
Ok(())
26712708
}

0 commit comments

Comments
 (0)