• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

lightningnetwork / lnd / 14880107727

07 May 2025 09:35AM UTC coverage: 58.446% (-10.5%) from 68.992%
14880107727

Pull #9789

github

web-flow
Merge ed3471042 into 67a40c90a
Pull Request #9789: multi: use updated TLV SizeFunc signature

54 of 95 new or added lines in 19 files covered. (56.84%)

28462 existing lines in 449 files now uncovered.

97165 of 166247 relevant lines covered (58.45%)

1.81 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

85.71
/lnwire/channel_type.go
1
package lnwire
2

3
import (
4
        "io"
5

6
        "github.com/lightningnetwork/lnd/tlv"
7
)
8

9
const (
10
        // ChannelTypeRecordType is the type of the experimental record used
11
        // to denote which channel type is being negotiated.
12
        ChannelTypeRecordType tlv.Type = 1
13
)
14

15
// ChannelType represents a specific channel type as a set of feature bits that
16
// comprise it.
17
type ChannelType RawFeatureVector
18

19
// featureBitLen returns the length in bytes of the encoded feature bits.
20
func (c ChannelType) featureBitLen() (uint64, error) {
3✔
21
        fv := RawFeatureVector(c)
3✔
22

3✔
23
        return fv.sizeFunc()
3✔
24
}
3✔
25

26
// Record returns a TLV record that can be used to encode/decode the channel
27
// type from a given TLV stream.
28
func (c *ChannelType) Record() tlv.Record {
3✔
29
        return tlv.MakeDynamicRecord(
3✔
30
                ChannelTypeRecordType, c, c.featureBitLen, channelTypeEncoder,
3✔
31
                channelTypeDecoder,
3✔
32
        )
3✔
33
}
3✔
34

35
// channelTypeEncoder is a custom TLV encoder for the ChannelType record.
36
func channelTypeEncoder(w io.Writer, val interface{}, buf *[8]byte) error {
3✔
37
        if v, ok := val.(*ChannelType); ok {
6✔
38
                fv := RawFeatureVector(*v)
3✔
39
                return rawFeatureEncoder(w, &fv, buf)
3✔
40
        }
3✔
41

42
        return tlv.NewTypeForEncodingErr(val, "*lnwire.ChannelType")
×
43
}
44

45
// channelTypeDecoder is a custom TLV decoder for the ChannelType record.
46
func channelTypeDecoder(r io.Reader, val interface{}, buf *[8]byte,
47
        l uint64) error {
3✔
48

3✔
49
        if v, ok := val.(*ChannelType); ok {
6✔
50
                fv := NewRawFeatureVector()
3✔
51

3✔
52
                if err := rawFeatureDecoder(r, fv, buf, l); err != nil {
3✔
UNCOV
53
                        return err
×
UNCOV
54
                }
×
55

56
                *v = ChannelType(*fv)
3✔
57
                return nil
3✔
58
        }
59

60
        return tlv.NewTypeForEncodingErr(val, "*lnwire.ChannelType")
×
61
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc