Merge pull request #4163 from cfromknecht/version-rpc

verrpc: add GetVersion endpoint
This commit is contained in:
Olaoluwa Osuntokun 2020-04-13 16:03:52 -07:00 committed by GitHub
commit 786e278e12
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
16 changed files with 1448 additions and 791 deletions

View file

@ -22,7 +22,7 @@ ANDROID_BUILD_DIR := $(MOBILE_BUILD_DIR)/android
ANDROID_BUILD := $(ANDROID_BUILD_DIR)/Lndmobile.aar
COMMIT := $(shell git describe --abbrev=40 --dirty)
LDFLAGS := -ldflags "-X $(PKG)/build.Commit=$(COMMIT)"
COMMIT_HASH := $(shell git rev-parse HEAD)
BTCD_COMMIT := $(shell cat go.mod | \
grep $(BTCD_PKG) | \
@ -38,6 +38,7 @@ GOBUILD := GO111MODULE=on go build -v
GOINSTALL := GO111MODULE=on go install -v
GOTEST := GO111MODULE=on go test
GOVERSION := $(shell go version | awk '{print $$3}')
GOFILES_NOVENDOR = $(shell find . -type f -name '*.go' -not -path "./vendor/*")
GOLIST := go list -deps $(PKG)/... | grep '$(PKG)'| grep -v '/vendor/'
GOLISTCOVER := $(shell go list -deps -f '{{.ImportPath}}' ./... | grep '$(PKG)' | sed -e 's/^$(ESCPKG)/./')
@ -51,6 +52,15 @@ include make/testing_flags.mk
DEV_TAGS := $(if ${tags},$(DEV_TAGS) ${tags},$(DEV_TAGS))
make_ldflags = $(shell echo -ldflags \"-X $(PKG)/build.Commit=$(COMMIT) \
-X $(PKG)/build.CommitHash=$(COMMIT_HASH) \
-X $(PKG)/build.GoVersion=$(GOVERSION) \
-X $(PKG)/build.RawTags=$(shell echo $(1) | sed -e 's/ /,/g')\")
LDFLAGS := $(call make_ldflags, ${tags})
DEV_LDFLAGS := $(call make_ldflags, $(DEV_TAGS))
ITEST_LDFLAGS := $(call make_ldflags, $(ITEST_TAGS))
# Linting uses a lot of memory, so keep it under control by limiting the number
# of workers if requested.
ifneq ($(workers),)
@ -95,13 +105,13 @@ btcd:
build:
@$(call print, "Building debug lnd and lncli.")
$(GOBUILD) -tags="$(DEV_TAGS)" -o lnd-debug $(LDFLAGS) $(PKG)/cmd/lnd
$(GOBUILD) -tags="$(DEV_TAGS)" -o lncli-debug $(LDFLAGS) $(PKG)/cmd/lncli
$(GOBUILD) -tags="$(DEV_TAGS)" -o lnd-debug $(DEV_LDFLAGS) $(PKG)/cmd/lnd
$(GOBUILD) -tags="$(DEV_TAGS)" -o lncli-debug $(DEV_LDFLAGS) $(PKG)/cmd/lncli
build-itest:
@$(call print, "Building itest lnd and lncli.")
$(GOBUILD) -tags="$(ITEST_TAGS)" -o lnd-itest $(LDFLAGS) $(PKG)/cmd/lnd
$(GOBUILD) -tags="$(ITEST_TAGS)" -o lncli-itest $(LDFLAGS) $(PKG)/cmd/lncli
$(GOBUILD) -tags="$(ITEST_TAGS)" -o lnd-itest $(ITEST_LDFLAGS) $(PKG)/cmd/lnd
$(GOBUILD) -tags="$(ITEST_TAGS)" -o lncli-itest $(ITEST_LDFLAGS) $(PKG)/cmd/lncli
install:
@$(call print, "Installing lnd and lncli.")

View file

@ -6,61 +6,85 @@
package build
import (
"bytes"
"fmt"
"strings"
)
// Commit stores the current commit hash of this build, this should be set using
// the -ldflags during compilation.
var Commit string
var (
// Commit stores the current commit of this build, which includes the
// most recent tag, the number of commits since that tag (if non-zero),
// the commit hash, and a dirty marker. This should be set using the
// -ldflags during compilation.
Commit string
// semanticAlphabet
// CommitHash stores the current commit hash of this build, this should
// be set using the -ldflags during compilation.
CommitHash string
// RawTags contains the raw set of build tags, separated by commas. This
// should be set using -ldflags during compilation.
RawTags string
// GoVersion stores the go version that the executable was compiled
// with. This hsould be set using -ldflags during compilation.
GoVersion string
)
// semanticAlphabet is the set of characters that are permitted for use in an
// AppPreRelease.
const semanticAlphabet = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-"
// These constants define the application version and follow the semantic
// versioning 2.0.0 spec (http://semver.org/).
const (
appMajor uint = 0
appMinor uint = 9
appPatch uint = 0
// AppMajor defines the major version of this binary.
AppMajor uint = 0
// appPreRelease MUST only contain characters from semanticAlphabet
// AppMinor defines the minor version of this binary.
AppMinor uint = 9
// AppPatch defines the application patch for this binary.
AppPatch uint = 0
// AppPreRelease MUST only contain characters from semanticAlphabet
// per the semantic versioning spec.
appPreRelease = "beta"
AppPreRelease = "beta"
)
func init() {
// Assert that AppPreRelease is valid according to the semantic
// versioning guidelines for pre-release version and build metadata
// strings. In particular it MUST only contain characters in
// semanticAlphabet.
for _, r := range AppPreRelease {
if !strings.ContainsRune(semanticAlphabet, r) {
panic(fmt.Errorf("rune: %v is not in the semantic "+
"alphabet", r))
}
}
}
// Version returns the application version as a properly formed string per the
// semantic versioning 2.0.0 spec (http://semver.org/).
func Version() string {
// Start with the major, minor, and patch versions.
version := fmt.Sprintf("%d.%d.%d", appMajor, appMinor, appPatch)
version := fmt.Sprintf("%d.%d.%d", AppMajor, AppMinor, AppPatch)
// Append pre-release version if there is one. The hyphen called for
// by the semantic versioning spec is automatically appended and should
// not be contained in the pre-release string. The pre-release version
// is not appended if it contains invalid characters.
preRelease := normalizeVerString(appPreRelease)
if preRelease != "" {
version = fmt.Sprintf("%s-%s", version, preRelease)
// Append pre-release version if there is one. The hyphen called for by
// the semantic versioning spec is automatically appended and should not
// be contained in the pre-release string.
if AppPreRelease != "" {
version = fmt.Sprintf("%s-%s", version, AppPreRelease)
}
// Append commit hash of current build to version.
version = fmt.Sprintf("%s commit=%s", version, Commit)
return version
}
// normalizeVerString returns the passed string stripped of all characters which
// are not valid according to the semantic versioning guidelines for pre-release
// version and build metadata strings. In particular they MUST only contain
// characters in semanticAlphabet.
func normalizeVerString(str string) string {
var result bytes.Buffer
for _, r := range str {
if strings.ContainsRune(semanticAlphabet, r) {
result.WriteRune(r)
}
// Tags returns the list of build tags that were compiled into the executable.
func Tags() []string {
if len(RawTags) == 0 {
return nil
}
return result.String()
return strings.Split(RawTags, ",")
}

54
cmd/lncli/cmd_version.go Normal file
View file

@ -0,0 +1,54 @@
package main
import (
"context"
"fmt"
"github.com/lightningnetwork/lnd/build"
"github.com/lightningnetwork/lnd/lnrpc/lnclipb"
"github.com/lightningnetwork/lnd/lnrpc/verrpc"
"github.com/urfave/cli"
)
var versionCommand = cli.Command{
Name: "version",
Usage: "Display lncli and lnd version info.",
Description: `
Returns version information about both lncli and lnd. If lncli is unable
to connect to lnd, the command fails but still prints the lncli version.
`,
Action: actionDecorator(version),
}
func version(ctx *cli.Context) error {
conn := getClientConn(ctx, false)
defer conn.Close()
versions := &lnclipb.VersionResponse{
Lncli: &verrpc.Version{
Commit: build.Commit,
CommitHash: build.CommitHash,
Version: build.Version(),
AppMajor: uint32(build.AppMajor),
AppMinor: uint32(build.AppMinor),
AppPatch: uint32(build.AppPatch),
AppPreRelease: build.AppPreRelease,
BuildTags: build.Tags(),
GoVersion: build.GoVersion,
},
}
client := verrpc.NewVersionerClient(conn)
ctxb := context.Background()
lndVersion, err := client.GetVersion(ctxb, &verrpc.VersionRequest{})
if err != nil {
printRespJSON(versions)
return fmt.Errorf("unable fetch version from lnd: %v", err)
}
versions.Lnd = lndVersion
printRespJSON(versions)
return nil
}

View file

@ -301,6 +301,7 @@ func main() {
restoreChanBackupCommand,
bakeMacaroonCommand,
trackPaymentCommand,
versionCommand,
}
// Add any extra commands determined by build flags.

91
lnrpc/lnclipb/lncli.pb.go Normal file
View file

@ -0,0 +1,91 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// source: lnclipb/lncli.proto
package lnclipb
import (
fmt "fmt"
proto "github.com/golang/protobuf/proto"
verrpc "github.com/lightningnetwork/lnd/lnrpc/verrpc"
math "math"
)
// Reference imports to suppress errors if they are not otherwise used.
var _ = proto.Marshal
var _ = fmt.Errorf
var _ = math.Inf
// This is a compile-time assertion to ensure that this generated file
// is compatible with the proto package it is being compiled against.
// A compilation error at this line likely means your copy of the
// proto package needs to be updated.
const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package
type VersionResponse struct {
/// The version information for lncli.
Lncli *verrpc.Version `protobuf:"bytes,1,opt,name=lncli,proto3" json:"lncli,omitempty"`
/// The version information for lnd.
Lnd *verrpc.Version `protobuf:"bytes,2,opt,name=lnd,proto3" json:"lnd,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *VersionResponse) Reset() { *m = VersionResponse{} }
func (m *VersionResponse) String() string { return proto.CompactTextString(m) }
func (*VersionResponse) ProtoMessage() {}
func (*VersionResponse) Descriptor() ([]byte, []int) {
return fileDescriptor_88b54c9c61b986c4, []int{0}
}
func (m *VersionResponse) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_VersionResponse.Unmarshal(m, b)
}
func (m *VersionResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_VersionResponse.Marshal(b, m, deterministic)
}
func (m *VersionResponse) XXX_Merge(src proto.Message) {
xxx_messageInfo_VersionResponse.Merge(m, src)
}
func (m *VersionResponse) XXX_Size() int {
return xxx_messageInfo_VersionResponse.Size(m)
}
func (m *VersionResponse) XXX_DiscardUnknown() {
xxx_messageInfo_VersionResponse.DiscardUnknown(m)
}
var xxx_messageInfo_VersionResponse proto.InternalMessageInfo
func (m *VersionResponse) GetLncli() *verrpc.Version {
if m != nil {
return m.Lncli
}
return nil
}
func (m *VersionResponse) GetLnd() *verrpc.Version {
if m != nil {
return m.Lnd
}
return nil
}
func init() {
proto.RegisterType((*VersionResponse)(nil), "lnclipb.VersionResponse")
}
func init() { proto.RegisterFile("lnclipb/lncli.proto", fileDescriptor_88b54c9c61b986c4) }
var fileDescriptor_88b54c9c61b986c4 = []byte{
// 159 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x12, 0xce, 0xc9, 0x4b, 0xce,
0xc9, 0x2c, 0x48, 0xd2, 0x07, 0xd3, 0x7a, 0x05, 0x45, 0xf9, 0x25, 0xf9, 0x42, 0xec, 0x50, 0x41,
0x29, 0xe1, 0xb2, 0xd4, 0xa2, 0xa2, 0x82, 0x64, 0x7d, 0x08, 0x05, 0x91, 0x55, 0x8a, 0xe6, 0xe2,
0x0f, 0x4b, 0x2d, 0x2a, 0xce, 0xcc, 0xcf, 0x0b, 0x4a, 0x2d, 0x2e, 0xc8, 0xcf, 0x2b, 0x4e, 0x15,
0x52, 0xe5, 0x62, 0x05, 0x6b, 0x91, 0x60, 0x54, 0x60, 0xd4, 0xe0, 0x36, 0xe2, 0xd7, 0x83, 0x6a,
0x80, 0xa9, 0x83, 0xc8, 0x0a, 0x29, 0x72, 0x31, 0xe7, 0xe4, 0xa5, 0x48, 0x30, 0x61, 0x57, 0x04,
0x92, 0x73, 0xd2, 0x8f, 0xd2, 0x4d, 0xcf, 0x2c, 0xc9, 0x28, 0x4d, 0xd2, 0x4b, 0xce, 0xcf, 0xd5,
0xcf, 0xc9, 0x4c, 0xcf, 0x28, 0xc9, 0xcb, 0xcc, 0x4b, 0xcf, 0x4b, 0x2d, 0x29, 0xcf, 0x2f, 0xca,
0xd6, 0xcf, 0xc9, 0x4b, 0xd1, 0xcf, 0xc9, 0x03, 0x39, 0x09, 0xea, 0xc4, 0x24, 0x36, 0xb0, 0xa3,
0x8c, 0x01, 0x01, 0x00, 0x00, 0xff, 0xff, 0x4d, 0xfc, 0x5e, 0x89, 0xc9, 0x00, 0x00, 0x00,
}

15
lnrpc/lnclipb/lncli.proto Normal file
View file

@ -0,0 +1,15 @@
syntax = "proto3";
import "verrpc/verrpc.proto";
package lnclipb;
option go_package = "github.com/lightningnetwork/lnd/lnrpc/lnclipb";
message VersionResponse {
/// The version information for lncli.
verrpc.Version lncli = 1;
/// The version information for lnd.
verrpc.Version lnd = 2;
};

File diff suppressed because it is too large Load diff

View file

@ -1660,6 +1660,9 @@ message GetInfoResponse {
/// The version of the LND software that the node is running.
string version = 14;
/// The SHA1 commit hash that the daemon is compiled with.
string commit_hash = 20;
/// The identity pubkey of the current node.
string identity_pubkey = 1;

View file

@ -2923,6 +2923,10 @@
"type": "string",
"description": "/ The version of the LND software that the node is running."
},
"commit_hash": {
"type": "string",
"description": "/ The SHA1 commit hash that the daemon is compiled with."
},
"identity_pubkey": {
"type": "string",
"description": "/ The identity pubkey of the current node."

25
lnrpc/verrpc/driver.go Normal file
View file

@ -0,0 +1,25 @@
package verrpc
import (
"fmt"
"github.com/lightningnetwork/lnd/lnrpc"
)
func init() {
subServer := &lnrpc.SubServerDriver{
SubServerName: subServerName,
New: func(c lnrpc.SubServerConfigDispatcher) (lnrpc.SubServer,
lnrpc.MacaroonPerms, error) {
return &Server{}, macPermissions, nil
},
}
// We'll register ourselves as a sub-RPC server within the global lnrpc
// package namespace.
if err := lnrpc.RegisterSubServer(subServer); err != nil {
panic(fmt.Sprintf("failed to register sub server driver '%s': %v",
subServerName, err))
}
}

32
lnrpc/verrpc/log.go Normal file
View file

@ -0,0 +1,32 @@
package verrpc
import (
"github.com/btcsuite/btclog"
"github.com/lightningnetwork/lnd/build"
)
// log is a logger that is initialized with no output filters. This
// means the package will not perform any logging by default until the caller
// requests it.
var log btclog.Logger
// Subsystem defines the logging code for this subsystem.
const Subsystem = "VRPC"
// The default amount of logging is none.
func init() {
UseLogger(build.NewSubLogger(Subsystem, nil))
}
// DisableLog disables all library log output. Logging output is disabled
// by default until UseLogger is called.
func DisableLog() {
UseLogger(btclog.Disabled)
}
// UseLogger uses a specified Logger to output package logging info.
// This should be used in preference to SetLogWriter if the caller is also
// using btclog.
func UseLogger(logger btclog.Logger) {
log = logger
}

75
lnrpc/verrpc/server.go Normal file
View file

@ -0,0 +1,75 @@
package verrpc
import (
"context"
"github.com/lightningnetwork/lnd/build"
"google.golang.org/grpc"
"gopkg.in/macaroon-bakery.v2/bakery"
)
const subServerName = "VersionRPC"
var macPermissions = map[string][]bakery.Op{
"/verrpc.Versioner/GetVersion": {{
Entity: "info",
Action: "read",
}},
}
// Server is an rpc server that supports querying for information about the
// running binary.
type Server struct{}
// Start launches any helper goroutines required for the rpcServer to function.
//
// NOTE: This is part of the lnrpc.SubServer interface.
func (s *Server) Start() error {
return nil
}
// Stop signals any active goroutines for a graceful closure.
//
// NOTE: This is part of the lnrpc.SubServer interface.
func (s *Server) Stop() error {
return nil
}
// Name returns a unique string representation of the sub-server. This can be
// used to identify the sub-server and also de-duplicate them.
//
// NOTE: This is part of the lnrpc.SubServer interface.
func (s *Server) Name() string {
return subServerName
}
// RegisterWithRootServer will be called by the root gRPC server to direct a
// sub RPC server to register itself with the main gRPC root server. Until this
// is called, each sub-server won't be able to have requests routed towards it.
//
// NOTE: This is part of the lnrpc.SubServer interface.
func (s *Server) RegisterWithRootServer(grpcServer *grpc.Server) error {
RegisterVersionerServer(grpcServer, s)
log.Debugf("Versioner RPC server successfully registered with root " +
"gRPC server")
return nil
}
// GetVersion returns information about the compiled binary.
func (s *Server) GetVersion(_ context.Context,
_ *VersionRequest) (*Version, error) {
return &Version{
Commit: build.Commit,
CommitHash: build.CommitHash,
Version: build.Version(),
AppMajor: uint32(build.AppMajor),
AppMinor: uint32(build.AppMinor),
AppPatch: uint32(build.AppPatch),
AppPreRelease: build.AppPreRelease,
BuildTags: build.Tags(),
GoVersion: build.GoVersion,
}, nil
}

268
lnrpc/verrpc/verrpc.pb.go Normal file
View file

@ -0,0 +1,268 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// source: verrpc/verrpc.proto
package verrpc
import (
context "context"
fmt "fmt"
proto "github.com/golang/protobuf/proto"
grpc "google.golang.org/grpc"
math "math"
)
// Reference imports to suppress errors if they are not otherwise used.
var _ = proto.Marshal
var _ = fmt.Errorf
var _ = math.Inf
// This is a compile-time assertion to ensure that this generated file
// is compatible with the proto package it is being compiled against.
// A compilation error at this line likely means your copy of the
// proto package needs to be updated.
const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package
type VersionRequest struct {
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *VersionRequest) Reset() { *m = VersionRequest{} }
func (m *VersionRequest) String() string { return proto.CompactTextString(m) }
func (*VersionRequest) ProtoMessage() {}
func (*VersionRequest) Descriptor() ([]byte, []int) {
return fileDescriptor_494312204cefa0e6, []int{0}
}
func (m *VersionRequest) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_VersionRequest.Unmarshal(m, b)
}
func (m *VersionRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_VersionRequest.Marshal(b, m, deterministic)
}
func (m *VersionRequest) XXX_Merge(src proto.Message) {
xxx_messageInfo_VersionRequest.Merge(m, src)
}
func (m *VersionRequest) XXX_Size() int {
return xxx_messageInfo_VersionRequest.Size(m)
}
func (m *VersionRequest) XXX_DiscardUnknown() {
xxx_messageInfo_VersionRequest.DiscardUnknown(m)
}
var xxx_messageInfo_VersionRequest proto.InternalMessageInfo
type Version struct {
/// A verbose description of the daemon's commit.
Commit string `protobuf:"bytes,1,opt,name=commit,proto3" json:"commit,omitempty"`
/// The SHA1 commit hash that the daemon is compiled with.
CommitHash string `protobuf:"bytes,2,opt,name=commit_hash,json=commitHash,proto3" json:"commit_hash,omitempty"`
/// The semantic version.
Version string `protobuf:"bytes,3,opt,name=version,proto3" json:"version,omitempty"`
/// The major application version.
AppMajor uint32 `protobuf:"varint,4,opt,name=app_major,json=appMajor,proto3" json:"app_major,omitempty"`
/// The minor application version.
AppMinor uint32 `protobuf:"varint,5,opt,name=app_minor,json=appMinor,proto3" json:"app_minor,omitempty"`
/// The application patch number.
AppPatch uint32 `protobuf:"varint,6,opt,name=app_patch,json=appPatch,proto3" json:"app_patch,omitempty"`
/// The application pre-release modifier, possibly empty.
AppPreRelease string `protobuf:"bytes,7,opt,name=app_pre_release,json=appPreRelease,proto3" json:"app_pre_release,omitempty"`
/// The list of build tags that were supplied during comilation.
BuildTags []string `protobuf:"bytes,8,rep,name=build_tags,json=buildTags,proto3" json:"build_tags,omitempty"`
/// The version of go that compiled the executable.
GoVersion string `protobuf:"bytes,9,opt,name=go_version,json=goVersion,proto3" json:"go_version,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *Version) Reset() { *m = Version{} }
func (m *Version) String() string { return proto.CompactTextString(m) }
func (*Version) ProtoMessage() {}
func (*Version) Descriptor() ([]byte, []int) {
return fileDescriptor_494312204cefa0e6, []int{1}
}
func (m *Version) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_Version.Unmarshal(m, b)
}
func (m *Version) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_Version.Marshal(b, m, deterministic)
}
func (m *Version) XXX_Merge(src proto.Message) {
xxx_messageInfo_Version.Merge(m, src)
}
func (m *Version) XXX_Size() int {
return xxx_messageInfo_Version.Size(m)
}
func (m *Version) XXX_DiscardUnknown() {
xxx_messageInfo_Version.DiscardUnknown(m)
}
var xxx_messageInfo_Version proto.InternalMessageInfo
func (m *Version) GetCommit() string {
if m != nil {
return m.Commit
}
return ""
}
func (m *Version) GetCommitHash() string {
if m != nil {
return m.CommitHash
}
return ""
}
func (m *Version) GetVersion() string {
if m != nil {
return m.Version
}
return ""
}
func (m *Version) GetAppMajor() uint32 {
if m != nil {
return m.AppMajor
}
return 0
}
func (m *Version) GetAppMinor() uint32 {
if m != nil {
return m.AppMinor
}
return 0
}
func (m *Version) GetAppPatch() uint32 {
if m != nil {
return m.AppPatch
}
return 0
}
func (m *Version) GetAppPreRelease() string {
if m != nil {
return m.AppPreRelease
}
return ""
}
func (m *Version) GetBuildTags() []string {
if m != nil {
return m.BuildTags
}
return nil
}
func (m *Version) GetGoVersion() string {
if m != nil {
return m.GoVersion
}
return ""
}
func init() {
proto.RegisterType((*VersionRequest)(nil), "verrpc.VersionRequest")
proto.RegisterType((*Version)(nil), "verrpc.Version")
}
func init() { proto.RegisterFile("verrpc/verrpc.proto", fileDescriptor_494312204cefa0e6) }
var fileDescriptor_494312204cefa0e6 = []byte{
// 300 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x5c, 0x91, 0x51, 0x4b, 0xf3, 0x30,
0x14, 0x86, 0xd9, 0xf6, 0x7d, 0xdd, 0x72, 0x64, 0x4e, 0x22, 0x48, 0x50, 0xc4, 0xb1, 0x0b, 0xd9,
0x85, 0xb4, 0xa0, 0xf8, 0x07, 0x76, 0xa3, 0x37, 0x82, 0x14, 0xf1, 0xc2, 0x9b, 0x92, 0x75, 0x87,
0x34, 0xda, 0x26, 0x31, 0xc9, 0xe6, 0x6f, 0xf1, 0xdf, 0x4a, 0x93, 0xae, 0x43, 0xaf, 0x7a, 0x9e,
0xf7, 0x29, 0xa7, 0xe5, 0x3d, 0x70, 0xba, 0x43, 0x6b, 0x4d, 0x99, 0xc5, 0x47, 0x6a, 0xac, 0xf6,
0x9a, 0x26, 0x91, 0x16, 0x27, 0x70, 0xfc, 0x8a, 0xd6, 0x49, 0xad, 0x72, 0xfc, 0xdc, 0xa2, 0xf3,
0x8b, 0xef, 0x21, 0x8c, 0xbb, 0x88, 0x9e, 0x41, 0x52, 0xea, 0xa6, 0x91, 0x9e, 0x0d, 0xe6, 0x83,
0x25, 0xc9, 0x3b, 0xa2, 0x57, 0x70, 0x14, 0xa7, 0xa2, 0xe2, 0xae, 0x62, 0xc3, 0x20, 0x21, 0x46,
0x8f, 0xdc, 0x55, 0x94, 0xc1, 0x78, 0x17, 0x77, 0xb0, 0x51, 0x90, 0x7b, 0xa4, 0x17, 0x40, 0xb8,
0x31, 0x45, 0xc3, 0xdf, 0xb5, 0x65, 0xff, 0xe6, 0x83, 0xe5, 0x34, 0x9f, 0x70, 0x63, 0x9e, 0x5a,
0xee, 0xa5, 0x54, 0xda, 0xb2, 0xff, 0x07, 0xd9, 0xf2, 0x5e, 0x1a, 0xee, 0xcb, 0x8a, 0x25, 0xbd,
0x7c, 0x6e, 0x99, 0x5e, 0xc3, 0x2c, 0x48, 0x8b, 0x85, 0xc5, 0x1a, 0xb9, 0x43, 0x36, 0x0e, 0x1f,
0x9e, 0xb6, 0xaf, 0x58, 0xcc, 0x63, 0x48, 0x2f, 0x01, 0xd6, 0x5b, 0x59, 0x6f, 0x0a, 0xcf, 0x85,
0x63, 0x93, 0xf9, 0x68, 0x49, 0x72, 0x12, 0x92, 0x17, 0x2e, 0x5c, 0xab, 0x85, 0x2e, 0xf6, 0xbf,
0x4e, 0xc2, 0x06, 0x22, 0x74, 0xd7, 0xc7, 0xed, 0x0a, 0x48, 0x37, 0xa2, 0xa5, 0xf7, 0x00, 0x0f,
0xe8, 0xfb, 0xaa, 0xd2, 0xae, 0xdf, 0xdf, 0x75, 0x9e, 0xcf, 0xfe, 0xe4, 0xab, 0xf4, 0xed, 0x46,
0x48, 0x5f, 0x6d, 0xd7, 0x69, 0xa9, 0x9b, 0xac, 0x96, 0xa2, 0xf2, 0x4a, 0x2a, 0xa1, 0xd0, 0x7f,
0x69, 0xfb, 0x91, 0xd5, 0x6a, 0x93, 0xd5, 0xea, 0x70, 0xaf, 0x75, 0x12, 0x0e, 0x76, 0xf7, 0x13,
0x00, 0x00, 0xff, 0xff, 0x00, 0x3d, 0xb5, 0x81, 0xc7, 0x01, 0x00, 0x00,
}
// Reference imports to suppress errors if they are not otherwise used.
var _ context.Context
var _ grpc.ClientConn
// This is a compile-time assertion to ensure that this generated file
// is compatible with the grpc package it is being compiled against.
const _ = grpc.SupportPackageIsVersion4
// VersionerClient is the client API for Versioner service.
//
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream.
type VersionerClient interface {
GetVersion(ctx context.Context, in *VersionRequest, opts ...grpc.CallOption) (*Version, error)
}
type versionerClient struct {
cc *grpc.ClientConn
}
func NewVersionerClient(cc *grpc.ClientConn) VersionerClient {
return &versionerClient{cc}
}
func (c *versionerClient) GetVersion(ctx context.Context, in *VersionRequest, opts ...grpc.CallOption) (*Version, error) {
out := new(Version)
err := c.cc.Invoke(ctx, "/verrpc.Versioner/GetVersion", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
// VersionerServer is the server API for Versioner service.
type VersionerServer interface {
GetVersion(context.Context, *VersionRequest) (*Version, error)
}
func RegisterVersionerServer(s *grpc.Server, srv VersionerServer) {
s.RegisterService(&_Versioner_serviceDesc, srv)
}
func _Versioner_GetVersion_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(VersionRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(VersionerServer).GetVersion(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/verrpc.Versioner/GetVersion",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(VersionerServer).GetVersion(ctx, req.(*VersionRequest))
}
return interceptor(ctx, in, info, handler)
}
var _Versioner_serviceDesc = grpc.ServiceDesc{
ServiceName: "verrpc.Versioner",
HandlerType: (*VersionerServer)(nil),
Methods: []grpc.MethodDesc{
{
MethodName: "GetVersion",
Handler: _Versioner_GetVersion_Handler,
},
},
Streams: []grpc.StreamDesc{},
Metadata: "verrpc/verrpc.proto",
}

41
lnrpc/verrpc/verrpc.proto Normal file
View file

@ -0,0 +1,41 @@
syntax = "proto3";
package verrpc;
option go_package = "github.com/lightningnetwork/lnd/lnrpc/verrpc";
service Versioner {
rpc GetVersion (VersionRequest) returns (Version);
};
message VersionRequest {
};
message Version {
/// A verbose description of the daemon's commit.
string commit = 1;
/// The SHA1 commit hash that the daemon is compiled with.
string commit_hash = 2;
/// The semantic version.
string version = 3;
/// The major application version.
uint32 app_major = 4;
/// The minor application version.
uint32 app_minor = 5;
/// The application patch number.
uint32 app_patch = 6;
/// The application pre-release modifier, possibly empty.
string app_pre_release = 7;
/// The list of build tags that were supplied during comilation.
repeated string build_tags = 8;
/// The version of go that compiled the executable.
string go_version = 9;
};

2
log.go
View file

@ -23,6 +23,7 @@ import (
"github.com/lightningnetwork/lnd/lnrpc/invoicesrpc"
"github.com/lightningnetwork/lnd/lnrpc/routerrpc"
"github.com/lightningnetwork/lnd/lnrpc/signrpc"
"github.com/lightningnetwork/lnd/lnrpc/verrpc"
"github.com/lightningnetwork/lnd/lnrpc/walletrpc"
"github.com/lightningnetwork/lnd/lnrpc/wtclientrpc"
"github.com/lightningnetwork/lnd/lnwallet"
@ -103,6 +104,7 @@ func init() {
addSubLogger(routerrpc.Subsystem, routerrpc.UseLogger)
addSubLogger(wtclientrpc.Subsystem, wtclientrpc.UseLogger)
addSubLogger(chanfitness.Subsystem, chanfitness.UseLogger)
addSubLogger(verrpc.Subsystem, verrpc.UseLogger)
}
// addSubLogger is a helper method to conveniently create and register the

View file

@ -2407,7 +2407,8 @@ func (r *rpcServer) GetInfo(ctx context.Context,
Alias: nodeAnn.Alias.String(),
Color: routing.EncodeHexColor(nodeAnn.RGBColor),
BestHeaderTimestamp: int64(bestHeaderTimestamp),
Version: build.Version(),
Version: build.Version() + " commit=" + build.Commit,
CommitHash: build.CommitHash,
SyncedToGraph: isGraphSynced,
Features: features,
}, nil