Skip to content

Commit b0dce2a

Browse files
committed
Allow arbitrary length path_id in encrypted_data
BOLT 4 allows the path_id in encrypted_data to be of an arbitrary length, but the code currently only allows 32 bytes. Update it to match the specification.
1 parent 15b1c9b commit b0dce2a

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

lightning/src/blinded_path/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ pub(crate) struct ReceiveTlvs {
208208
/// If `path_id` is `Some`, it is used to identify the blinded path that this onion message is
209209
/// sending to. This is useful for receivers to check that said blinded path is being used in
210210
/// the right context.
211-
pub(super) path_id: Option<[u8; 32]>,
211+
pub(super) path_id: Option<Vec<u8>>,
212212
}
213213

214214
impl Writeable for ForwardTlvs {
@@ -226,7 +226,7 @@ impl Writeable for ReceiveTlvs {
226226
fn write<W: Writer>(&self, writer: &mut W) -> Result<(), io::Error> {
227227
// TODO: write padding
228228
encode_tlv_stream!(writer, {
229-
(6, self.path_id, option),
229+
(6, self.path_id, (option, encoding: WithoutLength)),
230230
});
231231
Ok(())
232232
}

lightning/src/onion_message/messenger.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,7 @@ where
323323
}
324324

325325
fn respond_with_onion_message<T: CustomOnionMessageContents>(
326-
&self, response: OnionMessageContents<T>, path_id: Option<[u8; 32]>,
326+
&self, response: OnionMessageContents<T>, path_id: Option<Vec<u8>>,
327327
reply_path: Option<BlindedPath>
328328
) {
329329
let sender = match self.node_signer.get_node_id(Recipient::Node) {

lightning/src/onion_message/packet.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -275,13 +275,13 @@ impl Readable for ControlTlvs {
275275
let mut _padding: Option<Padding> = None;
276276
let mut _short_channel_id: Option<u64> = None;
277277
let mut next_node_id: Option<PublicKey> = None;
278-
let mut path_id: Option<[u8; 32]> = None;
278+
let mut path_id: Option<Vec<u8>> = None;
279279
let mut next_blinding_override: Option<PublicKey> = None;
280280
decode_tlv_stream!(&mut r, {
281281
(1, _padding, option),
282282
(2, _short_channel_id, option),
283283
(4, next_node_id, option),
284-
(6, path_id, option),
284+
(6, path_id, optional_vec),
285285
(8, next_blinding_override, option),
286286
});
287287

0 commit comments

Comments
 (0)