Skip to content

Commit c8033e1

Browse files
morehouseguggero
authored andcommitted
lnwire: fail decoding on incorrect number of timestamps
Currently if an incorrect number of timestamps is given, we fail later on in the GossipSyncer. It makes more sense to fail right away, since we already do that for incorrect SCID formats (e.g., unsorted or duplicate SCIDs). There is already a matching check in Encode for incorrect number of timestamps, so adding this check to Decode makes things symmetric.
1 parent 9bf48a7 commit c8033e1

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

lnwire/reply_channel_range.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,12 @@ func (c *ReplyChannelRange) Decode(r io.Reader, pver uint32) error {
104104
// Set the corresponding TLV types if they were included in the stream.
105105
if val, ok := typeMap[TimestampsRecordType]; ok && val == nil {
106106
c.Timestamps = timeStamps
107+
108+
// Check that a timestamp was provided for each SCID.
109+
if len(c.Timestamps) != len(c.ShortChanIDs) {
110+
return fmt.Errorf("number of timestamps does not " +
111+
"match number of SCIDs")
112+
}
107113
}
108114

109115
if len(tlvRecords) != 0 {

0 commit comments

Comments
 (0)