From 62888894d2597a7b667e3151a7f4fe350375f260 Mon Sep 17 00:00:00 2001 From: Oliver Gugger Date: Tue, 27 Jul 2021 12:59:55 +0200 Subject: [PATCH] walletrpc: add missing REST body annotation The missing body annotation caused the library to ignore any parameters sent to this RPC endpoint when using the REST proxy. --- lnrpc/walletrpc/walletkit.pb.gw.go | 17 ++++++++------- lnrpc/walletrpc/walletkit.swagger.json | 29 ++++++++++++++++++++++++++ lnrpc/walletrpc/walletkit.yaml | 1 + 3 files changed, 39 insertions(+), 8 deletions(-) diff --git a/lnrpc/walletrpc/walletkit.pb.gw.go b/lnrpc/walletrpc/walletkit.pb.gw.go index ec5c4b754..f3f06ef80 100644 --- a/lnrpc/walletrpc/walletkit.pb.gw.go +++ b/lnrpc/walletrpc/walletkit.pb.gw.go @@ -32,18 +32,15 @@ var _ = runtime.String var _ = utilities.NewDoubleArray var _ = descriptor.ForMessage -var ( - filter_WalletKit_ListUnspent_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} -) - func request_WalletKit_ListUnspent_0(ctx context.Context, marshaler runtime.Marshaler, client WalletKitClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var protoReq ListUnspentRequest var metadata runtime.ServerMetadata - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + newReader, berr := utilities.IOReaderFactory(req.Body) + if berr != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr) } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_WalletKit_ListUnspent_0); err != nil { + if err := marshaler.NewDecoder(newReader()).Decode(&protoReq); err != nil && err != io.EOF { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } @@ -56,7 +53,11 @@ func local_request_WalletKit_ListUnspent_0(ctx context.Context, marshaler runtim var protoReq ListUnspentRequest var metadata runtime.ServerMetadata - if err := runtime.PopulateQueryParameters(&protoReq, req.URL.Query(), filter_WalletKit_ListUnspent_0); err != nil { + 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) } diff --git a/lnrpc/walletrpc/walletkit.swagger.json b/lnrpc/walletrpc/walletkit.swagger.json index f87fd4b95..31394d3c1 100644 --- a/lnrpc/walletrpc/walletkit.swagger.json +++ b/lnrpc/walletrpc/walletkit.swagger.json @@ -533,6 +533,16 @@ } } }, + "parameters": [ + { + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/walletrpcListUnspentRequest" + } + } + ], "tags": [ "WalletKit" ] @@ -1212,6 +1222,25 @@ } } }, + "walletrpcListUnspentRequest": { + "type": "object", + "properties": { + "min_confs": { + "type": "integer", + "format": "int32", + "description": "The minimum number of confirmations to be included." + }, + "max_confs": { + "type": "integer", + "format": "int32", + "description": "The maximum number of confirmations to be included." + }, + "account": { + "type": "string", + "description": "An optional filter to only include outputs belonging to an account." + } + } + }, "walletrpcListUnspentResponse": { "type": "object", "properties": { diff --git a/lnrpc/walletrpc/walletkit.yaml b/lnrpc/walletrpc/walletkit.yaml index 291b8508d..7ad00c0f4 100644 --- a/lnrpc/walletrpc/walletkit.yaml +++ b/lnrpc/walletrpc/walletkit.yaml @@ -5,6 +5,7 @@ http: rules: - selector: walletrpc.WalletKit.ListUnspent post: "/v2/wallet/utxos" + body: "*" - selector: walletrpc.WalletKit.LeaseOutput post: "/v2/wallet/utxos/lease" body: "*"