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

lightningnetwork / lnd / 12115442155

02 Dec 2024 08:28AM UTC coverage: 48.662% (-10.3%) from 58.948%
12115442155

Pull #9175

github

ellemouton
netann: update ChanAnn2 validation to work for P2WSH channels

This commit expands the ChannelAnnouncement2 validation for the case
where it is announcing a P2WSH channel.
Pull Request #9175: lnwire+netann: update structure of g175 messages to be pure TLV

6 of 314 new or added lines in 9 files covered. (1.91%)

27532 existing lines in 434 files now uncovered.

97890 of 201164 relevant lines covered (48.66%)

0.52 hits per line

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

78.95
/lnwire/typed_lease_expiry.go
1
package lnwire
2

3
import (
4
        "io"
5

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

9
const (
10
        // LeaseExpiryType is the type of the experimental record used to
11
        // communicate the expiration of a channel lease throughout the channel
12
        // funding process.
13
        //
14
        // TODO: Decide on actual TLV type. Custom records start at 2^16.
15
        LeaseExpiryRecordType tlv.Type = 1 << 16
16
)
17

18
// LeaseExpiry represents the absolute expiration height of a channel lease. All
19
// outputs that pay directly to the channel initiator are locked until this
20
// height is reached.
21
type LeaseExpiry uint32
22

23
// Record returns a TLV record that can be used to encode/decode the LeaseExpiry
24
// type from a given TLV stream.
25
func (l *LeaseExpiry) Record() tlv.Record {
1✔
26
        return tlv.MakeStaticRecord(
1✔
27
                LeaseExpiryRecordType, l, 4, leaseExpiryEncoder, leaseExpiryDecoder,
1✔
28
        )
1✔
29
}
1✔
30

31
// leaseExpiryEncoder is a custom TLV encoder for the LeaseExpiry record.
32
func leaseExpiryEncoder(w io.Writer, val interface{}, buf *[8]byte) error {
1✔
33
        if v, ok := val.(*LeaseExpiry); ok {
2✔
34
                return tlv.EUint32T(w, uint32(*v), buf)
1✔
35
        }
1✔
36

37
        return tlv.NewTypeForEncodingErr(val, "lnwire.LeaseExpiry")
×
38
}
39

40
// leaseExpiryDecoder is a custom TLV decoder for the LeaseExpiry record.
41
func leaseExpiryDecoder(r io.Reader, val interface{}, buf *[8]byte, l uint64) error {
1✔
42
        if v, ok := val.(*LeaseExpiry); ok {
2✔
43
                var leaseExpiry uint32
1✔
44
                if err := tlv.DUint32(r, &leaseExpiry, buf, l); err != nil {
1✔
UNCOV
45
                        return err
×
UNCOV
46
                }
×
47
                *v = LeaseExpiry(leaseExpiry)
1✔
48
                return nil
1✔
49
        }
50

51
        return tlv.NewTypeForEncodingErr(val, "lnwire.LeaseExpiry")
×
52
}
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