lnwire: sort records in ExtractRecords

This ensures that the caller doesn't need to worry about the TLV type
ordering of the records the pass into the function.
This commit is contained in:
Olaoluwa Osuntokun 2023-01-16 19:43:59 -08:00
parent 25dfbadd23
commit 7ae4bf0672
No known key found for this signature in database
GPG Key ID: 3BBD59E99B280306

View File

@ -90,6 +90,10 @@ func (e *ExtraOpaqueData) ExtractRecords(recordProducers ...tlv.RecordProducer)
records = append(records, producer.Record())
}
// Ensure that the set of records are sorted before we attempt to
// decode from the stream, to ensure they're canonical.
tlv.SortRecords(records)
extraBytesReader := bytes.NewReader(*e)
tlvStream, err := tlv.NewStream(records...)