• 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

46.3
/lnrpc/walletrpc/driver.go
1
//go:build walletrpc
2
// +build walletrpc
3

4
package walletrpc
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
        // We'll attempt to look up the config that we expect, according to our
4✔
20
        // SubServerName name. If we can't find this, then we'll exit with an
4✔
21
        // error, as we're unable to properly initialize ourselves without this
4✔
22
        // config.
4✔
23
        subServerConf, ok := configRegistry.FetchConfig(SubServerName)
4✔
24
        if !ok {
4✔
NEW
25
                return nil, fmt.Errorf("unable to find config for subserver "+
×
NEW
26
                        "type %s", SubServerName)
×
UNCOV
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)
4✔
32
        if !ok {
4✔
NEW
33
                return nil, fmt.Errorf("wrong type of config for subserver "+
×
NEW
34
                        "%s, expected %T got %T", SubServerName, &Config{},
×
NEW
35
                        subServerConf)
×
NEW
36
        }
×
37

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

44
        return config, nil
4✔
45
}
46

47
// verifyDependencies ensures that the dependencies in the config are properly
48
// set.
49
//
50
//nolint:stylecheck
51
func verifyDependencies(config *Config) error {
4✔
52
        // Before we try to make the new WalletKit service instance, we'll
4✔
53
        // perform some sanity checks on the arguments to ensure that they're
4✔
54
        // usable.
4✔
55
        switch {
4✔
56
        case config.MacService != nil && config.NetworkDir == "":
×
NEW
57
                return fmt.Errorf("NetworkDir must be set to create " +
×
NEW
58
                        "WalletKit RPC server")
×
59

60
        case config.FeeEstimator == nil:
×
NEW
61
                return fmt.Errorf("FeeEstimator must be set to create " +
×
NEW
62
                        "WalletKit RPC server")
×
63

64
        case config.Wallet == nil:
×
NEW
65
                return fmt.Errorf("Wallet must be set to create WalletKit " +
×
NEW
66
                        "RPC server")
×
67

68
        case config.KeyRing == nil:
×
NEW
69
                return fmt.Errorf("KeyRing must be set to create WalletKit " +
×
NEW
70
                        "RPC server")
×
71

72
        case config.Sweeper == nil:
×
NEW
73
                return fmt.Errorf("Sweeper must be set to create WalletKit " +
×
NEW
74
                        "RPC server")
×
75

76
        case config.Chain == nil:
×
NEW
77
                return fmt.Errorf("Chain must be set to create WalletKit RPC " +
×
NEW
78
                        "server")
×
79
        }
80

81
        return nil
4✔
82
}
83

84
func init() {
4✔
85
        subServer := &lnrpc.SubServerDriver{
4✔
86
                SubServerName: SubServerName,
4✔
87
                NewGrpcHandler: func() lnrpc.GrpcHandler {
8✔
88
                        return &ServerShell{}
4✔
89
                },
4✔
90
        }
91

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