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

lightningnetwork / lnd / 13211764208

08 Feb 2025 03:08AM UTC coverage: 49.288% (-9.5%) from 58.815%
13211764208

Pull #9489

github

calvinrzachman
itest: verify switchrpc server enforces send then track

We prevent the rpc server from allowing onion dispatches for
attempt IDs which have already been tracked by rpc clients.

This helps protect the client from leaking a duplicate onion
attempt. NOTE: This is not the only method for solving this
issue! The issue could be addressed via careful client side
programming which accounts for the uncertainty and async
nature of dispatching onions to a remote process via RPC.
This would require some lnd ChannelRouter changes for how
we intend to use these RPCs though.
Pull Request #9489: multi: add BuildOnion, SendOnion, and TrackOnion RPCs

474 of 990 new or added lines in 11 files covered. (47.88%)

27321 existing lines in 435 files now uncovered.

101192 of 205306 relevant lines covered (49.29%)

1.54 hits per line

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

66.67
/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 {
3✔
22
        return tlv.MakeStaticRecord(
3✔
23
                FeeRecordType, l, 8, feeEncoder, feeDecoder, //nolint:gomnd
3✔
24
        )
3✔
25
}
3✔
26

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

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

38
        return tlv.EUint32T(w, uint32(v.FeeRate), buf)
3✔
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 {
3✔
43
        v, ok := val.(*Fee)
3✔
44
        if !ok {
3✔
45
                return tlv.NewTypeForDecodingErr(val, "lnwire.Fee", l, 8)
×
46
        }
×
47

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

56
        v.FeeRate = int32(feeRate)
3✔
57
        v.BaseFee = int32(baseFee)
3✔
58

3✔
59
        return nil
3✔
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