smite: add update_add_htlc message codec#33
smite: add update_add_htlc message codec#33kartikangiras wants to merge 1 commit intomorehouse:masterfrom
Conversation
| /// | ||
| /// This is typically a variable-length field containing the encrypted | ||
| /// route information that only the next hop can decrypt. | ||
| pub onion_routing_packet: Vec<u8>, |
There was a problem hiding this comment.
The onion package is exactly of size 1366, so rather than Vec, using [u8; 1366] makes more sense as it will save heap memory and will also ensure no memory-related bugs are raised in future.
| let amount_msat = WireFormat::read(&mut cursor)?; | ||
| let payment_hash: [u8; 32] = WireFormat::read(&mut cursor)?; | ||
| let cltv_expiry = WireFormat::read(&mut cursor)?; | ||
| let onion_routing_packet = Vec::<u8>::read(&mut cursor)?; |
There was a problem hiding this comment.
Similarly, for onion_packet_routing decoding, as it is of fixed size, and to support the above comment let onion_routing_packet = <[u8; 1366]>::read(&mut cursor)?; using this for decoding will be more safe and better.
| } | ||
|
|
||
| #[test] | ||
| fn decode_truncated_amount_msat() { |
There was a problem hiding this comment.
I think the calculation of offsets in this test is a bit off and should be somewhere bw 40 to 47 (channelID 32 bytes + htlc_id 8 bytes and then this field for another 8 bytes).
| } | ||
|
|
||
| #[test] | ||
| fn decode_truncated_payment_hash() { |
There was a problem hiding this comment.
Because you missed htlc_id bytes, here too we have to add, so the offset should be bw 48 and 48+32)
| } | ||
|
|
||
| #[test] | ||
| fn decode_truncated_cltv_expiry() { |
There was a problem hiding this comment.
Similarly, here too the offset should be 80 or more for this test
Add support for Message Type: [UPDATE_ADD_HTLC] (type 128).
realtes to #5