mirror of
https://github.com/lightningnetwork/lnd.git
synced 2024-11-19 01:43:16 +01:00
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.
This commit is contained in:
parent
65046561c4
commit
c1a6d3ac31
@ -104,6 +104,12 @@ func (c *ReplyChannelRange) Decode(r io.Reader, pver uint32) error {
|
||||
// Set the corresponding TLV types if they were included in the stream.
|
||||
if val, ok := typeMap[TimestampsRecordType]; ok && val == nil {
|
||||
c.Timestamps = timeStamps
|
||||
|
||||
// Check that a timestamp was provided for each SCID.
|
||||
if len(c.Timestamps) != len(c.ShortChanIDs) {
|
||||
return fmt.Errorf("number of timestamps does not " +
|
||||
"match number of SCIDs")
|
||||
}
|
||||
}
|
||||
|
||||
if len(tlvRecords) != 0 {
|
||||
|
Loading…
Reference in New Issue
Block a user