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

lightningnetwork / lnd / 15951470896

29 Jun 2025 04:23AM UTC coverage: 67.594% (-0.01%) from 67.606%
15951470896

Pull #9751

github

web-flow
Merge 599d9b051 into 6290edf14
Pull Request #9751: multi: update Go to 1.23.10 and update some packages

135088 of 199851 relevant lines covered (67.59%)

21909.44 hits per line

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

80.0
/lnwire/typed_fee.go
1
package lnwire
2

3
import (
4
        "io"
5

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

9
const (
10
        FeeRecordType tlv.Type = 55555
11
)
12

13
// Fee represents a fee schedule.
14
type Fee struct {
15
        BaseFee int32
16
        FeeRate int32
17
}
18

19
// Record returns a TLV record that can be used to encode/decode the fee
20
// type from a given TLV stream.
21
func (l *Fee) Record() tlv.Record {
14,055✔
22
        return tlv.MakeStaticRecord(
14,055✔
23
                FeeRecordType, l, 8, feeEncoder, feeDecoder, //nolint:gomnd
14,055✔
24
        )
14,055✔
25
}
14,055✔
26

27
// feeEncoder is a custom TLV encoder for the fee record.
28
func feeEncoder(w io.Writer, val interface{}, buf *[8]byte) error {
714✔
29
        v, ok := val.(*Fee)
714✔
30
        if !ok {
714✔
31
                return tlv.NewTypeForEncodingErr(val, "lnwire.Fee")
×
32
        }
×
33

34
        if err := tlv.EUint32T(w, uint32(v.BaseFee), buf); err != nil {
714✔
35
                return err
×
36
        }
×
37

38
        return tlv.EUint32T(w, uint32(v.FeeRate), buf)
714✔
39
}
40

41
// feeDecoder is a custom TLV decoder for the fee record.
42
func feeDecoder(r io.Reader, val interface{}, buf *[8]byte, l uint64) error {
1,773✔
43
        v, ok := val.(*Fee)
1,773✔
44
        if !ok {
1,773✔
45
                return tlv.NewTypeForDecodingErr(val, "lnwire.Fee", l, 8)
×
46
        }
×
47

48
        var baseFee, feeRate uint32
1,773✔
49
        if err := tlv.DUint32(r, &baseFee, buf, 4); err != nil {
1,775✔
50
                return err
2✔
51
        }
2✔
52
        if err := tlv.DUint32(r, &feeRate, buf, 4); err != nil {
1,773✔
53
                return err
2✔
54
        }
2✔
55

56
        v.FeeRate = int32(feeRate)
1,769✔
57
        v.BaseFee = int32(baseFee)
1,769✔
58

1,769✔
59
        return nil
1,769✔
60
}
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