You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
De/serialize custom TLVs on {Inbound,Outbound}OnionPayload
When serialized, the TLVs in `OutboundOnionPayload`, unlike a normal
TLV stream, are prefixed with the length of the stream. To allow a user
to add arbitrary custom TLVs, we aren't able to communicate to our
serialization macros exactly which fields to expect, so this commit
adds new macro variants to allow appending an extra set of bytes (and
modifying the prefixed length accordingly).
Because the keysend preimage TLV has a type number in the custom type
range, and a user's TLVs may have type numbers above and/or below
keysend's type number, and because TLV streams must be serialized in
increasing order by type number, this commit also ensures the keysend
TLV is properly sorted/serialized amongst the custom TLVs.
if amt.0 > MAX_VALUE_MSAT{returnErr(DecodeError::InvalidValue)}
@@ -2033,6 +2053,7 @@ impl Readable for InboundOnionPayload {
2033
2053
keysend_preimage,
2034
2054
amt_msat: amt.0,
2035
2055
outgoing_cltv_value: cltv_value.0,
2056
+
custom_tlvs,
2036
2057
})
2037
2058
}
2038
2059
}
@@ -3566,6 +3587,7 @@ mod tests {
3566
3587
keysend_preimage:None,
3567
3588
amt_msat:0x0badf00d01020304,
3568
3589
outgoing_cltv_value:0xffffffff,
3590
+
custom_tlvs:vec![],
3569
3591
};
3570
3592
let encoded_value = outbound_msg.encode();
3571
3593
let target_value = hex::decode("1002080badf00d010203040404ffffffff").unwrap();
@@ -3590,6 +3612,7 @@ mod tests {
3590
3612
keysend_preimage:None,
3591
3613
amt_msat:0x0badf00d01020304,
3592
3614
outgoing_cltv_value:0xffffffff,
3615
+
custom_tlvs:vec![],
3593
3616
};
3594
3617
let encoded_value = outbound_msg.encode();
3595
3618
let target_value = hex::decode("3602080badf00d010203040404ffffffff082442424242424242424242424242424242424242424242424242424242424242421badca1f").unwrap();
0 commit comments