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

lightningnetwork / lnd / 12012751795

25 Nov 2024 02:40PM UTC coverage: 49.835% (-9.2%) from 59.013%
12012751795

Pull #9303

github

yyforyongyu
lnwallet: add debug logs
Pull Request #9303: htlcswitch+routing: handle nil pointer dereference properly

20 of 23 new or added lines in 4 files covered. (86.96%)

25467 existing lines in 425 files now uncovered.

99835 of 200331 relevant lines covered (49.84%)

2.07 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 {
4✔
26
        return tlv.MakeStaticRecord(
4✔
27
                LeaseExpiryRecordType, l, 4, leaseExpiryEncoder, leaseExpiryDecoder,
4✔
28
        )
4✔
29
}
4✔
30

31
// leaseExpiryEncoder is a custom TLV encoder for the LeaseExpiry record.
32
func leaseExpiryEncoder(w io.Writer, val interface{}, buf *[8]byte) error {
4✔
33
        if v, ok := val.(*LeaseExpiry); ok {
8✔
34
                return tlv.EUint32T(w, uint32(*v), buf)
4✔
35
        }
4✔
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 {
4✔
42
        if v, ok := val.(*LeaseExpiry); ok {
8✔
43
                var leaseExpiry uint32
4✔
44
                if err := tlv.DUint32(r, &leaseExpiry, buf, l); err != nil {
4✔
UNCOV
45
                        return err
×
UNCOV
46
                }
×
47
                *v = LeaseExpiry(leaseExpiry)
4✔
48
                return nil
4✔
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