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;
@ -252,7 +203,7 @@ message LoopOutRequest {
message LoopInRequest {
/*
Requested swap amount in sat. This does not include the swap and miner
Requested swap amount in sat. This does not include the swap and miner
fee.
*/
int64 amt = 1;
@ -268,7 +219,7 @@ message LoopInRequest {
/*
Maximum in on-chain fees that we are willing to spend. If we want to
publish the on-chain htlc and the fee estimate turns out higher than this
value, we cancel the swap.
value, we cancel the swap.
max_miner_fee is typically taken from the response of the GetQuote call.
*/
@ -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;
/*
@ -742,7 +691,7 @@ message LiquidityParameters {
/*
The parts per million of swap amount that is allowed to be allocated to swap
fees. This value is applied across swap categories and may not be set in
fees. This value is applied across swap categories and may not be set in
conjunction with sweep fee rate, swap fee ppm, routing fee ppm, prepay
routing, max prepay and max miner fee.
*/
@ -801,8 +750,8 @@ message LiquidityParameters {
uint64 failure_backoff_sec = 9;
/*
Set to true to enable automatic dispatch of swaps. All swaps will be limited
to the fee categories set by these parameters, and total expenditure will
Set to true to enable automatic dispatch of swaps. All swaps will be limited
to the fee categories set by these parameters, and total expenditure will
be limited to the autoloop budget.
*/
bool autoloop = 10;
@ -854,7 +803,7 @@ message LiquidityRule {
*/
uint64 channel_id = 1;
/*
/*
The public key of the peer that this rule should be applied to. This field
may not be set when the channel id field is set.
*/
@ -901,25 +850,25 @@ enum AutoReason {
AUTO_REASON_UNKNOWN = 0;
/*
Budget not started indicates that we do not recommend any swaps because
Budget not started indicates that we do not recommend any swaps because
the start time for our budget has not arrived yet.
*/
AUTO_REASON_BUDGET_NOT_STARTED = 1;
/*
Sweep fees indicates that the estimated fees to sweep swaps are too high
Sweep fees indicates that the estimated fees to sweep swaps are too high
right now.
*/
AUTO_REASON_SWEEP_FEES = 2;
/*
Budget elapsed indicates that the autoloop budget for the period has been
Budget elapsed indicates that the autoloop budget for the period has been
elapsed.
*/
AUTO_REASON_BUDGET_ELAPSED = 3;
/*
In flight indicates that the limit on in-flight automatically dispatched
In flight indicates that the limit on in-flight automatically dispatched
swaps has already been reached.
*/
AUTO_REASON_IN_FLIGHT = 4;
@ -952,21 +901,21 @@ enum AutoReason {
AUTO_REASON_LOOP_OUT = 9;
/*
Loop In indicates that a loop in swap is currently in flight for the peer,
Loop In indicates that a loop in swap is currently in flight for the peer,
so it is not eligible.
*/
AUTO_REASON_LOOP_IN = 10;
/*
Liquidity ok indicates that a target meets the liquidity balance expressed
Liquidity ok indicates that a target meets the liquidity balance expressed
in its rule, so no swap is needed.
*/
AUTO_REASON_LIQUIDITY_OK = 11;
/*
Budget insufficient indicates that we cannot perform a swap because we do
not have enough pending budget available. This differs from budget elapsed,
because we still have some budget available, but we have allocated it to
/*
Budget insufficient indicates that we cannot perform a swap because we do
not have enough pending budget available. This differs from budget elapsed,
because we still have some budget available, but we have allocated it to
other swaps.
*/
AUTO_REASON_BUDGET_INSUFFICIENT = 12;
@ -976,14 +925,14 @@ enum AutoReason {
the portion of total swap amount that we allow fees to consume.
*/
AUTO_REASON_FEE_INSUFFICIENT = 13;
}
}
message Disqualified {
/*
The short channel ID of the channel that was excluded from our suggestions.
*/
uint64 channel_id = 1;
uint64 channel_id = 1;
/*
The public key of the peer that was excluded from our suggestions.
*/

@ -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": {
@ -414,7 +414,7 @@
"AUTO_REASON_FEE_INSUFFICIENT"
],
"default": "AUTO_REASON_UNKNOWN",
"description": " - AUTO_REASON_BUDGET_NOT_STARTED: Budget not started indicates that we do not recommend any swaps because \nthe start time for our budget has not arrived yet.\n - AUTO_REASON_SWEEP_FEES: Sweep fees indicates that the estimated fees to sweep swaps are too high \nright now.\n - AUTO_REASON_BUDGET_ELAPSED: Budget elapsed indicates that the autoloop budget for the period has been \nelapsed.\n - AUTO_REASON_IN_FLIGHT: In flight indicates that the limit on in-flight automatically dispatched \nswaps has already been reached.\n - AUTO_REASON_SWAP_FEE: Swap fee indicates that the server fee for a specific swap is too high.\n - AUTO_REASON_MINER_FEE: Miner fee indicates that the miner fee for a specific swap is to high.\n - AUTO_REASON_PREPAY: Prepay indicates that the prepay fee for a specific swap is too high.\n - AUTO_REASON_FAILURE_BACKOFF: Failure backoff indicates that a swap has recently failed for this target,\nand the backoff period has not yet passed.\n - AUTO_REASON_LOOP_OUT: Loop out indicates that a loop out swap is currently utilizing the channel,\nso it is not eligible.\n - AUTO_REASON_LOOP_IN: Loop In indicates that a loop in swap is currently in flight for the peer, \nso it is not eligible.\n - AUTO_REASON_LIQUIDITY_OK: Liquidity ok indicates that a target meets the liquidity balance expressed \nin its rule, so no swap is needed.\n - AUTO_REASON_BUDGET_INSUFFICIENT: Budget insufficient indicates that we cannot perform a swap because we do \nnot have enough pending budget available. This differs from budget elapsed, \nbecause we still have some budget available, but we have allocated it to \nother swaps.\n - AUTO_REASON_FEE_INSUFFICIENT: Fee insufficient indicates that the fee estimate for a swap is higher than\nthe portion of total swap amount that we allow fees to consume."
"description": " - AUTO_REASON_BUDGET_NOT_STARTED: Budget not started indicates that we do not recommend any swaps because\nthe start time for our budget has not arrived yet.\n - AUTO_REASON_SWEEP_FEES: Sweep fees indicates that the estimated fees to sweep swaps are too high\nright now.\n - AUTO_REASON_BUDGET_ELAPSED: Budget elapsed indicates that the autoloop budget for the period has been\nelapsed.\n - AUTO_REASON_IN_FLIGHT: In flight indicates that the limit on in-flight automatically dispatched\nswaps has already been reached.\n - AUTO_REASON_SWAP_FEE: Swap fee indicates that the server fee for a specific swap is too high.\n - AUTO_REASON_MINER_FEE: Miner fee indicates that the miner fee for a specific swap is to high.\n - AUTO_REASON_PREPAY: Prepay indicates that the prepay fee for a specific swap is too high.\n - AUTO_REASON_FAILURE_BACKOFF: Failure backoff indicates that a swap has recently failed for this target,\nand the backoff period has not yet passed.\n - AUTO_REASON_LOOP_OUT: Loop out indicates that a loop out swap is currently utilizing the channel,\nso it is not eligible.\n - AUTO_REASON_LOOP_IN: Loop In indicates that a loop in swap is currently in flight for the peer,\nso it is not eligible.\n - AUTO_REASON_LIQUIDITY_OK: Liquidity ok indicates that a target meets the liquidity balance expressed\nin its rule, so no swap is needed.\n - AUTO_REASON_BUDGET_INSUFFICIENT: Budget insufficient indicates that we cannot perform a swap because we do\nnot have enough pending budget available. This differs from budget elapsed,\nbecause we still have some budget available, but we have allocated it to\nother swaps.\n - AUTO_REASON_FEE_INSUFFICIENT: Fee insufficient indicates that the fee estimate for a swap is higher than\nthe portion of total swap amount that we allow fees to consume."
},
"looprpcDisqualified": {
"type": "object",
@ -502,7 +502,7 @@
"fee_ppm": {
"type": "string",
"format": "uint64",
"description": "The parts per million of swap amount that is allowed to be allocated to swap\nfees. This value is applied across swap categories and may not be set in \nconjunction with sweep fee rate, swap fee ppm, routing fee ppm, prepay\nrouting, max prepay and max miner fee."
"description": "The parts per million of swap amount that is allowed to be allocated to swap\nfees. This value is applied across swap categories and may not be set in\nconjunction with sweep fee rate, swap fee ppm, routing fee ppm, prepay\nrouting, max prepay and max miner fee."
},
"sweep_fee_rate_sat_per_vbyte": {
"type": "string",
@ -547,7 +547,7 @@
"autoloop": {
"type": "boolean",
"format": "boolean",
"description": "Set to true to enable automatic dispatch of swaps. All swaps will be limited \nto the fee categories set by these parameters, and total expenditure will \nbe limited to the autoloop budget."
"description": "Set to true to enable automatic dispatch of swaps. All swaps will be limited\nto the fee categories set by these parameters, and total expenditure will\nbe limited to the autoloop budget."
},
"autoloop_budget_sat": {
"type": "string",
@ -631,7 +631,7 @@
"amt": {
"type": "string",
"format": "int64",
"description": "Requested swap amount in sat. This does not include the swap and miner \nfee."
"description": "Requested swap amount in sat. This does not include the swap and miner\nfee."
},
"max_swap_fee": {
"type": "string",
@ -641,7 +641,7 @@
"max_miner_fee": {
"type": "string",
"format": "int64",
"description": "Maximum in on-chain fees that we are willing to spend. If we want to\npublish the on-chain htlc and the fee estimate turns out higher than this\nvalue, we cancel the swap. \n\nmax_miner_fee is typically taken from the response of the GetQuote call."
"description": "Maximum in on-chain fees that we are willing to spend. If we want to\npublish the on-chain htlc and the fee estimate turns out higher than this\nvalue, we cancel the swap.\n\nmax_miner_fee is typically taken from the response of the GetQuote call."
},
"last_hop": {
"type": "string",
@ -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 (m *ForceAutoLoopRequest) XXX_Merge(src proto.Message) {
xxx_messageInfo_ForceAutoLoopRequest.Merge(m, src)
}
func (m *ForceAutoLoopRequest) XXX_Size() int {
return xxx_messageInfo_ForceAutoLoopRequest.Size(m)
func (x *ForceAutoLoopRequest) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (m *ForceAutoLoopRequest) XXX_DiscardUnknown() {
xxx_messageInfo_ForceAutoLoopRequest.DiscardUnknown(m)
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)
}
return ms
}
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 (m *ForceAutoLoopResponse) XXX_Merge(src proto.Message) {
xxx_messageInfo_ForceAutoLoopResponse.Merge(m, src)
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
}
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 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}
# 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. \
--go_out=plugins=grpc,paths=source_relative:. \
"${file}"
done
# Generate the REST reverse proxy for the client only.
protoc -I/usr/local/include -I. \
--grpc-gateway_out=logtostderr=true,paths=source_relative,grpc_api_configuration=rest-annotations.yaml:. \
"client.proto"
done
# Only generate the REST proxy and definitions for the client component.
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
# Finally, generate the swagger file which describes the REST API in detail.
protoc -I/usr/local/include -I. \
--swagger_out=logtostderr=true,grpc_api_configuration=rest-annotations.yaml:. \
"client.proto"
}
protoc -I/usr/local/include -I. \
-I$GOPATH/src/github.com/grpc-ecosystem/grpc-gateway/third_party/googleapis \
--swagger_out=logtostderr=true:. \
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);
@ -27,7 +27,7 @@ service SwapServer {
rpc SubscribeLoopInUpdates (SubscribeUpdatesRequest)
returns (stream SubscribeLoopInUpdatesResponse);
rpc CancelLoopOutSwap(CancelLoopOutSwapRequest)
rpc CancelLoopOutSwap (CancelLoopOutSwapRequest)
returns (CancelLoopOutSwapResponse);
}
@ -307,7 +307,7 @@ enum ServerSwapState {
SERVER_CLIENT_INVOICE_CANCEL = 14;
}
message SubscribeLoopOutUpdatesResponse{
message SubscribeLoopOutUpdatesResponse {
// The unix timestamp in nanoseconds when the swap was updated.
int64 timestamp_ns = 1;
@ -315,7 +315,7 @@ message SubscribeLoopOutUpdatesResponse{
ServerSwapState state = 2;
}
message SubscribeLoopInUpdatesResponse{
message SubscribeLoopInUpdatesResponse {
// The unix timestamp in nanoseconds when the swap was updated.
int64 timestamp_ns = 1;
@ -327,7 +327,7 @@ enum RoutePaymentType {
// No reason, used to distinguish from the default value.
ROUTE_UNKNOWN = 0;
// Prepay route indicates that the swap was canceled because the client
// Prepay route indicates that the swap was canceled because the client
// could not find a route to the server for the prepay.
PREPAY_ROUTE = 1;
@ -380,12 +380,12 @@ message RouteCancel {
repeated HtlcAttempt attempts = 2;
// The reason that the payment failed.
PaymentFailureReason failure = 3;
PaymentFailureReason failure = 3;
}
message HtlcAttempt {
// The number of hops from the htlc's failure hop that it needed to take
// to reach the server's node.
// to reach the server's node.
uint32 remaining_hops = 1;
}
@ -394,7 +394,7 @@ message CancelLoopOutSwapRequest {
ProtocolVersion protocol_version = 1;
// The swap hash.
bytes swap_hash = 2;
bytes swap_hash = 2;
// The payment address for the swap invoice, used to ensure that only the
// swap owner can cancel the payment.
@ -406,4 +406,5 @@ message CancelLoopOutSwapRequest {
}
}
message CancelLoopOutSwapResponse{}
message CancelLoopOutSwapResponse {
}

Loading…
Cancel
Save