Merge pull request #403 from guggero/docker-rpc

looprpc: generate protos with docker
pull/405/head
Oliver Gugger 3 years ago committed by GitHub
commit e7ee29bd83
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -74,5 +74,9 @@ install:
$(GOINSTALL) -tags="${tags}" $(LDFLAGS) $(PKG)/cmd/loopd
rpc:
@$(call print, "Compiling RPC protos.")
cd looprpc; ./gen_protos.sh
@$(call print, "Compiling protos.")
cd ./looprpc; ./gen_protos_docker.sh
rpc-check: rpc
@$(call print, "Verifying protos.")
if test -n "$$(git describe --dirty | grep dirty)"; then echo "Protos not properly formatted or not compiled with correct version!"; git status; git diff; exit 1; fi

@ -203,8 +203,8 @@ func loopOut(ctx *cli.Context) error {
}
fmt.Printf("Swap initiated\n")
fmt.Printf("ID: %v\n", resp.Id)
fmt.Printf("HTLC address: %v\n", resp.HtlcAddress)
fmt.Printf("ID: %x\n", resp.IdBytes)
fmt.Printf("HTLC address: %v\n", resp.HtlcAddress) // nolint:staticcheck
if resp.ServerMessage != "" {
fmt.Printf("Server message: %v\n", resp.ServerMessage)
}

@ -21,8 +21,8 @@ require (
github.com/stretchr/testify v1.7.0
github.com/urfave/cli v1.20.0
golang.org/x/net v0.0.0-20200520004742-59133d7f0dd7
google.golang.org/genproto v0.0.0-20190927181202-20e1ac93f88c
google.golang.org/grpc v1.29.1
google.golang.org/protobuf v1.23.0
gopkg.in/macaroon-bakery.v2 v2.0.1
gopkg.in/macaroon.v2 v2.1.0
)

@ -121,12 +121,12 @@ func (s *swapClientServer) LoopOut(ctx context.Context,
}
switch {
case in.LoopOutChannel != 0 && len(in.OutgoingChanSet) > 0:
case in.LoopOutChannel != 0 && len(in.OutgoingChanSet) > 0: // nolint:staticcheck
return nil, errors.New("loop_out_channel and outgoing_" +
"chan_ids are mutually exclusive")
case in.LoopOutChannel != 0:
req.OutgoingChanSet = loopdb.ChannelSet{in.LoopOutChannel}
case in.LoopOutChannel != 0: // nolint:staticcheck
req.OutgoingChanSet = loopdb.ChannelSet{in.LoopOutChannel} // nolint:staticcheck
default:
req.OutgoingChanSet = in.OutgoingChanSet
@ -540,9 +540,9 @@ func (s *swapClientServer) LoopIn(ctx context.Context,
if req.ExternalHtlc {
response.HtlcAddressNp2Wsh = swapInfo.HtlcAddressNP2WSH.String()
response.HtlcAddress = response.HtlcAddressNp2Wsh
response.HtlcAddress = response.HtlcAddressNp2Wsh // nolint:staticcheck
} else {
response.HtlcAddress = response.HtlcAddressP2Wsh
response.HtlcAddress = response.HtlcAddressP2Wsh // nolint:staticcheck
}
return response, nil

@ -0,0 +1,7 @@
---
Language: Proto
BasedOnStyle: Google
IndentWidth: 4
AllowShortFunctionsOnASingleLine: None
SpaceBeforeParens: Always
CompactNamespaces: false

@ -0,0 +1,22 @@
FROM golang:1.15.6-buster
RUN apt-get update && apt-get install -y \
git \
protobuf-compiler='3.6*' \
clang-format='1:7.0*'
# We don't want any default values for these variables to make sure they're
# explicitly provided by parsing the go.mod file. Otherwise we might forget to
# update them here if we bump the versions.
ARG PROTOC_GEN_VERSION
ARG GRPC_GATEWAY_VERSION
RUN cd /tmp \
&& export GO111MODULE=on \
&& go get github.com/golang/protobuf/protoc-gen-go@${PROTOC_GEN_VERSION} \
&& go get github.com/grpc-ecosystem/grpc-gateway/protoc-gen-grpc-gateway@${GRPC_GATEWAY_VERSION} \
&& go get github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger@${GRPC_GATEWAY_VERSION}
WORKDIR /build
CMD ["/bin/bash", "/build/looprpc/gen_protos.sh"]

File diff suppressed because it is too large Load Diff

@ -1,9 +1,9 @@
syntax = "proto3";
import "google/api/annotations.proto";
package looprpc;
option go_package = "github.com/lightninglabs/loop/looprpc";
/*
SwapClient is a service that handles the client side process of onchain/offchain
swaps. The service is designed for a single client.
@ -15,12 +15,7 @@ service SwapClient {
point onwards, progress can be tracked via the SwapStatus stream that is
returned from Monitor().
*/
rpc LoopOut (LoopOutRequest) returns (SwapResponse) {
option (google.api.http) = {
post: "/v1/loop/out"
body: "*"
};
}
rpc LoopOut (LoopOutRequest) returns (SwapResponse);
/* loop: `in`
LoopIn initiates a loop in swap with the given parameters. The call
@ -28,12 +23,7 @@ service SwapClient {
point onwards, progress can be tracked via the SwapStatus stream
that is returned from Monitor().
*/
rpc LoopIn (LoopInRequest) returns (SwapResponse) {
option (google.api.http) = {
post: "/v1/loop/in"
body: "*"
};
}
rpc LoopIn (LoopInRequest) returns (SwapResponse);
/* loop: `monitor`
Monitor will return a stream of swap updates for currently active swaps.
@ -44,102 +34,63 @@ service SwapClient {
ListSwaps returns a list of all currently known swaps and their current
status.
*/
rpc ListSwaps (ListSwapsRequest) returns (ListSwapsResponse) {
option (google.api.http) = {
get: "/v1/loop/swaps"
};
}
rpc ListSwaps (ListSwapsRequest) returns (ListSwapsResponse);
/* loop: `swapinfo`
SwapInfo returns all known details about a single swap.
*/
rpc SwapInfo (SwapInfoRequest) returns (SwapStatus) {
option (google.api.http) = {
get: "/v1/loop/swap/{id}"
};
}
rpc SwapInfo (SwapInfoRequest) returns (SwapStatus);
/* loop: `terms`
LoopOutTerms returns the terms that the server enforces for a loop out swap.
*/
rpc LoopOutTerms (TermsRequest) returns (OutTermsResponse) {
option (google.api.http) = {
get: "/v1/loop/out/terms"
};
}
rpc LoopOutTerms (TermsRequest) returns (OutTermsResponse);
/* loop: `quote`
LoopOutQuote returns a quote for a loop out swap with the provided
parameters.
*/
rpc LoopOutQuote (QuoteRequest) returns (OutQuoteResponse) {
option (google.api.http) = {
get: "/v1/loop/out/quote/{amt}"
};
}
rpc LoopOutQuote (QuoteRequest) returns (OutQuoteResponse);
/* loop: `terms`
GetTerms returns the terms that the server enforces for swaps.
*/
rpc GetLoopInTerms (TermsRequest) returns (InTermsResponse) {
option (google.api.http) = {
get: "/v1/loop/in/terms"
};
}
rpc GetLoopInTerms (TermsRequest) returns (InTermsResponse);
/* loop: `quote`
GetQuote returns a quote for a swap with the provided parameters.
*/
rpc GetLoopInQuote (QuoteRequest) returns (InQuoteResponse) {
option (google.api.http) = {
get: "/v1/loop/in/quote/{amt}"
};
}
rpc GetLoopInQuote (QuoteRequest) returns (InQuoteResponse);
/* loop: `listauth`
GetLsatTokens returns all LSAT tokens the daemon ever paid for.
*/
rpc GetLsatTokens (TokensRequest) returns (TokensResponse) {
option (google.api.http) = {
get: "/v1/lsat/tokens"
};
}
rpc GetLsatTokens (TokensRequest) returns (TokensResponse);
/*
/* loop: `getparams`
GetLiquidityParams gets the parameters that the daemon's liquidity manager
is currently configured with. This may be nil if nothing is configured.
[EXPERIMENTAL]: endpoint is subject to change.
*/
rpc GetLiquidityParams (GetLiquidityParamsRequest) returns (LiquidityParameters) {
option (google.api.http) = {
get: "/v1/liquidity/params"
};
}
rpc GetLiquidityParams (GetLiquidityParamsRequest)
returns (LiquidityParameters);
/*
/* loop: `setparams`
SetLiquidityParams sets a new set of parameters for the daemon's liquidity
manager. Note that the full set of parameters must be provided, because
this call fully overwrites our existing parameters.
[EXPERIMENTAL]: endpoint is subject to change.
*/
rpc SetLiquidityParams (SetLiquidityParamsRequest) returns (SetLiquidityParamsResponse) {
option (google.api.http) = {
post: "/v1/liquidity/params"
body: "*"
};
}
rpc SetLiquidityParams (SetLiquidityParamsRequest)
returns (SetLiquidityParamsResponse);
/*
/* loop: `suggestswaps`
SuggestSwaps returns a list of recommended swaps based on the current
state of your node's channels and it's liquidity manager parameters.
Note that only loop out suggestions are currently supported.
[EXPERIMENTAL]: endpoint is subject to change.
*/
rpc SuggestSwaps (SuggestSwapsRequest) returns (SuggestSwapsResponse) {
option (google.api.http) = {
get: "/v1/auto/suggest"
};
}
rpc SuggestSwaps (SuggestSwapsRequest) returns (SuggestSwapsResponse);
}
message LoopOutRequest {
@ -154,9 +105,9 @@ message LoopOutRequest {
string dest = 2;
/*
Maximum off-chain fee in sat that may be paid for swap payment to the server.
This limit is applied during path finding. Typically this value is taken
from the response of the GetQuote call.
Maximum off-chain fee in sat that may be paid for swap payment to the
server. This limit is applied during path finding. Typically this value is
taken from the response of the GetQuote call.
*/
int64 max_swap_routing_fee = 3;
@ -548,7 +499,6 @@ message TermsRequest {
}
message InTermsResponse {
reserved 1, 2, 3, 4, 7;
/*
@ -563,7 +513,6 @@ message InTermsResponse {
}
message OutTermsResponse {
reserved 1, 2, 3, 4, 7;
/*

@ -13,7 +13,7 @@
"paths": {
"/v1/auto/suggest": {
"get": {
"summary": "SuggestSwaps returns a list of recommended swaps based on the current\nstate of your node's channels and it's liquidity manager parameters.\nNote that only loop out suggestions are currently supported.\n[EXPERIMENTAL]: endpoint is subject to change.",
"summary": "loop: `suggestswaps`\nSuggestSwaps returns a list of recommended swaps based on the current\nstate of your node's channels and it's liquidity manager parameters.\nNote that only loop out suggestions are currently supported.\n[EXPERIMENTAL]: endpoint is subject to change.",
"operationId": "SuggestSwaps",
"responses": {
"200": {
@ -36,7 +36,7 @@
},
"/v1/liquidity/params": {
"get": {
"summary": "GetLiquidityParams gets the parameters that the daemon's liquidity manager\nis currently configured with. This may be nil if nothing is configured.\n[EXPERIMENTAL]: endpoint is subject to change.",
"summary": "loop: `getparams`\nGetLiquidityParams gets the parameters that the daemon's liquidity manager\nis currently configured with. This may be nil if nothing is configured.\n[EXPERIMENTAL]: endpoint is subject to change.",
"operationId": "GetLiquidityParams",
"responses": {
"200": {
@ -57,7 +57,7 @@
]
},
"post": {
"summary": "SetLiquidityParams sets a new set of parameters for the daemon's liquidity\nmanager. Note that the full set of parameters must be provided, because\nthis call fully overwrites our existing parameters.\n[EXPERIMENTAL]: endpoint is subject to change.",
"summary": "loop: `setparams`\nSetLiquidityParams sets a new set of parameters for the daemon's liquidity\nmanager. Note that the full set of parameters must be provided, because\nthis call fully overwrites our existing parameters.\n[EXPERIMENTAL]: endpoint is subject to change.",
"operationId": "SetLiquidityParams",
"responses": {
"200": {
@ -683,7 +683,7 @@
"max_swap_routing_fee": {
"type": "string",
"format": "int64",
"description": "Maximum off-chain fee in sat that may be paid for swap payment to the server.\nThis limit is applied during path finding. Typically this value is taken\nfrom the response of the GetQuote call."
"description": "Maximum off-chain fee in sat that may be paid for swap payment to the\nserver. This limit is applied during path finding. Typically this value is\ntaken from the response of the GetQuote call."
},
"max_prepay_routing_fee": {
"type": "string",

@ -1,117 +1,214 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.23.0
// protoc v3.6.1
// source: debug.proto
package looprpc
import (
context "context"
fmt "fmt"
proto "github.com/golang/protobuf/proto"
grpc "google.golang.org/grpc"
codes "google.golang.org/grpc/codes"
status "google.golang.org/grpc/status"
math "math"
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
reflect "reflect"
sync "sync"
)
// Reference imports to suppress errors if they are not otherwise used.
var _ = proto.Marshal
var _ = fmt.Errorf
var _ = math.Inf
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)
)
// 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
// This is a compile-time assertion that a sufficiently up-to-date version
// of the legacy proto package is being used.
const _ = proto.ProtoPackageIsVersion4
type ForceAutoLoopRequest struct {
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
}
func (m *ForceAutoLoopRequest) Reset() { *m = ForceAutoLoopRequest{} }
func (m *ForceAutoLoopRequest) String() string { return proto.CompactTextString(m) }
func (*ForceAutoLoopRequest) ProtoMessage() {}
func (*ForceAutoLoopRequest) Descriptor() ([]byte, []int) {
return fileDescriptor_8d9d361be58531fb, []int{0}
func (x *ForceAutoLoopRequest) Reset() {
*x = ForceAutoLoopRequest{}
if protoimpl.UnsafeEnabled {
mi := &file_debug_proto_msgTypes[0]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (m *ForceAutoLoopRequest) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_ForceAutoLoopRequest.Unmarshal(m, b)
}
func (m *ForceAutoLoopRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_ForceAutoLoopRequest.Marshal(b, m, deterministic)
func (x *ForceAutoLoopRequest) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (m *ForceAutoLoopRequest) XXX_Merge(src proto.Message) {
xxx_messageInfo_ForceAutoLoopRequest.Merge(m, src)
func (*ForceAutoLoopRequest) ProtoMessage() {}
func (x *ForceAutoLoopRequest) ProtoReflect() protoreflect.Message {
mi := &file_debug_proto_msgTypes[0]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
func (m *ForceAutoLoopRequest) XXX_Size() int {
return xxx_messageInfo_ForceAutoLoopRequest.Size(m)
return ms
}
func (m *ForceAutoLoopRequest) XXX_DiscardUnknown() {
xxx_messageInfo_ForceAutoLoopRequest.DiscardUnknown(m)
return mi.MessageOf(x)
}
var xxx_messageInfo_ForceAutoLoopRequest proto.InternalMessageInfo
// Deprecated: Use ForceAutoLoopRequest.ProtoReflect.Descriptor instead.
func (*ForceAutoLoopRequest) Descriptor() ([]byte, []int) {
return file_debug_proto_rawDescGZIP(), []int{0}
}
type ForceAutoLoopResponse struct {
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
}
func (m *ForceAutoLoopResponse) Reset() { *m = ForceAutoLoopResponse{} }
func (m *ForceAutoLoopResponse) String() string { return proto.CompactTextString(m) }
func (*ForceAutoLoopResponse) ProtoMessage() {}
func (*ForceAutoLoopResponse) Descriptor() ([]byte, []int) {
return fileDescriptor_8d9d361be58531fb, []int{1}
func (x *ForceAutoLoopResponse) Reset() {
*x = ForceAutoLoopResponse{}
if protoimpl.UnsafeEnabled {
mi := &file_debug_proto_msgTypes[1]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (m *ForceAutoLoopResponse) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_ForceAutoLoopResponse.Unmarshal(m, b)
func (x *ForceAutoLoopResponse) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (m *ForceAutoLoopResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_ForceAutoLoopResponse.Marshal(b, m, deterministic)
func (*ForceAutoLoopResponse) ProtoMessage() {}
func (x *ForceAutoLoopResponse) ProtoReflect() protoreflect.Message {
mi := &file_debug_proto_msgTypes[1]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
func (m *ForceAutoLoopResponse) XXX_Merge(src proto.Message) {
xxx_messageInfo_ForceAutoLoopResponse.Merge(m, src)
return mi.MessageOf(x)
}
func (m *ForceAutoLoopResponse) XXX_Size() int {
return xxx_messageInfo_ForceAutoLoopResponse.Size(m)
// Deprecated: Use ForceAutoLoopResponse.ProtoReflect.Descriptor instead.
func (*ForceAutoLoopResponse) Descriptor() ([]byte, []int) {
return file_debug_proto_rawDescGZIP(), []int{1}
}
func (m *ForceAutoLoopResponse) XXX_DiscardUnknown() {
xxx_messageInfo_ForceAutoLoopResponse.DiscardUnknown(m)
var File_debug_proto protoreflect.FileDescriptor
var file_debug_proto_rawDesc = []byte{
0x0a, 0x0b, 0x64, 0x65, 0x62, 0x75, 0x67, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x07, 0x6c,
0x6f, 0x6f, 0x70, 0x72, 0x70, 0x63, 0x22, 0x16, 0x0a, 0x14, 0x46, 0x6f, 0x72, 0x63, 0x65, 0x41,
0x75, 0x74, 0x6f, 0x4c, 0x6f, 0x6f, 0x70, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x22, 0x17,
0x0a, 0x15, 0x46, 0x6f, 0x72, 0x63, 0x65, 0x41, 0x75, 0x74, 0x6f, 0x4c, 0x6f, 0x6f, 0x70, 0x52,
0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x32, 0x57, 0x0a, 0x05, 0x44, 0x65, 0x62, 0x75, 0x67,
0x12, 0x4e, 0x0a, 0x0d, 0x46, 0x6f, 0x72, 0x63, 0x65, 0x41, 0x75, 0x74, 0x6f, 0x4c, 0x6f, 0x6f,
0x70, 0x12, 0x1d, 0x2e, 0x6c, 0x6f, 0x6f, 0x70, 0x72, 0x70, 0x63, 0x2e, 0x46, 0x6f, 0x72, 0x63,
0x65, 0x41, 0x75, 0x74, 0x6f, 0x4c, 0x6f, 0x6f, 0x70, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74,
0x1a, 0x1e, 0x2e, 0x6c, 0x6f, 0x6f, 0x70, 0x72, 0x70, 0x63, 0x2e, 0x46, 0x6f, 0x72, 0x63, 0x65,
0x41, 0x75, 0x74, 0x6f, 0x4c, 0x6f, 0x6f, 0x70, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65,
0x42, 0x27, 0x5a, 0x25, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x6c,
0x69, 0x67, 0x68, 0x74, 0x6e, 0x69, 0x6e, 0x67, 0x6c, 0x61, 0x62, 0x73, 0x2f, 0x6c, 0x6f, 0x6f,
0x70, 0x2f, 0x6c, 0x6f, 0x6f, 0x70, 0x72, 0x70, 0x63, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f,
0x33,
}
var xxx_messageInfo_ForceAutoLoopResponse proto.InternalMessageInfo
var (
file_debug_proto_rawDescOnce sync.Once
file_debug_proto_rawDescData = file_debug_proto_rawDesc
)
func init() {
proto.RegisterType((*ForceAutoLoopRequest)(nil), "looprpc.ForceAutoLoopRequest")
proto.RegisterType((*ForceAutoLoopResponse)(nil), "looprpc.ForceAutoLoopResponse")
func file_debug_proto_rawDescGZIP() []byte {
file_debug_proto_rawDescOnce.Do(func() {
file_debug_proto_rawDescData = protoimpl.X.CompressGZIP(file_debug_proto_rawDescData)
})
return file_debug_proto_rawDescData
}
func init() { proto.RegisterFile("debug.proto", fileDescriptor_8d9d361be58531fb) }
var file_debug_proto_msgTypes = make([]protoimpl.MessageInfo, 2)
var file_debug_proto_goTypes = []interface{}{
(*ForceAutoLoopRequest)(nil), // 0: looprpc.ForceAutoLoopRequest
(*ForceAutoLoopResponse)(nil), // 1: looprpc.ForceAutoLoopResponse
}
var file_debug_proto_depIdxs = []int32{
0, // 0: looprpc.Debug.ForceAutoLoop:input_type -> looprpc.ForceAutoLoopRequest
1, // 1: looprpc.Debug.ForceAutoLoop:output_type -> looprpc.ForceAutoLoopResponse
1, // [1:2] is the sub-list for method output_type
0, // [0:1] is the sub-list for method input_type
0, // [0:0] is the sub-list for extension type_name
0, // [0:0] is the sub-list for extension extendee
0, // [0:0] is the sub-list for field type_name
}
var fileDescriptor_8d9d361be58531fb = []byte{
// 117 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0xe2, 0x4e, 0x49, 0x4d, 0x2a,
0x4d, 0xd7, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x62, 0xcf, 0xc9, 0xcf, 0x2f, 0x28, 0x2a, 0x48,
0x56, 0x12, 0xe3, 0x12, 0x71, 0xcb, 0x2f, 0x4a, 0x4e, 0x75, 0x2c, 0x2d, 0xc9, 0xf7, 0xc9, 0xcf,
0x2f, 0x08, 0x4a, 0x2d, 0x2c, 0x4d, 0x2d, 0x2e, 0x51, 0x12, 0xe7, 0x12, 0x45, 0x13, 0x2f, 0x2e,
0xc8, 0xcf, 0x2b, 0x4e, 0x35, 0x8a, 0xe4, 0x62, 0x75, 0x01, 0x19, 0x24, 0x14, 0xc0, 0xc5, 0x8b,
0xa2, 0x42, 0x48, 0x56, 0x0f, 0x6a, 0xa8, 0x1e, 0x36, 0x13, 0xa5, 0xe4, 0x70, 0x49, 0x43, 0x0c,
0x56, 0x62, 0x48, 0x62, 0x03, 0xbb, 0xcd, 0x18, 0x10, 0x00, 0x00, 0xff, 0xff, 0x39, 0x7a, 0x3c,
0x6b, 0xaa, 0x00, 0x00, 0x00,
func init() { file_debug_proto_init() }
func file_debug_proto_init() {
if File_debug_proto != nil {
return
}
if !protoimpl.UnsafeEnabled {
file_debug_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*ForceAutoLoopRequest); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_debug_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*ForceAutoLoopResponse); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
}
type x struct{}
out := protoimpl.TypeBuilder{
File: protoimpl.DescBuilder{
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: file_debug_proto_rawDesc,
NumEnums: 0,
NumMessages: 2,
NumExtensions: 0,
NumServices: 1,
},
GoTypes: file_debug_proto_goTypes,
DependencyIndexes: file_debug_proto_depIdxs,
MessageInfos: file_debug_proto_msgTypes,
}.Build()
File_debug_proto = out.File
file_debug_proto_rawDesc = nil
file_debug_proto_goTypes = nil
file_debug_proto_depIdxs = nil
}
// Reference imports to suppress errors if they are not otherwise used.
var _ context.Context
var _ grpc.ClientConn
var _ grpc.ClientConnInterface
// 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
const _ = grpc.SupportPackageIsVersion6
// DebugClient is the client API for Debug service.
//
@ -125,10 +222,10 @@ type DebugClient interface {
}
type debugClient struct {
cc *grpc.ClientConn
cc grpc.ClientConnInterface
}
func NewDebugClient(cc *grpc.ClientConn) DebugClient {
func NewDebugClient(cc grpc.ClientConnInterface) DebugClient {
return &debugClient{cc}
}
@ -154,7 +251,7 @@ type DebugServer interface {
type UnimplementedDebugServer struct {
}
func (*UnimplementedDebugServer) ForceAutoLoop(ctx context.Context, req *ForceAutoLoopRequest) (*ForceAutoLoopResponse, error) {
func (*UnimplementedDebugServer) ForceAutoLoop(context.Context, *ForceAutoLoopRequest) (*ForceAutoLoopResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method ForceAutoLoop not implemented")
}

@ -2,6 +2,8 @@ syntax = "proto3";
package looprpc;
option go_package = "github.com/lightninglabs/loop/looprpc";
/*
Debug is a service that exposes endpoints intended for testing purposes. These
endpoints should not operate on mainnet, and should only be included if loop is
@ -13,7 +15,7 @@ service Debug {
mainnet. This endpoint ticks our autoloop timer, triggering automated
dispatch of a swap if one is suggested.
*/
rpc ForceAutoLoop(ForceAutoLoopRequest) returns (ForceAutoLoopResponse){}
rpc ForceAutoLoop (ForceAutoLoopRequest) returns (ForceAutoLoopResponse);
}
message ForceAutoLoopRequest {

@ -1,24 +1,36 @@
#!/bin/sh
#!/bin/bash
set -e
# generate compiles the *.pb.go stubs from the *.proto files.
function generate() {
# Generate the gRPC bindings for all proto files.
for file in ./*.proto
do
protoc -I/usr/local/include -I. \
-I$GOPATH/src/github.com/grpc-ecosystem/grpc-gateway/third_party/googleapis \
--go_out=plugins=grpc,paths=source_relative:. \
${file}
"${file}"
done
# Only generate the REST proxy and definitions for the client component.
# Generate the REST reverse proxy for the client only.
protoc -I/usr/local/include -I. \
-I$GOPATH/src/github.com/grpc-ecosystem/grpc-gateway/third_party/googleapis \
--grpc-gateway_out=logtostderr=true:. \
client.proto
--grpc-gateway_out=logtostderr=true,paths=source_relative,grpc_api_configuration=rest-annotations.yaml:. \
"client.proto"
# Finally, generate the swagger file which describes the REST API in detail.
protoc -I/usr/local/include -I. \
-I$GOPATH/src/github.com/grpc-ecosystem/grpc-gateway/third_party/googleapis \
--swagger_out=logtostderr=true:. \
client.proto
--swagger_out=logtostderr=true,grpc_api_configuration=rest-annotations.yaml:. \
"client.proto"
}
# format formats the *.proto files with the clang-format utility.
function format() {
find . -name "*.proto" -print0 | xargs -0 clang-format --style=file -i
}
# Compile and format the looprpc package.
pushd looprpc
format
generate
popd

@ -0,0 +1,23 @@
#!/bin/bash
set -e
# Directory of the script file, independent of where it's called from.
DIR="$(cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd)"
PROTOC_GEN_VERSION=$(go list -f '{{.Version}}' -m github.com/golang/protobuf)
GRPC_GATEWAY_VERSION=$(go list -f '{{.Version}}' -m github.com/grpc-ecosystem/grpc-gateway)
echo "Building protobuf compiler docker image..."
docker build -q -t loop-protobuf-builder \
--build-arg PROTOC_GEN_VERSION="$PROTOC_GEN_VERSION" \
--build-arg GRPC_GATEWAY_VERSION="$GRPC_GATEWAY_VERSION" \
.
echo "Compiling and formatting *.proto files..."
docker run \
--rm \
--user $UID:$UID \
-e UID=$UID \
-v "$DIR/../:/build" \
loop-protobuf-builder

@ -0,0 +1,33 @@
type: google.api.Service
config_version: 3
http:
rules:
# client.proto
- selector: looprpc.SwapClient.LoopOut
post: "/v1/loop/out"
body: "*"
- selector: looprpc.SwapClient.LoopIn
post: "/v1/loop/in"
body: "*"
- selector: looprpc.SwapClient.ListSwaps
get: "/v1/loop/swaps"
- selector: looprpc.SwapClient.SwapInfo
get: "/v1/loop/swap/{id}"
- selector: looprpc.SwapClient.LoopOutTerms
get: "/v1/loop/out/terms"
- selector: looprpc.SwapClient.LoopOutQuote
get: "/v1/loop/out/quote/{amt}"
- selector: looprpc.SwapClient.GetLoopInTerms
get: "/v1/loop/in/terms"
- selector: looprpc.SwapClient.GetLoopInQuote
get: "/v1/loop/in/quote/{amt}"
- selector: looprpc.SwapClient.GetLsatTokens
get: "/v1/lsat/tokens"
- selector: looprpc.SwapClient.GetLiquidityParams
get: "/v1/liquidity/params"
- selector: looprpc.SwapClient.SetLiquidityParams
post: "/v1/liquidity/params"
body: "*"
- selector: looprpc.SwapClient.SuggestSwaps
get: "/v1/auto/suggest"

File diff suppressed because it is too large Load Diff

@ -1,9 +1,9 @@
syntax = "proto3";
import "google/api/annotations.proto";
package looprpc;
option go_package = "github.com/lightninglabs/loop/looprpc";
service SwapServer {
rpc LoopOutTerms (ServerLoopOutTermsRequest) returns (ServerLoopOutTerms);
@ -406,4 +406,5 @@ message CancelLoopOutSwapRequest {
}
}
message CancelLoopOutSwapResponse{}
message CancelLoopOutSwapResponse {
}

Loading…
Cancel
Save