mirror of
https://github.com/getAlby/lndhub.go.git
synced 2025-12-20 14:14:47 +01:00
Merge pull request #346 from getAlby/chore/remove-grpc
remove grpc server
This commit is contained in:
@@ -1,65 +0,0 @@
|
|||||||
/*
|
|
||||||
*
|
|
||||||
* Copyright 2015 gRPC authors.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
// Package main implements a client for Greeter service.
|
|
||||||
package main
|
|
||||||
|
|
||||||
import (
|
|
||||||
"context"
|
|
||||||
"flag"
|
|
||||||
"fmt"
|
|
||||||
"io"
|
|
||||||
"log"
|
|
||||||
|
|
||||||
"github.com/getAlby/lndhub.go/lndhubrpc"
|
|
||||||
"google.golang.org/grpc"
|
|
||||||
"google.golang.org/grpc/credentials/insecure"
|
|
||||||
)
|
|
||||||
|
|
||||||
var (
|
|
||||||
addr = flag.String("addr", "localhost:10009", "the address to connect to")
|
|
||||||
)
|
|
||||||
|
|
||||||
func main() {
|
|
||||||
flag.Parse()
|
|
||||||
// Set up a connection to the server.
|
|
||||||
conn, err := grpc.Dial(*addr, grpc.WithTransportCredentials(insecure.NewCredentials()))
|
|
||||||
if err != nil {
|
|
||||||
log.Fatalf("did not connect: %v", err)
|
|
||||||
}
|
|
||||||
defer conn.Close()
|
|
||||||
c := lndhubrpc.NewInvoiceSubscriptionClient(conn)
|
|
||||||
id := uint32(115)
|
|
||||||
r, err := c.SubsribeInvoices(context.Background(), &lndhubrpc.SubsribeInvoicesRequest{
|
|
||||||
FromId: &id,
|
|
||||||
})
|
|
||||||
if err != nil {
|
|
||||||
log.Fatalf("could not greet: %v", err)
|
|
||||||
}
|
|
||||||
fmt.Println("starting loop")
|
|
||||||
for {
|
|
||||||
result, err := r.Recv()
|
|
||||||
if err != nil {
|
|
||||||
if err == io.EOF {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
fmt.Println(err.Error())
|
|
||||||
}
|
|
||||||
fmt.Println(result)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,121 +0,0 @@
|
|||||||
package integration_tests
|
|
||||||
|
|
||||||
import (
|
|
||||||
"context"
|
|
||||||
"fmt"
|
|
||||||
"log"
|
|
||||||
"net"
|
|
||||||
"testing"
|
|
||||||
|
|
||||||
"github.com/getAlby/lndhub.go/common"
|
|
||||||
"github.com/getAlby/lndhub.go/controllers"
|
|
||||||
"github.com/getAlby/lndhub.go/lib"
|
|
||||||
"github.com/getAlby/lndhub.go/lib/responses"
|
|
||||||
"github.com/getAlby/lndhub.go/lib/service"
|
|
||||||
"github.com/getAlby/lndhub.go/lib/tokens"
|
|
||||||
"github.com/getAlby/lndhub.go/lndhubrpc"
|
|
||||||
"github.com/go-playground/validator/v10"
|
|
||||||
"github.com/labstack/echo/v4"
|
|
||||||
"github.com/stretchr/testify/assert"
|
|
||||||
"github.com/stretchr/testify/suite"
|
|
||||||
"google.golang.org/grpc"
|
|
||||||
"google.golang.org/grpc/credentials/insecure"
|
|
||||||
)
|
|
||||||
|
|
||||||
type GrpcTestSuite struct {
|
|
||||||
TestSuite
|
|
||||||
service *service.LndhubService
|
|
||||||
mlnd *MockLND
|
|
||||||
userLogin ExpectedCreateUserResponseBody
|
|
||||||
userToken string
|
|
||||||
invoiceChan chan (*lndhubrpc.Invoice)
|
|
||||||
grpcClient lndhubrpc.InvoiceSubscription_SubsribeInvoicesClient
|
|
||||||
invoiceUpdateSubCancelFn context.CancelFunc
|
|
||||||
}
|
|
||||||
|
|
||||||
func (suite *GrpcTestSuite) SetupSuite() {
|
|
||||||
suite.invoiceChan = make(chan (*lndhubrpc.Invoice))
|
|
||||||
|
|
||||||
mlnd := newDefaultMockLND()
|
|
||||||
svc, err := LndHubTestServiceInit(mlnd)
|
|
||||||
svc.Config.GRPCPort = 10009
|
|
||||||
suite.mlnd = mlnd
|
|
||||||
if err != nil {
|
|
||||||
log.Fatalf("Error initializing test service: %v", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
users, userTokens, err := createUsers(svc, 1)
|
|
||||||
if err != nil {
|
|
||||||
log.Fatalf("Error creating test users: %v", err)
|
|
||||||
}
|
|
||||||
// Subscribe to LND invoice updates in the background
|
|
||||||
// store cancel func to be called in tear down suite
|
|
||||||
ctx, cancel := context.WithCancel(context.Background())
|
|
||||||
suite.invoiceUpdateSubCancelFn = cancel
|
|
||||||
go svc.InvoiceUpdateSubscription(ctx)
|
|
||||||
|
|
||||||
//start grpc server
|
|
||||||
lis, err := net.Listen("tcp", fmt.Sprintf(":%d", svc.Config.GRPCPort))
|
|
||||||
if err != nil {
|
|
||||||
svc.Logger.Fatalf("Failed to start grpc server: %v", err)
|
|
||||||
}
|
|
||||||
grpcServer := svc.NewGrpcServer(ctx)
|
|
||||||
go func() {
|
|
||||||
err = grpcServer.Serve(lis)
|
|
||||||
if err != nil {
|
|
||||||
svc.Logger.Error(err)
|
|
||||||
}
|
|
||||||
}()
|
|
||||||
|
|
||||||
go StartGrpcClient(ctx, svc.Config.GRPCPort, suite.invoiceChan)
|
|
||||||
|
|
||||||
suite.service = svc
|
|
||||||
e := echo.New()
|
|
||||||
|
|
||||||
e.HTTPErrorHandler = responses.HTTPErrorHandler
|
|
||||||
e.Validator = &lib.CustomValidator{Validator: validator.New()}
|
|
||||||
suite.echo = e
|
|
||||||
suite.userLogin = users[0]
|
|
||||||
suite.userToken = userTokens[0]
|
|
||||||
suite.echo.Use(tokens.Middleware([]byte(suite.service.Config.JWTSecret)))
|
|
||||||
suite.echo.POST("/addinvoice", controllers.NewAddInvoiceController(suite.service).AddInvoice)
|
|
||||||
}
|
|
||||||
func (suite *GrpcTestSuite) TestGrpc() {
|
|
||||||
// create incoming invoice and fund account
|
|
||||||
invoice := suite.createAddInvoiceReq(1000, "integration test grpc", suite.userToken)
|
|
||||||
err := suite.mlnd.mockPaidInvoice(invoice, 0, false, nil)
|
|
||||||
assert.NoError(suite.T(), err)
|
|
||||||
invoiceFromClient := <-suite.invoiceChan
|
|
||||||
assert.Equal(suite.T(), "integration test grpc", invoiceFromClient.Memo)
|
|
||||||
assert.Equal(suite.T(), common.InvoiceTypeIncoming, invoiceFromClient.Type)
|
|
||||||
}
|
|
||||||
|
|
||||||
func StartGrpcClient(ctx context.Context, port int, invoiceChan chan (*lndhubrpc.Invoice)) error {
|
|
||||||
addr := fmt.Sprintf("localhost:%d", port)
|
|
||||||
conn, err := grpc.Dial(addr, grpc.WithTransportCredentials(insecure.NewCredentials()))
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
defer conn.Close()
|
|
||||||
c := lndhubrpc.NewInvoiceSubscriptionClient(conn)
|
|
||||||
r, err := c.SubsribeInvoices(context.Background(), &lndhubrpc.SubsribeInvoicesRequest{})
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
for {
|
|
||||||
result, err := r.Recv()
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
invoiceChan <- result
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (suite *GrpcTestSuite) TearDownSuite() {
|
|
||||||
suite.invoiceUpdateSubCancelFn()
|
|
||||||
clearTable(suite.service, "invoices")
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestGrpcSuite(t *testing.T) {
|
|
||||||
suite.Run(t, new(GrpcTestSuite))
|
|
||||||
}
|
|
||||||
@@ -1,105 +0,0 @@
|
|||||||
package service
|
|
||||||
|
|
||||||
import (
|
|
||||||
"context"
|
|
||||||
|
|
||||||
"github.com/getAlby/lndhub.go/common"
|
|
||||||
"github.com/getAlby/lndhub.go/db/models"
|
|
||||||
"github.com/getAlby/lndhub.go/lndhubrpc"
|
|
||||||
pb "github.com/getAlby/lndhub.go/lndhubrpc"
|
|
||||||
"google.golang.org/grpc"
|
|
||||||
"google.golang.org/protobuf/types/known/timestamppb"
|
|
||||||
)
|
|
||||||
|
|
||||||
func (svc *LndhubService) NewGrpcServer(ctx context.Context) *grpc.Server {
|
|
||||||
s := grpc.NewServer()
|
|
||||||
grpcServer, err := NewGrpcServer(svc, ctx)
|
|
||||||
if err != nil {
|
|
||||||
svc.Logger.Fatalf("Failed to init grpc server, %s", err.Error())
|
|
||||||
}
|
|
||||||
lndhubrpc.RegisterInvoiceSubscriptionServer(s, grpcServer)
|
|
||||||
return s
|
|
||||||
}
|
|
||||||
|
|
||||||
// server is used to implement helloworld.GreeterServer.
|
|
||||||
type Server struct {
|
|
||||||
pb.UnimplementedInvoiceSubscriptionServer
|
|
||||||
svc *LndhubService
|
|
||||||
ctx context.Context
|
|
||||||
}
|
|
||||||
|
|
||||||
func NewGrpcServer(svc *LndhubService, ctx context.Context) (*Server, error) {
|
|
||||||
return &Server{
|
|
||||||
svc: svc,
|
|
||||||
ctx: ctx,
|
|
||||||
}, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *Server) SubsribeInvoices(req *lndhubrpc.SubsribeInvoicesRequest, srv lndhubrpc.InvoiceSubscription_SubsribeInvoicesServer) error {
|
|
||||||
incomingInvoices, _, err := s.svc.InvoicePubSub.Subscribe(common.InvoiceTypeIncoming)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
alreadySeenId := int64(-1)
|
|
||||||
if req.FromId != nil {
|
|
||||||
//look up all settled incoming invoices from a certain id
|
|
||||||
//and return them first
|
|
||||||
invoices := []models.Invoice{}
|
|
||||||
err := s.svc.DB.NewSelect().Model(&invoices).Where("state = 'settled'").Where("type = 'incoming'").Where("id > ?", *req.FromId).OrderExpr("id ASC").Scan(s.ctx)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
//add this so we can avoid duplicates in case of a race condition:
|
|
||||||
//when an invoice is settled in the time between the execution of
|
|
||||||
//"InvoicePubSub.Subscribe" and the SQL query execution by the db
|
|
||||||
//it can be both in the "incomingInvoices" channel and the SQL result set.
|
|
||||||
if len(invoices) != 0 {
|
|
||||||
alreadySeenId = int64(invoices[len(invoices)-1].ID)
|
|
||||||
}
|
|
||||||
for _, inv := range invoices {
|
|
||||||
srv.Send(convertInvoice(inv))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for {
|
|
||||||
select {
|
|
||||||
case <-s.ctx.Done():
|
|
||||||
return nil
|
|
||||||
case inv := <-incomingInvoices:
|
|
||||||
//in case we've already send it over
|
|
||||||
if inv.ID > alreadySeenId {
|
|
||||||
srv.Send(convertInvoice(inv))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func convertInvoice(inv models.Invoice) *pb.Invoice {
|
|
||||||
customRecords := []*pb.Invoice_CustomRecords{}
|
|
||||||
for key, value := range inv.DestinationCustomRecords {
|
|
||||||
customRecords = append(customRecords, &pb.Invoice_CustomRecords{
|
|
||||||
//todo: fix types
|
|
||||||
Key: key,
|
|
||||||
Value: value,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
return &pb.Invoice{
|
|
||||||
Id: uint32(inv.ID),
|
|
||||||
Type: inv.Type,
|
|
||||||
UserId: uint32(inv.UserID),
|
|
||||||
Amount: uint32(inv.Amount),
|
|
||||||
Fee: uint32(inv.Fee),
|
|
||||||
Memo: inv.Memo,
|
|
||||||
DescriptionHash: inv.DescriptionHash,
|
|
||||||
PaymentRequest: inv.PaymentRequest,
|
|
||||||
DestinationPubkeyHex: inv.DestinationPubkeyHex,
|
|
||||||
CustomRecords: customRecords,
|
|
||||||
RHash: inv.RHash,
|
|
||||||
Preimage: inv.Preimage,
|
|
||||||
Keysend: inv.Keysend,
|
|
||||||
State: inv.State,
|
|
||||||
CreatedAt: timestamppb.New(inv.CreatedAt),
|
|
||||||
ExpiresAt: timestamppb.New(inv.ExpiresAt.Time),
|
|
||||||
UpdatedAt: timestamppb.New(inv.UpdatedAt.Time),
|
|
||||||
SettledAt: timestamppb.New(inv.SettledAt.Time),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,475 +0,0 @@
|
|||||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
|
||||||
// versions:
|
|
||||||
// protoc-gen-go v1.28.1
|
|
||||||
// protoc v3.21.9
|
|
||||||
// source: lndhubrpc/lndhub.proto
|
|
||||||
|
|
||||||
package lndhubrpc
|
|
||||||
|
|
||||||
import (
|
|
||||||
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
|
|
||||||
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
|
|
||||||
timestamppb "google.golang.org/protobuf/types/known/timestamppb"
|
|
||||||
reflect "reflect"
|
|
||||||
sync "sync"
|
|
||||||
)
|
|
||||||
|
|
||||||
const (
|
|
||||||
// Verify that this generated code is sufficiently up-to-date.
|
|
||||||
_ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
|
|
||||||
// Verify that runtime/protoimpl is sufficiently up-to-date.
|
|
||||||
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
|
|
||||||
)
|
|
||||||
|
|
||||||
type SubsribeInvoicesRequest struct {
|
|
||||||
state protoimpl.MessageState
|
|
||||||
sizeCache protoimpl.SizeCache
|
|
||||||
unknownFields protoimpl.UnknownFields
|
|
||||||
|
|
||||||
FromId *uint32 `protobuf:"varint,1,opt,name=fromId,proto3,oneof" json:"fromId,omitempty"`
|
|
||||||
}
|
|
||||||
|
|
||||||
func (x *SubsribeInvoicesRequest) Reset() {
|
|
||||||
*x = SubsribeInvoicesRequest{}
|
|
||||||
if protoimpl.UnsafeEnabled {
|
|
||||||
mi := &file_lndhubrpc_lndhub_proto_msgTypes[0]
|
|
||||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
|
||||||
ms.StoreMessageInfo(mi)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (x *SubsribeInvoicesRequest) String() string {
|
|
||||||
return protoimpl.X.MessageStringOf(x)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (*SubsribeInvoicesRequest) ProtoMessage() {}
|
|
||||||
|
|
||||||
func (x *SubsribeInvoicesRequest) ProtoReflect() protoreflect.Message {
|
|
||||||
mi := &file_lndhubrpc_lndhub_proto_msgTypes[0]
|
|
||||||
if protoimpl.UnsafeEnabled && x != nil {
|
|
||||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
|
||||||
if ms.LoadMessageInfo() == nil {
|
|
||||||
ms.StoreMessageInfo(mi)
|
|
||||||
}
|
|
||||||
return ms
|
|
||||||
}
|
|
||||||
return mi.MessageOf(x)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Deprecated: Use SubsribeInvoicesRequest.ProtoReflect.Descriptor instead.
|
|
||||||
func (*SubsribeInvoicesRequest) Descriptor() ([]byte, []int) {
|
|
||||||
return file_lndhubrpc_lndhub_proto_rawDescGZIP(), []int{0}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (x *SubsribeInvoicesRequest) GetFromId() uint32 {
|
|
||||||
if x != nil && x.FromId != nil {
|
|
||||||
return *x.FromId
|
|
||||||
}
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
|
|
||||||
type Invoice struct {
|
|
||||||
state protoimpl.MessageState
|
|
||||||
sizeCache protoimpl.SizeCache
|
|
||||||
unknownFields protoimpl.UnknownFields
|
|
||||||
|
|
||||||
Id uint32 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"`
|
|
||||||
Type string `protobuf:"bytes,2,opt,name=type,proto3" json:"type,omitempty"`
|
|
||||||
UserId uint32 `protobuf:"varint,3,opt,name=user_id,json=userId,proto3" json:"user_id,omitempty"`
|
|
||||||
Amount uint32 `protobuf:"varint,4,opt,name=amount,proto3" json:"amount,omitempty"`
|
|
||||||
Fee uint32 `protobuf:"varint,5,opt,name=fee,proto3" json:"fee,omitempty"`
|
|
||||||
Memo string `protobuf:"bytes,6,opt,name=memo,proto3" json:"memo,omitempty"`
|
|
||||||
DescriptionHash string `protobuf:"bytes,7,opt,name=description_hash,json=descriptionHash,proto3" json:"description_hash,omitempty"`
|
|
||||||
PaymentRequest string `protobuf:"bytes,8,opt,name=payment_request,json=paymentRequest,proto3" json:"payment_request,omitempty"`
|
|
||||||
DestinationPubkeyHex string `protobuf:"bytes,9,opt,name=destination_pubkey_hex,json=destinationPubkeyHex,proto3" json:"destination_pubkey_hex,omitempty"`
|
|
||||||
CustomRecords []*Invoice_CustomRecords `protobuf:"bytes,10,rep,name=custom_records,json=customRecords,proto3" json:"custom_records,omitempty"`
|
|
||||||
RHash string `protobuf:"bytes,11,opt,name=r_hash,json=rHash,proto3" json:"r_hash,omitempty"`
|
|
||||||
Preimage string `protobuf:"bytes,12,opt,name=preimage,proto3" json:"preimage,omitempty"`
|
|
||||||
Keysend bool `protobuf:"varint,13,opt,name=keysend,proto3" json:"keysend,omitempty"`
|
|
||||||
State string `protobuf:"bytes,14,opt,name=state,proto3" json:"state,omitempty"`
|
|
||||||
CreatedAt *timestamppb.Timestamp `protobuf:"bytes,15,opt,name=created_at,json=createdAt,proto3" json:"created_at,omitempty"`
|
|
||||||
ExpiresAt *timestamppb.Timestamp `protobuf:"bytes,16,opt,name=expires_at,json=expiresAt,proto3" json:"expires_at,omitempty"`
|
|
||||||
UpdatedAt *timestamppb.Timestamp `protobuf:"bytes,17,opt,name=updated_at,json=updatedAt,proto3" json:"updated_at,omitempty"`
|
|
||||||
SettledAt *timestamppb.Timestamp `protobuf:"bytes,18,opt,name=settled_at,json=settledAt,proto3" json:"settled_at,omitempty"`
|
|
||||||
}
|
|
||||||
|
|
||||||
func (x *Invoice) Reset() {
|
|
||||||
*x = Invoice{}
|
|
||||||
if protoimpl.UnsafeEnabled {
|
|
||||||
mi := &file_lndhubrpc_lndhub_proto_msgTypes[1]
|
|
||||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
|
||||||
ms.StoreMessageInfo(mi)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (x *Invoice) String() string {
|
|
||||||
return protoimpl.X.MessageStringOf(x)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (*Invoice) ProtoMessage() {}
|
|
||||||
|
|
||||||
func (x *Invoice) ProtoReflect() protoreflect.Message {
|
|
||||||
mi := &file_lndhubrpc_lndhub_proto_msgTypes[1]
|
|
||||||
if protoimpl.UnsafeEnabled && x != nil {
|
|
||||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
|
||||||
if ms.LoadMessageInfo() == nil {
|
|
||||||
ms.StoreMessageInfo(mi)
|
|
||||||
}
|
|
||||||
return ms
|
|
||||||
}
|
|
||||||
return mi.MessageOf(x)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Deprecated: Use Invoice.ProtoReflect.Descriptor instead.
|
|
||||||
func (*Invoice) Descriptor() ([]byte, []int) {
|
|
||||||
return file_lndhubrpc_lndhub_proto_rawDescGZIP(), []int{1}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (x *Invoice) GetId() uint32 {
|
|
||||||
if x != nil {
|
|
||||||
return x.Id
|
|
||||||
}
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
|
|
||||||
func (x *Invoice) GetType() string {
|
|
||||||
if x != nil {
|
|
||||||
return x.Type
|
|
||||||
}
|
|
||||||
return ""
|
|
||||||
}
|
|
||||||
|
|
||||||
func (x *Invoice) GetUserId() uint32 {
|
|
||||||
if x != nil {
|
|
||||||
return x.UserId
|
|
||||||
}
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
|
|
||||||
func (x *Invoice) GetAmount() uint32 {
|
|
||||||
if x != nil {
|
|
||||||
return x.Amount
|
|
||||||
}
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
|
|
||||||
func (x *Invoice) GetFee() uint32 {
|
|
||||||
if x != nil {
|
|
||||||
return x.Fee
|
|
||||||
}
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
|
|
||||||
func (x *Invoice) GetMemo() string {
|
|
||||||
if x != nil {
|
|
||||||
return x.Memo
|
|
||||||
}
|
|
||||||
return ""
|
|
||||||
}
|
|
||||||
|
|
||||||
func (x *Invoice) GetDescriptionHash() string {
|
|
||||||
if x != nil {
|
|
||||||
return x.DescriptionHash
|
|
||||||
}
|
|
||||||
return ""
|
|
||||||
}
|
|
||||||
|
|
||||||
func (x *Invoice) GetPaymentRequest() string {
|
|
||||||
if x != nil {
|
|
||||||
return x.PaymentRequest
|
|
||||||
}
|
|
||||||
return ""
|
|
||||||
}
|
|
||||||
|
|
||||||
func (x *Invoice) GetDestinationPubkeyHex() string {
|
|
||||||
if x != nil {
|
|
||||||
return x.DestinationPubkeyHex
|
|
||||||
}
|
|
||||||
return ""
|
|
||||||
}
|
|
||||||
|
|
||||||
func (x *Invoice) GetCustomRecords() []*Invoice_CustomRecords {
|
|
||||||
if x != nil {
|
|
||||||
return x.CustomRecords
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (x *Invoice) GetRHash() string {
|
|
||||||
if x != nil {
|
|
||||||
return x.RHash
|
|
||||||
}
|
|
||||||
return ""
|
|
||||||
}
|
|
||||||
|
|
||||||
func (x *Invoice) GetPreimage() string {
|
|
||||||
if x != nil {
|
|
||||||
return x.Preimage
|
|
||||||
}
|
|
||||||
return ""
|
|
||||||
}
|
|
||||||
|
|
||||||
func (x *Invoice) GetKeysend() bool {
|
|
||||||
if x != nil {
|
|
||||||
return x.Keysend
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
func (x *Invoice) GetState() string {
|
|
||||||
if x != nil {
|
|
||||||
return x.State
|
|
||||||
}
|
|
||||||
return ""
|
|
||||||
}
|
|
||||||
|
|
||||||
func (x *Invoice) GetCreatedAt() *timestamppb.Timestamp {
|
|
||||||
if x != nil {
|
|
||||||
return x.CreatedAt
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (x *Invoice) GetExpiresAt() *timestamppb.Timestamp {
|
|
||||||
if x != nil {
|
|
||||||
return x.ExpiresAt
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (x *Invoice) GetUpdatedAt() *timestamppb.Timestamp {
|
|
||||||
if x != nil {
|
|
||||||
return x.UpdatedAt
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (x *Invoice) GetSettledAt() *timestamppb.Timestamp {
|
|
||||||
if x != nil {
|
|
||||||
return x.SettledAt
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
type Invoice_CustomRecords struct {
|
|
||||||
state protoimpl.MessageState
|
|
||||||
sizeCache protoimpl.SizeCache
|
|
||||||
unknownFields protoimpl.UnknownFields
|
|
||||||
|
|
||||||
Key uint64 `protobuf:"varint,1,opt,name=key,proto3" json:"key,omitempty"`
|
|
||||||
Value []byte `protobuf:"bytes,2,opt,name=value,proto3" json:"value,omitempty"`
|
|
||||||
}
|
|
||||||
|
|
||||||
func (x *Invoice_CustomRecords) Reset() {
|
|
||||||
*x = Invoice_CustomRecords{}
|
|
||||||
if protoimpl.UnsafeEnabled {
|
|
||||||
mi := &file_lndhubrpc_lndhub_proto_msgTypes[2]
|
|
||||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
|
||||||
ms.StoreMessageInfo(mi)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (x *Invoice_CustomRecords) String() string {
|
|
||||||
return protoimpl.X.MessageStringOf(x)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (*Invoice_CustomRecords) ProtoMessage() {}
|
|
||||||
|
|
||||||
func (x *Invoice_CustomRecords) ProtoReflect() protoreflect.Message {
|
|
||||||
mi := &file_lndhubrpc_lndhub_proto_msgTypes[2]
|
|
||||||
if protoimpl.UnsafeEnabled && x != nil {
|
|
||||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
|
||||||
if ms.LoadMessageInfo() == nil {
|
|
||||||
ms.StoreMessageInfo(mi)
|
|
||||||
}
|
|
||||||
return ms
|
|
||||||
}
|
|
||||||
return mi.MessageOf(x)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Deprecated: Use Invoice_CustomRecords.ProtoReflect.Descriptor instead.
|
|
||||||
func (*Invoice_CustomRecords) Descriptor() ([]byte, []int) {
|
|
||||||
return file_lndhubrpc_lndhub_proto_rawDescGZIP(), []int{1, 0}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (x *Invoice_CustomRecords) GetKey() uint64 {
|
|
||||||
if x != nil {
|
|
||||||
return x.Key
|
|
||||||
}
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
|
|
||||||
func (x *Invoice_CustomRecords) GetValue() []byte {
|
|
||||||
if x != nil {
|
|
||||||
return x.Value
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
var File_lndhubrpc_lndhub_proto protoreflect.FileDescriptor
|
|
||||||
|
|
||||||
var file_lndhubrpc_lndhub_proto_rawDesc = []byte{
|
|
||||||
0x0a, 0x16, 0x6c, 0x6e, 0x64, 0x68, 0x75, 0x62, 0x72, 0x70, 0x63, 0x2f, 0x6c, 0x6e, 0x64, 0x68,
|
|
||||||
0x75, 0x62, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x09, 0x6c, 0x6e, 0x64, 0x68, 0x75, 0x62,
|
|
||||||
0x72, 0x70, 0x63, 0x1a, 0x1f, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74,
|
|
||||||
0x6f, 0x62, 0x75, 0x66, 0x2f, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x2e, 0x70,
|
|
||||||
0x72, 0x6f, 0x74, 0x6f, 0x22, 0x41, 0x0a, 0x17, 0x53, 0x75, 0x62, 0x73, 0x72, 0x69, 0x62, 0x65,
|
|
||||||
0x49, 0x6e, 0x76, 0x6f, 0x69, 0x63, 0x65, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12,
|
|
||||||
0x1b, 0x0a, 0x06, 0x66, 0x72, 0x6f, 0x6d, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0d, 0x48,
|
|
||||||
0x00, 0x52, 0x06, 0x66, 0x72, 0x6f, 0x6d, 0x49, 0x64, 0x88, 0x01, 0x01, 0x42, 0x09, 0x0a, 0x07,
|
|
||||||
0x5f, 0x66, 0x72, 0x6f, 0x6d, 0x49, 0x64, 0x22, 0xdf, 0x05, 0x0a, 0x07, 0x49, 0x6e, 0x76, 0x6f,
|
|
||||||
0x69, 0x63, 0x65, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0d, 0x52,
|
|
||||||
0x02, 0x69, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28,
|
|
||||||
0x09, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x12, 0x17, 0x0a, 0x07, 0x75, 0x73, 0x65, 0x72, 0x5f,
|
|
||||||
0x69, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x06, 0x75, 0x73, 0x65, 0x72, 0x49, 0x64,
|
|
||||||
0x12, 0x16, 0x0a, 0x06, 0x61, 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0d,
|
|
||||||
0x52, 0x06, 0x61, 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x10, 0x0a, 0x03, 0x66, 0x65, 0x65, 0x18,
|
|
||||||
0x05, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x03, 0x66, 0x65, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x6d, 0x65,
|
|
||||||
0x6d, 0x6f, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6d, 0x65, 0x6d, 0x6f, 0x12, 0x29,
|
|
||||||
0x0a, 0x10, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x68, 0x61,
|
|
||||||
0x73, 0x68, 0x18, 0x07, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0f, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69,
|
|
||||||
0x70, 0x74, 0x69, 0x6f, 0x6e, 0x48, 0x61, 0x73, 0x68, 0x12, 0x27, 0x0a, 0x0f, 0x70, 0x61, 0x79,
|
|
||||||
0x6d, 0x65, 0x6e, 0x74, 0x5f, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x18, 0x08, 0x20, 0x01,
|
|
||||||
0x28, 0x09, 0x52, 0x0e, 0x70, 0x61, 0x79, 0x6d, 0x65, 0x6e, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65,
|
|
||||||
0x73, 0x74, 0x12, 0x34, 0x0a, 0x16, 0x64, 0x65, 0x73, 0x74, 0x69, 0x6e, 0x61, 0x74, 0x69, 0x6f,
|
|
||||||
0x6e, 0x5f, 0x70, 0x75, 0x62, 0x6b, 0x65, 0x79, 0x5f, 0x68, 0x65, 0x78, 0x18, 0x09, 0x20, 0x01,
|
|
||||||
0x28, 0x09, 0x52, 0x14, 0x64, 0x65, 0x73, 0x74, 0x69, 0x6e, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x50,
|
|
||||||
0x75, 0x62, 0x6b, 0x65, 0x79, 0x48, 0x65, 0x78, 0x12, 0x47, 0x0a, 0x0e, 0x63, 0x75, 0x73, 0x74,
|
|
||||||
0x6f, 0x6d, 0x5f, 0x72, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x73, 0x18, 0x0a, 0x20, 0x03, 0x28, 0x0b,
|
|
||||||
0x32, 0x20, 0x2e, 0x6c, 0x6e, 0x64, 0x68, 0x75, 0x62, 0x72, 0x70, 0x63, 0x2e, 0x49, 0x6e, 0x76,
|
|
||||||
0x6f, 0x69, 0x63, 0x65, 0x2e, 0x43, 0x75, 0x73, 0x74, 0x6f, 0x6d, 0x52, 0x65, 0x63, 0x6f, 0x72,
|
|
||||||
0x64, 0x73, 0x52, 0x0d, 0x63, 0x75, 0x73, 0x74, 0x6f, 0x6d, 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64,
|
|
||||||
0x73, 0x12, 0x15, 0x0a, 0x06, 0x72, 0x5f, 0x68, 0x61, 0x73, 0x68, 0x18, 0x0b, 0x20, 0x01, 0x28,
|
|
||||||
0x09, 0x52, 0x05, 0x72, 0x48, 0x61, 0x73, 0x68, 0x12, 0x1a, 0x0a, 0x08, 0x70, 0x72, 0x65, 0x69,
|
|
||||||
0x6d, 0x61, 0x67, 0x65, 0x18, 0x0c, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x70, 0x72, 0x65, 0x69,
|
|
||||||
0x6d, 0x61, 0x67, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x6b, 0x65, 0x79, 0x73, 0x65, 0x6e, 0x64, 0x18,
|
|
||||||
0x0d, 0x20, 0x01, 0x28, 0x08, 0x52, 0x07, 0x6b, 0x65, 0x79, 0x73, 0x65, 0x6e, 0x64, 0x12, 0x14,
|
|
||||||
0x0a, 0x05, 0x73, 0x74, 0x61, 0x74, 0x65, 0x18, 0x0e, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x73,
|
|
||||||
0x74, 0x61, 0x74, 0x65, 0x12, 0x39, 0x0a, 0x0a, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x5f,
|
|
||||||
0x61, 0x74, 0x18, 0x0f, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c,
|
|
||||||
0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73,
|
|
||||||
0x74, 0x61, 0x6d, 0x70, 0x52, 0x09, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x41, 0x74, 0x12,
|
|
||||||
0x39, 0x0a, 0x0a, 0x65, 0x78, 0x70, 0x69, 0x72, 0x65, 0x73, 0x5f, 0x61, 0x74, 0x18, 0x10, 0x20,
|
|
||||||
0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f,
|
|
||||||
0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52,
|
|
||||||
0x09, 0x65, 0x78, 0x70, 0x69, 0x72, 0x65, 0x73, 0x41, 0x74, 0x12, 0x39, 0x0a, 0x0a, 0x75, 0x70,
|
|
||||||
0x64, 0x61, 0x74, 0x65, 0x64, 0x5f, 0x61, 0x74, 0x18, 0x11, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a,
|
|
||||||
0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66,
|
|
||||||
0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x09, 0x75, 0x70, 0x64, 0x61,
|
|
||||||
0x74, 0x65, 0x64, 0x41, 0x74, 0x12, 0x39, 0x0a, 0x0a, 0x73, 0x65, 0x74, 0x74, 0x6c, 0x65, 0x64,
|
|
||||||
0x5f, 0x61, 0x74, 0x18, 0x12, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67,
|
|
||||||
0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65,
|
|
||||||
0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x09, 0x73, 0x65, 0x74, 0x74, 0x6c, 0x65, 0x64, 0x41, 0x74,
|
|
||||||
0x1a, 0x37, 0x0a, 0x0d, 0x43, 0x75, 0x73, 0x74, 0x6f, 0x6d, 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64,
|
|
||||||
0x73, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x04, 0x52, 0x03,
|
|
||||||
0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01,
|
|
||||||
0x28, 0x0c, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x32, 0x65, 0x0a, 0x13, 0x49, 0x6e, 0x76,
|
|
||||||
0x6f, 0x69, 0x63, 0x65, 0x53, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e,
|
|
||||||
0x12, 0x4e, 0x0a, 0x10, 0x53, 0x75, 0x62, 0x73, 0x72, 0x69, 0x62, 0x65, 0x49, 0x6e, 0x76, 0x6f,
|
|
||||||
0x69, 0x63, 0x65, 0x73, 0x12, 0x22, 0x2e, 0x6c, 0x6e, 0x64, 0x68, 0x75, 0x62, 0x72, 0x70, 0x63,
|
|
||||||
0x2e, 0x53, 0x75, 0x62, 0x73, 0x72, 0x69, 0x62, 0x65, 0x49, 0x6e, 0x76, 0x6f, 0x69, 0x63, 0x65,
|
|
||||||
0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x12, 0x2e, 0x6c, 0x6e, 0x64, 0x68, 0x75,
|
|
||||||
0x62, 0x72, 0x70, 0x63, 0x2e, 0x49, 0x6e, 0x76, 0x6f, 0x69, 0x63, 0x65, 0x22, 0x00, 0x30, 0x01,
|
|
||||||
0x42, 0x28, 0x5a, 0x26, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x67,
|
|
||||||
0x65, 0x74, 0x41, 0x6c, 0x62, 0x79, 0x2f, 0x6c, 0x6e, 0x64, 0x68, 0x75, 0x62, 0x2e, 0x67, 0x6f,
|
|
||||||
0x2f, 0x6c, 0x6e, 0x64, 0x68, 0x75, 0x62, 0x72, 0x70, 0x63, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74,
|
|
||||||
0x6f, 0x33,
|
|
||||||
}
|
|
||||||
|
|
||||||
var (
|
|
||||||
file_lndhubrpc_lndhub_proto_rawDescOnce sync.Once
|
|
||||||
file_lndhubrpc_lndhub_proto_rawDescData = file_lndhubrpc_lndhub_proto_rawDesc
|
|
||||||
)
|
|
||||||
|
|
||||||
func file_lndhubrpc_lndhub_proto_rawDescGZIP() []byte {
|
|
||||||
file_lndhubrpc_lndhub_proto_rawDescOnce.Do(func() {
|
|
||||||
file_lndhubrpc_lndhub_proto_rawDescData = protoimpl.X.CompressGZIP(file_lndhubrpc_lndhub_proto_rawDescData)
|
|
||||||
})
|
|
||||||
return file_lndhubrpc_lndhub_proto_rawDescData
|
|
||||||
}
|
|
||||||
|
|
||||||
var file_lndhubrpc_lndhub_proto_msgTypes = make([]protoimpl.MessageInfo, 3)
|
|
||||||
var file_lndhubrpc_lndhub_proto_goTypes = []interface{}{
|
|
||||||
(*SubsribeInvoicesRequest)(nil), // 0: lndhubrpc.SubsribeInvoicesRequest
|
|
||||||
(*Invoice)(nil), // 1: lndhubrpc.Invoice
|
|
||||||
(*Invoice_CustomRecords)(nil), // 2: lndhubrpc.Invoice.CustomRecords
|
|
||||||
(*timestamppb.Timestamp)(nil), // 3: google.protobuf.Timestamp
|
|
||||||
}
|
|
||||||
var file_lndhubrpc_lndhub_proto_depIdxs = []int32{
|
|
||||||
2, // 0: lndhubrpc.Invoice.custom_records:type_name -> lndhubrpc.Invoice.CustomRecords
|
|
||||||
3, // 1: lndhubrpc.Invoice.created_at:type_name -> google.protobuf.Timestamp
|
|
||||||
3, // 2: lndhubrpc.Invoice.expires_at:type_name -> google.protobuf.Timestamp
|
|
||||||
3, // 3: lndhubrpc.Invoice.updated_at:type_name -> google.protobuf.Timestamp
|
|
||||||
3, // 4: lndhubrpc.Invoice.settled_at:type_name -> google.protobuf.Timestamp
|
|
||||||
0, // 5: lndhubrpc.InvoiceSubscription.SubsribeInvoices:input_type -> lndhubrpc.SubsribeInvoicesRequest
|
|
||||||
1, // 6: lndhubrpc.InvoiceSubscription.SubsribeInvoices:output_type -> lndhubrpc.Invoice
|
|
||||||
6, // [6:7] is the sub-list for method output_type
|
|
||||||
5, // [5:6] is the sub-list for method input_type
|
|
||||||
5, // [5:5] is the sub-list for extension type_name
|
|
||||||
5, // [5:5] is the sub-list for extension extendee
|
|
||||||
0, // [0:5] is the sub-list for field type_name
|
|
||||||
}
|
|
||||||
|
|
||||||
func init() { file_lndhubrpc_lndhub_proto_init() }
|
|
||||||
func file_lndhubrpc_lndhub_proto_init() {
|
|
||||||
if File_lndhubrpc_lndhub_proto != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if !protoimpl.UnsafeEnabled {
|
|
||||||
file_lndhubrpc_lndhub_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
|
|
||||||
switch v := v.(*SubsribeInvoicesRequest); i {
|
|
||||||
case 0:
|
|
||||||
return &v.state
|
|
||||||
case 1:
|
|
||||||
return &v.sizeCache
|
|
||||||
case 2:
|
|
||||||
return &v.unknownFields
|
|
||||||
default:
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
}
|
|
||||||
file_lndhubrpc_lndhub_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
|
|
||||||
switch v := v.(*Invoice); i {
|
|
||||||
case 0:
|
|
||||||
return &v.state
|
|
||||||
case 1:
|
|
||||||
return &v.sizeCache
|
|
||||||
case 2:
|
|
||||||
return &v.unknownFields
|
|
||||||
default:
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
}
|
|
||||||
file_lndhubrpc_lndhub_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} {
|
|
||||||
switch v := v.(*Invoice_CustomRecords); i {
|
|
||||||
case 0:
|
|
||||||
return &v.state
|
|
||||||
case 1:
|
|
||||||
return &v.sizeCache
|
|
||||||
case 2:
|
|
||||||
return &v.unknownFields
|
|
||||||
default:
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
file_lndhubrpc_lndhub_proto_msgTypes[0].OneofWrappers = []interface{}{}
|
|
||||||
type x struct{}
|
|
||||||
out := protoimpl.TypeBuilder{
|
|
||||||
File: protoimpl.DescBuilder{
|
|
||||||
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
|
|
||||||
RawDescriptor: file_lndhubrpc_lndhub_proto_rawDesc,
|
|
||||||
NumEnums: 0,
|
|
||||||
NumMessages: 3,
|
|
||||||
NumExtensions: 0,
|
|
||||||
NumServices: 1,
|
|
||||||
},
|
|
||||||
GoTypes: file_lndhubrpc_lndhub_proto_goTypes,
|
|
||||||
DependencyIndexes: file_lndhubrpc_lndhub_proto_depIdxs,
|
|
||||||
MessageInfos: file_lndhubrpc_lndhub_proto_msgTypes,
|
|
||||||
}.Build()
|
|
||||||
File_lndhubrpc_lndhub_proto = out.File
|
|
||||||
file_lndhubrpc_lndhub_proto_rawDesc = nil
|
|
||||||
file_lndhubrpc_lndhub_proto_goTypes = nil
|
|
||||||
file_lndhubrpc_lndhub_proto_depIdxs = nil
|
|
||||||
}
|
|
||||||
@@ -1,39 +0,0 @@
|
|||||||
syntax = "proto3";
|
|
||||||
option go_package = "github.com/getAlby/lndhub.go/lndhubrpc";
|
|
||||||
|
|
||||||
import "google/protobuf/timestamp.proto";
|
|
||||||
package lndhubrpc;
|
|
||||||
|
|
||||||
// The greeting service definition.
|
|
||||||
service InvoiceSubscription {
|
|
||||||
rpc SubsribeInvoices (SubsribeInvoicesRequest) returns (stream Invoice) {}
|
|
||||||
}
|
|
||||||
message SubsribeInvoicesRequest {
|
|
||||||
optional uint32 fromId = 1;
|
|
||||||
}
|
|
||||||
message Invoice {
|
|
||||||
|
|
||||||
message CustomRecords {
|
|
||||||
uint64 key = 1;
|
|
||||||
bytes value = 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
uint32 id = 1;
|
|
||||||
string type = 2;
|
|
||||||
uint32 user_id = 3;
|
|
||||||
uint32 amount = 4;
|
|
||||||
uint32 fee = 5;
|
|
||||||
string memo = 6;
|
|
||||||
string description_hash = 7;
|
|
||||||
string payment_request = 8;
|
|
||||||
string destination_pubkey_hex = 9;
|
|
||||||
repeated CustomRecords custom_records = 10;
|
|
||||||
string r_hash = 11;
|
|
||||||
string preimage = 12;
|
|
||||||
bool keysend = 13;
|
|
||||||
string state = 14;
|
|
||||||
google.protobuf.Timestamp created_at = 15;
|
|
||||||
google.protobuf.Timestamp expires_at = 16;
|
|
||||||
google.protobuf.Timestamp updated_at = 17;
|
|
||||||
google.protobuf.Timestamp settled_at = 18;
|
|
||||||
}
|
|
||||||
@@ -1,132 +0,0 @@
|
|||||||
// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
|
|
||||||
// versions:
|
|
||||||
// - protoc-gen-go-grpc v1.2.0
|
|
||||||
// - protoc v3.21.9
|
|
||||||
// source: lndhubrpc/lndhub.proto
|
|
||||||
|
|
||||||
package lndhubrpc
|
|
||||||
|
|
||||||
import (
|
|
||||||
context "context"
|
|
||||||
grpc "google.golang.org/grpc"
|
|
||||||
codes "google.golang.org/grpc/codes"
|
|
||||||
status "google.golang.org/grpc/status"
|
|
||||||
)
|
|
||||||
|
|
||||||
// This is a compile-time assertion to ensure that this generated file
|
|
||||||
// is compatible with the grpc package it is being compiled against.
|
|
||||||
// Requires gRPC-Go v1.32.0 or later.
|
|
||||||
const _ = grpc.SupportPackageIsVersion7
|
|
||||||
|
|
||||||
// InvoiceSubscriptionClient is the client API for InvoiceSubscription service.
|
|
||||||
//
|
|
||||||
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.
|
|
||||||
type InvoiceSubscriptionClient interface {
|
|
||||||
SubsribeInvoices(ctx context.Context, in *SubsribeInvoicesRequest, opts ...grpc.CallOption) (InvoiceSubscription_SubsribeInvoicesClient, error)
|
|
||||||
}
|
|
||||||
|
|
||||||
type invoiceSubscriptionClient struct {
|
|
||||||
cc grpc.ClientConnInterface
|
|
||||||
}
|
|
||||||
|
|
||||||
func NewInvoiceSubscriptionClient(cc grpc.ClientConnInterface) InvoiceSubscriptionClient {
|
|
||||||
return &invoiceSubscriptionClient{cc}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *invoiceSubscriptionClient) SubsribeInvoices(ctx context.Context, in *SubsribeInvoicesRequest, opts ...grpc.CallOption) (InvoiceSubscription_SubsribeInvoicesClient, error) {
|
|
||||||
stream, err := c.cc.NewStream(ctx, &InvoiceSubscription_ServiceDesc.Streams[0], "/lndhubrpc.InvoiceSubscription/SubsribeInvoices", opts...)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
x := &invoiceSubscriptionSubsribeInvoicesClient{stream}
|
|
||||||
if err := x.ClientStream.SendMsg(in); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
if err := x.ClientStream.CloseSend(); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return x, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
type InvoiceSubscription_SubsribeInvoicesClient interface {
|
|
||||||
Recv() (*Invoice, error)
|
|
||||||
grpc.ClientStream
|
|
||||||
}
|
|
||||||
|
|
||||||
type invoiceSubscriptionSubsribeInvoicesClient struct {
|
|
||||||
grpc.ClientStream
|
|
||||||
}
|
|
||||||
|
|
||||||
func (x *invoiceSubscriptionSubsribeInvoicesClient) Recv() (*Invoice, error) {
|
|
||||||
m := new(Invoice)
|
|
||||||
if err := x.ClientStream.RecvMsg(m); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return m, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// InvoiceSubscriptionServer is the server API for InvoiceSubscription service.
|
|
||||||
// All implementations must embed UnimplementedInvoiceSubscriptionServer
|
|
||||||
// for forward compatibility
|
|
||||||
type InvoiceSubscriptionServer interface {
|
|
||||||
SubsribeInvoices(*SubsribeInvoicesRequest, InvoiceSubscription_SubsribeInvoicesServer) error
|
|
||||||
mustEmbedUnimplementedInvoiceSubscriptionServer()
|
|
||||||
}
|
|
||||||
|
|
||||||
// UnimplementedInvoiceSubscriptionServer must be embedded to have forward compatible implementations.
|
|
||||||
type UnimplementedInvoiceSubscriptionServer struct {
|
|
||||||
}
|
|
||||||
|
|
||||||
func (UnimplementedInvoiceSubscriptionServer) SubsribeInvoices(*SubsribeInvoicesRequest, InvoiceSubscription_SubsribeInvoicesServer) error {
|
|
||||||
return status.Errorf(codes.Unimplemented, "method SubsribeInvoices not implemented")
|
|
||||||
}
|
|
||||||
func (UnimplementedInvoiceSubscriptionServer) mustEmbedUnimplementedInvoiceSubscriptionServer() {}
|
|
||||||
|
|
||||||
// UnsafeInvoiceSubscriptionServer may be embedded to opt out of forward compatibility for this service.
|
|
||||||
// Use of this interface is not recommended, as added methods to InvoiceSubscriptionServer will
|
|
||||||
// result in compilation errors.
|
|
||||||
type UnsafeInvoiceSubscriptionServer interface {
|
|
||||||
mustEmbedUnimplementedInvoiceSubscriptionServer()
|
|
||||||
}
|
|
||||||
|
|
||||||
func RegisterInvoiceSubscriptionServer(s grpc.ServiceRegistrar, srv InvoiceSubscriptionServer) {
|
|
||||||
s.RegisterService(&InvoiceSubscription_ServiceDesc, srv)
|
|
||||||
}
|
|
||||||
|
|
||||||
func _InvoiceSubscription_SubsribeInvoices_Handler(srv interface{}, stream grpc.ServerStream) error {
|
|
||||||
m := new(SubsribeInvoicesRequest)
|
|
||||||
if err := stream.RecvMsg(m); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
return srv.(InvoiceSubscriptionServer).SubsribeInvoices(m, &invoiceSubscriptionSubsribeInvoicesServer{stream})
|
|
||||||
}
|
|
||||||
|
|
||||||
type InvoiceSubscription_SubsribeInvoicesServer interface {
|
|
||||||
Send(*Invoice) error
|
|
||||||
grpc.ServerStream
|
|
||||||
}
|
|
||||||
|
|
||||||
type invoiceSubscriptionSubsribeInvoicesServer struct {
|
|
||||||
grpc.ServerStream
|
|
||||||
}
|
|
||||||
|
|
||||||
func (x *invoiceSubscriptionSubsribeInvoicesServer) Send(m *Invoice) error {
|
|
||||||
return x.ServerStream.SendMsg(m)
|
|
||||||
}
|
|
||||||
|
|
||||||
// InvoiceSubscription_ServiceDesc is the grpc.ServiceDesc for InvoiceSubscription service.
|
|
||||||
// It's only intended for direct use with grpc.RegisterService,
|
|
||||||
// and not to be introspected or modified (even as a copy)
|
|
||||||
var InvoiceSubscription_ServiceDesc = grpc.ServiceDesc{
|
|
||||||
ServiceName: "lndhubrpc.InvoiceSubscription",
|
|
||||||
HandlerType: (*InvoiceSubscriptionServer)(nil),
|
|
||||||
Methods: []grpc.MethodDesc{},
|
|
||||||
Streams: []grpc.StreamDesc{
|
|
||||||
{
|
|
||||||
StreamName: "SubsribeInvoices",
|
|
||||||
Handler: _InvoiceSubscription_SubsribeInvoices_Handler,
|
|
||||||
ServerStreams: true,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
Metadata: "lndhubrpc/lndhub.proto",
|
|
||||||
}
|
|
||||||
23
main.go
23
main.go
@@ -5,7 +5,6 @@ import (
|
|||||||
"embed"
|
"embed"
|
||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
"net"
|
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
"os/signal"
|
"os/signal"
|
||||||
@@ -37,7 +36,6 @@ import (
|
|||||||
"github.com/uptrace/bun/migrate"
|
"github.com/uptrace/bun/migrate"
|
||||||
"github.com/ziflex/lecho/v3"
|
"github.com/ziflex/lecho/v3"
|
||||||
"golang.org/x/time/rate"
|
"golang.org/x/time/rate"
|
||||||
"google.golang.org/grpc"
|
|
||||||
ddEcho "gopkg.in/DataDog/dd-trace-go.v1/contrib/labstack/echo.v4"
|
ddEcho "gopkg.in/DataDog/dd-trace-go.v1/contrib/labstack/echo.v4"
|
||||||
"gopkg.in/DataDog/dd-trace-go.v1/ddtrace/tracer"
|
"gopkg.in/DataDog/dd-trace-go.v1/ddtrace/tracer"
|
||||||
)
|
)
|
||||||
@@ -264,23 +262,6 @@ func main() {
|
|||||||
}()
|
}()
|
||||||
}
|
}
|
||||||
|
|
||||||
var grpcServer *grpc.Server
|
|
||||||
if svc.Config.EnableGRPC {
|
|
||||||
//start grpc server
|
|
||||||
lis, err := net.Listen("tcp", fmt.Sprintf(":%d", svc.Config.GRPCPort))
|
|
||||||
if err != nil {
|
|
||||||
svc.Logger.Fatalf("Failed to start grpc server: %v", err)
|
|
||||||
}
|
|
||||||
grpcServer = svc.NewGrpcServer(startupCtx)
|
|
||||||
go func() {
|
|
||||||
svc.Logger.Infof("Starting grpc server at port %d", svc.Config.GRPCPort)
|
|
||||||
err = grpcServer.Serve(lis)
|
|
||||||
if err != nil {
|
|
||||||
svc.Logger.Error(err)
|
|
||||||
}
|
|
||||||
}()
|
|
||||||
}
|
|
||||||
|
|
||||||
//Start Prometheus server if necessary
|
//Start Prometheus server if necessary
|
||||||
var echoPrometheus *echo.Echo
|
var echoPrometheus *echo.Echo
|
||||||
if svc.Config.EnablePrometheus {
|
if svc.Config.EnablePrometheus {
|
||||||
@@ -317,10 +298,6 @@ func main() {
|
|||||||
e.Logger.Fatal(err)
|
e.Logger.Fatal(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if c.EnableGRPC {
|
|
||||||
grpcServer.Stop()
|
|
||||||
svc.Logger.Info("GRPC server exited.")
|
|
||||||
}
|
|
||||||
//Wait for graceful shutdown of background routines
|
//Wait for graceful shutdown of background routines
|
||||||
backgroundWg.Wait()
|
backgroundWg.Wait()
|
||||||
svc.Logger.Info("LNDhub exiting gracefully. Goodbye.")
|
svc.Logger.Info("LNDhub exiting gracefully. Goodbye.")
|
||||||
|
|||||||
Reference in New Issue
Block a user