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

lightningnetwork / lnd / 18908318090

29 Oct 2025 12:45PM UTC coverage: 66.185%. First build
18908318090

Pull #9489

github

web-flow
Merge bb65b4fde into 1ccb52620
Pull Request #9489: multi: add BuildOnion, SendOnion, and TrackOnion RPCs

484 of 629 new or added lines in 14 files covered. (76.95%)

138000 of 208508 relevant lines covered (66.18%)

21020.57 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
        if config.HtlcDispatcher == nil {
3✔
NEW
41
                return nil, nil, fmt.Errorf("switch must be set to create " +
×
NEW
42
                        "SwitchRPC")
×
NEW
43
        }
×
44

45
        return New(config)
3✔
46
}
47

48
// init registers this package's gRPC subserver so that lnd's main RPC server
49
// knows it exists and can later invoke RegisterWithRootServer to attach the
50
// service handlers.
51
func init() {
7✔
52
        subServer := &lnrpc.SubServerDriver{
7✔
53
                SubServerName: subServerName,
7✔
54
                NewGrpcHandler: func() lnrpc.GrpcHandler {
10✔
55
                        return &ServerShell{}
3✔
56
                },
3✔
57
        }
58

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