diff --git a/lnwire/features.go b/lnwire/features.go index 7700e2d5..7900a9b3 100644 --- a/lnwire/features.go +++ b/lnwire/features.go @@ -216,8 +216,16 @@ func (fv *RawFeatureVector) Encode(w io.Writer) error { return fv.encode(w, length, 8) } +// EncodeBase256 writes the feature vector in base256 representation. Every +// feature is encoded as a bit, and the bit vector is serialized using the least +// number of bytes. +func (fv *RawFeatureVector) EncodeBase256(w io.Writer) error { + length := fv.SerializeSize() + return fv.encode(w, length, 8) +} + // EncodeBase32 writes the feature vector in base32 representation. Every feature -// encoded as a bit, and the bit vector is serialized using the least number of +// is encoded as a bit, and the bit vector is serialized using the least number of // bytes. func (fv *RawFeatureVector) EncodeBase32(w io.Writer) error { length := fv.SerializeSize32() @@ -239,8 +247,8 @@ func (fv *RawFeatureVector) encode(w io.Writer, length, width int) error { } // Decode reads the feature vector from its byte representation. Every feature -// encoded as a bit, and the bit vector is serialized using the least number of -// bytes. Since the bit vector length is variable, the first two bytes of the +// is encoded as a bit, and the bit vector is serialized using the least number +// of bytes. Since the bit vector length is variable, the first two bytes of the // serialization represent the length. func (fv *RawFeatureVector) Decode(r io.Reader) error { // Read the length of the feature vector. @@ -253,6 +261,13 @@ func (fv *RawFeatureVector) Decode(r io.Reader) error { return fv.decode(r, int(length), 8) } +// DecodeBase256 reads the feature vector from its base256 representation. Every +// feature encoded as a bit, and the bit vector is serialized using the least +// number of bytes. +func (fv *RawFeatureVector) DecodeBase256(r io.Reader, length int) error { + return fv.decode(r, length, 8) +} + // DecodeBase32 reads the feature vector from its base32 representation. Every // feature encoded as a bit, and the bit vector is serialized using the least // number of bytes.