From 7ae4bf0672521f7566462b697d99babacab49d55 Mon Sep 17 00:00:00 2001 From: Olaoluwa Osuntokun Date: Mon, 16 Jan 2023 19:43:59 -0800 Subject: [PATCH] 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. --- lnwire/extra_bytes.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lnwire/extra_bytes.go b/lnwire/extra_bytes.go index 17fd6df67..200f313ca 100644 --- a/lnwire/extra_bytes.go +++ b/lnwire/extra_bytes.go @@ -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...)