From 0ef659a486f70408e1a5fe6a4e909e5d894c1a54 Mon Sep 17 00:00:00 2001 From: Joost Jager Date: Mon, 15 Jun 2020 11:29:43 +0200 Subject: [PATCH 1/2] looprpc: generate with latest lnd versions of the proto generators https://github.com/lightningnetwork/lnd/commit/3ef41dd198cf21b3f33f4d844261e94eae67a93d --- go.mod | 2 +- go.sum | 4 +- looprpc/client.pb.go | 37 ++++ looprpc/client.pb.gw.go | 378 ++++++++++++++++++++++++++++++++++-- looprpc/client.swagger.json | 93 +++++++-- looprpc/server.pb.go | 28 +++ 6 files changed, 510 insertions(+), 32 deletions(-) diff --git a/go.mod b/go.mod index 7fd61c2..df7dff0 100644 --- a/go.mod +++ b/go.mod @@ -8,7 +8,7 @@ require ( github.com/fortytw2/leaktest v1.3.0 github.com/golang/protobuf v1.3.2 github.com/google/go-cmp v0.3.1 // indirect - github.com/grpc-ecosystem/grpc-gateway v1.12.2 + github.com/grpc-ecosystem/grpc-gateway v1.14.3 github.com/jessevdk/go-flags v1.4.0 github.com/lightninglabs/protobuf-hex-display v1.3.3-0.20191212020323-b444784ce75d github.com/lightningnetwork/lnd v0.10.0-beta.rc6.0.20200603030653-09bb9db78246 diff --git a/go.sum b/go.sum index b673904..52c0c68 100644 --- a/go.sum +++ b/go.sum @@ -124,8 +124,8 @@ github.com/grpc-ecosystem/go-grpc-middleware v1.0.0/go.mod h1:FiyG127CGDf3tlThmg github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0 h1:Ovs26xHkKqVztRpIrF/92BcuyuQ/YW4NSIpoGtfXNho= github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0/go.mod h1:8NvIoxWQoOIhqOTXgfV/d3M/q6VIi02HzZEHgUlZvzk= github.com/grpc-ecosystem/grpc-gateway v1.8.6/go.mod h1:vNeuVxBJEsws4ogUvrchl83t/GYV9WGTSLVdBhOQFDY= -github.com/grpc-ecosystem/grpc-gateway v1.12.2 h1:D0EVSTwQoQOyfY35QNSuPJA4jpZRtkoGYWQMB7XNg5o= -github.com/grpc-ecosystem/grpc-gateway v1.12.2/go.mod h1:8XEsbTttt/W+VvjtQhLACqCisSPWTxCZ7sBRjU6iH9c= +github.com/grpc-ecosystem/grpc-gateway v1.14.3 h1:OCJlWkOUoTnl0neNGlf4fUm3TmbEtguw7vR+nGtnDjY= +github.com/grpc-ecosystem/grpc-gateway v1.14.3/go.mod h1:6CwZWGDSPRJidgKAtJVvND6soZe6fT7iteq8wDPdhb0= github.com/hpcloud/tail v1.0.0 h1:nfCOvKYfkgYP8hkirhJocXT2+zOD8yUNjXaWfTlyFKI= github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= github.com/jackpal/gateway v1.0.5/go.mod h1:lTpwd4ACLXmpyiCTRtfiNyVnUmqT9RivzCDQetPfnjA= diff --git a/looprpc/client.pb.go b/looprpc/client.pb.go index f1a0b68..c53a39a 100644 --- a/looprpc/client.pb.go +++ b/looprpc/client.pb.go @@ -9,6 +9,8 @@ import ( proto "github.com/golang/protobuf/proto" _ "google.golang.org/genproto/googleapis/api/annotations" grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" math "math" ) @@ -1563,6 +1565,41 @@ type SwapClientServer interface { GetLsatTokens(context.Context, *TokensRequest) (*TokensResponse, error) } +// UnimplementedSwapClientServer can be embedded to have forward compatible implementations. +type UnimplementedSwapClientServer struct { +} + +func (*UnimplementedSwapClientServer) LoopOut(ctx context.Context, req *LoopOutRequest) (*SwapResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method LoopOut not implemented") +} +func (*UnimplementedSwapClientServer) LoopIn(ctx context.Context, req *LoopInRequest) (*SwapResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method LoopIn not implemented") +} +func (*UnimplementedSwapClientServer) Monitor(req *MonitorRequest, srv SwapClient_MonitorServer) error { + return status.Errorf(codes.Unimplemented, "method Monitor not implemented") +} +func (*UnimplementedSwapClientServer) ListSwaps(ctx context.Context, req *ListSwapsRequest) (*ListSwapsResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method ListSwaps not implemented") +} +func (*UnimplementedSwapClientServer) SwapInfo(ctx context.Context, req *SwapInfoRequest) (*SwapStatus, error) { + return nil, status.Errorf(codes.Unimplemented, "method SwapInfo not implemented") +} +func (*UnimplementedSwapClientServer) LoopOutTerms(ctx context.Context, req *TermsRequest) (*TermsResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method LoopOutTerms not implemented") +} +func (*UnimplementedSwapClientServer) LoopOutQuote(ctx context.Context, req *QuoteRequest) (*QuoteResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method LoopOutQuote not implemented") +} +func (*UnimplementedSwapClientServer) GetLoopInTerms(ctx context.Context, req *TermsRequest) (*TermsResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method GetLoopInTerms not implemented") +} +func (*UnimplementedSwapClientServer) GetLoopInQuote(ctx context.Context, req *QuoteRequest) (*QuoteResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method GetLoopInQuote not implemented") +} +func (*UnimplementedSwapClientServer) GetLsatTokens(ctx context.Context, req *TokensRequest) (*TokensResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method GetLsatTokens not implemented") +} + func RegisterSwapClientServer(s *grpc.Server, srv SwapClientServer) { s.RegisterService(&_SwapClient_serviceDesc, srv) } diff --git a/looprpc/client.pb.gw.go b/looprpc/client.pb.gw.go index e45c4c5..0dfa2d9 100644 --- a/looprpc/client.pb.gw.go +++ b/looprpc/client.pb.gw.go @@ -13,6 +13,7 @@ import ( "io" "net/http" + "github.com/golang/protobuf/descriptor" "github.com/golang/protobuf/proto" "github.com/grpc-ecosystem/grpc-gateway/runtime" "github.com/grpc-ecosystem/grpc-gateway/utilities" @@ -22,11 +23,13 @@ import ( "google.golang.org/grpc/status" ) +// Suppress "imported and not used" errors var _ codes.Code var _ io.Reader var _ status.Status var _ = runtime.String var _ = utilities.NewDoubleArray +var _ = descriptor.ForMessage func request_SwapClient_LoopOut_0(ctx context.Context, marshaler runtime.Marshaler, client SwapClientClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var protoReq LoopOutRequest @@ -45,6 +48,23 @@ func request_SwapClient_LoopOut_0(ctx context.Context, marshaler runtime.Marshal } +func local_request_SwapClient_LoopOut_0(ctx context.Context, marshaler runtime.Marshaler, server SwapClientServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq LoopOutRequest + var metadata runtime.ServerMetadata + + newReader, berr := utilities.IOReaderFactory(req.Body) + if berr != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr) + } + if err := marshaler.NewDecoder(newReader()).Decode(&protoReq); err != nil && err != io.EOF { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := server.LoopOut(ctx, &protoReq) + return msg, metadata, err + +} + func request_SwapClient_LoopIn_0(ctx context.Context, marshaler runtime.Marshaler, client SwapClientClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var protoReq LoopInRequest var metadata runtime.ServerMetadata @@ -62,6 +82,23 @@ func request_SwapClient_LoopIn_0(ctx context.Context, marshaler runtime.Marshale } +func local_request_SwapClient_LoopIn_0(ctx context.Context, marshaler runtime.Marshaler, server SwapClientServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq LoopInRequest + var metadata runtime.ServerMetadata + + newReader, berr := utilities.IOReaderFactory(req.Body) + if berr != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr) + } + if err := marshaler.NewDecoder(newReader()).Decode(&protoReq); err != nil && err != io.EOF { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := server.LoopIn(ctx, &protoReq) + return msg, metadata, err + +} + func request_SwapClient_ListSwaps_0(ctx context.Context, marshaler runtime.Marshaler, client SwapClientClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var protoReq ListSwapsRequest var metadata runtime.ServerMetadata @@ -71,6 +108,15 @@ func request_SwapClient_ListSwaps_0(ctx context.Context, marshaler runtime.Marsh } +func local_request_SwapClient_ListSwaps_0(ctx context.Context, marshaler runtime.Marshaler, server SwapClientServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq ListSwapsRequest + var metadata runtime.ServerMetadata + + msg, err := server.ListSwaps(ctx, &protoReq) + return msg, metadata, err + +} + func request_SwapClient_SwapInfo_0(ctx context.Context, marshaler runtime.Marshaler, client SwapClientClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var protoReq SwapInfoRequest var metadata runtime.ServerMetadata @@ -98,6 +144,33 @@ func request_SwapClient_SwapInfo_0(ctx context.Context, marshaler runtime.Marsha } +func local_request_SwapClient_SwapInfo_0(ctx context.Context, marshaler runtime.Marshaler, server SwapClientServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq SwapInfoRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "id") + } + + protoReq.Id, err = runtime.Bytes(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) + } + + msg, err := server.SwapInfo(ctx, &protoReq) + return msg, metadata, err + +} + func request_SwapClient_LoopOutTerms_0(ctx context.Context, marshaler runtime.Marshaler, client SwapClientClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var protoReq TermsRequest var metadata runtime.ServerMetadata @@ -107,6 +180,15 @@ func request_SwapClient_LoopOutTerms_0(ctx context.Context, marshaler runtime.Ma } +func local_request_SwapClient_LoopOutTerms_0(ctx context.Context, marshaler runtime.Marshaler, server SwapClientServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq TermsRequest + var metadata runtime.ServerMetadata + + msg, err := server.LoopOutTerms(ctx, &protoReq) + return msg, metadata, err + +} + var ( filter_SwapClient_LoopOutQuote_0 = &utilities.DoubleArray{Encoding: map[string]int{"amt": 0}, Base: []int{1, 1, 0}, Check: []int{0, 1, 2}} ) @@ -133,7 +215,10 @@ func request_SwapClient_LoopOutQuote_0(ctx context.Context, marshaler runtime.Ma return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "amt", err) } - if err := runtime.PopulateQueryParameters(&protoReq, req.URL.Query(), filter_SwapClient_LoopOutQuote_0); err != nil { + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_SwapClient_LoopOutQuote_0); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } @@ -142,6 +227,37 @@ func request_SwapClient_LoopOutQuote_0(ctx context.Context, marshaler runtime.Ma } +func local_request_SwapClient_LoopOutQuote_0(ctx context.Context, marshaler runtime.Marshaler, server SwapClientServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QuoteRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["amt"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "amt") + } + + protoReq.Amt, err = runtime.Int64(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "amt", err) + } + + if err := runtime.PopulateQueryParameters(&protoReq, req.URL.Query(), filter_SwapClient_LoopOutQuote_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := server.LoopOutQuote(ctx, &protoReq) + return msg, metadata, err + +} + func request_SwapClient_GetLoopInTerms_0(ctx context.Context, marshaler runtime.Marshaler, client SwapClientClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var protoReq TermsRequest var metadata runtime.ServerMetadata @@ -151,6 +267,15 @@ func request_SwapClient_GetLoopInTerms_0(ctx context.Context, marshaler runtime. } +func local_request_SwapClient_GetLoopInTerms_0(ctx context.Context, marshaler runtime.Marshaler, server SwapClientServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq TermsRequest + var metadata runtime.ServerMetadata + + msg, err := server.GetLoopInTerms(ctx, &protoReq) + return msg, metadata, err + +} + var ( filter_SwapClient_GetLoopInQuote_0 = &utilities.DoubleArray{Encoding: map[string]int{"amt": 0}, Base: []int{1, 1, 0}, Check: []int{0, 1, 2}} ) @@ -177,7 +302,10 @@ func request_SwapClient_GetLoopInQuote_0(ctx context.Context, marshaler runtime. return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "amt", err) } - if err := runtime.PopulateQueryParameters(&protoReq, req.URL.Query(), filter_SwapClient_GetLoopInQuote_0); err != nil { + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_SwapClient_GetLoopInQuote_0); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } @@ -186,6 +314,37 @@ func request_SwapClient_GetLoopInQuote_0(ctx context.Context, marshaler runtime. } +func local_request_SwapClient_GetLoopInQuote_0(ctx context.Context, marshaler runtime.Marshaler, server SwapClientServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QuoteRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["amt"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "amt") + } + + protoReq.Amt, err = runtime.Int64(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "amt", err) + } + + if err := runtime.PopulateQueryParameters(&protoReq, req.URL.Query(), filter_SwapClient_GetLoopInQuote_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := server.GetLoopInQuote(ctx, &protoReq) + return msg, metadata, err + +} + func request_SwapClient_GetLsatTokens_0(ctx context.Context, marshaler runtime.Marshaler, client SwapClientClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var protoReq TokensRequest var metadata runtime.ServerMetadata @@ -195,6 +354,203 @@ func request_SwapClient_GetLsatTokens_0(ctx context.Context, marshaler runtime.M } +func local_request_SwapClient_GetLsatTokens_0(ctx context.Context, marshaler runtime.Marshaler, server SwapClientServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq TokensRequest + var metadata runtime.ServerMetadata + + msg, err := server.GetLsatTokens(ctx, &protoReq) + return msg, metadata, err + +} + +// RegisterSwapClientHandlerServer registers the http handlers for service SwapClient to "mux". +// UnaryRPC :call SwapClientServer directly. +// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. +func RegisterSwapClientHandlerServer(ctx context.Context, mux *runtime.ServeMux, server SwapClientServer) error { + + mux.Handle("POST", pattern_SwapClient_LoopOut_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_SwapClient_LoopOut_0(rctx, inboundMarshaler, server, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_SwapClient_LoopOut_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("POST", pattern_SwapClient_LoopIn_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_SwapClient_LoopIn_0(rctx, inboundMarshaler, server, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_SwapClient_LoopIn_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_SwapClient_ListSwaps_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_SwapClient_ListSwaps_0(rctx, inboundMarshaler, server, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_SwapClient_ListSwaps_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_SwapClient_SwapInfo_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_SwapClient_SwapInfo_0(rctx, inboundMarshaler, server, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_SwapClient_SwapInfo_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_SwapClient_LoopOutTerms_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_SwapClient_LoopOutTerms_0(rctx, inboundMarshaler, server, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_SwapClient_LoopOutTerms_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_SwapClient_LoopOutQuote_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_SwapClient_LoopOutQuote_0(rctx, inboundMarshaler, server, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_SwapClient_LoopOutQuote_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_SwapClient_GetLoopInTerms_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_SwapClient_GetLoopInTerms_0(rctx, inboundMarshaler, server, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_SwapClient_GetLoopInTerms_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_SwapClient_GetLoopInQuote_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_SwapClient_GetLoopInQuote_0(rctx, inboundMarshaler, server, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_SwapClient_GetLoopInQuote_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_SwapClient_GetLsatTokens_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_SwapClient_GetLsatTokens_0(rctx, inboundMarshaler, server, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_SwapClient_GetLsatTokens_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + return nil +} + // RegisterSwapClientHandlerFromEndpoint is same as RegisterSwapClientHandler but // automatically dials to "endpoint" and closes the connection when "ctx" gets done. func RegisterSwapClientHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) { @@ -417,23 +773,23 @@ func RegisterSwapClientHandlerClient(ctx context.Context, mux *runtime.ServeMux, } var ( - pattern_SwapClient_LoopOut_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"v1", "loop", "out"}, "")) + pattern_SwapClient_LoopOut_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"v1", "loop", "out"}, "", runtime.AssumeColonVerbOpt(true))) - pattern_SwapClient_LoopIn_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"v1", "loop", "in"}, "")) + pattern_SwapClient_LoopIn_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"v1", "loop", "in"}, "", runtime.AssumeColonVerbOpt(true))) - pattern_SwapClient_ListSwaps_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"v1", "loop", "swaps"}, "")) + pattern_SwapClient_ListSwaps_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"v1", "loop", "swaps"}, "", runtime.AssumeColonVerbOpt(true))) - pattern_SwapClient_SwapInfo_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3}, []string{"v1", "loop", "swap", "id"}, "")) + pattern_SwapClient_SwapInfo_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3}, []string{"v1", "loop", "swap", "id"}, "", runtime.AssumeColonVerbOpt(true))) - pattern_SwapClient_LoopOutTerms_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"v1", "loop", "out", "terms"}, "")) + pattern_SwapClient_LoopOutTerms_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"v1", "loop", "out", "terms"}, "", runtime.AssumeColonVerbOpt(true))) - pattern_SwapClient_LoopOutQuote_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4}, []string{"v1", "loop", "out", "quote", "amt"}, "")) + pattern_SwapClient_LoopOutQuote_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4}, []string{"v1", "loop", "out", "quote", "amt"}, "", runtime.AssumeColonVerbOpt(true))) - pattern_SwapClient_GetLoopInTerms_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"v1", "loop", "in", "terms"}, "")) + pattern_SwapClient_GetLoopInTerms_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"v1", "loop", "in", "terms"}, "", runtime.AssumeColonVerbOpt(true))) - pattern_SwapClient_GetLoopInQuote_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4}, []string{"v1", "loop", "in", "quote", "amt"}, "")) + pattern_SwapClient_GetLoopInQuote_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4}, []string{"v1", "loop", "in", "quote", "amt"}, "", runtime.AssumeColonVerbOpt(true))) - pattern_SwapClient_GetLsatTokens_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"v1", "lsat", "tokens"}, "")) + pattern_SwapClient_GetLsatTokens_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"v1", "lsat", "tokens"}, "", runtime.AssumeColonVerbOpt(true))) ) var ( diff --git a/looprpc/client.swagger.json b/looprpc/client.swagger.json index 4e3958a..75ec66d 100644 --- a/looprpc/client.swagger.json +++ b/looprpc/client.swagger.json @@ -4,10 +4,6 @@ "title": "client.proto", "version": "version not set" }, - "schemes": [ - "http", - "https" - ], "consumes": [ "application/json" ], @@ -25,6 +21,12 @@ "schema": { "$ref": "#/definitions/looprpcSwapResponse" } + }, + "default": { + "description": "An unexpected error response", + "schema": { + "$ref": "#/definitions/runtimeError" + } } }, "parameters": [ @@ -52,6 +54,12 @@ "schema": { "$ref": "#/definitions/looprpcQuoteResponse" } + }, + "default": { + "description": "An unexpected error response", + "schema": { + "$ref": "#/definitions/runtimeError" + } } }, "parameters": [ @@ -103,6 +111,12 @@ "schema": { "$ref": "#/definitions/looprpcTermsResponse" } + }, + "default": { + "description": "An unexpected error response", + "schema": { + "$ref": "#/definitions/runtimeError" + } } }, "tags": [ @@ -120,6 +134,12 @@ "schema": { "$ref": "#/definitions/looprpcSwapResponse" } + }, + "default": { + "description": "An unexpected error response", + "schema": { + "$ref": "#/definitions/runtimeError" + } } }, "parameters": [ @@ -147,6 +167,12 @@ "schema": { "$ref": "#/definitions/looprpcQuoteResponse" } + }, + "default": { + "description": "An unexpected error response", + "schema": { + "$ref": "#/definitions/runtimeError" + } } }, "parameters": [ @@ -198,6 +224,12 @@ "schema": { "$ref": "#/definitions/looprpcTermsResponse" } + }, + "default": { + "description": "An unexpected error response", + "schema": { + "$ref": "#/definitions/runtimeError" + } } }, "tags": [ @@ -215,6 +247,12 @@ "schema": { "$ref": "#/definitions/looprpcSwapStatus" } + }, + "default": { + "description": "An unexpected error response", + "schema": { + "$ref": "#/definitions/runtimeError" + } } }, "parameters": [ @@ -242,6 +280,12 @@ "schema": { "$ref": "#/definitions/looprpcListSwapsResponse" } + }, + "default": { + "description": "An unexpected error response", + "schema": { + "$ref": "#/definitions/runtimeError" + } } }, "tags": [ @@ -259,6 +303,12 @@ "schema": { "$ref": "#/definitions/looprpcTokensResponse" } + }, + "default": { + "description": "An unexpected error response", + "schema": { + "$ref": "#/definitions/runtimeError" + } } }, "tags": [ @@ -602,6 +652,27 @@ } } }, + "runtimeError": { + "type": "object", + "properties": { + "error": { + "type": "string" + }, + "code": { + "type": "integer", + "format": "int32" + }, + "message": { + "type": "string" + }, + "details": { + "type": "array", + "items": { + "$ref": "#/definitions/protobufAny" + } + } + } + }, "runtimeStreamError": { "type": "object", "properties": { @@ -627,19 +698,5 @@ } } } - }, - "x-stream-definitions": { - "looprpcSwapStatus": { - "type": "object", - "properties": { - "result": { - "$ref": "#/definitions/looprpcSwapStatus" - }, - "error": { - "$ref": "#/definitions/runtimeStreamError" - } - }, - "title": "Stream result of looprpcSwapStatus" - } } } diff --git a/looprpc/server.pb.go b/looprpc/server.pb.go index 2e907ff..30187ed 100644 --- a/looprpc/server.pb.go +++ b/looprpc/server.pb.go @@ -9,6 +9,8 @@ import ( proto "github.com/golang/protobuf/proto" _ "google.golang.org/genproto/googleapis/api/annotations" grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" math "math" ) @@ -1047,6 +1049,32 @@ type SwapServerServer interface { LoopInQuote(context.Context, *ServerLoopInQuoteRequest) (*ServerLoopInQuoteResponse, error) } +// UnimplementedSwapServerServer can be embedded to have forward compatible implementations. +type UnimplementedSwapServerServer struct { +} + +func (*UnimplementedSwapServerServer) LoopOutTerms(ctx context.Context, req *ServerLoopOutTermsRequest) (*ServerLoopOutTerms, error) { + return nil, status.Errorf(codes.Unimplemented, "method LoopOutTerms not implemented") +} +func (*UnimplementedSwapServerServer) NewLoopOutSwap(ctx context.Context, req *ServerLoopOutRequest) (*ServerLoopOutResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method NewLoopOutSwap not implemented") +} +func (*UnimplementedSwapServerServer) LoopOutPushPreimage(ctx context.Context, req *ServerLoopOutPushPreimageRequest) (*ServerLoopOutPushPreimageResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method LoopOutPushPreimage not implemented") +} +func (*UnimplementedSwapServerServer) LoopOutQuote(ctx context.Context, req *ServerLoopOutQuoteRequest) (*ServerLoopOutQuote, error) { + return nil, status.Errorf(codes.Unimplemented, "method LoopOutQuote not implemented") +} +func (*UnimplementedSwapServerServer) LoopInTerms(ctx context.Context, req *ServerLoopInTermsRequest) (*ServerLoopInTerms, error) { + return nil, status.Errorf(codes.Unimplemented, "method LoopInTerms not implemented") +} +func (*UnimplementedSwapServerServer) NewLoopInSwap(ctx context.Context, req *ServerLoopInRequest) (*ServerLoopInResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method NewLoopInSwap not implemented") +} +func (*UnimplementedSwapServerServer) LoopInQuote(ctx context.Context, req *ServerLoopInQuoteRequest) (*ServerLoopInQuoteResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method LoopInQuote not implemented") +} + func RegisterSwapServerServer(s *grpc.Server, srv SwapServerServer) { s.RegisterService(&_SwapServer_serviceDesc, srv) } From 8a4ce0ed89a760b2702c178623f8b5ea2f20a079 Mon Sep 17 00:00:00 2001 From: Joost Jager Date: Mon, 15 Jun 2020 11:30:12 +0200 Subject: [PATCH 2/2] looprpc: fix doc on routing fee units --- looprpc/client.pb.go | 4 ++-- looprpc/client.proto | 4 ++-- looprpc/client.swagger.json | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/looprpc/client.pb.go b/looprpc/client.pb.go index c53a39a..f0b3961 100644 --- a/looprpc/client.pb.go +++ b/looprpc/client.pb.go @@ -119,12 +119,12 @@ type LoopOutRequest struct { //Base58 encoded destination address for the swap. Dest string `protobuf:"bytes,2,opt,name=dest,proto3" json:"dest,omitempty"` //* - //Maximum off-chain fee in msat that may be paid for payment to the server. + //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. MaxSwapRoutingFee int64 `protobuf:"varint,3,opt,name=max_swap_routing_fee,json=maxSwapRoutingFee,proto3" json:"max_swap_routing_fee,omitempty"` //* - //Maximum off-chain fee in msat that may be paid for payment to the server. + //Maximum off-chain fee in sat that may be paid for the prepay to the server. //This limit is applied during path finding. Typically this value is taken //from the response of the GetQuote call. MaxPrepayRoutingFee int64 `protobuf:"varint,4,opt,name=max_prepay_routing_fee,json=maxPrepayRoutingFee,proto3" json:"max_prepay_routing_fee,omitempty"` diff --git a/looprpc/client.proto b/looprpc/client.proto index 76c23d5..95b97a4 100644 --- a/looprpc/client.proto +++ b/looprpc/client.proto @@ -118,14 +118,14 @@ message LoopOutRequest { string dest = 2; /** - Maximum off-chain fee in msat that may be paid for payment to the server. + 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; /** - Maximum off-chain fee in msat that may be paid for payment to the server. + Maximum off-chain fee in sat that may be paid for the prepay to the server. This limit is applied during path finding. Typically this value is taken from the response of the GetQuote call. */ diff --git a/looprpc/client.swagger.json b/looprpc/client.swagger.json index 75ec66d..4d750c4 100644 --- a/looprpc/client.swagger.json +++ b/looprpc/client.swagger.json @@ -380,12 +380,12 @@ "max_swap_routing_fee": { "type": "string", "format": "int64", - "description": "*\nMaximum off-chain fee in msat that may be paid for payment to the server.\nThis limit is applied during path finding. Typically this value is taken\nfrom the response of the GetQuote call." + "description": "*\nMaximum 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." }, "max_prepay_routing_fee": { "type": "string", "format": "int64", - "description": "*\nMaximum off-chain fee in msat that may be paid for payment to the server.\nThis limit is applied during path finding. Typically this value is taken\nfrom the response of the GetQuote call." + "description": "*\nMaximum off-chain fee in sat that may be paid for the prepay to the server.\nThis limit is applied during path finding. Typically this value is taken\nfrom the response of the GetQuote call." }, "max_swap_fee": { "type": "string",