lnd/lnwire/encoding.go
Techlateef e20fc80d41 lnwire: remove legacy zlib encoding for channel queries
This commit removes support for the deprecated EncodingSortedZlib
format (type 1) which was dropped from the BOLT 7 specification.
All zlib compression and decompression logic has been removed from
lnwire messages. The EncodingSortedZlib constant is now marked as
Deprecated to retain protocol documentation. The decode path now
explicitly returns an error when a peer attempts to send zlib-encoded
data, rather than a generic unknown encoding error. All tests that
previously verified zlib scenarios have been cleaned up or deleted.
This removal is safe because lnd has never sent zlib-encoded data,
and nobody on the network sends type 1.
Additionally, dropping this encoding removes the package-global
zlibDecodeMtx, improving performance and security without introducing
new DoS vectors, as receiving type 1 now simply triggers an instant
disconnect.
2026-08-06 19:39:33 +01:00

35 lines
1.1 KiB
Go

package lnwire
import "github.com/lightningnetwork/lnd/tlv"
// QueryEncoding is an enum-like type that represents exactly how a set data is
// encoded on the wire.
type QueryEncoding uint8
const (
// EncodingSortedPlain signals that the set of data is encoded using the
// regular encoding, in a sorted order.
EncodingSortedPlain QueryEncoding = 0
// EncodingSortedZlib signals that the set of data was encoded using
// zlib compression. This encoding was dropped from the BOLT 7 spec
// and is no longer supported. The constant is retained to reject the
// encoding in both directions (encoding and decoding).
//
// Deprecated: zlib encoding is not accepted or produced by lnd.
EncodingSortedZlib QueryEncoding = 1
)
// recordProducer is a simple helper struct that implements the
// tlv.RecordProducer interface.
type recordProducer struct {
record tlv.Record
}
// Record returns the underlying record.
func (r *recordProducer) Record() tlv.Record {
return r.record
}
// Ensure that recordProducer implements the tlv.RecordProducer interface.
var _ tlv.RecordProducer = (*recordProducer)(nil)