• 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

61.29
/lnrpc/switchrpc/driver.go
1
//go:build switchrpc
2
// +build switchrpc
3

4
package switchrpc
5

6
import (
7
        "fmt"
8

9
        "github.com/lightningnetwork/lnd/lnrpc"
10
)
11

12
// createNewSubServer is a helper method that will create the new router sub
13
// server given the main config dispatcher method. If we're unable to find the
14
// config that is meant for us in the config dispatcher, then we'll exit with
15
// an error.
16
func createNewSubServer(configRegistry lnrpc.SubServerConfigDispatcher) (
17
        *Server, lnrpc.MacaroonPerms, error) {
3✔
18

3✔
19
        // We'll attempt to look up the config that we expect, according to our
3✔
20
        // subServerName name. If we can't find this, then we'll exit with an
3✔
21
        // error, as we're unable to properly initialize ourselves without this
3✔
22
        // config.
3✔
23
        subServerConf, ok := configRegistry.FetchConfig(subServerName)
3✔
24
        if !ok {
3✔
NEW
25
                return nil, nil, fmt.Errorf("unable to find config for "+
×
NEW
26
                        "subserver type %s", subServerName)
×
NEW
27
        }
×
28

29
        // Now that we've found an object mapping to our service name, we'll
30
        // ensure that it's the type we need.
31
        config, ok := subServerConf.(*Config)
3✔
32
        if !ok {
3✔
NEW
33
                return nil, nil, fmt.Errorf("wrong type of config for "+
×
NEW
34
                        "subserver %s, expected %T got %T", subServerName,
×
NEW
35
                        &Config{}, subServerConf)
×
NEW
36
        }
×
37

38
        // Before we try to make the new switch service instance, we'll perform
39
        // some sanity checks on the arguments to ensure that they're usable.
40
        switch {
3✔
NEW
41
        case config.Switch == nil:
×
NEW
42
                return nil, nil, fmt.Errorf("Switch must be set to create " +
×
NEW
43
                        "SwitchRPC")
×
44
        }
45

46
        return New(config)
3✔
47
}
48

49
func init() {
3✔
50
        subServer := &lnrpc.SubServerDriver{
3✔
51
                SubServerName: subServerName,
3✔
52
                NewGrpcHandler: func() lnrpc.GrpcHandler {
6✔
53
                        return &ServerShell{}
3✔
54
                },
3✔
55
        }
56

57
        // If the build tag is active, then we'll register ourselves as a
58
        // sub-RPC server within the global lnrpc package namespace.
59
        if err := lnrpc.RegisterSubServer(subServer); err != nil {
3✔
NEW
60
                panic(fmt.Sprintf("failed to register sub server driver '%s': %v",
×
NEW
61
                        subServerName, err))
×
62
        }
63
}
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