From ff79a164ef00a6e02b13b615cec97875189ed65b Mon Sep 17 00:00:00 2001 From: George Tsagkarelis Date: Wed, 27 Nov 2024 12:58:14 +0100 Subject: [PATCH] tchrpc: change FundChannel endpoint to POST --- taprpc/tapchannelrpc/tapchannel.pb.gw.go | 22 +++--- taprpc/tapchannelrpc/tapchannel.swagger.json | 76 ++++++++++---------- taprpc/tapchannelrpc/tapchannel.yaml | 3 +- 3 files changed, 49 insertions(+), 52 deletions(-) diff --git a/taprpc/tapchannelrpc/tapchannel.pb.gw.go b/taprpc/tapchannelrpc/tapchannel.pb.gw.go index ea154ac21..525410927 100644 --- a/taprpc/tapchannelrpc/tapchannel.pb.gw.go +++ b/taprpc/tapchannelrpc/tapchannel.pb.gw.go @@ -31,18 +31,15 @@ var _ = runtime.String var _ = utilities.NewDoubleArray var _ = metadata.Join -var ( - filter_TaprootAssetChannels_FundChannel_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} -) - func request_TaprootAssetChannels_FundChannel_0(ctx context.Context, marshaler runtime.Marshaler, client TaprootAssetChannelsClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var protoReq FundChannelRequest 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_TaprootAssetChannels_FundChannel_0); err != nil { + if err := marshaler.NewDecoder(newReader()).Decode(&protoReq); err != nil && err != io.EOF { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } @@ -55,10 +52,11 @@ func local_request_TaprootAssetChannels_FundChannel_0(ctx context.Context, marsh var protoReq FundChannelRequest 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_TaprootAssetChannels_FundChannel_0); err != nil { + if err := marshaler.NewDecoder(newReader()).Decode(&protoReq); err != nil && err != io.EOF { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } @@ -166,7 +164,7 @@ func local_request_TaprootAssetChannels_AddInvoice_0(ctx context.Context, marsha // Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterTaprootAssetChannelsHandlerFromEndpoint instead. func RegisterTaprootAssetChannelsHandlerServer(ctx context.Context, mux *runtime.ServeMux, server TaprootAssetChannelsServer) error { - mux.Handle("GET", pattern_TaprootAssetChannels_FundChannel_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + mux.Handle("POST", pattern_TaprootAssetChannels_FundChannel_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() var stream runtime.ServerTransportStream @@ -289,7 +287,7 @@ func RegisterTaprootAssetChannelsHandler(ctx context.Context, mux *runtime.Serve // "TaprootAssetChannelsClient" to call the correct interceptors. func RegisterTaprootAssetChannelsHandlerClient(ctx context.Context, mux *runtime.ServeMux, client TaprootAssetChannelsClient) error { - mux.Handle("GET", pattern_TaprootAssetChannels_FundChannel_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + mux.Handle("POST", pattern_TaprootAssetChannels_FundChannel_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) diff --git a/taprpc/tapchannelrpc/tapchannel.swagger.json b/taprpc/tapchannelrpc/tapchannel.swagger.json index afff9033e..c7801012c 100644 --- a/taprpc/tapchannelrpc/tapchannel.swagger.json +++ b/taprpc/tapchannelrpc/tapchannel.swagger.json @@ -50,7 +50,7 @@ } }, "/v1/taproot-assets/channels/fund": { - "get": { + "post": { "summary": "FundChannel initiates the channel funding negotiation with a peer for the\ncreation of a channel that contains a specified amount of a given asset.", "operationId": "TaprootAssetChannels_FundChannel", "responses": { @@ -69,44 +69,12 @@ }, "parameters": [ { - "name": "asset_amount", - "description": "The asset amount to fund the channel with. The BTC amount is fixed and\ncannot be customized (for now).", - "in": "query", - "required": false, - "type": "string", - "format": "uint64" - }, - { - "name": "asset_id", - "description": "The asset ID to use for the channel funding.", - "in": "query", - "required": false, - "type": "string", - "format": "byte" - }, - { - "name": "peer_pubkey", - "description": "The public key of the peer to open the channel with. Must already be\nconnected to this peer.", - "in": "query", - "required": false, - "type": "string", - "format": "byte" - }, - { - "name": "fee_rate_sat_per_vbyte", - "description": "The channel funding fee rate in sat/vByte.", - "in": "query", - "required": false, - "type": "integer", - "format": "int64" - }, - { - "name": "push_sat", - "description": "The number of satoshis to give the remote side as part of the initial\ncommitment state. This is equivalent to first opening a channel and then\nsending the remote party funds, but all done in one step. Therefore, this\nis equivalent to a donation to the remote party, unless they reimburse\nthe funds in another way (outside the protocol).", - "in": "query", - "required": false, - "type": "string", - "format": "int64" + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/tapchannelrpcFundChannelRequest" + } } ], "tags": [ @@ -1395,6 +1363,36 @@ } } }, + "tapchannelrpcFundChannelRequest": { + "type": "object", + "properties": { + "asset_amount": { + "type": "string", + "format": "uint64", + "description": "The asset amount to fund the channel with. The BTC amount is fixed and\ncannot be customized (for now)." + }, + "asset_id": { + "type": "string", + "format": "byte", + "description": "The asset ID to use for the channel funding." + }, + "peer_pubkey": { + "type": "string", + "format": "byte", + "description": "The public key of the peer to open the channel with. Must already be\nconnected to this peer." + }, + "fee_rate_sat_per_vbyte": { + "type": "integer", + "format": "int64", + "description": "The channel funding fee rate in sat/vByte." + }, + "push_sat": { + "type": "string", + "format": "int64", + "description": "The number of satoshis to give the remote side as part of the initial\ncommitment state. This is equivalent to first opening a channel and then\nsending the remote party funds, but all done in one step. Therefore, this\nis equivalent to a donation to the remote party, unless they reimburse\nthe funds in another way (outside the protocol)." + } + } + }, "tapchannelrpcFundChannelResponse": { "type": "object", "properties": { diff --git a/taprpc/tapchannelrpc/tapchannel.yaml b/taprpc/tapchannelrpc/tapchannel.yaml index a396b5078..c4a87ada7 100644 --- a/taprpc/tapchannelrpc/tapchannel.yaml +++ b/taprpc/tapchannelrpc/tapchannel.yaml @@ -4,7 +4,8 @@ config_version: 3 http: rules: - selector: tapchannelrpc.TaprootAssetChannels.FundChannel - get: "/v1/taproot-assets/channels/fund" + post: "/v1/taproot-assets/channels/fund" + body: "*" - selector: tapchannelrpc.TaprootAssetChannels.EncodeCustomRecords post: "/v1/taproot-assets/channels/encode-custom-data" body: "*"