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

lightningnetwork / lnd / 11954082915

21 Nov 2024 01:20PM UTC coverage: 59.327% (+0.6%) from 58.776%
11954082915

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

1940 of 2984 new or added lines in 44 files covered. (65.01%)

226 existing lines in 37 files now uncovered.

135234 of 227947 relevant lines covered (59.33%)

19316.75 hits per line

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

60.53
/lnrpc/signrpc/driver.go
1
//go:build signrpc
2
// +build signrpc
3

4
package signrpc
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) {
4✔
19

4✔
20
        // We'll attempt to look up the config that we expect, according to our
4✔
21
        // SubServerName name. If we can't find this, then we'll exit with an
4✔
22
        // error, as we're unable to properly initialize ourselves without this
4✔
23
        // config.
4✔
24
        subServerConf, ok := configRegistry.FetchConfig(SubServerName)
4✔
25
        if !ok {
4✔
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)
4✔
33
        if !ok {
4✔
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 {
8✔
40
                if err := verifyDependencies(config); err != nil {
4✔
NEW
41
                        return nil, err
×
NEW
42
                }
×
43
        }
44

45
        return config, nil
4✔
46
}
47

48
// verifyDependencies ensures that the dependencies in the config are properly
49
// set.
50
//
51
//nolint:stylecheck
52
func verifyDependencies(config *Config) error {
4✔
53
        switch {
4✔
54
        // If the macaroon service is set (we should use macaroons), then
55
        // ensure that we know where to look for them, or create them if not
56
        // found.
57
        case config.MacService != nil && config.NetworkDir == "":
×
NEW
58
                return fmt.Errorf("NetworkDir must be set to create Signrpc")
×
59
        case config.Signer == nil:
×
NEW
60
                return fmt.Errorf("Signer must be set to create Signrpc")
×
61
        }
62

63
        return nil
4✔
64
}
65

66
func init() {
4✔
67
        subServer := &lnrpc.SubServerDriver{
4✔
68
                SubServerName: SubServerName,
4✔
69
                NewGrpcHandler: func() lnrpc.GrpcHandler {
8✔
70
                        return &ServerShell{}
4✔
71
                },
4✔
72
        }
73

74
        // If the build tag is active, then we'll register ourselves as a
75
        // sub-RPC server within the global lnrpc package namespace.
76
        if err := lnrpc.RegisterSubServer(subServer); err != nil {
4✔
77
                panic(fmt.Sprintf("failed to register sub server driver '%s': %v",
×
NEW
78
                        SubServerName, err))
×
79
        }
80
}
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