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

lightningnetwork / lnd / 12412879685

19 Dec 2024 12:40PM UTC coverage: 58.744% (+0.09%) from 58.653%
12412879685

Pull #8754

github

ViktorTigerstrom
itest: wrap deriveCustomScopeAccounts at 80 chars

This commit fixes that word wrapping for the deriveCustomScopeAccounts
function docs, and ensures that it wraps at 80 characters or less.
Pull Request #8754: Add `Outbound` Remote Signer implementation

1858 of 2816 new or added lines in 47 files covered. (65.98%)

267 existing lines in 51 files now uncovered.

136038 of 231578 relevant lines covered (58.74%)

19020.65 hits per line

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

59.09
/lnrpc/chainrpc/driver.go
1
//go:build chainrpc
2
// +build chainrpc
3

4
package chainrpc
5

6
import (
7
        "fmt"
8

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

12
// getConfig is a helper method that will fetch the config for sub-server given
13
// the main config dispatcher method. If we're unable to find the config
14
// that is meant for us in the config dispatcher, then we'll exit with an
15
// error. If enforceDependencies is set to true, the function also verifies that
16
// the dependencies in the config are properly set.
17
func getConfig(configRegistry lnrpc.SubServerConfigDispatcher,
18
        enforceDependencies bool) (*Config, error) {
3✔
19

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

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

39
        if enforceDependencies {
6✔
40
                if err := verifyDependencies(config); err != nil {
3✔
NEW
41
                        return nil, err
×
NEW
42
                }
×
43
        }
44

45
        return config, nil
3✔
46
}
47

48
// verifyDependencies ensures that the dependencies in the config are properly
49
// set.
50
func verifyDependencies(config *Config) error {
3✔
51
        // Before we try to make the new chain notifier service instance, we'll
3✔
52
        // perform some sanity checks on the arguments to ensure that they're
3✔
53
        // usable.
3✔
54
        switch {
3✔
55
        // If the macaroon service is set (we should use macaroons), then
56
        // ensure that we know where to look for them, or create them if not
57
        // found.
58
        case config.MacService != nil && config.NetworkDir == "":
×
NEW
59
                return fmt.Errorf("NetworkDir must be set to create chainrpc")
×
60

61
        case config.ChainNotifier == nil:
×
NEW
62
                return fmt.Errorf("ChainNotifier must be set to create " +
×
NEW
63
                        "chainrpc")
×
64

65
        case config.Chain == nil:
×
NEW
66
                return fmt.Errorf("field Chain must be set to create chainrpc")
×
67
        }
68

69
        return nil
3✔
70
}
71

72
func init() {
3✔
73
        subServer := &lnrpc.SubServerDriver{
3✔
74
                SubServerName: subServerName,
3✔
75
                NewGrpcHandler: func() lnrpc.GrpcHandler {
6✔
76
                        return &ServerShell{}
3✔
77
                },
3✔
78
        }
79

80
        // If the build tag is active, then we'll register ourselves as a
81
        // sub-RPC server within the global lnrpc package namespace.
82
        if err := lnrpc.RegisterSubServer(subServer); err != nil {
3✔
83
                panic(fmt.Sprintf("failed to register subserver driver %s: %v",
×
84
                        subServerName, err))
×
85
        }
86
}
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