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

lightningnetwork / lnd / 13974489001

20 Mar 2025 04:32PM UTC coverage: 56.292% (-2.9%) from 59.168%
13974489001

Pull #8754

github

web-flow
Merge aed149e6b into ea050d06f
Pull Request #8754: Add `Outbound` Remote Signer implementation

594 of 1713 new or added lines in 26 files covered. (34.68%)

23052 existing lines in 272 files now uncovered.

105921 of 188165 relevant lines covered (56.29%)

23796.34 hits per line

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

0.0
/lnrpc/verrpc/server.go
1
package verrpc
2

3
import (
4
        "context"
5

6
        "github.com/grpc-ecosystem/grpc-gateway/v2/runtime"
7
        "github.com/lightningnetwork/lnd/build"
8
        "github.com/lightningnetwork/lnd/lnrpc"
9
        "google.golang.org/grpc"
10
        "gopkg.in/macaroon-bakery.v2/bakery"
11
)
12

13
const subServerName = "VersionRPC"
14

15
var macPermissions = map[string][]bakery.Op{
16
        "/verrpc.Versioner/GetVersion": {{
17
                Entity: "info",
18
                Action: "read",
19
        }},
20
}
21

22
// ServerShell is a shell struct holding a reference to the actual sub-server.
23
// It is used to register the gRPC sub-server with the root server before we
24
// have the necessary dependencies to populate the actual sub-server.
25
type ServerShell struct {
26
        VersionerServer
27
}
28

29
// Server is an rpc server that supports querying for information about the
30
// running binary.
31
type Server struct {
32
        // Required by the grpc-gateway/v2 library for forward compatibility.
33
        UnimplementedVersionerServer
34
}
35

36
// Stop signals any active goroutines for a graceful closure.
37
//
38
// NOTE: This is part of the lnrpc.SubServer interface.
NEW
39
func (s *Server) Stop() error {
×
UNCOV
40
        return nil
×
UNCOV
41
}
×
42

43
// InjectDependencies populates the sub-server's dependencies. If the
44
// finalizeDependencies boolean is true, then the sub-server will finalize its
45
// dependencies and return an error if any required dependencies are missing.
46
//
47
// NOTE: This is part of the lnrpc.SubServer interface.
48
func (s *Server) InjectDependencies(_ lnrpc.SubServerConfigDispatcher,
NEW
49
        _ bool) error {
×
NEW
50
        // There are no specific dependencies to populate for this subServer.
×
UNCOV
51
        return nil
×
UNCOV
52
}
×
53

54
// Name returns a unique string representation of the sub-server. This can be
55
// used to identify the sub-server and also de-duplicate them.
56
//
57
// NOTE: This is part of the lnrpc.SubServer interface.
UNCOV
58
func (s *Server) Name() string {
×
UNCOV
59
        return subServerName
×
UNCOV
60
}
×
61

62
// RegisterWithRootServer will be called by the root gRPC server to direct a
63
// sub RPC server to register itself with the main gRPC root server. Until this
64
// is called, each sub-server won't be able to have requests routed towards it.
65
//
66
// NOTE: This is part of the lnrpc.GrpcHandler interface.
UNCOV
67
func (r *ServerShell) RegisterWithRootServer(grpcServer *grpc.Server) error {
×
UNCOV
68
        RegisterVersionerServer(grpcServer, r)
×
UNCOV
69

×
UNCOV
70
        log.Debugf("Versioner RPC server successfully registered with root " +
×
UNCOV
71
                "gRPC server")
×
UNCOV
72

×
UNCOV
73
        return nil
×
UNCOV
74
}
×
75

76
// RegisterWithRestServer will be called by the root REST mux to direct a sub
77
// RPC server to register itself with the main REST mux server. Until this is
78
// called, each sub-server won't be able to have requests routed towards it.
79
//
80
// NOTE: This is part of the lnrpc.GrpcHandler interface.
81
func (r *ServerShell) RegisterWithRestServer(ctx context.Context,
UNCOV
82
        mux *runtime.ServeMux, dest string, opts []grpc.DialOption) error {
×
UNCOV
83

×
UNCOV
84
        // We make sure that we register it with the main REST server to ensure
×
UNCOV
85
        // all our methods are routed properly.
×
UNCOV
86
        err := RegisterVersionerHandlerFromEndpoint(ctx, mux, dest, opts)
×
UNCOV
87
        if err != nil {
×
88
                log.Errorf("Could not register Versioner REST server "+
×
89
                        "with root REST server: %v", err)
×
90
                return err
×
91
        }
×
92

UNCOV
93
        log.Debugf("Versioner REST server successfully registered with " +
×
UNCOV
94
                "root REST server")
×
UNCOV
95
        return nil
×
96
}
97

98
// CreateSubServer creates an instance of the sub-server, and returns the
99
// macaroon permissions that the sub-server wishes to pass on to the root server
100
// for all methods routed towards it.
101
//
102
// NOTE: This is part of the lnrpc.GrpcHandler interface.
103
func (r *ServerShell) CreateSubServer() (
UNCOV
104
        lnrpc.SubServer, lnrpc.MacaroonPerms, error) {
×
UNCOV
105

×
UNCOV
106
        subServer := &Server{}
×
UNCOV
107
        r.VersionerServer = subServer
×
UNCOV
108
        return subServer, macPermissions, nil
×
UNCOV
109
}
×
110

111
// GetVersion returns information about the compiled binary.
112
func (s *Server) GetVersion(_ context.Context,
UNCOV
113
        _ *VersionRequest) (*Version, error) {
×
UNCOV
114

×
UNCOV
115
        return &Version{
×
UNCOV
116
                Commit:        build.Commit,
×
UNCOV
117
                CommitHash:    build.CommitHash,
×
UNCOV
118
                Version:       build.Version(),
×
UNCOV
119
                AppMajor:      uint32(build.AppMajor),
×
UNCOV
120
                AppMinor:      uint32(build.AppMinor),
×
UNCOV
121
                AppPatch:      uint32(build.AppPatch),
×
UNCOV
122
                AppPreRelease: build.AppPreRelease,
×
UNCOV
123
                BuildTags:     build.Tags(),
×
UNCOV
124
                GoVersion:     build.GoVersion,
×
UNCOV
125
        }, nil
×
UNCOV
126
}
×
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