mirror of
https://github.com/aljazceru/ark.git
synced 2025-12-17 12:14:21 +01:00
Move redeem transactions creation client-side (#388)
* move OOR transaction creation client-side * robust redeem tx checks * optimize GetVtxos db call * rename CompleteAsyncPayment --> SubmitRedeemTx * fix permissions.go
This commit is contained in:
@@ -101,14 +101,14 @@
|
||||
]
|
||||
}
|
||||
},
|
||||
"/v1/payment": {
|
||||
"/v1/redeem-tx": {
|
||||
"post": {
|
||||
"operationId": "ArkService_CreatePayment",
|
||||
"operationId": "ArkService_SubmitRedeemTx",
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "A successful response.",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/v1CreatePaymentResponse"
|
||||
"$ref": "#/definitions/v1SubmitRedeemTxResponse"
|
||||
}
|
||||
},
|
||||
"default": {
|
||||
@@ -124,39 +124,7 @@
|
||||
"in": "body",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"$ref": "#/definitions/v1CreatePaymentRequest"
|
||||
}
|
||||
}
|
||||
],
|
||||
"tags": [
|
||||
"ArkService"
|
||||
]
|
||||
}
|
||||
},
|
||||
"/v1/payment/complete": {
|
||||
"post": {
|
||||
"operationId": "ArkService_CompletePayment",
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "A successful response.",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/v1CompletePaymentResponse"
|
||||
}
|
||||
},
|
||||
"default": {
|
||||
"description": "An unexpected error response.",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/rpcStatus"
|
||||
}
|
||||
}
|
||||
},
|
||||
"parameters": [
|
||||
{
|
||||
"name": "body",
|
||||
"in": "body",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"$ref": "#/definitions/v1CompletePaymentRequest"
|
||||
"$ref": "#/definitions/v1SubmitRedeemTxRequest"
|
||||
}
|
||||
}
|
||||
],
|
||||
@@ -570,56 +538,6 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"v1AsyncPaymentInput": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"input": {
|
||||
"$ref": "#/definitions/v1Input"
|
||||
},
|
||||
"forfeitLeafHash": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"v1CompletePaymentRequest": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"signedRedeemTx": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"v1CompletePaymentResponse": {
|
||||
"type": "object"
|
||||
},
|
||||
"v1CreatePaymentRequest": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"inputs": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "object",
|
||||
"$ref": "#/definitions/v1AsyncPaymentInput"
|
||||
}
|
||||
},
|
||||
"outputs": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "object",
|
||||
"$ref": "#/definitions/v1Output"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"v1CreatePaymentResponse": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"signedRedeemTx": {
|
||||
"type": "string",
|
||||
"title": "signed only by the ASP"
|
||||
}
|
||||
}
|
||||
},
|
||||
"v1DeleteNostrRecipientRequest": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
@@ -1112,6 +1030,22 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"v1SubmitRedeemTxRequest": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"redeemTx": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"v1SubmitRedeemTxResponse": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"signedRedeemTx": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"v1SubmitSignedForfeitTxsRequest": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
|
||||
@@ -62,17 +62,9 @@ service ArkService {
|
||||
};
|
||||
};
|
||||
|
||||
/* Async Payment APIs */
|
||||
|
||||
rpc CreatePayment(CreatePaymentRequest) returns (CreatePaymentResponse) {
|
||||
rpc SubmitRedeemTx(SubmitRedeemTxRequest) returns (SubmitRedeemTxResponse) {
|
||||
option (google.api.http) = {
|
||||
post: "/v1/payment"
|
||||
body: "*"
|
||||
};
|
||||
}
|
||||
rpc CompletePayment(CompletePaymentRequest) returns (CompletePaymentResponse) {
|
||||
option (google.api.http) = {
|
||||
post: "/v1/payment/complete"
|
||||
post: "/v1/redeem-tx"
|
||||
body: "*"
|
||||
};
|
||||
}
|
||||
@@ -200,25 +192,12 @@ message PingRequest {
|
||||
}
|
||||
message PingResponse {}
|
||||
|
||||
/* Async Payment API messages */
|
||||
|
||||
message AsyncPaymentInput {
|
||||
Input input = 1;
|
||||
string forfeit_leaf_hash = 2;
|
||||
message SubmitRedeemTxRequest {
|
||||
string redeem_tx = 1;
|
||||
}
|
||||
|
||||
message CreatePaymentRequest {
|
||||
repeated AsyncPaymentInput inputs = 1;
|
||||
repeated Output outputs = 2;
|
||||
}
|
||||
message CreatePaymentResponse {
|
||||
string signed_redeem_tx = 1; // signed only by the ASP
|
||||
}
|
||||
|
||||
message CompletePaymentRequest {
|
||||
message SubmitRedeemTxResponse {
|
||||
string signed_redeem_tx = 1;
|
||||
}
|
||||
message CompletePaymentResponse {}
|
||||
|
||||
/* Explorer-like API messages */
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -274,54 +274,28 @@ func local_request_ArkService_Ping_0(ctx context.Context, marshaler runtime.Mars
|
||||
|
||||
}
|
||||
|
||||
func request_ArkService_CreatePayment_0(ctx context.Context, marshaler runtime.Marshaler, client ArkServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
||||
var protoReq CreatePaymentRequest
|
||||
func request_ArkService_SubmitRedeemTx_0(ctx context.Context, marshaler runtime.Marshaler, client ArkServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
||||
var protoReq SubmitRedeemTxRequest
|
||||
var metadata runtime.ServerMetadata
|
||||
|
||||
if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && err != io.EOF {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
||||
}
|
||||
|
||||
msg, err := client.CreatePayment(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
|
||||
msg, err := client.SubmitRedeemTx(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
|
||||
return msg, metadata, err
|
||||
|
||||
}
|
||||
|
||||
func local_request_ArkService_CreatePayment_0(ctx context.Context, marshaler runtime.Marshaler, server ArkServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
||||
var protoReq CreatePaymentRequest
|
||||
func local_request_ArkService_SubmitRedeemTx_0(ctx context.Context, marshaler runtime.Marshaler, server ArkServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
||||
var protoReq SubmitRedeemTxRequest
|
||||
var metadata runtime.ServerMetadata
|
||||
|
||||
if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && err != io.EOF {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
||||
}
|
||||
|
||||
msg, err := server.CreatePayment(ctx, &protoReq)
|
||||
return msg, metadata, err
|
||||
|
||||
}
|
||||
|
||||
func request_ArkService_CompletePayment_0(ctx context.Context, marshaler runtime.Marshaler, client ArkServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
||||
var protoReq CompletePaymentRequest
|
||||
var metadata runtime.ServerMetadata
|
||||
|
||||
if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && err != io.EOF {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
||||
}
|
||||
|
||||
msg, err := client.CompletePayment(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
|
||||
return msg, metadata, err
|
||||
|
||||
}
|
||||
|
||||
func local_request_ArkService_CompletePayment_0(ctx context.Context, marshaler runtime.Marshaler, server ArkServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
||||
var protoReq CompletePaymentRequest
|
||||
var metadata runtime.ServerMetadata
|
||||
|
||||
if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && err != io.EOF {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
||||
}
|
||||
|
||||
msg, err := server.CompletePayment(ctx, &protoReq)
|
||||
msg, err := server.SubmitRedeemTx(ctx, &protoReq)
|
||||
return msg, metadata, err
|
||||
|
||||
}
|
||||
@@ -765,7 +739,7 @@ func RegisterArkServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux,
|
||||
|
||||
})
|
||||
|
||||
mux.Handle("POST", pattern_ArkService_CreatePayment_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
||||
mux.Handle("POST", pattern_ArkService_SubmitRedeemTx_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
||||
ctx, cancel := context.WithCancel(req.Context())
|
||||
defer cancel()
|
||||
var stream runtime.ServerTransportStream
|
||||
@@ -773,12 +747,12 @@ func RegisterArkServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux,
|
||||
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
||||
var err error
|
||||
var annotatedContext context.Context
|
||||
annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/ark.v1.ArkService/CreatePayment", runtime.WithHTTPPathPattern("/v1/payment"))
|
||||
annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/ark.v1.ArkService/SubmitRedeemTx", runtime.WithHTTPPathPattern("/v1/redeem-tx"))
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
resp, md, err := local_request_ArkService_CreatePayment_0(annotatedContext, inboundMarshaler, server, req, pathParams)
|
||||
resp, md, err := local_request_ArkService_SubmitRedeemTx_0(annotatedContext, inboundMarshaler, server, req, pathParams)
|
||||
md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
|
||||
annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
|
||||
if err != nil {
|
||||
@@ -786,32 +760,7 @@ func RegisterArkServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux,
|
||||
return
|
||||
}
|
||||
|
||||
forward_ArkService_CreatePayment_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
||||
|
||||
})
|
||||
|
||||
mux.Handle("POST", pattern_ArkService_CompletePayment_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
||||
ctx, cancel := context.WithCancel(req.Context())
|
||||
defer cancel()
|
||||
var stream runtime.ServerTransportStream
|
||||
ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
|
||||
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
||||
var err error
|
||||
var annotatedContext context.Context
|
||||
annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/ark.v1.ArkService/CompletePayment", runtime.WithHTTPPathPattern("/v1/payment/complete"))
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
resp, md, err := local_request_ArkService_CompletePayment_0(annotatedContext, inboundMarshaler, server, req, pathParams)
|
||||
md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
|
||||
annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
|
||||
if err != nil {
|
||||
runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
|
||||
forward_ArkService_CompletePayment_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
||||
forward_ArkService_SubmitRedeemTx_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
||||
|
||||
})
|
||||
|
||||
@@ -1186,47 +1135,25 @@ func RegisterArkServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux,
|
||||
|
||||
})
|
||||
|
||||
mux.Handle("POST", pattern_ArkService_CreatePayment_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
||||
mux.Handle("POST", pattern_ArkService_SubmitRedeemTx_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)
|
||||
var err error
|
||||
var annotatedContext context.Context
|
||||
annotatedContext, err = runtime.AnnotateContext(ctx, mux, req, "/ark.v1.ArkService/CreatePayment", runtime.WithHTTPPathPattern("/v1/payment"))
|
||||
annotatedContext, err = runtime.AnnotateContext(ctx, mux, req, "/ark.v1.ArkService/SubmitRedeemTx", runtime.WithHTTPPathPattern("/v1/redeem-tx"))
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
resp, md, err := request_ArkService_CreatePayment_0(annotatedContext, inboundMarshaler, client, req, pathParams)
|
||||
resp, md, err := request_ArkService_SubmitRedeemTx_0(annotatedContext, inboundMarshaler, client, req, pathParams)
|
||||
annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
|
||||
if err != nil {
|
||||
runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
|
||||
forward_ArkService_CreatePayment_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
||||
|
||||
})
|
||||
|
||||
mux.Handle("POST", pattern_ArkService_CompletePayment_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)
|
||||
var err error
|
||||
var annotatedContext context.Context
|
||||
annotatedContext, err = runtime.AnnotateContext(ctx, mux, req, "/ark.v1.ArkService/CompletePayment", runtime.WithHTTPPathPattern("/v1/payment/complete"))
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
resp, md, err := request_ArkService_CompletePayment_0(annotatedContext, inboundMarshaler, client, req, pathParams)
|
||||
annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
|
||||
if err != nil {
|
||||
runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
|
||||
forward_ArkService_CompletePayment_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
||||
forward_ArkService_SubmitRedeemTx_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
||||
|
||||
})
|
||||
|
||||
@@ -1384,9 +1311,7 @@ var (
|
||||
|
||||
pattern_ArkService_Ping_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3}, []string{"v1", "round", "ping", "payment_id"}, ""))
|
||||
|
||||
pattern_ArkService_CreatePayment_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"v1", "payment"}, ""))
|
||||
|
||||
pattern_ArkService_CompletePayment_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"v1", "payment", "complete"}, ""))
|
||||
pattern_ArkService_SubmitRedeemTx_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"v1", "redeem-tx"}, ""))
|
||||
|
||||
pattern_ArkService_GetRound_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 1, 0, 4, 1, 5, 2}, []string{"v1", "round", "txid"}, ""))
|
||||
|
||||
@@ -1420,9 +1345,7 @@ var (
|
||||
|
||||
forward_ArkService_Ping_0 = runtime.ForwardResponseMessage
|
||||
|
||||
forward_ArkService_CreatePayment_0 = runtime.ForwardResponseMessage
|
||||
|
||||
forward_ArkService_CompletePayment_0 = runtime.ForwardResponseMessage
|
||||
forward_ArkService_SubmitRedeemTx_0 = runtime.ForwardResponseMessage
|
||||
|
||||
forward_ArkService_GetRound_0 = runtime.ForwardResponseMessage
|
||||
|
||||
|
||||
@@ -27,8 +27,7 @@ type ArkServiceClient interface {
|
||||
SubmitSignedForfeitTxs(ctx context.Context, in *SubmitSignedForfeitTxsRequest, opts ...grpc.CallOption) (*SubmitSignedForfeitTxsResponse, error)
|
||||
GetEventStream(ctx context.Context, in *GetEventStreamRequest, opts ...grpc.CallOption) (ArkService_GetEventStreamClient, error)
|
||||
Ping(ctx context.Context, in *PingRequest, opts ...grpc.CallOption) (*PingResponse, error)
|
||||
CreatePayment(ctx context.Context, in *CreatePaymentRequest, opts ...grpc.CallOption) (*CreatePaymentResponse, error)
|
||||
CompletePayment(ctx context.Context, in *CompletePaymentRequest, opts ...grpc.CallOption) (*CompletePaymentResponse, error)
|
||||
SubmitRedeemTx(ctx context.Context, in *SubmitRedeemTxRequest, opts ...grpc.CallOption) (*SubmitRedeemTxResponse, error)
|
||||
GetRound(ctx context.Context, in *GetRoundRequest, opts ...grpc.CallOption) (*GetRoundResponse, error)
|
||||
GetRoundById(ctx context.Context, in *GetRoundByIdRequest, opts ...grpc.CallOption) (*GetRoundByIdResponse, error)
|
||||
ListVtxos(ctx context.Context, in *ListVtxosRequest, opts ...grpc.CallOption) (*ListVtxosResponse, error)
|
||||
@@ -149,18 +148,9 @@ func (c *arkServiceClient) Ping(ctx context.Context, in *PingRequest, opts ...gr
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *arkServiceClient) CreatePayment(ctx context.Context, in *CreatePaymentRequest, opts ...grpc.CallOption) (*CreatePaymentResponse, error) {
|
||||
out := new(CreatePaymentResponse)
|
||||
err := c.cc.Invoke(ctx, "/ark.v1.ArkService/CreatePayment", in, out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *arkServiceClient) CompletePayment(ctx context.Context, in *CompletePaymentRequest, opts ...grpc.CallOption) (*CompletePaymentResponse, error) {
|
||||
out := new(CompletePaymentResponse)
|
||||
err := c.cc.Invoke(ctx, "/ark.v1.ArkService/CompletePayment", in, out, opts...)
|
||||
func (c *arkServiceClient) SubmitRedeemTx(ctx context.Context, in *SubmitRedeemTxRequest, opts ...grpc.CallOption) (*SubmitRedeemTxResponse, error) {
|
||||
out := new(SubmitRedeemTxResponse)
|
||||
err := c.cc.Invoke(ctx, "/ark.v1.ArkService/SubmitRedeemTx", in, out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -257,8 +247,7 @@ type ArkServiceServer interface {
|
||||
SubmitSignedForfeitTxs(context.Context, *SubmitSignedForfeitTxsRequest) (*SubmitSignedForfeitTxsResponse, error)
|
||||
GetEventStream(*GetEventStreamRequest, ArkService_GetEventStreamServer) error
|
||||
Ping(context.Context, *PingRequest) (*PingResponse, error)
|
||||
CreatePayment(context.Context, *CreatePaymentRequest) (*CreatePaymentResponse, error)
|
||||
CompletePayment(context.Context, *CompletePaymentRequest) (*CompletePaymentResponse, error)
|
||||
SubmitRedeemTx(context.Context, *SubmitRedeemTxRequest) (*SubmitRedeemTxResponse, error)
|
||||
GetRound(context.Context, *GetRoundRequest) (*GetRoundResponse, error)
|
||||
GetRoundById(context.Context, *GetRoundByIdRequest) (*GetRoundByIdResponse, error)
|
||||
ListVtxos(context.Context, *ListVtxosRequest) (*ListVtxosResponse, error)
|
||||
@@ -298,11 +287,8 @@ func (UnimplementedArkServiceServer) GetEventStream(*GetEventStreamRequest, ArkS
|
||||
func (UnimplementedArkServiceServer) Ping(context.Context, *PingRequest) (*PingResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method Ping not implemented")
|
||||
}
|
||||
func (UnimplementedArkServiceServer) CreatePayment(context.Context, *CreatePaymentRequest) (*CreatePaymentResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method CreatePayment not implemented")
|
||||
}
|
||||
func (UnimplementedArkServiceServer) CompletePayment(context.Context, *CompletePaymentRequest) (*CompletePaymentResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method CompletePayment not implemented")
|
||||
func (UnimplementedArkServiceServer) SubmitRedeemTx(context.Context, *SubmitRedeemTxRequest) (*SubmitRedeemTxResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method SubmitRedeemTx not implemented")
|
||||
}
|
||||
func (UnimplementedArkServiceServer) GetRound(context.Context, *GetRoundRequest) (*GetRoundResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method GetRound not implemented")
|
||||
@@ -499,38 +485,20 @@ func _ArkService_Ping_Handler(srv interface{}, ctx context.Context, dec func(int
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _ArkService_CreatePayment_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(CreatePaymentRequest)
|
||||
func _ArkService_SubmitRedeemTx_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(SubmitRedeemTxRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(ArkServiceServer).CreatePayment(ctx, in)
|
||||
return srv.(ArkServiceServer).SubmitRedeemTx(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: "/ark.v1.ArkService/CreatePayment",
|
||||
FullMethod: "/ark.v1.ArkService/SubmitRedeemTx",
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(ArkServiceServer).CreatePayment(ctx, req.(*CreatePaymentRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _ArkService_CompletePayment_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(CompletePaymentRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(ArkServiceServer).CompletePayment(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: "/ark.v1.ArkService/CompletePayment",
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(ArkServiceServer).CompletePayment(ctx, req.(*CompletePaymentRequest))
|
||||
return srv.(ArkServiceServer).SubmitRedeemTx(ctx, req.(*SubmitRedeemTxRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
@@ -686,12 +654,8 @@ var ArkService_ServiceDesc = grpc.ServiceDesc{
|
||||
Handler: _ArkService_Ping_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "CreatePayment",
|
||||
Handler: _ArkService_CreatePayment_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "CompletePayment",
|
||||
Handler: _ArkService_CompletePayment_Handler,
|
||||
MethodName: "SubmitRedeemTx",
|
||||
Handler: _ArkService_SubmitRedeemTx_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "GetRound",
|
||||
|
||||
80
common/bitcointree/pending.go
Normal file
80
common/bitcointree/pending.go
Normal file
@@ -0,0 +1,80 @@
|
||||
package bitcointree
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/ark-network/ark/common"
|
||||
"github.com/btcsuite/btcd/btcutil/psbt"
|
||||
"github.com/btcsuite/btcd/txscript"
|
||||
"github.com/btcsuite/btcd/wire"
|
||||
)
|
||||
|
||||
func BuildRedeemTx(
|
||||
vtxos []common.VtxoInput,
|
||||
outputs []*wire.TxOut,
|
||||
feeAmount int64,
|
||||
) (string, error) {
|
||||
if len(vtxos) <= 0 {
|
||||
return "", fmt.Errorf("missing vtxos")
|
||||
}
|
||||
|
||||
ins := make([]*wire.OutPoint, 0, len(vtxos))
|
||||
witnessUtxos := make(map[int]*wire.TxOut)
|
||||
tapscripts := make(map[int]*psbt.TaprootTapLeafScript)
|
||||
|
||||
for index, vtxo := range vtxos {
|
||||
rootHash := vtxo.Tapscript.ControlBlock.RootHash(vtxo.Tapscript.RevealedScript)
|
||||
taprootKey := txscript.ComputeTaprootOutputKey(UnspendableKey(), rootHash)
|
||||
|
||||
vtxoOutputScript, err := common.P2TRScript(taprootKey)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
witnessUtxos[index] = &wire.TxOut{
|
||||
Value: vtxo.Amount,
|
||||
PkScript: vtxoOutputScript,
|
||||
}
|
||||
|
||||
ctrlBlockBytes, err := vtxo.Tapscript.ControlBlock.ToBytes()
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
tapscripts[index] = &psbt.TaprootTapLeafScript{
|
||||
ControlBlock: ctrlBlockBytes,
|
||||
Script: vtxo.Tapscript.RevealedScript,
|
||||
LeafVersion: txscript.BaseLeafVersion,
|
||||
}
|
||||
|
||||
ins = append(ins, vtxo.Outpoint)
|
||||
}
|
||||
|
||||
if feeAmount >= outputs[len(outputs)-1].Value {
|
||||
return "", fmt.Errorf("redeem tx fee is higher than the amount of the change receiver")
|
||||
}
|
||||
|
||||
sequences := make([]uint32, len(ins))
|
||||
for i := range sequences {
|
||||
sequences[i] = wire.MaxTxInSequenceNum
|
||||
}
|
||||
|
||||
redeemPtx, err := psbt.New(
|
||||
ins, outputs, 2, 0, sequences,
|
||||
)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
for i := range redeemPtx.Inputs {
|
||||
redeemPtx.Inputs[i].WitnessUtxo = witnessUtxos[i]
|
||||
redeemPtx.Inputs[i].TaprootLeafScript = []*psbt.TaprootTapLeafScript{tapscripts[i]}
|
||||
}
|
||||
|
||||
redeemTx, err := redeemPtx.B64Encode()
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
return redeemTx, nil
|
||||
}
|
||||
@@ -26,7 +26,7 @@ var ConnectorTxSize = (&input.TxWeightEstimator{}).
|
||||
AddP2TROutput().
|
||||
VSize()
|
||||
|
||||
func ComputeForfeitMinRelayFee(
|
||||
func ComputeForfeitTxFee(
|
||||
feeRate chainfee.SatPerKVByte,
|
||||
tapscript *waddrmgr.Tapscript,
|
||||
witnessSize int,
|
||||
@@ -57,3 +57,32 @@ func ComputeForfeitMinRelayFee(
|
||||
|
||||
return uint64(feeRate.FeeForVSize(lntypes.VByte(txWeightEstimator.VSize())).ToUnit(btcutil.AmountSatoshi)), nil
|
||||
}
|
||||
|
||||
func ComputeRedeemTxFee(
|
||||
feeRate chainfee.SatPerKVByte,
|
||||
vtxos []VtxoInput,
|
||||
numOutputs int,
|
||||
) (int64, error) {
|
||||
if len(vtxos) <= 0 {
|
||||
return 0, fmt.Errorf("missing vtxos")
|
||||
}
|
||||
|
||||
redeemTxWeightEstimator := &input.TxWeightEstimator{}
|
||||
|
||||
// Estimate inputs
|
||||
for _, vtxo := range vtxos {
|
||||
if vtxo.Tapscript == nil {
|
||||
txid := vtxo.Outpoint.Hash.String()
|
||||
return 0, fmt.Errorf("missing tapscript for vtxo %s", txid)
|
||||
}
|
||||
|
||||
redeemTxWeightEstimator.AddTapscriptInput(lntypes.WeightUnit(vtxo.WitnessSize), vtxo.Tapscript)
|
||||
}
|
||||
|
||||
// Estimate outputs
|
||||
for i := 0; i < numOutputs; i++ {
|
||||
redeemTxWeightEstimator.AddP2TROutput()
|
||||
}
|
||||
|
||||
return int64(feeRate.FeeForVSize(lntypes.VByte(redeemTxWeightEstimator.VSize())).ToUnit(btcutil.AmountSatoshi)), nil
|
||||
}
|
||||
|
||||
13
common/types.go
Normal file
13
common/types.go
Normal file
@@ -0,0 +1,13 @@
|
||||
package common
|
||||
|
||||
import (
|
||||
"github.com/btcsuite/btcd/wire"
|
||||
"github.com/btcsuite/btcwallet/waddrmgr"
|
||||
)
|
||||
|
||||
type VtxoInput struct {
|
||||
Outpoint *wire.OutPoint
|
||||
Amount int64
|
||||
Tapscript *waddrmgr.Tapscript
|
||||
WitnessSize int
|
||||
}
|
||||
@@ -1,9 +1,14 @@
|
||||
.PHONY: genrest test vet lint prepare-wasm-test
|
||||
|
||||
REST_DIR = $(PWD)/client/rest/service
|
||||
|
||||
## genrest: compiles rest client from stub with https://github.com/go-swagger/go-swagger
|
||||
genrest:
|
||||
@echo "Cleaning existing files..."
|
||||
@rm -rf $(REST_DIR)
|
||||
@echo "Generating rest client from stub..."
|
||||
@swagger generate client -f ../../api-spec/openapi/swagger/ark/v1/service.swagger.json -t ./client/rest/service --client-package=arkservice
|
||||
@mkdir -p $(REST_DIR)
|
||||
@swagger generate client -f ../../api-spec/openapi/swagger/ark/v1/service.swagger.json -t $(REST_DIR) --client-package=arkservice
|
||||
|
||||
## test: runs unit tests
|
||||
test:
|
||||
|
||||
@@ -9,7 +9,6 @@ import (
|
||||
"github.com/ark-network/ark/common/bitcointree"
|
||||
"github.com/ark-network/ark/common/tree"
|
||||
"github.com/btcsuite/btcd/btcec/v2/schnorr"
|
||||
"github.com/btcsuite/btcd/chaincfg/chainhash"
|
||||
"github.com/decred/dcrd/dcrec/secp256k1/v4"
|
||||
"github.com/lightningnetwork/lnd/lnwallet/chainfee"
|
||||
)
|
||||
@@ -47,12 +46,9 @@ type ASPClient interface {
|
||||
ctx context.Context, paymentID string,
|
||||
) (<-chan RoundEventChannel, func(), error)
|
||||
Ping(ctx context.Context, paymentID string) error
|
||||
CreatePayment(
|
||||
ctx context.Context, inputs []AsyncPaymentInput, outputs []Output,
|
||||
) (string, error)
|
||||
CompletePayment(
|
||||
SubmitRedeemTx(
|
||||
ctx context.Context, signedRedeemTx string,
|
||||
) error
|
||||
) (string, error)
|
||||
ListVtxos(ctx context.Context, addr string) ([]Vtxo, []Vtxo, error)
|
||||
GetRound(ctx context.Context, txID string) (*Round, error)
|
||||
GetRoundByID(ctx context.Context, roundID string) (*Round, error)
|
||||
@@ -92,11 +88,6 @@ type Input struct {
|
||||
Tapscripts []string
|
||||
}
|
||||
|
||||
type AsyncPaymentInput struct {
|
||||
Input
|
||||
ForfeitLeafHash chainhash.Hash
|
||||
}
|
||||
|
||||
type Vtxo struct {
|
||||
Outpoint
|
||||
Pubkey string
|
||||
|
||||
@@ -245,28 +245,19 @@ func (a *grpcClient) Ping(
|
||||
return err
|
||||
}
|
||||
|
||||
func (a *grpcClient) CreatePayment(
|
||||
ctx context.Context, inputs []client.AsyncPaymentInput, outputs []client.Output,
|
||||
func (a *grpcClient) SubmitRedeemTx(
|
||||
ctx context.Context, redeemTx string,
|
||||
) (string, error) {
|
||||
req := &arkv1.CreatePaymentRequest{
|
||||
Inputs: asyncIns(inputs).toProto(),
|
||||
Outputs: outs(outputs).toProto(),
|
||||
req := &arkv1.SubmitRedeemTxRequest{
|
||||
RedeemTx: redeemTx,
|
||||
}
|
||||
resp, err := a.svc.CreatePayment(ctx, req)
|
||||
|
||||
resp, err := a.svc.SubmitRedeemTx(ctx, req)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
return resp.SignedRedeemTx, nil
|
||||
}
|
||||
|
||||
func (a *grpcClient) CompletePayment(
|
||||
ctx context.Context, redeemTx string,
|
||||
) error {
|
||||
req := &arkv1.CompletePaymentRequest{
|
||||
SignedRedeemTx: redeemTx,
|
||||
}
|
||||
_, err := a.svc.CompletePayment(ctx, req)
|
||||
return err
|
||||
return resp.GetSignedRedeemTx(), nil
|
||||
}
|
||||
|
||||
func (a *grpcClient) GetRound(
|
||||
|
||||
@@ -152,23 +152,6 @@ func toProtoInput(i client.Input) *arkv1.Input {
|
||||
}
|
||||
}
|
||||
|
||||
func toAsyncProtoInput(i client.AsyncPaymentInput) *arkv1.AsyncPaymentInput {
|
||||
return &arkv1.AsyncPaymentInput{
|
||||
Input: toProtoInput(i.Input),
|
||||
ForfeitLeafHash: i.ForfeitLeafHash.String(),
|
||||
}
|
||||
}
|
||||
|
||||
type asyncIns []client.AsyncPaymentInput
|
||||
|
||||
func (i asyncIns) toProto() []*arkv1.AsyncPaymentInput {
|
||||
list := make([]*arkv1.AsyncPaymentInput, 0, len(i))
|
||||
for _, ii := range i {
|
||||
list = append(list, toAsyncProtoInput(ii))
|
||||
}
|
||||
return list
|
||||
}
|
||||
|
||||
type ins []client.Input
|
||||
|
||||
func (i ins) toProto() []*arkv1.Input {
|
||||
|
||||
@@ -14,7 +14,6 @@ import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
arkv1 "github.com/ark-network/ark/api-spec/protobuf/gen/ark/v1"
|
||||
"github.com/ark-network/ark/common/bitcointree"
|
||||
"github.com/ark-network/ark/common/tree"
|
||||
"github.com/ark-network/ark/pkg/client-sdk/client"
|
||||
@@ -393,57 +392,16 @@ func (a *restClient) Ping(
|
||||
return err
|
||||
}
|
||||
|
||||
func (a *restClient) CreatePayment(
|
||||
ctx context.Context, inputs []client.AsyncPaymentInput, outputs []client.Output,
|
||||
func (a *restClient) SubmitRedeemTx(
|
||||
ctx context.Context, redeemTx string,
|
||||
) (string, error) {
|
||||
ins := make([]*models.V1AsyncPaymentInput, 0, len(inputs))
|
||||
for _, i := range inputs {
|
||||
ins = append(ins, &models.V1AsyncPaymentInput{
|
||||
Input: &models.V1Input{
|
||||
Outpoint: &models.V1Outpoint{
|
||||
Txid: i.Input.Txid,
|
||||
Vout: int64(i.VOut),
|
||||
},
|
||||
Tapscripts: &models.V1Tapscripts{
|
||||
Scripts: i.Input.Tapscripts,
|
||||
},
|
||||
},
|
||||
ForfeitLeafHash: i.ForfeitLeafHash.String(),
|
||||
})
|
||||
req := &models.V1SubmitRedeemTxRequest{
|
||||
RedeemTx: redeemTx,
|
||||
}
|
||||
outs := make([]*models.V1Output, 0, len(outputs))
|
||||
for _, o := range outputs {
|
||||
outs = append(outs, &models.V1Output{
|
||||
Address: o.Address,
|
||||
Amount: strconv.Itoa(int(o.Amount)),
|
||||
})
|
||||
}
|
||||
body := models.V1CreatePaymentRequest{
|
||||
Inputs: ins,
|
||||
Outputs: outs,
|
||||
}
|
||||
resp, err := a.svc.ArkServiceCreatePayment(
|
||||
ark_service.NewArkServiceCreatePaymentParams().WithBody(&body),
|
||||
resp, err := a.svc.ArkServiceSubmitRedeemTx(
|
||||
ark_service.NewArkServiceSubmitRedeemTxParams().WithBody(req),
|
||||
)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
return resp.GetPayload().SignedRedeemTx, nil
|
||||
}
|
||||
|
||||
func (a *restClient) CompletePayment(
|
||||
ctx context.Context, signedRedeemTx string,
|
||||
) error {
|
||||
req := &arkv1.CompletePaymentRequest{
|
||||
SignedRedeemTx: signedRedeemTx,
|
||||
}
|
||||
body := models.V1CompletePaymentRequest{
|
||||
SignedRedeemTx: req.GetSignedRedeemTx(),
|
||||
}
|
||||
_, err := a.svc.ArkServiceCompletePayment(
|
||||
ark_service.NewArkServiceCompletePaymentParams().WithBody(&body),
|
||||
)
|
||||
return err
|
||||
return resp.Payload.SignedRedeemTx, err
|
||||
}
|
||||
|
||||
func (a *restClient) GetRound(
|
||||
|
||||
@@ -1,150 +0,0 @@
|
||||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
package ark_service
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the swagger generate command
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
"time"
|
||||
|
||||
"github.com/go-openapi/errors"
|
||||
"github.com/go-openapi/runtime"
|
||||
cr "github.com/go-openapi/runtime/client"
|
||||
"github.com/go-openapi/strfmt"
|
||||
|
||||
"github.com/ark-network/ark/pkg/client-sdk/client/rest/service/models"
|
||||
)
|
||||
|
||||
// NewArkServiceClaimPaymentParams creates a new ArkServiceClaimPaymentParams object,
|
||||
// with the default timeout for this client.
|
||||
//
|
||||
// Default values are not hydrated, since defaults are normally applied by the API server side.
|
||||
//
|
||||
// To enforce default values in parameter, use SetDefaults or WithDefaults.
|
||||
func NewArkServiceClaimPaymentParams() *ArkServiceClaimPaymentParams {
|
||||
return &ArkServiceClaimPaymentParams{
|
||||
timeout: cr.DefaultTimeout,
|
||||
}
|
||||
}
|
||||
|
||||
// NewArkServiceClaimPaymentParamsWithTimeout creates a new ArkServiceClaimPaymentParams object
|
||||
// with the ability to set a timeout on a request.
|
||||
func NewArkServiceClaimPaymentParamsWithTimeout(timeout time.Duration) *ArkServiceClaimPaymentParams {
|
||||
return &ArkServiceClaimPaymentParams{
|
||||
timeout: timeout,
|
||||
}
|
||||
}
|
||||
|
||||
// NewArkServiceClaimPaymentParamsWithContext creates a new ArkServiceClaimPaymentParams object
|
||||
// with the ability to set a context for a request.
|
||||
func NewArkServiceClaimPaymentParamsWithContext(ctx context.Context) *ArkServiceClaimPaymentParams {
|
||||
return &ArkServiceClaimPaymentParams{
|
||||
Context: ctx,
|
||||
}
|
||||
}
|
||||
|
||||
// NewArkServiceClaimPaymentParamsWithHTTPClient creates a new ArkServiceClaimPaymentParams object
|
||||
// with the ability to set a custom HTTPClient for a request.
|
||||
func NewArkServiceClaimPaymentParamsWithHTTPClient(client *http.Client) *ArkServiceClaimPaymentParams {
|
||||
return &ArkServiceClaimPaymentParams{
|
||||
HTTPClient: client,
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
ArkServiceClaimPaymentParams contains all the parameters to send to the API endpoint
|
||||
|
||||
for the ark service claim payment operation.
|
||||
|
||||
Typically these are written to a http.Request.
|
||||
*/
|
||||
type ArkServiceClaimPaymentParams struct {
|
||||
|
||||
// Body.
|
||||
Body *models.V1ClaimPaymentRequest
|
||||
|
||||
timeout time.Duration
|
||||
Context context.Context
|
||||
HTTPClient *http.Client
|
||||
}
|
||||
|
||||
// WithDefaults hydrates default values in the ark service claim payment params (not the query body).
|
||||
//
|
||||
// All values with no default are reset to their zero value.
|
||||
func (o *ArkServiceClaimPaymentParams) WithDefaults() *ArkServiceClaimPaymentParams {
|
||||
o.SetDefaults()
|
||||
return o
|
||||
}
|
||||
|
||||
// SetDefaults hydrates default values in the ark service claim payment params (not the query body).
|
||||
//
|
||||
// All values with no default are reset to their zero value.
|
||||
func (o *ArkServiceClaimPaymentParams) SetDefaults() {
|
||||
// no default values defined for this parameter
|
||||
}
|
||||
|
||||
// WithTimeout adds the timeout to the ark service claim payment params
|
||||
func (o *ArkServiceClaimPaymentParams) WithTimeout(timeout time.Duration) *ArkServiceClaimPaymentParams {
|
||||
o.SetTimeout(timeout)
|
||||
return o
|
||||
}
|
||||
|
||||
// SetTimeout adds the timeout to the ark service claim payment params
|
||||
func (o *ArkServiceClaimPaymentParams) SetTimeout(timeout time.Duration) {
|
||||
o.timeout = timeout
|
||||
}
|
||||
|
||||
// WithContext adds the context to the ark service claim payment params
|
||||
func (o *ArkServiceClaimPaymentParams) WithContext(ctx context.Context) *ArkServiceClaimPaymentParams {
|
||||
o.SetContext(ctx)
|
||||
return o
|
||||
}
|
||||
|
||||
// SetContext adds the context to the ark service claim payment params
|
||||
func (o *ArkServiceClaimPaymentParams) SetContext(ctx context.Context) {
|
||||
o.Context = ctx
|
||||
}
|
||||
|
||||
// WithHTTPClient adds the HTTPClient to the ark service claim payment params
|
||||
func (o *ArkServiceClaimPaymentParams) WithHTTPClient(client *http.Client) *ArkServiceClaimPaymentParams {
|
||||
o.SetHTTPClient(client)
|
||||
return o
|
||||
}
|
||||
|
||||
// SetHTTPClient adds the HTTPClient to the ark service claim payment params
|
||||
func (o *ArkServiceClaimPaymentParams) SetHTTPClient(client *http.Client) {
|
||||
o.HTTPClient = client
|
||||
}
|
||||
|
||||
// WithBody adds the body to the ark service claim payment params
|
||||
func (o *ArkServiceClaimPaymentParams) WithBody(body *models.V1ClaimPaymentRequest) *ArkServiceClaimPaymentParams {
|
||||
o.SetBody(body)
|
||||
return o
|
||||
}
|
||||
|
||||
// SetBody adds the body to the ark service claim payment params
|
||||
func (o *ArkServiceClaimPaymentParams) SetBody(body *models.V1ClaimPaymentRequest) {
|
||||
o.Body = body
|
||||
}
|
||||
|
||||
// WriteToRequest writes these params to a swagger request
|
||||
func (o *ArkServiceClaimPaymentParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {
|
||||
|
||||
if err := r.SetTimeout(o.timeout); err != nil {
|
||||
return err
|
||||
}
|
||||
var res []error
|
||||
if o.Body != nil {
|
||||
if err := r.SetBodyParam(o.Body); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
if len(res) > 0 {
|
||||
return errors.CompositeValidationError(res...)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -1,185 +0,0 @@
|
||||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
package ark_service
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the swagger generate command
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io"
|
||||
|
||||
"github.com/go-openapi/runtime"
|
||||
"github.com/go-openapi/strfmt"
|
||||
|
||||
"github.com/ark-network/ark/pkg/client-sdk/client/rest/service/models"
|
||||
)
|
||||
|
||||
// ArkServiceClaimPaymentReader is a Reader for the ArkServiceClaimPayment structure.
|
||||
type ArkServiceClaimPaymentReader struct {
|
||||
formats strfmt.Registry
|
||||
}
|
||||
|
||||
// ReadResponse reads a server response into the received o.
|
||||
func (o *ArkServiceClaimPaymentReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) {
|
||||
switch response.Code() {
|
||||
case 200:
|
||||
result := NewArkServiceClaimPaymentOK()
|
||||
if err := result.readResponse(response, consumer, o.formats); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return result, nil
|
||||
default:
|
||||
result := NewArkServiceClaimPaymentDefault(response.Code())
|
||||
if err := result.readResponse(response, consumer, o.formats); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if response.Code()/100 == 2 {
|
||||
return result, nil
|
||||
}
|
||||
return nil, result
|
||||
}
|
||||
}
|
||||
|
||||
// NewArkServiceClaimPaymentOK creates a ArkServiceClaimPaymentOK with default headers values
|
||||
func NewArkServiceClaimPaymentOK() *ArkServiceClaimPaymentOK {
|
||||
return &ArkServiceClaimPaymentOK{}
|
||||
}
|
||||
|
||||
/*
|
||||
ArkServiceClaimPaymentOK describes a response with status code 200, with default header values.
|
||||
|
||||
A successful response.
|
||||
*/
|
||||
type ArkServiceClaimPaymentOK struct {
|
||||
Payload models.V1ClaimPaymentResponse
|
||||
}
|
||||
|
||||
// IsSuccess returns true when this ark service claim payment o k response has a 2xx status code
|
||||
func (o *ArkServiceClaimPaymentOK) IsSuccess() bool {
|
||||
return true
|
||||
}
|
||||
|
||||
// IsRedirect returns true when this ark service claim payment o k response has a 3xx status code
|
||||
func (o *ArkServiceClaimPaymentOK) IsRedirect() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
// IsClientError returns true when this ark service claim payment o k response has a 4xx status code
|
||||
func (o *ArkServiceClaimPaymentOK) IsClientError() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
// IsServerError returns true when this ark service claim payment o k response has a 5xx status code
|
||||
func (o *ArkServiceClaimPaymentOK) IsServerError() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
// IsCode returns true when this ark service claim payment o k response a status code equal to that given
|
||||
func (o *ArkServiceClaimPaymentOK) IsCode(code int) bool {
|
||||
return code == 200
|
||||
}
|
||||
|
||||
// Code gets the status code for the ark service claim payment o k response
|
||||
func (o *ArkServiceClaimPaymentOK) Code() int {
|
||||
return 200
|
||||
}
|
||||
|
||||
func (o *ArkServiceClaimPaymentOK) Error() string {
|
||||
payload, _ := json.Marshal(o.Payload)
|
||||
return fmt.Sprintf("[POST /v1/payment/claim][%d] arkServiceClaimPaymentOK %s", 200, payload)
|
||||
}
|
||||
|
||||
func (o *ArkServiceClaimPaymentOK) String() string {
|
||||
payload, _ := json.Marshal(o.Payload)
|
||||
return fmt.Sprintf("[POST /v1/payment/claim][%d] arkServiceClaimPaymentOK %s", 200, payload)
|
||||
}
|
||||
|
||||
func (o *ArkServiceClaimPaymentOK) GetPayload() models.V1ClaimPaymentResponse {
|
||||
return o.Payload
|
||||
}
|
||||
|
||||
func (o *ArkServiceClaimPaymentOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
|
||||
|
||||
// response payload
|
||||
if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// NewArkServiceClaimPaymentDefault creates a ArkServiceClaimPaymentDefault with default headers values
|
||||
func NewArkServiceClaimPaymentDefault(code int) *ArkServiceClaimPaymentDefault {
|
||||
return &ArkServiceClaimPaymentDefault{
|
||||
_statusCode: code,
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
ArkServiceClaimPaymentDefault describes a response with status code -1, with default header values.
|
||||
|
||||
An unexpected error response.
|
||||
*/
|
||||
type ArkServiceClaimPaymentDefault struct {
|
||||
_statusCode int
|
||||
|
||||
Payload *models.RPCStatus
|
||||
}
|
||||
|
||||
// IsSuccess returns true when this ark service claim payment default response has a 2xx status code
|
||||
func (o *ArkServiceClaimPaymentDefault) IsSuccess() bool {
|
||||
return o._statusCode/100 == 2
|
||||
}
|
||||
|
||||
// IsRedirect returns true when this ark service claim payment default response has a 3xx status code
|
||||
func (o *ArkServiceClaimPaymentDefault) IsRedirect() bool {
|
||||
return o._statusCode/100 == 3
|
||||
}
|
||||
|
||||
// IsClientError returns true when this ark service claim payment default response has a 4xx status code
|
||||
func (o *ArkServiceClaimPaymentDefault) IsClientError() bool {
|
||||
return o._statusCode/100 == 4
|
||||
}
|
||||
|
||||
// IsServerError returns true when this ark service claim payment default response has a 5xx status code
|
||||
func (o *ArkServiceClaimPaymentDefault) IsServerError() bool {
|
||||
return o._statusCode/100 == 5
|
||||
}
|
||||
|
||||
// IsCode returns true when this ark service claim payment default response a status code equal to that given
|
||||
func (o *ArkServiceClaimPaymentDefault) IsCode(code int) bool {
|
||||
return o._statusCode == code
|
||||
}
|
||||
|
||||
// Code gets the status code for the ark service claim payment default response
|
||||
func (o *ArkServiceClaimPaymentDefault) Code() int {
|
||||
return o._statusCode
|
||||
}
|
||||
|
||||
func (o *ArkServiceClaimPaymentDefault) Error() string {
|
||||
payload, _ := json.Marshal(o.Payload)
|
||||
return fmt.Sprintf("[POST /v1/payment/claim][%d] ArkService_ClaimPayment default %s", o._statusCode, payload)
|
||||
}
|
||||
|
||||
func (o *ArkServiceClaimPaymentDefault) String() string {
|
||||
payload, _ := json.Marshal(o.Payload)
|
||||
return fmt.Sprintf("[POST /v1/payment/claim][%d] ArkService_ClaimPayment default %s", o._statusCode, payload)
|
||||
}
|
||||
|
||||
func (o *ArkServiceClaimPaymentDefault) GetPayload() *models.RPCStatus {
|
||||
return o.Payload
|
||||
}
|
||||
|
||||
func (o *ArkServiceClaimPaymentDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
|
||||
|
||||
o.Payload = new(models.RPCStatus)
|
||||
|
||||
// response payload
|
||||
if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
@@ -54,10 +54,6 @@ type ClientOption func(*runtime.ClientOperation)
|
||||
|
||||
// ClientService is the interface for Client methods
|
||||
type ClientService interface {
|
||||
ArkServiceCompletePayment(params *ArkServiceCompletePaymentParams, opts ...ClientOption) (*ArkServiceCompletePaymentOK, error)
|
||||
|
||||
ArkServiceCreatePayment(params *ArkServiceCreatePaymentParams, opts ...ClientOption) (*ArkServiceCreatePaymentOK, error)
|
||||
|
||||
ArkServiceDeleteNostrRecipient(params *ArkServiceDeleteNostrRecipientParams, opts ...ClientOption) (*ArkServiceDeleteNostrRecipientOK, error)
|
||||
|
||||
ArkServiceGetBoardingAddress(params *ArkServiceGetBoardingAddressParams, opts ...ClientOption) (*ArkServiceGetBoardingAddressOK, error)
|
||||
@@ -82,6 +78,8 @@ type ClientService interface {
|
||||
|
||||
ArkServiceSetNostrRecipient(params *ArkServiceSetNostrRecipientParams, opts ...ClientOption) (*ArkServiceSetNostrRecipientOK, error)
|
||||
|
||||
ArkServiceSubmitRedeemTx(params *ArkServiceSubmitRedeemTxParams, opts ...ClientOption) (*ArkServiceSubmitRedeemTxOK, error)
|
||||
|
||||
ArkServiceSubmitSignedForfeitTxs(params *ArkServiceSubmitSignedForfeitTxsParams, opts ...ClientOption) (*ArkServiceSubmitSignedForfeitTxsOK, error)
|
||||
|
||||
ArkServiceSubmitTreeNonces(params *ArkServiceSubmitTreeNoncesParams, opts ...ClientOption) (*ArkServiceSubmitTreeNoncesOK, error)
|
||||
@@ -91,80 +89,6 @@ type ClientService interface {
|
||||
SetTransport(transport runtime.ClientTransport)
|
||||
}
|
||||
|
||||
/*
|
||||
ArkServiceCompletePayment ark service complete payment API
|
||||
*/
|
||||
func (a *Client) ArkServiceCompletePayment(params *ArkServiceCompletePaymentParams, opts ...ClientOption) (*ArkServiceCompletePaymentOK, error) {
|
||||
// TODO: Validate the params before sending
|
||||
if params == nil {
|
||||
params = NewArkServiceCompletePaymentParams()
|
||||
}
|
||||
op := &runtime.ClientOperation{
|
||||
ID: "ArkService_CompletePayment",
|
||||
Method: "POST",
|
||||
PathPattern: "/v1/payment/complete",
|
||||
ProducesMediaTypes: []string{"application/json"},
|
||||
ConsumesMediaTypes: []string{"application/json"},
|
||||
Schemes: []string{"http"},
|
||||
Params: params,
|
||||
Reader: &ArkServiceCompletePaymentReader{formats: a.formats},
|
||||
Context: params.Context,
|
||||
Client: params.HTTPClient,
|
||||
}
|
||||
for _, opt := range opts {
|
||||
opt(op)
|
||||
}
|
||||
|
||||
result, err := a.transport.Submit(op)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
success, ok := result.(*ArkServiceCompletePaymentOK)
|
||||
if ok {
|
||||
return success, nil
|
||||
}
|
||||
// unexpected success response
|
||||
unexpectedSuccess := result.(*ArkServiceCompletePaymentDefault)
|
||||
return nil, runtime.NewAPIError("unexpected success response: content available as default response in error", unexpectedSuccess, unexpectedSuccess.Code())
|
||||
}
|
||||
|
||||
/*
|
||||
ArkServiceCreatePayment ark service create payment API
|
||||
*/
|
||||
func (a *Client) ArkServiceCreatePayment(params *ArkServiceCreatePaymentParams, opts ...ClientOption) (*ArkServiceCreatePaymentOK, error) {
|
||||
// TODO: Validate the params before sending
|
||||
if params == nil {
|
||||
params = NewArkServiceCreatePaymentParams()
|
||||
}
|
||||
op := &runtime.ClientOperation{
|
||||
ID: "ArkService_CreatePayment",
|
||||
Method: "POST",
|
||||
PathPattern: "/v1/payment",
|
||||
ProducesMediaTypes: []string{"application/json"},
|
||||
ConsumesMediaTypes: []string{"application/json"},
|
||||
Schemes: []string{"http"},
|
||||
Params: params,
|
||||
Reader: &ArkServiceCreatePaymentReader{formats: a.formats},
|
||||
Context: params.Context,
|
||||
Client: params.HTTPClient,
|
||||
}
|
||||
for _, opt := range opts {
|
||||
opt(op)
|
||||
}
|
||||
|
||||
result, err := a.transport.Submit(op)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
success, ok := result.(*ArkServiceCreatePaymentOK)
|
||||
if ok {
|
||||
return success, nil
|
||||
}
|
||||
// unexpected success response
|
||||
unexpectedSuccess := result.(*ArkServiceCreatePaymentDefault)
|
||||
return nil, runtime.NewAPIError("unexpected success response: content available as default response in error", unexpectedSuccess, unexpectedSuccess.Code())
|
||||
}
|
||||
|
||||
/*
|
||||
ArkServiceDeleteNostrRecipient ark service delete nostr recipient API
|
||||
*/
|
||||
@@ -609,6 +533,43 @@ func (a *Client) ArkServiceSetNostrRecipient(params *ArkServiceSetNostrRecipient
|
||||
return nil, runtime.NewAPIError("unexpected success response: content available as default response in error", unexpectedSuccess, unexpectedSuccess.Code())
|
||||
}
|
||||
|
||||
/*
|
||||
ArkServiceSubmitRedeemTx ark service submit redeem tx API
|
||||
*/
|
||||
func (a *Client) ArkServiceSubmitRedeemTx(params *ArkServiceSubmitRedeemTxParams, opts ...ClientOption) (*ArkServiceSubmitRedeemTxOK, error) {
|
||||
// TODO: Validate the params before sending
|
||||
if params == nil {
|
||||
params = NewArkServiceSubmitRedeemTxParams()
|
||||
}
|
||||
op := &runtime.ClientOperation{
|
||||
ID: "ArkService_SubmitRedeemTx",
|
||||
Method: "POST",
|
||||
PathPattern: "/v1/redeem-tx",
|
||||
ProducesMediaTypes: []string{"application/json"},
|
||||
ConsumesMediaTypes: []string{"application/json"},
|
||||
Schemes: []string{"http"},
|
||||
Params: params,
|
||||
Reader: &ArkServiceSubmitRedeemTxReader{formats: a.formats},
|
||||
Context: params.Context,
|
||||
Client: params.HTTPClient,
|
||||
}
|
||||
for _, opt := range opts {
|
||||
opt(op)
|
||||
}
|
||||
|
||||
result, err := a.transport.Submit(op)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
success, ok := result.(*ArkServiceSubmitRedeemTxOK)
|
||||
if ok {
|
||||
return success, nil
|
||||
}
|
||||
// unexpected success response
|
||||
unexpectedSuccess := result.(*ArkServiceSubmitRedeemTxDefault)
|
||||
return nil, runtime.NewAPIError("unexpected success response: content available as default response in error", unexpectedSuccess, unexpectedSuccess.Code())
|
||||
}
|
||||
|
||||
/*
|
||||
ArkServiceSubmitSignedForfeitTxs ark service submit signed forfeit txs API
|
||||
*/
|
||||
|
||||
@@ -1,150 +0,0 @@
|
||||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
package ark_service
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the swagger generate command
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
"time"
|
||||
|
||||
"github.com/go-openapi/errors"
|
||||
"github.com/go-openapi/runtime"
|
||||
cr "github.com/go-openapi/runtime/client"
|
||||
"github.com/go-openapi/strfmt"
|
||||
|
||||
"github.com/ark-network/ark/pkg/client-sdk/client/rest/service/models"
|
||||
)
|
||||
|
||||
// NewArkServiceCompletePaymentParams creates a new ArkServiceCompletePaymentParams object,
|
||||
// with the default timeout for this client.
|
||||
//
|
||||
// Default values are not hydrated, since defaults are normally applied by the API server side.
|
||||
//
|
||||
// To enforce default values in parameter, use SetDefaults or WithDefaults.
|
||||
func NewArkServiceCompletePaymentParams() *ArkServiceCompletePaymentParams {
|
||||
return &ArkServiceCompletePaymentParams{
|
||||
timeout: cr.DefaultTimeout,
|
||||
}
|
||||
}
|
||||
|
||||
// NewArkServiceCompletePaymentParamsWithTimeout creates a new ArkServiceCompletePaymentParams object
|
||||
// with the ability to set a timeout on a request.
|
||||
func NewArkServiceCompletePaymentParamsWithTimeout(timeout time.Duration) *ArkServiceCompletePaymentParams {
|
||||
return &ArkServiceCompletePaymentParams{
|
||||
timeout: timeout,
|
||||
}
|
||||
}
|
||||
|
||||
// NewArkServiceCompletePaymentParamsWithContext creates a new ArkServiceCompletePaymentParams object
|
||||
// with the ability to set a context for a request.
|
||||
func NewArkServiceCompletePaymentParamsWithContext(ctx context.Context) *ArkServiceCompletePaymentParams {
|
||||
return &ArkServiceCompletePaymentParams{
|
||||
Context: ctx,
|
||||
}
|
||||
}
|
||||
|
||||
// NewArkServiceCompletePaymentParamsWithHTTPClient creates a new ArkServiceCompletePaymentParams object
|
||||
// with the ability to set a custom HTTPClient for a request.
|
||||
func NewArkServiceCompletePaymentParamsWithHTTPClient(client *http.Client) *ArkServiceCompletePaymentParams {
|
||||
return &ArkServiceCompletePaymentParams{
|
||||
HTTPClient: client,
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
ArkServiceCompletePaymentParams contains all the parameters to send to the API endpoint
|
||||
|
||||
for the ark service complete payment operation.
|
||||
|
||||
Typically these are written to a http.Request.
|
||||
*/
|
||||
type ArkServiceCompletePaymentParams struct {
|
||||
|
||||
// Body.
|
||||
Body *models.V1CompletePaymentRequest
|
||||
|
||||
timeout time.Duration
|
||||
Context context.Context
|
||||
HTTPClient *http.Client
|
||||
}
|
||||
|
||||
// WithDefaults hydrates default values in the ark service complete payment params (not the query body).
|
||||
//
|
||||
// All values with no default are reset to their zero value.
|
||||
func (o *ArkServiceCompletePaymentParams) WithDefaults() *ArkServiceCompletePaymentParams {
|
||||
o.SetDefaults()
|
||||
return o
|
||||
}
|
||||
|
||||
// SetDefaults hydrates default values in the ark service complete payment params (not the query body).
|
||||
//
|
||||
// All values with no default are reset to their zero value.
|
||||
func (o *ArkServiceCompletePaymentParams) SetDefaults() {
|
||||
// no default values defined for this parameter
|
||||
}
|
||||
|
||||
// WithTimeout adds the timeout to the ark service complete payment params
|
||||
func (o *ArkServiceCompletePaymentParams) WithTimeout(timeout time.Duration) *ArkServiceCompletePaymentParams {
|
||||
o.SetTimeout(timeout)
|
||||
return o
|
||||
}
|
||||
|
||||
// SetTimeout adds the timeout to the ark service complete payment params
|
||||
func (o *ArkServiceCompletePaymentParams) SetTimeout(timeout time.Duration) {
|
||||
o.timeout = timeout
|
||||
}
|
||||
|
||||
// WithContext adds the context to the ark service complete payment params
|
||||
func (o *ArkServiceCompletePaymentParams) WithContext(ctx context.Context) *ArkServiceCompletePaymentParams {
|
||||
o.SetContext(ctx)
|
||||
return o
|
||||
}
|
||||
|
||||
// SetContext adds the context to the ark service complete payment params
|
||||
func (o *ArkServiceCompletePaymentParams) SetContext(ctx context.Context) {
|
||||
o.Context = ctx
|
||||
}
|
||||
|
||||
// WithHTTPClient adds the HTTPClient to the ark service complete payment params
|
||||
func (o *ArkServiceCompletePaymentParams) WithHTTPClient(client *http.Client) *ArkServiceCompletePaymentParams {
|
||||
o.SetHTTPClient(client)
|
||||
return o
|
||||
}
|
||||
|
||||
// SetHTTPClient adds the HTTPClient to the ark service complete payment params
|
||||
func (o *ArkServiceCompletePaymentParams) SetHTTPClient(client *http.Client) {
|
||||
o.HTTPClient = client
|
||||
}
|
||||
|
||||
// WithBody adds the body to the ark service complete payment params
|
||||
func (o *ArkServiceCompletePaymentParams) WithBody(body *models.V1CompletePaymentRequest) *ArkServiceCompletePaymentParams {
|
||||
o.SetBody(body)
|
||||
return o
|
||||
}
|
||||
|
||||
// SetBody adds the body to the ark service complete payment params
|
||||
func (o *ArkServiceCompletePaymentParams) SetBody(body *models.V1CompletePaymentRequest) {
|
||||
o.Body = body
|
||||
}
|
||||
|
||||
// WriteToRequest writes these params to a swagger request
|
||||
func (o *ArkServiceCompletePaymentParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {
|
||||
|
||||
if err := r.SetTimeout(o.timeout); err != nil {
|
||||
return err
|
||||
}
|
||||
var res []error
|
||||
if o.Body != nil {
|
||||
if err := r.SetBodyParam(o.Body); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
if len(res) > 0 {
|
||||
return errors.CompositeValidationError(res...)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -1,185 +0,0 @@
|
||||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
package ark_service
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the swagger generate command
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io"
|
||||
|
||||
"github.com/go-openapi/runtime"
|
||||
"github.com/go-openapi/strfmt"
|
||||
|
||||
"github.com/ark-network/ark/pkg/client-sdk/client/rest/service/models"
|
||||
)
|
||||
|
||||
// ArkServiceCompletePaymentReader is a Reader for the ArkServiceCompletePayment structure.
|
||||
type ArkServiceCompletePaymentReader struct {
|
||||
formats strfmt.Registry
|
||||
}
|
||||
|
||||
// ReadResponse reads a server response into the received o.
|
||||
func (o *ArkServiceCompletePaymentReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) {
|
||||
switch response.Code() {
|
||||
case 200:
|
||||
result := NewArkServiceCompletePaymentOK()
|
||||
if err := result.readResponse(response, consumer, o.formats); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return result, nil
|
||||
default:
|
||||
result := NewArkServiceCompletePaymentDefault(response.Code())
|
||||
if err := result.readResponse(response, consumer, o.formats); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if response.Code()/100 == 2 {
|
||||
return result, nil
|
||||
}
|
||||
return nil, result
|
||||
}
|
||||
}
|
||||
|
||||
// NewArkServiceCompletePaymentOK creates a ArkServiceCompletePaymentOK with default headers values
|
||||
func NewArkServiceCompletePaymentOK() *ArkServiceCompletePaymentOK {
|
||||
return &ArkServiceCompletePaymentOK{}
|
||||
}
|
||||
|
||||
/*
|
||||
ArkServiceCompletePaymentOK describes a response with status code 200, with default header values.
|
||||
|
||||
A successful response.
|
||||
*/
|
||||
type ArkServiceCompletePaymentOK struct {
|
||||
Payload models.V1CompletePaymentResponse
|
||||
}
|
||||
|
||||
// IsSuccess returns true when this ark service complete payment o k response has a 2xx status code
|
||||
func (o *ArkServiceCompletePaymentOK) IsSuccess() bool {
|
||||
return true
|
||||
}
|
||||
|
||||
// IsRedirect returns true when this ark service complete payment o k response has a 3xx status code
|
||||
func (o *ArkServiceCompletePaymentOK) IsRedirect() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
// IsClientError returns true when this ark service complete payment o k response has a 4xx status code
|
||||
func (o *ArkServiceCompletePaymentOK) IsClientError() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
// IsServerError returns true when this ark service complete payment o k response has a 5xx status code
|
||||
func (o *ArkServiceCompletePaymentOK) IsServerError() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
// IsCode returns true when this ark service complete payment o k response a status code equal to that given
|
||||
func (o *ArkServiceCompletePaymentOK) IsCode(code int) bool {
|
||||
return code == 200
|
||||
}
|
||||
|
||||
// Code gets the status code for the ark service complete payment o k response
|
||||
func (o *ArkServiceCompletePaymentOK) Code() int {
|
||||
return 200
|
||||
}
|
||||
|
||||
func (o *ArkServiceCompletePaymentOK) Error() string {
|
||||
payload, _ := json.Marshal(o.Payload)
|
||||
return fmt.Sprintf("[POST /v1/payment/complete][%d] arkServiceCompletePaymentOK %s", 200, payload)
|
||||
}
|
||||
|
||||
func (o *ArkServiceCompletePaymentOK) String() string {
|
||||
payload, _ := json.Marshal(o.Payload)
|
||||
return fmt.Sprintf("[POST /v1/payment/complete][%d] arkServiceCompletePaymentOK %s", 200, payload)
|
||||
}
|
||||
|
||||
func (o *ArkServiceCompletePaymentOK) GetPayload() models.V1CompletePaymentResponse {
|
||||
return o.Payload
|
||||
}
|
||||
|
||||
func (o *ArkServiceCompletePaymentOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
|
||||
|
||||
// response payload
|
||||
if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// NewArkServiceCompletePaymentDefault creates a ArkServiceCompletePaymentDefault with default headers values
|
||||
func NewArkServiceCompletePaymentDefault(code int) *ArkServiceCompletePaymentDefault {
|
||||
return &ArkServiceCompletePaymentDefault{
|
||||
_statusCode: code,
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
ArkServiceCompletePaymentDefault describes a response with status code -1, with default header values.
|
||||
|
||||
An unexpected error response.
|
||||
*/
|
||||
type ArkServiceCompletePaymentDefault struct {
|
||||
_statusCode int
|
||||
|
||||
Payload *models.RPCStatus
|
||||
}
|
||||
|
||||
// IsSuccess returns true when this ark service complete payment default response has a 2xx status code
|
||||
func (o *ArkServiceCompletePaymentDefault) IsSuccess() bool {
|
||||
return o._statusCode/100 == 2
|
||||
}
|
||||
|
||||
// IsRedirect returns true when this ark service complete payment default response has a 3xx status code
|
||||
func (o *ArkServiceCompletePaymentDefault) IsRedirect() bool {
|
||||
return o._statusCode/100 == 3
|
||||
}
|
||||
|
||||
// IsClientError returns true when this ark service complete payment default response has a 4xx status code
|
||||
func (o *ArkServiceCompletePaymentDefault) IsClientError() bool {
|
||||
return o._statusCode/100 == 4
|
||||
}
|
||||
|
||||
// IsServerError returns true when this ark service complete payment default response has a 5xx status code
|
||||
func (o *ArkServiceCompletePaymentDefault) IsServerError() bool {
|
||||
return o._statusCode/100 == 5
|
||||
}
|
||||
|
||||
// IsCode returns true when this ark service complete payment default response a status code equal to that given
|
||||
func (o *ArkServiceCompletePaymentDefault) IsCode(code int) bool {
|
||||
return o._statusCode == code
|
||||
}
|
||||
|
||||
// Code gets the status code for the ark service complete payment default response
|
||||
func (o *ArkServiceCompletePaymentDefault) Code() int {
|
||||
return o._statusCode
|
||||
}
|
||||
|
||||
func (o *ArkServiceCompletePaymentDefault) Error() string {
|
||||
payload, _ := json.Marshal(o.Payload)
|
||||
return fmt.Sprintf("[POST /v1/payment/complete][%d] ArkService_CompletePayment default %s", o._statusCode, payload)
|
||||
}
|
||||
|
||||
func (o *ArkServiceCompletePaymentDefault) String() string {
|
||||
payload, _ := json.Marshal(o.Payload)
|
||||
return fmt.Sprintf("[POST /v1/payment/complete][%d] ArkService_CompletePayment default %s", o._statusCode, payload)
|
||||
}
|
||||
|
||||
func (o *ArkServiceCompletePaymentDefault) GetPayload() *models.RPCStatus {
|
||||
return o.Payload
|
||||
}
|
||||
|
||||
func (o *ArkServiceCompletePaymentDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
|
||||
|
||||
o.Payload = new(models.RPCStatus)
|
||||
|
||||
// response payload
|
||||
if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
@@ -1,150 +0,0 @@
|
||||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
package ark_service
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the swagger generate command
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
"time"
|
||||
|
||||
"github.com/go-openapi/errors"
|
||||
"github.com/go-openapi/runtime"
|
||||
cr "github.com/go-openapi/runtime/client"
|
||||
"github.com/go-openapi/strfmt"
|
||||
|
||||
"github.com/ark-network/ark/pkg/client-sdk/client/rest/service/models"
|
||||
)
|
||||
|
||||
// NewArkServiceCreatePaymentParams creates a new ArkServiceCreatePaymentParams object,
|
||||
// with the default timeout for this client.
|
||||
//
|
||||
// Default values are not hydrated, since defaults are normally applied by the API server side.
|
||||
//
|
||||
// To enforce default values in parameter, use SetDefaults or WithDefaults.
|
||||
func NewArkServiceCreatePaymentParams() *ArkServiceCreatePaymentParams {
|
||||
return &ArkServiceCreatePaymentParams{
|
||||
timeout: cr.DefaultTimeout,
|
||||
}
|
||||
}
|
||||
|
||||
// NewArkServiceCreatePaymentParamsWithTimeout creates a new ArkServiceCreatePaymentParams object
|
||||
// with the ability to set a timeout on a request.
|
||||
func NewArkServiceCreatePaymentParamsWithTimeout(timeout time.Duration) *ArkServiceCreatePaymentParams {
|
||||
return &ArkServiceCreatePaymentParams{
|
||||
timeout: timeout,
|
||||
}
|
||||
}
|
||||
|
||||
// NewArkServiceCreatePaymentParamsWithContext creates a new ArkServiceCreatePaymentParams object
|
||||
// with the ability to set a context for a request.
|
||||
func NewArkServiceCreatePaymentParamsWithContext(ctx context.Context) *ArkServiceCreatePaymentParams {
|
||||
return &ArkServiceCreatePaymentParams{
|
||||
Context: ctx,
|
||||
}
|
||||
}
|
||||
|
||||
// NewArkServiceCreatePaymentParamsWithHTTPClient creates a new ArkServiceCreatePaymentParams object
|
||||
// with the ability to set a custom HTTPClient for a request.
|
||||
func NewArkServiceCreatePaymentParamsWithHTTPClient(client *http.Client) *ArkServiceCreatePaymentParams {
|
||||
return &ArkServiceCreatePaymentParams{
|
||||
HTTPClient: client,
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
ArkServiceCreatePaymentParams contains all the parameters to send to the API endpoint
|
||||
|
||||
for the ark service create payment operation.
|
||||
|
||||
Typically these are written to a http.Request.
|
||||
*/
|
||||
type ArkServiceCreatePaymentParams struct {
|
||||
|
||||
// Body.
|
||||
Body *models.V1CreatePaymentRequest
|
||||
|
||||
timeout time.Duration
|
||||
Context context.Context
|
||||
HTTPClient *http.Client
|
||||
}
|
||||
|
||||
// WithDefaults hydrates default values in the ark service create payment params (not the query body).
|
||||
//
|
||||
// All values with no default are reset to their zero value.
|
||||
func (o *ArkServiceCreatePaymentParams) WithDefaults() *ArkServiceCreatePaymentParams {
|
||||
o.SetDefaults()
|
||||
return o
|
||||
}
|
||||
|
||||
// SetDefaults hydrates default values in the ark service create payment params (not the query body).
|
||||
//
|
||||
// All values with no default are reset to their zero value.
|
||||
func (o *ArkServiceCreatePaymentParams) SetDefaults() {
|
||||
// no default values defined for this parameter
|
||||
}
|
||||
|
||||
// WithTimeout adds the timeout to the ark service create payment params
|
||||
func (o *ArkServiceCreatePaymentParams) WithTimeout(timeout time.Duration) *ArkServiceCreatePaymentParams {
|
||||
o.SetTimeout(timeout)
|
||||
return o
|
||||
}
|
||||
|
||||
// SetTimeout adds the timeout to the ark service create payment params
|
||||
func (o *ArkServiceCreatePaymentParams) SetTimeout(timeout time.Duration) {
|
||||
o.timeout = timeout
|
||||
}
|
||||
|
||||
// WithContext adds the context to the ark service create payment params
|
||||
func (o *ArkServiceCreatePaymentParams) WithContext(ctx context.Context) *ArkServiceCreatePaymentParams {
|
||||
o.SetContext(ctx)
|
||||
return o
|
||||
}
|
||||
|
||||
// SetContext adds the context to the ark service create payment params
|
||||
func (o *ArkServiceCreatePaymentParams) SetContext(ctx context.Context) {
|
||||
o.Context = ctx
|
||||
}
|
||||
|
||||
// WithHTTPClient adds the HTTPClient to the ark service create payment params
|
||||
func (o *ArkServiceCreatePaymentParams) WithHTTPClient(client *http.Client) *ArkServiceCreatePaymentParams {
|
||||
o.SetHTTPClient(client)
|
||||
return o
|
||||
}
|
||||
|
||||
// SetHTTPClient adds the HTTPClient to the ark service create payment params
|
||||
func (o *ArkServiceCreatePaymentParams) SetHTTPClient(client *http.Client) {
|
||||
o.HTTPClient = client
|
||||
}
|
||||
|
||||
// WithBody adds the body to the ark service create payment params
|
||||
func (o *ArkServiceCreatePaymentParams) WithBody(body *models.V1CreatePaymentRequest) *ArkServiceCreatePaymentParams {
|
||||
o.SetBody(body)
|
||||
return o
|
||||
}
|
||||
|
||||
// SetBody adds the body to the ark service create payment params
|
||||
func (o *ArkServiceCreatePaymentParams) SetBody(body *models.V1CreatePaymentRequest) {
|
||||
o.Body = body
|
||||
}
|
||||
|
||||
// WriteToRequest writes these params to a swagger request
|
||||
func (o *ArkServiceCreatePaymentParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {
|
||||
|
||||
if err := r.SetTimeout(o.timeout); err != nil {
|
||||
return err
|
||||
}
|
||||
var res []error
|
||||
if o.Body != nil {
|
||||
if err := r.SetBodyParam(o.Body); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
if len(res) > 0 {
|
||||
return errors.CompositeValidationError(res...)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -1,187 +0,0 @@
|
||||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
package ark_service
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the swagger generate command
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io"
|
||||
|
||||
"github.com/go-openapi/runtime"
|
||||
"github.com/go-openapi/strfmt"
|
||||
|
||||
"github.com/ark-network/ark/pkg/client-sdk/client/rest/service/models"
|
||||
)
|
||||
|
||||
// ArkServiceCreatePaymentReader is a Reader for the ArkServiceCreatePayment structure.
|
||||
type ArkServiceCreatePaymentReader struct {
|
||||
formats strfmt.Registry
|
||||
}
|
||||
|
||||
// ReadResponse reads a server response into the received o.
|
||||
func (o *ArkServiceCreatePaymentReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) {
|
||||
switch response.Code() {
|
||||
case 200:
|
||||
result := NewArkServiceCreatePaymentOK()
|
||||
if err := result.readResponse(response, consumer, o.formats); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return result, nil
|
||||
default:
|
||||
result := NewArkServiceCreatePaymentDefault(response.Code())
|
||||
if err := result.readResponse(response, consumer, o.formats); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if response.Code()/100 == 2 {
|
||||
return result, nil
|
||||
}
|
||||
return nil, result
|
||||
}
|
||||
}
|
||||
|
||||
// NewArkServiceCreatePaymentOK creates a ArkServiceCreatePaymentOK with default headers values
|
||||
func NewArkServiceCreatePaymentOK() *ArkServiceCreatePaymentOK {
|
||||
return &ArkServiceCreatePaymentOK{}
|
||||
}
|
||||
|
||||
/*
|
||||
ArkServiceCreatePaymentOK describes a response with status code 200, with default header values.
|
||||
|
||||
A successful response.
|
||||
*/
|
||||
type ArkServiceCreatePaymentOK struct {
|
||||
Payload *models.V1CreatePaymentResponse
|
||||
}
|
||||
|
||||
// IsSuccess returns true when this ark service create payment o k response has a 2xx status code
|
||||
func (o *ArkServiceCreatePaymentOK) IsSuccess() bool {
|
||||
return true
|
||||
}
|
||||
|
||||
// IsRedirect returns true when this ark service create payment o k response has a 3xx status code
|
||||
func (o *ArkServiceCreatePaymentOK) IsRedirect() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
// IsClientError returns true when this ark service create payment o k response has a 4xx status code
|
||||
func (o *ArkServiceCreatePaymentOK) IsClientError() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
// IsServerError returns true when this ark service create payment o k response has a 5xx status code
|
||||
func (o *ArkServiceCreatePaymentOK) IsServerError() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
// IsCode returns true when this ark service create payment o k response a status code equal to that given
|
||||
func (o *ArkServiceCreatePaymentOK) IsCode(code int) bool {
|
||||
return code == 200
|
||||
}
|
||||
|
||||
// Code gets the status code for the ark service create payment o k response
|
||||
func (o *ArkServiceCreatePaymentOK) Code() int {
|
||||
return 200
|
||||
}
|
||||
|
||||
func (o *ArkServiceCreatePaymentOK) Error() string {
|
||||
payload, _ := json.Marshal(o.Payload)
|
||||
return fmt.Sprintf("[POST /v1/payment][%d] arkServiceCreatePaymentOK %s", 200, payload)
|
||||
}
|
||||
|
||||
func (o *ArkServiceCreatePaymentOK) String() string {
|
||||
payload, _ := json.Marshal(o.Payload)
|
||||
return fmt.Sprintf("[POST /v1/payment][%d] arkServiceCreatePaymentOK %s", 200, payload)
|
||||
}
|
||||
|
||||
func (o *ArkServiceCreatePaymentOK) GetPayload() *models.V1CreatePaymentResponse {
|
||||
return o.Payload
|
||||
}
|
||||
|
||||
func (o *ArkServiceCreatePaymentOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
|
||||
|
||||
o.Payload = new(models.V1CreatePaymentResponse)
|
||||
|
||||
// response payload
|
||||
if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// NewArkServiceCreatePaymentDefault creates a ArkServiceCreatePaymentDefault with default headers values
|
||||
func NewArkServiceCreatePaymentDefault(code int) *ArkServiceCreatePaymentDefault {
|
||||
return &ArkServiceCreatePaymentDefault{
|
||||
_statusCode: code,
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
ArkServiceCreatePaymentDefault describes a response with status code -1, with default header values.
|
||||
|
||||
An unexpected error response.
|
||||
*/
|
||||
type ArkServiceCreatePaymentDefault struct {
|
||||
_statusCode int
|
||||
|
||||
Payload *models.RPCStatus
|
||||
}
|
||||
|
||||
// IsSuccess returns true when this ark service create payment default response has a 2xx status code
|
||||
func (o *ArkServiceCreatePaymentDefault) IsSuccess() bool {
|
||||
return o._statusCode/100 == 2
|
||||
}
|
||||
|
||||
// IsRedirect returns true when this ark service create payment default response has a 3xx status code
|
||||
func (o *ArkServiceCreatePaymentDefault) IsRedirect() bool {
|
||||
return o._statusCode/100 == 3
|
||||
}
|
||||
|
||||
// IsClientError returns true when this ark service create payment default response has a 4xx status code
|
||||
func (o *ArkServiceCreatePaymentDefault) IsClientError() bool {
|
||||
return o._statusCode/100 == 4
|
||||
}
|
||||
|
||||
// IsServerError returns true when this ark service create payment default response has a 5xx status code
|
||||
func (o *ArkServiceCreatePaymentDefault) IsServerError() bool {
|
||||
return o._statusCode/100 == 5
|
||||
}
|
||||
|
||||
// IsCode returns true when this ark service create payment default response a status code equal to that given
|
||||
func (o *ArkServiceCreatePaymentDefault) IsCode(code int) bool {
|
||||
return o._statusCode == code
|
||||
}
|
||||
|
||||
// Code gets the status code for the ark service create payment default response
|
||||
func (o *ArkServiceCreatePaymentDefault) Code() int {
|
||||
return o._statusCode
|
||||
}
|
||||
|
||||
func (o *ArkServiceCreatePaymentDefault) Error() string {
|
||||
payload, _ := json.Marshal(o.Payload)
|
||||
return fmt.Sprintf("[POST /v1/payment][%d] ArkService_CreatePayment default %s", o._statusCode, payload)
|
||||
}
|
||||
|
||||
func (o *ArkServiceCreatePaymentDefault) String() string {
|
||||
payload, _ := json.Marshal(o.Payload)
|
||||
return fmt.Sprintf("[POST /v1/payment][%d] ArkService_CreatePayment default %s", o._statusCode, payload)
|
||||
}
|
||||
|
||||
func (o *ArkServiceCreatePaymentDefault) GetPayload() *models.RPCStatus {
|
||||
return o.Payload
|
||||
}
|
||||
|
||||
func (o *ArkServiceCreatePaymentDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
|
||||
|
||||
o.Payload = new(models.RPCStatus)
|
||||
|
||||
// response payload
|
||||
if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
@@ -1,150 +0,0 @@
|
||||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
package ark_service
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the swagger generate command
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
"time"
|
||||
|
||||
"github.com/go-openapi/errors"
|
||||
"github.com/go-openapi/runtime"
|
||||
cr "github.com/go-openapi/runtime/client"
|
||||
"github.com/go-openapi/strfmt"
|
||||
|
||||
"github.com/ark-network/ark/pkg/client-sdk/client/rest/service/models"
|
||||
)
|
||||
|
||||
// NewArkServiceFinalizePaymentParams creates a new ArkServiceFinalizePaymentParams object,
|
||||
// with the default timeout for this client.
|
||||
//
|
||||
// Default values are not hydrated, since defaults are normally applied by the API server side.
|
||||
//
|
||||
// To enforce default values in parameter, use SetDefaults or WithDefaults.
|
||||
func NewArkServiceFinalizePaymentParams() *ArkServiceFinalizePaymentParams {
|
||||
return &ArkServiceFinalizePaymentParams{
|
||||
timeout: cr.DefaultTimeout,
|
||||
}
|
||||
}
|
||||
|
||||
// NewArkServiceFinalizePaymentParamsWithTimeout creates a new ArkServiceFinalizePaymentParams object
|
||||
// with the ability to set a timeout on a request.
|
||||
func NewArkServiceFinalizePaymentParamsWithTimeout(timeout time.Duration) *ArkServiceFinalizePaymentParams {
|
||||
return &ArkServiceFinalizePaymentParams{
|
||||
timeout: timeout,
|
||||
}
|
||||
}
|
||||
|
||||
// NewArkServiceFinalizePaymentParamsWithContext creates a new ArkServiceFinalizePaymentParams object
|
||||
// with the ability to set a context for a request.
|
||||
func NewArkServiceFinalizePaymentParamsWithContext(ctx context.Context) *ArkServiceFinalizePaymentParams {
|
||||
return &ArkServiceFinalizePaymentParams{
|
||||
Context: ctx,
|
||||
}
|
||||
}
|
||||
|
||||
// NewArkServiceFinalizePaymentParamsWithHTTPClient creates a new ArkServiceFinalizePaymentParams object
|
||||
// with the ability to set a custom HTTPClient for a request.
|
||||
func NewArkServiceFinalizePaymentParamsWithHTTPClient(client *http.Client) *ArkServiceFinalizePaymentParams {
|
||||
return &ArkServiceFinalizePaymentParams{
|
||||
HTTPClient: client,
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
ArkServiceFinalizePaymentParams contains all the parameters to send to the API endpoint
|
||||
|
||||
for the ark service finalize payment operation.
|
||||
|
||||
Typically these are written to a http.Request.
|
||||
*/
|
||||
type ArkServiceFinalizePaymentParams struct {
|
||||
|
||||
// Body.
|
||||
Body *models.V1FinalizePaymentRequest
|
||||
|
||||
timeout time.Duration
|
||||
Context context.Context
|
||||
HTTPClient *http.Client
|
||||
}
|
||||
|
||||
// WithDefaults hydrates default values in the ark service finalize payment params (not the query body).
|
||||
//
|
||||
// All values with no default are reset to their zero value.
|
||||
func (o *ArkServiceFinalizePaymentParams) WithDefaults() *ArkServiceFinalizePaymentParams {
|
||||
o.SetDefaults()
|
||||
return o
|
||||
}
|
||||
|
||||
// SetDefaults hydrates default values in the ark service finalize payment params (not the query body).
|
||||
//
|
||||
// All values with no default are reset to their zero value.
|
||||
func (o *ArkServiceFinalizePaymentParams) SetDefaults() {
|
||||
// no default values defined for this parameter
|
||||
}
|
||||
|
||||
// WithTimeout adds the timeout to the ark service finalize payment params
|
||||
func (o *ArkServiceFinalizePaymentParams) WithTimeout(timeout time.Duration) *ArkServiceFinalizePaymentParams {
|
||||
o.SetTimeout(timeout)
|
||||
return o
|
||||
}
|
||||
|
||||
// SetTimeout adds the timeout to the ark service finalize payment params
|
||||
func (o *ArkServiceFinalizePaymentParams) SetTimeout(timeout time.Duration) {
|
||||
o.timeout = timeout
|
||||
}
|
||||
|
||||
// WithContext adds the context to the ark service finalize payment params
|
||||
func (o *ArkServiceFinalizePaymentParams) WithContext(ctx context.Context) *ArkServiceFinalizePaymentParams {
|
||||
o.SetContext(ctx)
|
||||
return o
|
||||
}
|
||||
|
||||
// SetContext adds the context to the ark service finalize payment params
|
||||
func (o *ArkServiceFinalizePaymentParams) SetContext(ctx context.Context) {
|
||||
o.Context = ctx
|
||||
}
|
||||
|
||||
// WithHTTPClient adds the HTTPClient to the ark service finalize payment params
|
||||
func (o *ArkServiceFinalizePaymentParams) WithHTTPClient(client *http.Client) *ArkServiceFinalizePaymentParams {
|
||||
o.SetHTTPClient(client)
|
||||
return o
|
||||
}
|
||||
|
||||
// SetHTTPClient adds the HTTPClient to the ark service finalize payment params
|
||||
func (o *ArkServiceFinalizePaymentParams) SetHTTPClient(client *http.Client) {
|
||||
o.HTTPClient = client
|
||||
}
|
||||
|
||||
// WithBody adds the body to the ark service finalize payment params
|
||||
func (o *ArkServiceFinalizePaymentParams) WithBody(body *models.V1FinalizePaymentRequest) *ArkServiceFinalizePaymentParams {
|
||||
o.SetBody(body)
|
||||
return o
|
||||
}
|
||||
|
||||
// SetBody adds the body to the ark service finalize payment params
|
||||
func (o *ArkServiceFinalizePaymentParams) SetBody(body *models.V1FinalizePaymentRequest) {
|
||||
o.Body = body
|
||||
}
|
||||
|
||||
// WriteToRequest writes these params to a swagger request
|
||||
func (o *ArkServiceFinalizePaymentParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {
|
||||
|
||||
if err := r.SetTimeout(o.timeout); err != nil {
|
||||
return err
|
||||
}
|
||||
var res []error
|
||||
if o.Body != nil {
|
||||
if err := r.SetBodyParam(o.Body); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
if len(res) > 0 {
|
||||
return errors.CompositeValidationError(res...)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -1,185 +0,0 @@
|
||||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
package ark_service
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the swagger generate command
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io"
|
||||
|
||||
"github.com/go-openapi/runtime"
|
||||
"github.com/go-openapi/strfmt"
|
||||
|
||||
"github.com/ark-network/ark/pkg/client-sdk/client/rest/service/models"
|
||||
)
|
||||
|
||||
// ArkServiceFinalizePaymentReader is a Reader for the ArkServiceFinalizePayment structure.
|
||||
type ArkServiceFinalizePaymentReader struct {
|
||||
formats strfmt.Registry
|
||||
}
|
||||
|
||||
// ReadResponse reads a server response into the received o.
|
||||
func (o *ArkServiceFinalizePaymentReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) {
|
||||
switch response.Code() {
|
||||
case 200:
|
||||
result := NewArkServiceFinalizePaymentOK()
|
||||
if err := result.readResponse(response, consumer, o.formats); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return result, nil
|
||||
default:
|
||||
result := NewArkServiceFinalizePaymentDefault(response.Code())
|
||||
if err := result.readResponse(response, consumer, o.formats); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if response.Code()/100 == 2 {
|
||||
return result, nil
|
||||
}
|
||||
return nil, result
|
||||
}
|
||||
}
|
||||
|
||||
// NewArkServiceFinalizePaymentOK creates a ArkServiceFinalizePaymentOK with default headers values
|
||||
func NewArkServiceFinalizePaymentOK() *ArkServiceFinalizePaymentOK {
|
||||
return &ArkServiceFinalizePaymentOK{}
|
||||
}
|
||||
|
||||
/*
|
||||
ArkServiceFinalizePaymentOK describes a response with status code 200, with default header values.
|
||||
|
||||
A successful response.
|
||||
*/
|
||||
type ArkServiceFinalizePaymentOK struct {
|
||||
Payload models.V1FinalizePaymentResponse
|
||||
}
|
||||
|
||||
// IsSuccess returns true when this ark service finalize payment o k response has a 2xx status code
|
||||
func (o *ArkServiceFinalizePaymentOK) IsSuccess() bool {
|
||||
return true
|
||||
}
|
||||
|
||||
// IsRedirect returns true when this ark service finalize payment o k response has a 3xx status code
|
||||
func (o *ArkServiceFinalizePaymentOK) IsRedirect() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
// IsClientError returns true when this ark service finalize payment o k response has a 4xx status code
|
||||
func (o *ArkServiceFinalizePaymentOK) IsClientError() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
// IsServerError returns true when this ark service finalize payment o k response has a 5xx status code
|
||||
func (o *ArkServiceFinalizePaymentOK) IsServerError() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
// IsCode returns true when this ark service finalize payment o k response a status code equal to that given
|
||||
func (o *ArkServiceFinalizePaymentOK) IsCode(code int) bool {
|
||||
return code == 200
|
||||
}
|
||||
|
||||
// Code gets the status code for the ark service finalize payment o k response
|
||||
func (o *ArkServiceFinalizePaymentOK) Code() int {
|
||||
return 200
|
||||
}
|
||||
|
||||
func (o *ArkServiceFinalizePaymentOK) Error() string {
|
||||
payload, _ := json.Marshal(o.Payload)
|
||||
return fmt.Sprintf("[POST /v1/payment/finalize][%d] arkServiceFinalizePaymentOK %s", 200, payload)
|
||||
}
|
||||
|
||||
func (o *ArkServiceFinalizePaymentOK) String() string {
|
||||
payload, _ := json.Marshal(o.Payload)
|
||||
return fmt.Sprintf("[POST /v1/payment/finalize][%d] arkServiceFinalizePaymentOK %s", 200, payload)
|
||||
}
|
||||
|
||||
func (o *ArkServiceFinalizePaymentOK) GetPayload() models.V1FinalizePaymentResponse {
|
||||
return o.Payload
|
||||
}
|
||||
|
||||
func (o *ArkServiceFinalizePaymentOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
|
||||
|
||||
// response payload
|
||||
if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// NewArkServiceFinalizePaymentDefault creates a ArkServiceFinalizePaymentDefault with default headers values
|
||||
func NewArkServiceFinalizePaymentDefault(code int) *ArkServiceFinalizePaymentDefault {
|
||||
return &ArkServiceFinalizePaymentDefault{
|
||||
_statusCode: code,
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
ArkServiceFinalizePaymentDefault describes a response with status code -1, with default header values.
|
||||
|
||||
An unexpected error response.
|
||||
*/
|
||||
type ArkServiceFinalizePaymentDefault struct {
|
||||
_statusCode int
|
||||
|
||||
Payload *models.RPCStatus
|
||||
}
|
||||
|
||||
// IsSuccess returns true when this ark service finalize payment default response has a 2xx status code
|
||||
func (o *ArkServiceFinalizePaymentDefault) IsSuccess() bool {
|
||||
return o._statusCode/100 == 2
|
||||
}
|
||||
|
||||
// IsRedirect returns true when this ark service finalize payment default response has a 3xx status code
|
||||
func (o *ArkServiceFinalizePaymentDefault) IsRedirect() bool {
|
||||
return o._statusCode/100 == 3
|
||||
}
|
||||
|
||||
// IsClientError returns true when this ark service finalize payment default response has a 4xx status code
|
||||
func (o *ArkServiceFinalizePaymentDefault) IsClientError() bool {
|
||||
return o._statusCode/100 == 4
|
||||
}
|
||||
|
||||
// IsServerError returns true when this ark service finalize payment default response has a 5xx status code
|
||||
func (o *ArkServiceFinalizePaymentDefault) IsServerError() bool {
|
||||
return o._statusCode/100 == 5
|
||||
}
|
||||
|
||||
// IsCode returns true when this ark service finalize payment default response a status code equal to that given
|
||||
func (o *ArkServiceFinalizePaymentDefault) IsCode(code int) bool {
|
||||
return o._statusCode == code
|
||||
}
|
||||
|
||||
// Code gets the status code for the ark service finalize payment default response
|
||||
func (o *ArkServiceFinalizePaymentDefault) Code() int {
|
||||
return o._statusCode
|
||||
}
|
||||
|
||||
func (o *ArkServiceFinalizePaymentDefault) Error() string {
|
||||
payload, _ := json.Marshal(o.Payload)
|
||||
return fmt.Sprintf("[POST /v1/payment/finalize][%d] ArkService_FinalizePayment default %s", o._statusCode, payload)
|
||||
}
|
||||
|
||||
func (o *ArkServiceFinalizePaymentDefault) String() string {
|
||||
payload, _ := json.Marshal(o.Payload)
|
||||
return fmt.Sprintf("[POST /v1/payment/finalize][%d] ArkService_FinalizePayment default %s", o._statusCode, payload)
|
||||
}
|
||||
|
||||
func (o *ArkServiceFinalizePaymentDefault) GetPayload() *models.RPCStatus {
|
||||
return o.Payload
|
||||
}
|
||||
|
||||
func (o *ArkServiceFinalizePaymentDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
|
||||
|
||||
o.Payload = new(models.RPCStatus)
|
||||
|
||||
// response payload
|
||||
if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
@@ -1,150 +0,0 @@
|
||||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
package ark_service
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the swagger generate command
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
"time"
|
||||
|
||||
"github.com/go-openapi/errors"
|
||||
"github.com/go-openapi/runtime"
|
||||
cr "github.com/go-openapi/runtime/client"
|
||||
"github.com/go-openapi/strfmt"
|
||||
|
||||
"github.com/ark-network/ark/pkg/client-sdk/client/rest/service/models"
|
||||
)
|
||||
|
||||
// NewArkServiceRegisterPaymentParams creates a new ArkServiceRegisterPaymentParams object,
|
||||
// with the default timeout for this client.
|
||||
//
|
||||
// Default values are not hydrated, since defaults are normally applied by the API server side.
|
||||
//
|
||||
// To enforce default values in parameter, use SetDefaults or WithDefaults.
|
||||
func NewArkServiceRegisterPaymentParams() *ArkServiceRegisterPaymentParams {
|
||||
return &ArkServiceRegisterPaymentParams{
|
||||
timeout: cr.DefaultTimeout,
|
||||
}
|
||||
}
|
||||
|
||||
// NewArkServiceRegisterPaymentParamsWithTimeout creates a new ArkServiceRegisterPaymentParams object
|
||||
// with the ability to set a timeout on a request.
|
||||
func NewArkServiceRegisterPaymentParamsWithTimeout(timeout time.Duration) *ArkServiceRegisterPaymentParams {
|
||||
return &ArkServiceRegisterPaymentParams{
|
||||
timeout: timeout,
|
||||
}
|
||||
}
|
||||
|
||||
// NewArkServiceRegisterPaymentParamsWithContext creates a new ArkServiceRegisterPaymentParams object
|
||||
// with the ability to set a context for a request.
|
||||
func NewArkServiceRegisterPaymentParamsWithContext(ctx context.Context) *ArkServiceRegisterPaymentParams {
|
||||
return &ArkServiceRegisterPaymentParams{
|
||||
Context: ctx,
|
||||
}
|
||||
}
|
||||
|
||||
// NewArkServiceRegisterPaymentParamsWithHTTPClient creates a new ArkServiceRegisterPaymentParams object
|
||||
// with the ability to set a custom HTTPClient for a request.
|
||||
func NewArkServiceRegisterPaymentParamsWithHTTPClient(client *http.Client) *ArkServiceRegisterPaymentParams {
|
||||
return &ArkServiceRegisterPaymentParams{
|
||||
HTTPClient: client,
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
ArkServiceRegisterPaymentParams contains all the parameters to send to the API endpoint
|
||||
|
||||
for the ark service register payment operation.
|
||||
|
||||
Typically these are written to a http.Request.
|
||||
*/
|
||||
type ArkServiceRegisterPaymentParams struct {
|
||||
|
||||
// Body.
|
||||
Body *models.V1RegisterPaymentRequest
|
||||
|
||||
timeout time.Duration
|
||||
Context context.Context
|
||||
HTTPClient *http.Client
|
||||
}
|
||||
|
||||
// WithDefaults hydrates default values in the ark service register payment params (not the query body).
|
||||
//
|
||||
// All values with no default are reset to their zero value.
|
||||
func (o *ArkServiceRegisterPaymentParams) WithDefaults() *ArkServiceRegisterPaymentParams {
|
||||
o.SetDefaults()
|
||||
return o
|
||||
}
|
||||
|
||||
// SetDefaults hydrates default values in the ark service register payment params (not the query body).
|
||||
//
|
||||
// All values with no default are reset to their zero value.
|
||||
func (o *ArkServiceRegisterPaymentParams) SetDefaults() {
|
||||
// no default values defined for this parameter
|
||||
}
|
||||
|
||||
// WithTimeout adds the timeout to the ark service register payment params
|
||||
func (o *ArkServiceRegisterPaymentParams) WithTimeout(timeout time.Duration) *ArkServiceRegisterPaymentParams {
|
||||
o.SetTimeout(timeout)
|
||||
return o
|
||||
}
|
||||
|
||||
// SetTimeout adds the timeout to the ark service register payment params
|
||||
func (o *ArkServiceRegisterPaymentParams) SetTimeout(timeout time.Duration) {
|
||||
o.timeout = timeout
|
||||
}
|
||||
|
||||
// WithContext adds the context to the ark service register payment params
|
||||
func (o *ArkServiceRegisterPaymentParams) WithContext(ctx context.Context) *ArkServiceRegisterPaymentParams {
|
||||
o.SetContext(ctx)
|
||||
return o
|
||||
}
|
||||
|
||||
// SetContext adds the context to the ark service register payment params
|
||||
func (o *ArkServiceRegisterPaymentParams) SetContext(ctx context.Context) {
|
||||
o.Context = ctx
|
||||
}
|
||||
|
||||
// WithHTTPClient adds the HTTPClient to the ark service register payment params
|
||||
func (o *ArkServiceRegisterPaymentParams) WithHTTPClient(client *http.Client) *ArkServiceRegisterPaymentParams {
|
||||
o.SetHTTPClient(client)
|
||||
return o
|
||||
}
|
||||
|
||||
// SetHTTPClient adds the HTTPClient to the ark service register payment params
|
||||
func (o *ArkServiceRegisterPaymentParams) SetHTTPClient(client *http.Client) {
|
||||
o.HTTPClient = client
|
||||
}
|
||||
|
||||
// WithBody adds the body to the ark service register payment params
|
||||
func (o *ArkServiceRegisterPaymentParams) WithBody(body *models.V1RegisterPaymentRequest) *ArkServiceRegisterPaymentParams {
|
||||
o.SetBody(body)
|
||||
return o
|
||||
}
|
||||
|
||||
// SetBody adds the body to the ark service register payment params
|
||||
func (o *ArkServiceRegisterPaymentParams) SetBody(body *models.V1RegisterPaymentRequest) {
|
||||
o.Body = body
|
||||
}
|
||||
|
||||
// WriteToRequest writes these params to a swagger request
|
||||
func (o *ArkServiceRegisterPaymentParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {
|
||||
|
||||
if err := r.SetTimeout(o.timeout); err != nil {
|
||||
return err
|
||||
}
|
||||
var res []error
|
||||
if o.Body != nil {
|
||||
if err := r.SetBodyParam(o.Body); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
if len(res) > 0 {
|
||||
return errors.CompositeValidationError(res...)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -1,187 +0,0 @@
|
||||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
package ark_service
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the swagger generate command
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io"
|
||||
|
||||
"github.com/go-openapi/runtime"
|
||||
"github.com/go-openapi/strfmt"
|
||||
|
||||
"github.com/ark-network/ark/pkg/client-sdk/client/rest/service/models"
|
||||
)
|
||||
|
||||
// ArkServiceRegisterPaymentReader is a Reader for the ArkServiceRegisterPayment structure.
|
||||
type ArkServiceRegisterPaymentReader struct {
|
||||
formats strfmt.Registry
|
||||
}
|
||||
|
||||
// ReadResponse reads a server response into the received o.
|
||||
func (o *ArkServiceRegisterPaymentReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) {
|
||||
switch response.Code() {
|
||||
case 200:
|
||||
result := NewArkServiceRegisterPaymentOK()
|
||||
if err := result.readResponse(response, consumer, o.formats); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return result, nil
|
||||
default:
|
||||
result := NewArkServiceRegisterPaymentDefault(response.Code())
|
||||
if err := result.readResponse(response, consumer, o.formats); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if response.Code()/100 == 2 {
|
||||
return result, nil
|
||||
}
|
||||
return nil, result
|
||||
}
|
||||
}
|
||||
|
||||
// NewArkServiceRegisterPaymentOK creates a ArkServiceRegisterPaymentOK with default headers values
|
||||
func NewArkServiceRegisterPaymentOK() *ArkServiceRegisterPaymentOK {
|
||||
return &ArkServiceRegisterPaymentOK{}
|
||||
}
|
||||
|
||||
/*
|
||||
ArkServiceRegisterPaymentOK describes a response with status code 200, with default header values.
|
||||
|
||||
A successful response.
|
||||
*/
|
||||
type ArkServiceRegisterPaymentOK struct {
|
||||
Payload *models.V1RegisterPaymentResponse
|
||||
}
|
||||
|
||||
// IsSuccess returns true when this ark service register payment o k response has a 2xx status code
|
||||
func (o *ArkServiceRegisterPaymentOK) IsSuccess() bool {
|
||||
return true
|
||||
}
|
||||
|
||||
// IsRedirect returns true when this ark service register payment o k response has a 3xx status code
|
||||
func (o *ArkServiceRegisterPaymentOK) IsRedirect() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
// IsClientError returns true when this ark service register payment o k response has a 4xx status code
|
||||
func (o *ArkServiceRegisterPaymentOK) IsClientError() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
// IsServerError returns true when this ark service register payment o k response has a 5xx status code
|
||||
func (o *ArkServiceRegisterPaymentOK) IsServerError() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
// IsCode returns true when this ark service register payment o k response a status code equal to that given
|
||||
func (o *ArkServiceRegisterPaymentOK) IsCode(code int) bool {
|
||||
return code == 200
|
||||
}
|
||||
|
||||
// Code gets the status code for the ark service register payment o k response
|
||||
func (o *ArkServiceRegisterPaymentOK) Code() int {
|
||||
return 200
|
||||
}
|
||||
|
||||
func (o *ArkServiceRegisterPaymentOK) Error() string {
|
||||
payload, _ := json.Marshal(o.Payload)
|
||||
return fmt.Sprintf("[POST /v1/payment/register][%d] arkServiceRegisterPaymentOK %s", 200, payload)
|
||||
}
|
||||
|
||||
func (o *ArkServiceRegisterPaymentOK) String() string {
|
||||
payload, _ := json.Marshal(o.Payload)
|
||||
return fmt.Sprintf("[POST /v1/payment/register][%d] arkServiceRegisterPaymentOK %s", 200, payload)
|
||||
}
|
||||
|
||||
func (o *ArkServiceRegisterPaymentOK) GetPayload() *models.V1RegisterPaymentResponse {
|
||||
return o.Payload
|
||||
}
|
||||
|
||||
func (o *ArkServiceRegisterPaymentOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
|
||||
|
||||
o.Payload = new(models.V1RegisterPaymentResponse)
|
||||
|
||||
// response payload
|
||||
if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// NewArkServiceRegisterPaymentDefault creates a ArkServiceRegisterPaymentDefault with default headers values
|
||||
func NewArkServiceRegisterPaymentDefault(code int) *ArkServiceRegisterPaymentDefault {
|
||||
return &ArkServiceRegisterPaymentDefault{
|
||||
_statusCode: code,
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
ArkServiceRegisterPaymentDefault describes a response with status code -1, with default header values.
|
||||
|
||||
An unexpected error response.
|
||||
*/
|
||||
type ArkServiceRegisterPaymentDefault struct {
|
||||
_statusCode int
|
||||
|
||||
Payload *models.RPCStatus
|
||||
}
|
||||
|
||||
// IsSuccess returns true when this ark service register payment default response has a 2xx status code
|
||||
func (o *ArkServiceRegisterPaymentDefault) IsSuccess() bool {
|
||||
return o._statusCode/100 == 2
|
||||
}
|
||||
|
||||
// IsRedirect returns true when this ark service register payment default response has a 3xx status code
|
||||
func (o *ArkServiceRegisterPaymentDefault) IsRedirect() bool {
|
||||
return o._statusCode/100 == 3
|
||||
}
|
||||
|
||||
// IsClientError returns true when this ark service register payment default response has a 4xx status code
|
||||
func (o *ArkServiceRegisterPaymentDefault) IsClientError() bool {
|
||||
return o._statusCode/100 == 4
|
||||
}
|
||||
|
||||
// IsServerError returns true when this ark service register payment default response has a 5xx status code
|
||||
func (o *ArkServiceRegisterPaymentDefault) IsServerError() bool {
|
||||
return o._statusCode/100 == 5
|
||||
}
|
||||
|
||||
// IsCode returns true when this ark service register payment default response a status code equal to that given
|
||||
func (o *ArkServiceRegisterPaymentDefault) IsCode(code int) bool {
|
||||
return o._statusCode == code
|
||||
}
|
||||
|
||||
// Code gets the status code for the ark service register payment default response
|
||||
func (o *ArkServiceRegisterPaymentDefault) Code() int {
|
||||
return o._statusCode
|
||||
}
|
||||
|
||||
func (o *ArkServiceRegisterPaymentDefault) Error() string {
|
||||
payload, _ := json.Marshal(o.Payload)
|
||||
return fmt.Sprintf("[POST /v1/payment/register][%d] ArkService_RegisterPayment default %s", o._statusCode, payload)
|
||||
}
|
||||
|
||||
func (o *ArkServiceRegisterPaymentDefault) String() string {
|
||||
payload, _ := json.Marshal(o.Payload)
|
||||
return fmt.Sprintf("[POST /v1/payment/register][%d] ArkService_RegisterPayment default %s", o._statusCode, payload)
|
||||
}
|
||||
|
||||
func (o *ArkServiceRegisterPaymentDefault) GetPayload() *models.RPCStatus {
|
||||
return o.Payload
|
||||
}
|
||||
|
||||
func (o *ArkServiceRegisterPaymentDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
|
||||
|
||||
o.Payload = new(models.RPCStatus)
|
||||
|
||||
// response payload
|
||||
if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
@@ -1,150 +0,0 @@
|
||||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
package ark_service
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the swagger generate command
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
"time"
|
||||
|
||||
"github.com/go-openapi/errors"
|
||||
"github.com/go-openapi/runtime"
|
||||
cr "github.com/go-openapi/runtime/client"
|
||||
"github.com/go-openapi/strfmt"
|
||||
|
||||
"github.com/ark-network/ark/pkg/client-sdk/client/rest/service/models"
|
||||
)
|
||||
|
||||
// NewArkServiceSendTreeNoncesParams creates a new ArkServiceSendTreeNoncesParams object,
|
||||
// with the default timeout for this client.
|
||||
//
|
||||
// Default values are not hydrated, since defaults are normally applied by the API server side.
|
||||
//
|
||||
// To enforce default values in parameter, use SetDefaults or WithDefaults.
|
||||
func NewArkServiceSendTreeNoncesParams() *ArkServiceSendTreeNoncesParams {
|
||||
return &ArkServiceSendTreeNoncesParams{
|
||||
timeout: cr.DefaultTimeout,
|
||||
}
|
||||
}
|
||||
|
||||
// NewArkServiceSendTreeNoncesParamsWithTimeout creates a new ArkServiceSendTreeNoncesParams object
|
||||
// with the ability to set a timeout on a request.
|
||||
func NewArkServiceSendTreeNoncesParamsWithTimeout(timeout time.Duration) *ArkServiceSendTreeNoncesParams {
|
||||
return &ArkServiceSendTreeNoncesParams{
|
||||
timeout: timeout,
|
||||
}
|
||||
}
|
||||
|
||||
// NewArkServiceSendTreeNoncesParamsWithContext creates a new ArkServiceSendTreeNoncesParams object
|
||||
// with the ability to set a context for a request.
|
||||
func NewArkServiceSendTreeNoncesParamsWithContext(ctx context.Context) *ArkServiceSendTreeNoncesParams {
|
||||
return &ArkServiceSendTreeNoncesParams{
|
||||
Context: ctx,
|
||||
}
|
||||
}
|
||||
|
||||
// NewArkServiceSendTreeNoncesParamsWithHTTPClient creates a new ArkServiceSendTreeNoncesParams object
|
||||
// with the ability to set a custom HTTPClient for a request.
|
||||
func NewArkServiceSendTreeNoncesParamsWithHTTPClient(client *http.Client) *ArkServiceSendTreeNoncesParams {
|
||||
return &ArkServiceSendTreeNoncesParams{
|
||||
HTTPClient: client,
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
ArkServiceSendTreeNoncesParams contains all the parameters to send to the API endpoint
|
||||
|
||||
for the ark service send tree nonces operation.
|
||||
|
||||
Typically these are written to a http.Request.
|
||||
*/
|
||||
type ArkServiceSendTreeNoncesParams struct {
|
||||
|
||||
// Body.
|
||||
Body *models.V1SendTreeNoncesRequest
|
||||
|
||||
timeout time.Duration
|
||||
Context context.Context
|
||||
HTTPClient *http.Client
|
||||
}
|
||||
|
||||
// WithDefaults hydrates default values in the ark service send tree nonces params (not the query body).
|
||||
//
|
||||
// All values with no default are reset to their zero value.
|
||||
func (o *ArkServiceSendTreeNoncesParams) WithDefaults() *ArkServiceSendTreeNoncesParams {
|
||||
o.SetDefaults()
|
||||
return o
|
||||
}
|
||||
|
||||
// SetDefaults hydrates default values in the ark service send tree nonces params (not the query body).
|
||||
//
|
||||
// All values with no default are reset to their zero value.
|
||||
func (o *ArkServiceSendTreeNoncesParams) SetDefaults() {
|
||||
// no default values defined for this parameter
|
||||
}
|
||||
|
||||
// WithTimeout adds the timeout to the ark service send tree nonces params
|
||||
func (o *ArkServiceSendTreeNoncesParams) WithTimeout(timeout time.Duration) *ArkServiceSendTreeNoncesParams {
|
||||
o.SetTimeout(timeout)
|
||||
return o
|
||||
}
|
||||
|
||||
// SetTimeout adds the timeout to the ark service send tree nonces params
|
||||
func (o *ArkServiceSendTreeNoncesParams) SetTimeout(timeout time.Duration) {
|
||||
o.timeout = timeout
|
||||
}
|
||||
|
||||
// WithContext adds the context to the ark service send tree nonces params
|
||||
func (o *ArkServiceSendTreeNoncesParams) WithContext(ctx context.Context) *ArkServiceSendTreeNoncesParams {
|
||||
o.SetContext(ctx)
|
||||
return o
|
||||
}
|
||||
|
||||
// SetContext adds the context to the ark service send tree nonces params
|
||||
func (o *ArkServiceSendTreeNoncesParams) SetContext(ctx context.Context) {
|
||||
o.Context = ctx
|
||||
}
|
||||
|
||||
// WithHTTPClient adds the HTTPClient to the ark service send tree nonces params
|
||||
func (o *ArkServiceSendTreeNoncesParams) WithHTTPClient(client *http.Client) *ArkServiceSendTreeNoncesParams {
|
||||
o.SetHTTPClient(client)
|
||||
return o
|
||||
}
|
||||
|
||||
// SetHTTPClient adds the HTTPClient to the ark service send tree nonces params
|
||||
func (o *ArkServiceSendTreeNoncesParams) SetHTTPClient(client *http.Client) {
|
||||
o.HTTPClient = client
|
||||
}
|
||||
|
||||
// WithBody adds the body to the ark service send tree nonces params
|
||||
func (o *ArkServiceSendTreeNoncesParams) WithBody(body *models.V1SendTreeNoncesRequest) *ArkServiceSendTreeNoncesParams {
|
||||
o.SetBody(body)
|
||||
return o
|
||||
}
|
||||
|
||||
// SetBody adds the body to the ark service send tree nonces params
|
||||
func (o *ArkServiceSendTreeNoncesParams) SetBody(body *models.V1SendTreeNoncesRequest) {
|
||||
o.Body = body
|
||||
}
|
||||
|
||||
// WriteToRequest writes these params to a swagger request
|
||||
func (o *ArkServiceSendTreeNoncesParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {
|
||||
|
||||
if err := r.SetTimeout(o.timeout); err != nil {
|
||||
return err
|
||||
}
|
||||
var res []error
|
||||
if o.Body != nil {
|
||||
if err := r.SetBodyParam(o.Body); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
if len(res) > 0 {
|
||||
return errors.CompositeValidationError(res...)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -1,185 +0,0 @@
|
||||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
package ark_service
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the swagger generate command
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io"
|
||||
|
||||
"github.com/go-openapi/runtime"
|
||||
"github.com/go-openapi/strfmt"
|
||||
|
||||
"github.com/ark-network/ark/pkg/client-sdk/client/rest/service/models"
|
||||
)
|
||||
|
||||
// ArkServiceSendTreeNoncesReader is a Reader for the ArkServiceSendTreeNonces structure.
|
||||
type ArkServiceSendTreeNoncesReader struct {
|
||||
formats strfmt.Registry
|
||||
}
|
||||
|
||||
// ReadResponse reads a server response into the received o.
|
||||
func (o *ArkServiceSendTreeNoncesReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) {
|
||||
switch response.Code() {
|
||||
case 200:
|
||||
result := NewArkServiceSendTreeNoncesOK()
|
||||
if err := result.readResponse(response, consumer, o.formats); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return result, nil
|
||||
default:
|
||||
result := NewArkServiceSendTreeNoncesDefault(response.Code())
|
||||
if err := result.readResponse(response, consumer, o.formats); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if response.Code()/100 == 2 {
|
||||
return result, nil
|
||||
}
|
||||
return nil, result
|
||||
}
|
||||
}
|
||||
|
||||
// NewArkServiceSendTreeNoncesOK creates a ArkServiceSendTreeNoncesOK with default headers values
|
||||
func NewArkServiceSendTreeNoncesOK() *ArkServiceSendTreeNoncesOK {
|
||||
return &ArkServiceSendTreeNoncesOK{}
|
||||
}
|
||||
|
||||
/*
|
||||
ArkServiceSendTreeNoncesOK describes a response with status code 200, with default header values.
|
||||
|
||||
A successful response.
|
||||
*/
|
||||
type ArkServiceSendTreeNoncesOK struct {
|
||||
Payload models.V1SendTreeNoncesResponse
|
||||
}
|
||||
|
||||
// IsSuccess returns true when this ark service send tree nonces o k response has a 2xx status code
|
||||
func (o *ArkServiceSendTreeNoncesOK) IsSuccess() bool {
|
||||
return true
|
||||
}
|
||||
|
||||
// IsRedirect returns true when this ark service send tree nonces o k response has a 3xx status code
|
||||
func (o *ArkServiceSendTreeNoncesOK) IsRedirect() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
// IsClientError returns true when this ark service send tree nonces o k response has a 4xx status code
|
||||
func (o *ArkServiceSendTreeNoncesOK) IsClientError() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
// IsServerError returns true when this ark service send tree nonces o k response has a 5xx status code
|
||||
func (o *ArkServiceSendTreeNoncesOK) IsServerError() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
// IsCode returns true when this ark service send tree nonces o k response a status code equal to that given
|
||||
func (o *ArkServiceSendTreeNoncesOK) IsCode(code int) bool {
|
||||
return code == 200
|
||||
}
|
||||
|
||||
// Code gets the status code for the ark service send tree nonces o k response
|
||||
func (o *ArkServiceSendTreeNoncesOK) Code() int {
|
||||
return 200
|
||||
}
|
||||
|
||||
func (o *ArkServiceSendTreeNoncesOK) Error() string {
|
||||
payload, _ := json.Marshal(o.Payload)
|
||||
return fmt.Sprintf("[POST /v1/payment/tree/nonces][%d] arkServiceSendTreeNoncesOK %s", 200, payload)
|
||||
}
|
||||
|
||||
func (o *ArkServiceSendTreeNoncesOK) String() string {
|
||||
payload, _ := json.Marshal(o.Payload)
|
||||
return fmt.Sprintf("[POST /v1/payment/tree/nonces][%d] arkServiceSendTreeNoncesOK %s", 200, payload)
|
||||
}
|
||||
|
||||
func (o *ArkServiceSendTreeNoncesOK) GetPayload() models.V1SendTreeNoncesResponse {
|
||||
return o.Payload
|
||||
}
|
||||
|
||||
func (o *ArkServiceSendTreeNoncesOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
|
||||
|
||||
// response payload
|
||||
if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// NewArkServiceSendTreeNoncesDefault creates a ArkServiceSendTreeNoncesDefault with default headers values
|
||||
func NewArkServiceSendTreeNoncesDefault(code int) *ArkServiceSendTreeNoncesDefault {
|
||||
return &ArkServiceSendTreeNoncesDefault{
|
||||
_statusCode: code,
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
ArkServiceSendTreeNoncesDefault describes a response with status code -1, with default header values.
|
||||
|
||||
An unexpected error response.
|
||||
*/
|
||||
type ArkServiceSendTreeNoncesDefault struct {
|
||||
_statusCode int
|
||||
|
||||
Payload *models.RPCStatus
|
||||
}
|
||||
|
||||
// IsSuccess returns true when this ark service send tree nonces default response has a 2xx status code
|
||||
func (o *ArkServiceSendTreeNoncesDefault) IsSuccess() bool {
|
||||
return o._statusCode/100 == 2
|
||||
}
|
||||
|
||||
// IsRedirect returns true when this ark service send tree nonces default response has a 3xx status code
|
||||
func (o *ArkServiceSendTreeNoncesDefault) IsRedirect() bool {
|
||||
return o._statusCode/100 == 3
|
||||
}
|
||||
|
||||
// IsClientError returns true when this ark service send tree nonces default response has a 4xx status code
|
||||
func (o *ArkServiceSendTreeNoncesDefault) IsClientError() bool {
|
||||
return o._statusCode/100 == 4
|
||||
}
|
||||
|
||||
// IsServerError returns true when this ark service send tree nonces default response has a 5xx status code
|
||||
func (o *ArkServiceSendTreeNoncesDefault) IsServerError() bool {
|
||||
return o._statusCode/100 == 5
|
||||
}
|
||||
|
||||
// IsCode returns true when this ark service send tree nonces default response a status code equal to that given
|
||||
func (o *ArkServiceSendTreeNoncesDefault) IsCode(code int) bool {
|
||||
return o._statusCode == code
|
||||
}
|
||||
|
||||
// Code gets the status code for the ark service send tree nonces default response
|
||||
func (o *ArkServiceSendTreeNoncesDefault) Code() int {
|
||||
return o._statusCode
|
||||
}
|
||||
|
||||
func (o *ArkServiceSendTreeNoncesDefault) Error() string {
|
||||
payload, _ := json.Marshal(o.Payload)
|
||||
return fmt.Sprintf("[POST /v1/payment/tree/nonces][%d] ArkService_SendTreeNonces default %s", o._statusCode, payload)
|
||||
}
|
||||
|
||||
func (o *ArkServiceSendTreeNoncesDefault) String() string {
|
||||
payload, _ := json.Marshal(o.Payload)
|
||||
return fmt.Sprintf("[POST /v1/payment/tree/nonces][%d] ArkService_SendTreeNonces default %s", o._statusCode, payload)
|
||||
}
|
||||
|
||||
func (o *ArkServiceSendTreeNoncesDefault) GetPayload() *models.RPCStatus {
|
||||
return o.Payload
|
||||
}
|
||||
|
||||
func (o *ArkServiceSendTreeNoncesDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
|
||||
|
||||
o.Payload = new(models.RPCStatus)
|
||||
|
||||
// response payload
|
||||
if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
@@ -1,150 +0,0 @@
|
||||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
package ark_service
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the swagger generate command
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
"time"
|
||||
|
||||
"github.com/go-openapi/errors"
|
||||
"github.com/go-openapi/runtime"
|
||||
cr "github.com/go-openapi/runtime/client"
|
||||
"github.com/go-openapi/strfmt"
|
||||
|
||||
"github.com/ark-network/ark/pkg/client-sdk/client/rest/service/models"
|
||||
)
|
||||
|
||||
// NewArkServiceSendTreeSignaturesParams creates a new ArkServiceSendTreeSignaturesParams object,
|
||||
// with the default timeout for this client.
|
||||
//
|
||||
// Default values are not hydrated, since defaults are normally applied by the API server side.
|
||||
//
|
||||
// To enforce default values in parameter, use SetDefaults or WithDefaults.
|
||||
func NewArkServiceSendTreeSignaturesParams() *ArkServiceSendTreeSignaturesParams {
|
||||
return &ArkServiceSendTreeSignaturesParams{
|
||||
timeout: cr.DefaultTimeout,
|
||||
}
|
||||
}
|
||||
|
||||
// NewArkServiceSendTreeSignaturesParamsWithTimeout creates a new ArkServiceSendTreeSignaturesParams object
|
||||
// with the ability to set a timeout on a request.
|
||||
func NewArkServiceSendTreeSignaturesParamsWithTimeout(timeout time.Duration) *ArkServiceSendTreeSignaturesParams {
|
||||
return &ArkServiceSendTreeSignaturesParams{
|
||||
timeout: timeout,
|
||||
}
|
||||
}
|
||||
|
||||
// NewArkServiceSendTreeSignaturesParamsWithContext creates a new ArkServiceSendTreeSignaturesParams object
|
||||
// with the ability to set a context for a request.
|
||||
func NewArkServiceSendTreeSignaturesParamsWithContext(ctx context.Context) *ArkServiceSendTreeSignaturesParams {
|
||||
return &ArkServiceSendTreeSignaturesParams{
|
||||
Context: ctx,
|
||||
}
|
||||
}
|
||||
|
||||
// NewArkServiceSendTreeSignaturesParamsWithHTTPClient creates a new ArkServiceSendTreeSignaturesParams object
|
||||
// with the ability to set a custom HTTPClient for a request.
|
||||
func NewArkServiceSendTreeSignaturesParamsWithHTTPClient(client *http.Client) *ArkServiceSendTreeSignaturesParams {
|
||||
return &ArkServiceSendTreeSignaturesParams{
|
||||
HTTPClient: client,
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
ArkServiceSendTreeSignaturesParams contains all the parameters to send to the API endpoint
|
||||
|
||||
for the ark service send tree signatures operation.
|
||||
|
||||
Typically these are written to a http.Request.
|
||||
*/
|
||||
type ArkServiceSendTreeSignaturesParams struct {
|
||||
|
||||
// Body.
|
||||
Body *models.V1SendTreeSignaturesRequest
|
||||
|
||||
timeout time.Duration
|
||||
Context context.Context
|
||||
HTTPClient *http.Client
|
||||
}
|
||||
|
||||
// WithDefaults hydrates default values in the ark service send tree signatures params (not the query body).
|
||||
//
|
||||
// All values with no default are reset to their zero value.
|
||||
func (o *ArkServiceSendTreeSignaturesParams) WithDefaults() *ArkServiceSendTreeSignaturesParams {
|
||||
o.SetDefaults()
|
||||
return o
|
||||
}
|
||||
|
||||
// SetDefaults hydrates default values in the ark service send tree signatures params (not the query body).
|
||||
//
|
||||
// All values with no default are reset to their zero value.
|
||||
func (o *ArkServiceSendTreeSignaturesParams) SetDefaults() {
|
||||
// no default values defined for this parameter
|
||||
}
|
||||
|
||||
// WithTimeout adds the timeout to the ark service send tree signatures params
|
||||
func (o *ArkServiceSendTreeSignaturesParams) WithTimeout(timeout time.Duration) *ArkServiceSendTreeSignaturesParams {
|
||||
o.SetTimeout(timeout)
|
||||
return o
|
||||
}
|
||||
|
||||
// SetTimeout adds the timeout to the ark service send tree signatures params
|
||||
func (o *ArkServiceSendTreeSignaturesParams) SetTimeout(timeout time.Duration) {
|
||||
o.timeout = timeout
|
||||
}
|
||||
|
||||
// WithContext adds the context to the ark service send tree signatures params
|
||||
func (o *ArkServiceSendTreeSignaturesParams) WithContext(ctx context.Context) *ArkServiceSendTreeSignaturesParams {
|
||||
o.SetContext(ctx)
|
||||
return o
|
||||
}
|
||||
|
||||
// SetContext adds the context to the ark service send tree signatures params
|
||||
func (o *ArkServiceSendTreeSignaturesParams) SetContext(ctx context.Context) {
|
||||
o.Context = ctx
|
||||
}
|
||||
|
||||
// WithHTTPClient adds the HTTPClient to the ark service send tree signatures params
|
||||
func (o *ArkServiceSendTreeSignaturesParams) WithHTTPClient(client *http.Client) *ArkServiceSendTreeSignaturesParams {
|
||||
o.SetHTTPClient(client)
|
||||
return o
|
||||
}
|
||||
|
||||
// SetHTTPClient adds the HTTPClient to the ark service send tree signatures params
|
||||
func (o *ArkServiceSendTreeSignaturesParams) SetHTTPClient(client *http.Client) {
|
||||
o.HTTPClient = client
|
||||
}
|
||||
|
||||
// WithBody adds the body to the ark service send tree signatures params
|
||||
func (o *ArkServiceSendTreeSignaturesParams) WithBody(body *models.V1SendTreeSignaturesRequest) *ArkServiceSendTreeSignaturesParams {
|
||||
o.SetBody(body)
|
||||
return o
|
||||
}
|
||||
|
||||
// SetBody adds the body to the ark service send tree signatures params
|
||||
func (o *ArkServiceSendTreeSignaturesParams) SetBody(body *models.V1SendTreeSignaturesRequest) {
|
||||
o.Body = body
|
||||
}
|
||||
|
||||
// WriteToRequest writes these params to a swagger request
|
||||
func (o *ArkServiceSendTreeSignaturesParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {
|
||||
|
||||
if err := r.SetTimeout(o.timeout); err != nil {
|
||||
return err
|
||||
}
|
||||
var res []error
|
||||
if o.Body != nil {
|
||||
if err := r.SetBodyParam(o.Body); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
if len(res) > 0 {
|
||||
return errors.CompositeValidationError(res...)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -1,185 +0,0 @@
|
||||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
package ark_service
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the swagger generate command
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io"
|
||||
|
||||
"github.com/go-openapi/runtime"
|
||||
"github.com/go-openapi/strfmt"
|
||||
|
||||
"github.com/ark-network/ark/pkg/client-sdk/client/rest/service/models"
|
||||
)
|
||||
|
||||
// ArkServiceSendTreeSignaturesReader is a Reader for the ArkServiceSendTreeSignatures structure.
|
||||
type ArkServiceSendTreeSignaturesReader struct {
|
||||
formats strfmt.Registry
|
||||
}
|
||||
|
||||
// ReadResponse reads a server response into the received o.
|
||||
func (o *ArkServiceSendTreeSignaturesReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) {
|
||||
switch response.Code() {
|
||||
case 200:
|
||||
result := NewArkServiceSendTreeSignaturesOK()
|
||||
if err := result.readResponse(response, consumer, o.formats); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return result, nil
|
||||
default:
|
||||
result := NewArkServiceSendTreeSignaturesDefault(response.Code())
|
||||
if err := result.readResponse(response, consumer, o.formats); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if response.Code()/100 == 2 {
|
||||
return result, nil
|
||||
}
|
||||
return nil, result
|
||||
}
|
||||
}
|
||||
|
||||
// NewArkServiceSendTreeSignaturesOK creates a ArkServiceSendTreeSignaturesOK with default headers values
|
||||
func NewArkServiceSendTreeSignaturesOK() *ArkServiceSendTreeSignaturesOK {
|
||||
return &ArkServiceSendTreeSignaturesOK{}
|
||||
}
|
||||
|
||||
/*
|
||||
ArkServiceSendTreeSignaturesOK describes a response with status code 200, with default header values.
|
||||
|
||||
A successful response.
|
||||
*/
|
||||
type ArkServiceSendTreeSignaturesOK struct {
|
||||
Payload models.V1SendTreeSignaturesResponse
|
||||
}
|
||||
|
||||
// IsSuccess returns true when this ark service send tree signatures o k response has a 2xx status code
|
||||
func (o *ArkServiceSendTreeSignaturesOK) IsSuccess() bool {
|
||||
return true
|
||||
}
|
||||
|
||||
// IsRedirect returns true when this ark service send tree signatures o k response has a 3xx status code
|
||||
func (o *ArkServiceSendTreeSignaturesOK) IsRedirect() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
// IsClientError returns true when this ark service send tree signatures o k response has a 4xx status code
|
||||
func (o *ArkServiceSendTreeSignaturesOK) IsClientError() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
// IsServerError returns true when this ark service send tree signatures o k response has a 5xx status code
|
||||
func (o *ArkServiceSendTreeSignaturesOK) IsServerError() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
// IsCode returns true when this ark service send tree signatures o k response a status code equal to that given
|
||||
func (o *ArkServiceSendTreeSignaturesOK) IsCode(code int) bool {
|
||||
return code == 200
|
||||
}
|
||||
|
||||
// Code gets the status code for the ark service send tree signatures o k response
|
||||
func (o *ArkServiceSendTreeSignaturesOK) Code() int {
|
||||
return 200
|
||||
}
|
||||
|
||||
func (o *ArkServiceSendTreeSignaturesOK) Error() string {
|
||||
payload, _ := json.Marshal(o.Payload)
|
||||
return fmt.Sprintf("[POST /v1/payment/tree/signatures][%d] arkServiceSendTreeSignaturesOK %s", 200, payload)
|
||||
}
|
||||
|
||||
func (o *ArkServiceSendTreeSignaturesOK) String() string {
|
||||
payload, _ := json.Marshal(o.Payload)
|
||||
return fmt.Sprintf("[POST /v1/payment/tree/signatures][%d] arkServiceSendTreeSignaturesOK %s", 200, payload)
|
||||
}
|
||||
|
||||
func (o *ArkServiceSendTreeSignaturesOK) GetPayload() models.V1SendTreeSignaturesResponse {
|
||||
return o.Payload
|
||||
}
|
||||
|
||||
func (o *ArkServiceSendTreeSignaturesOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
|
||||
|
||||
// response payload
|
||||
if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// NewArkServiceSendTreeSignaturesDefault creates a ArkServiceSendTreeSignaturesDefault with default headers values
|
||||
func NewArkServiceSendTreeSignaturesDefault(code int) *ArkServiceSendTreeSignaturesDefault {
|
||||
return &ArkServiceSendTreeSignaturesDefault{
|
||||
_statusCode: code,
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
ArkServiceSendTreeSignaturesDefault describes a response with status code -1, with default header values.
|
||||
|
||||
An unexpected error response.
|
||||
*/
|
||||
type ArkServiceSendTreeSignaturesDefault struct {
|
||||
_statusCode int
|
||||
|
||||
Payload *models.RPCStatus
|
||||
}
|
||||
|
||||
// IsSuccess returns true when this ark service send tree signatures default response has a 2xx status code
|
||||
func (o *ArkServiceSendTreeSignaturesDefault) IsSuccess() bool {
|
||||
return o._statusCode/100 == 2
|
||||
}
|
||||
|
||||
// IsRedirect returns true when this ark service send tree signatures default response has a 3xx status code
|
||||
func (o *ArkServiceSendTreeSignaturesDefault) IsRedirect() bool {
|
||||
return o._statusCode/100 == 3
|
||||
}
|
||||
|
||||
// IsClientError returns true when this ark service send tree signatures default response has a 4xx status code
|
||||
func (o *ArkServiceSendTreeSignaturesDefault) IsClientError() bool {
|
||||
return o._statusCode/100 == 4
|
||||
}
|
||||
|
||||
// IsServerError returns true when this ark service send tree signatures default response has a 5xx status code
|
||||
func (o *ArkServiceSendTreeSignaturesDefault) IsServerError() bool {
|
||||
return o._statusCode/100 == 5
|
||||
}
|
||||
|
||||
// IsCode returns true when this ark service send tree signatures default response a status code equal to that given
|
||||
func (o *ArkServiceSendTreeSignaturesDefault) IsCode(code int) bool {
|
||||
return o._statusCode == code
|
||||
}
|
||||
|
||||
// Code gets the status code for the ark service send tree signatures default response
|
||||
func (o *ArkServiceSendTreeSignaturesDefault) Code() int {
|
||||
return o._statusCode
|
||||
}
|
||||
|
||||
func (o *ArkServiceSendTreeSignaturesDefault) Error() string {
|
||||
payload, _ := json.Marshal(o.Payload)
|
||||
return fmt.Sprintf("[POST /v1/payment/tree/signatures][%d] ArkService_SendTreeSignatures default %s", o._statusCode, payload)
|
||||
}
|
||||
|
||||
func (o *ArkServiceSendTreeSignaturesDefault) String() string {
|
||||
payload, _ := json.Marshal(o.Payload)
|
||||
return fmt.Sprintf("[POST /v1/payment/tree/signatures][%d] ArkService_SendTreeSignatures default %s", o._statusCode, payload)
|
||||
}
|
||||
|
||||
func (o *ArkServiceSendTreeSignaturesDefault) GetPayload() *models.RPCStatus {
|
||||
return o.Payload
|
||||
}
|
||||
|
||||
func (o *ArkServiceSendTreeSignaturesDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
|
||||
|
||||
o.Payload = new(models.RPCStatus)
|
||||
|
||||
// response payload
|
||||
if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
@@ -0,0 +1,150 @@
|
||||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
package ark_service
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the swagger generate command
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
"time"
|
||||
|
||||
"github.com/go-openapi/errors"
|
||||
"github.com/go-openapi/runtime"
|
||||
cr "github.com/go-openapi/runtime/client"
|
||||
"github.com/go-openapi/strfmt"
|
||||
|
||||
"github.com/ark-network/ark/pkg/client-sdk/client/rest/service/models"
|
||||
)
|
||||
|
||||
// NewArkServiceSubmitRedeemTxParams creates a new ArkServiceSubmitRedeemTxParams object,
|
||||
// with the default timeout for this client.
|
||||
//
|
||||
// Default values are not hydrated, since defaults are normally applied by the API server side.
|
||||
//
|
||||
// To enforce default values in parameter, use SetDefaults or WithDefaults.
|
||||
func NewArkServiceSubmitRedeemTxParams() *ArkServiceSubmitRedeemTxParams {
|
||||
return &ArkServiceSubmitRedeemTxParams{
|
||||
timeout: cr.DefaultTimeout,
|
||||
}
|
||||
}
|
||||
|
||||
// NewArkServiceSubmitRedeemTxParamsWithTimeout creates a new ArkServiceSubmitRedeemTxParams object
|
||||
// with the ability to set a timeout on a request.
|
||||
func NewArkServiceSubmitRedeemTxParamsWithTimeout(timeout time.Duration) *ArkServiceSubmitRedeemTxParams {
|
||||
return &ArkServiceSubmitRedeemTxParams{
|
||||
timeout: timeout,
|
||||
}
|
||||
}
|
||||
|
||||
// NewArkServiceSubmitRedeemTxParamsWithContext creates a new ArkServiceSubmitRedeemTxParams object
|
||||
// with the ability to set a context for a request.
|
||||
func NewArkServiceSubmitRedeemTxParamsWithContext(ctx context.Context) *ArkServiceSubmitRedeemTxParams {
|
||||
return &ArkServiceSubmitRedeemTxParams{
|
||||
Context: ctx,
|
||||
}
|
||||
}
|
||||
|
||||
// NewArkServiceSubmitRedeemTxParamsWithHTTPClient creates a new ArkServiceSubmitRedeemTxParams object
|
||||
// with the ability to set a custom HTTPClient for a request.
|
||||
func NewArkServiceSubmitRedeemTxParamsWithHTTPClient(client *http.Client) *ArkServiceSubmitRedeemTxParams {
|
||||
return &ArkServiceSubmitRedeemTxParams{
|
||||
HTTPClient: client,
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
ArkServiceSubmitRedeemTxParams contains all the parameters to send to the API endpoint
|
||||
|
||||
for the ark service submit redeem tx operation.
|
||||
|
||||
Typically these are written to a http.Request.
|
||||
*/
|
||||
type ArkServiceSubmitRedeemTxParams struct {
|
||||
|
||||
// Body.
|
||||
Body *models.V1SubmitRedeemTxRequest
|
||||
|
||||
timeout time.Duration
|
||||
Context context.Context
|
||||
HTTPClient *http.Client
|
||||
}
|
||||
|
||||
// WithDefaults hydrates default values in the ark service submit redeem tx params (not the query body).
|
||||
//
|
||||
// All values with no default are reset to their zero value.
|
||||
func (o *ArkServiceSubmitRedeemTxParams) WithDefaults() *ArkServiceSubmitRedeemTxParams {
|
||||
o.SetDefaults()
|
||||
return o
|
||||
}
|
||||
|
||||
// SetDefaults hydrates default values in the ark service submit redeem tx params (not the query body).
|
||||
//
|
||||
// All values with no default are reset to their zero value.
|
||||
func (o *ArkServiceSubmitRedeemTxParams) SetDefaults() {
|
||||
// no default values defined for this parameter
|
||||
}
|
||||
|
||||
// WithTimeout adds the timeout to the ark service submit redeem tx params
|
||||
func (o *ArkServiceSubmitRedeemTxParams) WithTimeout(timeout time.Duration) *ArkServiceSubmitRedeemTxParams {
|
||||
o.SetTimeout(timeout)
|
||||
return o
|
||||
}
|
||||
|
||||
// SetTimeout adds the timeout to the ark service submit redeem tx params
|
||||
func (o *ArkServiceSubmitRedeemTxParams) SetTimeout(timeout time.Duration) {
|
||||
o.timeout = timeout
|
||||
}
|
||||
|
||||
// WithContext adds the context to the ark service submit redeem tx params
|
||||
func (o *ArkServiceSubmitRedeemTxParams) WithContext(ctx context.Context) *ArkServiceSubmitRedeemTxParams {
|
||||
o.SetContext(ctx)
|
||||
return o
|
||||
}
|
||||
|
||||
// SetContext adds the context to the ark service submit redeem tx params
|
||||
func (o *ArkServiceSubmitRedeemTxParams) SetContext(ctx context.Context) {
|
||||
o.Context = ctx
|
||||
}
|
||||
|
||||
// WithHTTPClient adds the HTTPClient to the ark service submit redeem tx params
|
||||
func (o *ArkServiceSubmitRedeemTxParams) WithHTTPClient(client *http.Client) *ArkServiceSubmitRedeemTxParams {
|
||||
o.SetHTTPClient(client)
|
||||
return o
|
||||
}
|
||||
|
||||
// SetHTTPClient adds the HTTPClient to the ark service submit redeem tx params
|
||||
func (o *ArkServiceSubmitRedeemTxParams) SetHTTPClient(client *http.Client) {
|
||||
o.HTTPClient = client
|
||||
}
|
||||
|
||||
// WithBody adds the body to the ark service submit redeem tx params
|
||||
func (o *ArkServiceSubmitRedeemTxParams) WithBody(body *models.V1SubmitRedeemTxRequest) *ArkServiceSubmitRedeemTxParams {
|
||||
o.SetBody(body)
|
||||
return o
|
||||
}
|
||||
|
||||
// SetBody adds the body to the ark service submit redeem tx params
|
||||
func (o *ArkServiceSubmitRedeemTxParams) SetBody(body *models.V1SubmitRedeemTxRequest) {
|
||||
o.Body = body
|
||||
}
|
||||
|
||||
// WriteToRequest writes these params to a swagger request
|
||||
func (o *ArkServiceSubmitRedeemTxParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {
|
||||
|
||||
if err := r.SetTimeout(o.timeout); err != nil {
|
||||
return err
|
||||
}
|
||||
var res []error
|
||||
if o.Body != nil {
|
||||
if err := r.SetBodyParam(o.Body); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
if len(res) > 0 {
|
||||
return errors.CompositeValidationError(res...)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -0,0 +1,187 @@
|
||||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
package ark_service
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the swagger generate command
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io"
|
||||
|
||||
"github.com/go-openapi/runtime"
|
||||
"github.com/go-openapi/strfmt"
|
||||
|
||||
"github.com/ark-network/ark/pkg/client-sdk/client/rest/service/models"
|
||||
)
|
||||
|
||||
// ArkServiceSubmitRedeemTxReader is a Reader for the ArkServiceSubmitRedeemTx structure.
|
||||
type ArkServiceSubmitRedeemTxReader struct {
|
||||
formats strfmt.Registry
|
||||
}
|
||||
|
||||
// ReadResponse reads a server response into the received o.
|
||||
func (o *ArkServiceSubmitRedeemTxReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) {
|
||||
switch response.Code() {
|
||||
case 200:
|
||||
result := NewArkServiceSubmitRedeemTxOK()
|
||||
if err := result.readResponse(response, consumer, o.formats); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return result, nil
|
||||
default:
|
||||
result := NewArkServiceSubmitRedeemTxDefault(response.Code())
|
||||
if err := result.readResponse(response, consumer, o.formats); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if response.Code()/100 == 2 {
|
||||
return result, nil
|
||||
}
|
||||
return nil, result
|
||||
}
|
||||
}
|
||||
|
||||
// NewArkServiceSubmitRedeemTxOK creates a ArkServiceSubmitRedeemTxOK with default headers values
|
||||
func NewArkServiceSubmitRedeemTxOK() *ArkServiceSubmitRedeemTxOK {
|
||||
return &ArkServiceSubmitRedeemTxOK{}
|
||||
}
|
||||
|
||||
/*
|
||||
ArkServiceSubmitRedeemTxOK describes a response with status code 200, with default header values.
|
||||
|
||||
A successful response.
|
||||
*/
|
||||
type ArkServiceSubmitRedeemTxOK struct {
|
||||
Payload *models.V1SubmitRedeemTxResponse
|
||||
}
|
||||
|
||||
// IsSuccess returns true when this ark service submit redeem tx o k response has a 2xx status code
|
||||
func (o *ArkServiceSubmitRedeemTxOK) IsSuccess() bool {
|
||||
return true
|
||||
}
|
||||
|
||||
// IsRedirect returns true when this ark service submit redeem tx o k response has a 3xx status code
|
||||
func (o *ArkServiceSubmitRedeemTxOK) IsRedirect() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
// IsClientError returns true when this ark service submit redeem tx o k response has a 4xx status code
|
||||
func (o *ArkServiceSubmitRedeemTxOK) IsClientError() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
// IsServerError returns true when this ark service submit redeem tx o k response has a 5xx status code
|
||||
func (o *ArkServiceSubmitRedeemTxOK) IsServerError() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
// IsCode returns true when this ark service submit redeem tx o k response a status code equal to that given
|
||||
func (o *ArkServiceSubmitRedeemTxOK) IsCode(code int) bool {
|
||||
return code == 200
|
||||
}
|
||||
|
||||
// Code gets the status code for the ark service submit redeem tx o k response
|
||||
func (o *ArkServiceSubmitRedeemTxOK) Code() int {
|
||||
return 200
|
||||
}
|
||||
|
||||
func (o *ArkServiceSubmitRedeemTxOK) Error() string {
|
||||
payload, _ := json.Marshal(o.Payload)
|
||||
return fmt.Sprintf("[POST /v1/redeem-tx][%d] arkServiceSubmitRedeemTxOK %s", 200, payload)
|
||||
}
|
||||
|
||||
func (o *ArkServiceSubmitRedeemTxOK) String() string {
|
||||
payload, _ := json.Marshal(o.Payload)
|
||||
return fmt.Sprintf("[POST /v1/redeem-tx][%d] arkServiceSubmitRedeemTxOK %s", 200, payload)
|
||||
}
|
||||
|
||||
func (o *ArkServiceSubmitRedeemTxOK) GetPayload() *models.V1SubmitRedeemTxResponse {
|
||||
return o.Payload
|
||||
}
|
||||
|
||||
func (o *ArkServiceSubmitRedeemTxOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
|
||||
|
||||
o.Payload = new(models.V1SubmitRedeemTxResponse)
|
||||
|
||||
// response payload
|
||||
if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// NewArkServiceSubmitRedeemTxDefault creates a ArkServiceSubmitRedeemTxDefault with default headers values
|
||||
func NewArkServiceSubmitRedeemTxDefault(code int) *ArkServiceSubmitRedeemTxDefault {
|
||||
return &ArkServiceSubmitRedeemTxDefault{
|
||||
_statusCode: code,
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
ArkServiceSubmitRedeemTxDefault describes a response with status code -1, with default header values.
|
||||
|
||||
An unexpected error response.
|
||||
*/
|
||||
type ArkServiceSubmitRedeemTxDefault struct {
|
||||
_statusCode int
|
||||
|
||||
Payload *models.RPCStatus
|
||||
}
|
||||
|
||||
// IsSuccess returns true when this ark service submit redeem tx default response has a 2xx status code
|
||||
func (o *ArkServiceSubmitRedeemTxDefault) IsSuccess() bool {
|
||||
return o._statusCode/100 == 2
|
||||
}
|
||||
|
||||
// IsRedirect returns true when this ark service submit redeem tx default response has a 3xx status code
|
||||
func (o *ArkServiceSubmitRedeemTxDefault) IsRedirect() bool {
|
||||
return o._statusCode/100 == 3
|
||||
}
|
||||
|
||||
// IsClientError returns true when this ark service submit redeem tx default response has a 4xx status code
|
||||
func (o *ArkServiceSubmitRedeemTxDefault) IsClientError() bool {
|
||||
return o._statusCode/100 == 4
|
||||
}
|
||||
|
||||
// IsServerError returns true when this ark service submit redeem tx default response has a 5xx status code
|
||||
func (o *ArkServiceSubmitRedeemTxDefault) IsServerError() bool {
|
||||
return o._statusCode/100 == 5
|
||||
}
|
||||
|
||||
// IsCode returns true when this ark service submit redeem tx default response a status code equal to that given
|
||||
func (o *ArkServiceSubmitRedeemTxDefault) IsCode(code int) bool {
|
||||
return o._statusCode == code
|
||||
}
|
||||
|
||||
// Code gets the status code for the ark service submit redeem tx default response
|
||||
func (o *ArkServiceSubmitRedeemTxDefault) Code() int {
|
||||
return o._statusCode
|
||||
}
|
||||
|
||||
func (o *ArkServiceSubmitRedeemTxDefault) Error() string {
|
||||
payload, _ := json.Marshal(o.Payload)
|
||||
return fmt.Sprintf("[POST /v1/redeem-tx][%d] ArkService_SubmitRedeemTx default %s", o._statusCode, payload)
|
||||
}
|
||||
|
||||
func (o *ArkServiceSubmitRedeemTxDefault) String() string {
|
||||
payload, _ := json.Marshal(o.Payload)
|
||||
return fmt.Sprintf("[POST /v1/redeem-tx][%d] ArkService_SubmitRedeemTx default %s", o._statusCode, payload)
|
||||
}
|
||||
|
||||
func (o *ArkServiceSubmitRedeemTxDefault) GetPayload() *models.RPCStatus {
|
||||
return o.Payload
|
||||
}
|
||||
|
||||
func (o *ArkServiceSubmitRedeemTxDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
|
||||
|
||||
o.Payload = new(models.RPCStatus)
|
||||
|
||||
// response payload
|
||||
if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
@@ -1,150 +0,0 @@
|
||||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
package ark_service
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the swagger generate command
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
"time"
|
||||
|
||||
"github.com/go-openapi/errors"
|
||||
"github.com/go-openapi/runtime"
|
||||
cr "github.com/go-openapi/runtime/client"
|
||||
"github.com/go-openapi/strfmt"
|
||||
|
||||
"github.com/ark-network/ark/pkg/client-sdk/client/rest/service/models"
|
||||
)
|
||||
|
||||
// NewArkServiceSubmitSignedForfeitTransactionsParams creates a new ArkServiceSubmitSignedForfeitTransactionsParams object,
|
||||
// with the default timeout for this client.
|
||||
//
|
||||
// Default values are not hydrated, since defaults are normally applied by the API server side.
|
||||
//
|
||||
// To enforce default values in parameter, use SetDefaults or WithDefaults.
|
||||
func NewArkServiceSubmitSignedForfeitTransactionsParams() *ArkServiceSubmitSignedForfeitTransactionsParams {
|
||||
return &ArkServiceSubmitSignedForfeitTransactionsParams{
|
||||
timeout: cr.DefaultTimeout,
|
||||
}
|
||||
}
|
||||
|
||||
// NewArkServiceSubmitSignedForfeitTransactionsParamsWithTimeout creates a new ArkServiceSubmitSignedForfeitTransactionsParams object
|
||||
// with the ability to set a timeout on a request.
|
||||
func NewArkServiceSubmitSignedForfeitTransactionsParamsWithTimeout(timeout time.Duration) *ArkServiceSubmitSignedForfeitTransactionsParams {
|
||||
return &ArkServiceSubmitSignedForfeitTransactionsParams{
|
||||
timeout: timeout,
|
||||
}
|
||||
}
|
||||
|
||||
// NewArkServiceSubmitSignedForfeitTransactionsParamsWithContext creates a new ArkServiceSubmitSignedForfeitTransactionsParams object
|
||||
// with the ability to set a context for a request.
|
||||
func NewArkServiceSubmitSignedForfeitTransactionsParamsWithContext(ctx context.Context) *ArkServiceSubmitSignedForfeitTransactionsParams {
|
||||
return &ArkServiceSubmitSignedForfeitTransactionsParams{
|
||||
Context: ctx,
|
||||
}
|
||||
}
|
||||
|
||||
// NewArkServiceSubmitSignedForfeitTransactionsParamsWithHTTPClient creates a new ArkServiceSubmitSignedForfeitTransactionsParams object
|
||||
// with the ability to set a custom HTTPClient for a request.
|
||||
func NewArkServiceSubmitSignedForfeitTransactionsParamsWithHTTPClient(client *http.Client) *ArkServiceSubmitSignedForfeitTransactionsParams {
|
||||
return &ArkServiceSubmitSignedForfeitTransactionsParams{
|
||||
HTTPClient: client,
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
ArkServiceSubmitSignedForfeitTransactionsParams contains all the parameters to send to the API endpoint
|
||||
|
||||
for the ark service submit signed forfeit transactions operation.
|
||||
|
||||
Typically these are written to a http.Request.
|
||||
*/
|
||||
type ArkServiceSubmitSignedForfeitTransactionsParams struct {
|
||||
|
||||
// Body.
|
||||
Body *models.V1SubmitSignedForfeitTransactionsRequest
|
||||
|
||||
timeout time.Duration
|
||||
Context context.Context
|
||||
HTTPClient *http.Client
|
||||
}
|
||||
|
||||
// WithDefaults hydrates default values in the ark service submit signed forfeit transactions params (not the query body).
|
||||
//
|
||||
// All values with no default are reset to their zero value.
|
||||
func (o *ArkServiceSubmitSignedForfeitTransactionsParams) WithDefaults() *ArkServiceSubmitSignedForfeitTransactionsParams {
|
||||
o.SetDefaults()
|
||||
return o
|
||||
}
|
||||
|
||||
// SetDefaults hydrates default values in the ark service submit signed forfeit transactions params (not the query body).
|
||||
//
|
||||
// All values with no default are reset to their zero value.
|
||||
func (o *ArkServiceSubmitSignedForfeitTransactionsParams) SetDefaults() {
|
||||
// no default values defined for this parameter
|
||||
}
|
||||
|
||||
// WithTimeout adds the timeout to the ark service submit signed forfeit transactions params
|
||||
func (o *ArkServiceSubmitSignedForfeitTransactionsParams) WithTimeout(timeout time.Duration) *ArkServiceSubmitSignedForfeitTransactionsParams {
|
||||
o.SetTimeout(timeout)
|
||||
return o
|
||||
}
|
||||
|
||||
// SetTimeout adds the timeout to the ark service submit signed forfeit transactions params
|
||||
func (o *ArkServiceSubmitSignedForfeitTransactionsParams) SetTimeout(timeout time.Duration) {
|
||||
o.timeout = timeout
|
||||
}
|
||||
|
||||
// WithContext adds the context to the ark service submit signed forfeit transactions params
|
||||
func (o *ArkServiceSubmitSignedForfeitTransactionsParams) WithContext(ctx context.Context) *ArkServiceSubmitSignedForfeitTransactionsParams {
|
||||
o.SetContext(ctx)
|
||||
return o
|
||||
}
|
||||
|
||||
// SetContext adds the context to the ark service submit signed forfeit transactions params
|
||||
func (o *ArkServiceSubmitSignedForfeitTransactionsParams) SetContext(ctx context.Context) {
|
||||
o.Context = ctx
|
||||
}
|
||||
|
||||
// WithHTTPClient adds the HTTPClient to the ark service submit signed forfeit transactions params
|
||||
func (o *ArkServiceSubmitSignedForfeitTransactionsParams) WithHTTPClient(client *http.Client) *ArkServiceSubmitSignedForfeitTransactionsParams {
|
||||
o.SetHTTPClient(client)
|
||||
return o
|
||||
}
|
||||
|
||||
// SetHTTPClient adds the HTTPClient to the ark service submit signed forfeit transactions params
|
||||
func (o *ArkServiceSubmitSignedForfeitTransactionsParams) SetHTTPClient(client *http.Client) {
|
||||
o.HTTPClient = client
|
||||
}
|
||||
|
||||
// WithBody adds the body to the ark service submit signed forfeit transactions params
|
||||
func (o *ArkServiceSubmitSignedForfeitTransactionsParams) WithBody(body *models.V1SubmitSignedForfeitTransactionsRequest) *ArkServiceSubmitSignedForfeitTransactionsParams {
|
||||
o.SetBody(body)
|
||||
return o
|
||||
}
|
||||
|
||||
// SetBody adds the body to the ark service submit signed forfeit transactions params
|
||||
func (o *ArkServiceSubmitSignedForfeitTransactionsParams) SetBody(body *models.V1SubmitSignedForfeitTransactionsRequest) {
|
||||
o.Body = body
|
||||
}
|
||||
|
||||
// WriteToRequest writes these params to a swagger request
|
||||
func (o *ArkServiceSubmitSignedForfeitTransactionsParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {
|
||||
|
||||
if err := r.SetTimeout(o.timeout); err != nil {
|
||||
return err
|
||||
}
|
||||
var res []error
|
||||
if o.Body != nil {
|
||||
if err := r.SetBodyParam(o.Body); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
if len(res) > 0 {
|
||||
return errors.CompositeValidationError(res...)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -1,185 +0,0 @@
|
||||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
package ark_service
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the swagger generate command
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io"
|
||||
|
||||
"github.com/go-openapi/runtime"
|
||||
"github.com/go-openapi/strfmt"
|
||||
|
||||
"github.com/ark-network/ark/pkg/client-sdk/client/rest/service/models"
|
||||
)
|
||||
|
||||
// ArkServiceSubmitSignedForfeitTransactionsReader is a Reader for the ArkServiceSubmitSignedForfeitTransactions structure.
|
||||
type ArkServiceSubmitSignedForfeitTransactionsReader struct {
|
||||
formats strfmt.Registry
|
||||
}
|
||||
|
||||
// ReadResponse reads a server response into the received o.
|
||||
func (o *ArkServiceSubmitSignedForfeitTransactionsReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) {
|
||||
switch response.Code() {
|
||||
case 200:
|
||||
result := NewArkServiceSubmitSignedForfeitTransactionsOK()
|
||||
if err := result.readResponse(response, consumer, o.formats); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return result, nil
|
||||
default:
|
||||
result := NewArkServiceSubmitSignedForfeitTransactionsDefault(response.Code())
|
||||
if err := result.readResponse(response, consumer, o.formats); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if response.Code()/100 == 2 {
|
||||
return result, nil
|
||||
}
|
||||
return nil, result
|
||||
}
|
||||
}
|
||||
|
||||
// NewArkServiceSubmitSignedForfeitTransactionsOK creates a ArkServiceSubmitSignedForfeitTransactionsOK with default headers values
|
||||
func NewArkServiceSubmitSignedForfeitTransactionsOK() *ArkServiceSubmitSignedForfeitTransactionsOK {
|
||||
return &ArkServiceSubmitSignedForfeitTransactionsOK{}
|
||||
}
|
||||
|
||||
/*
|
||||
ArkServiceSubmitSignedForfeitTransactionsOK describes a response with status code 200, with default header values.
|
||||
|
||||
A successful response.
|
||||
*/
|
||||
type ArkServiceSubmitSignedForfeitTransactionsOK struct {
|
||||
Payload models.V1SubmitSignedForfeitTransactionsResponse
|
||||
}
|
||||
|
||||
// IsSuccess returns true when this ark service submit signed forfeit transactions o k response has a 2xx status code
|
||||
func (o *ArkServiceSubmitSignedForfeitTransactionsOK) IsSuccess() bool {
|
||||
return true
|
||||
}
|
||||
|
||||
// IsRedirect returns true when this ark service submit signed forfeit transactions o k response has a 3xx status code
|
||||
func (o *ArkServiceSubmitSignedForfeitTransactionsOK) IsRedirect() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
// IsClientError returns true when this ark service submit signed forfeit transactions o k response has a 4xx status code
|
||||
func (o *ArkServiceSubmitSignedForfeitTransactionsOK) IsClientError() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
// IsServerError returns true when this ark service submit signed forfeit transactions o k response has a 5xx status code
|
||||
func (o *ArkServiceSubmitSignedForfeitTransactionsOK) IsServerError() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
// IsCode returns true when this ark service submit signed forfeit transactions o k response a status code equal to that given
|
||||
func (o *ArkServiceSubmitSignedForfeitTransactionsOK) IsCode(code int) bool {
|
||||
return code == 200
|
||||
}
|
||||
|
||||
// Code gets the status code for the ark service submit signed forfeit transactions o k response
|
||||
func (o *ArkServiceSubmitSignedForfeitTransactionsOK) Code() int {
|
||||
return 200
|
||||
}
|
||||
|
||||
func (o *ArkServiceSubmitSignedForfeitTransactionsOK) Error() string {
|
||||
payload, _ := json.Marshal(o.Payload)
|
||||
return fmt.Sprintf("[POST /v1/round/submitForfeitTxs][%d] arkServiceSubmitSignedForfeitTransactionsOK %s", 200, payload)
|
||||
}
|
||||
|
||||
func (o *ArkServiceSubmitSignedForfeitTransactionsOK) String() string {
|
||||
payload, _ := json.Marshal(o.Payload)
|
||||
return fmt.Sprintf("[POST /v1/round/submitForfeitTxs][%d] arkServiceSubmitSignedForfeitTransactionsOK %s", 200, payload)
|
||||
}
|
||||
|
||||
func (o *ArkServiceSubmitSignedForfeitTransactionsOK) GetPayload() models.V1SubmitSignedForfeitTransactionsResponse {
|
||||
return o.Payload
|
||||
}
|
||||
|
||||
func (o *ArkServiceSubmitSignedForfeitTransactionsOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
|
||||
|
||||
// response payload
|
||||
if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// NewArkServiceSubmitSignedForfeitTransactionsDefault creates a ArkServiceSubmitSignedForfeitTransactionsDefault with default headers values
|
||||
func NewArkServiceSubmitSignedForfeitTransactionsDefault(code int) *ArkServiceSubmitSignedForfeitTransactionsDefault {
|
||||
return &ArkServiceSubmitSignedForfeitTransactionsDefault{
|
||||
_statusCode: code,
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
ArkServiceSubmitSignedForfeitTransactionsDefault describes a response with status code -1, with default header values.
|
||||
|
||||
An unexpected error response.
|
||||
*/
|
||||
type ArkServiceSubmitSignedForfeitTransactionsDefault struct {
|
||||
_statusCode int
|
||||
|
||||
Payload *models.RPCStatus
|
||||
}
|
||||
|
||||
// IsSuccess returns true when this ark service submit signed forfeit transactions default response has a 2xx status code
|
||||
func (o *ArkServiceSubmitSignedForfeitTransactionsDefault) IsSuccess() bool {
|
||||
return o._statusCode/100 == 2
|
||||
}
|
||||
|
||||
// IsRedirect returns true when this ark service submit signed forfeit transactions default response has a 3xx status code
|
||||
func (o *ArkServiceSubmitSignedForfeitTransactionsDefault) IsRedirect() bool {
|
||||
return o._statusCode/100 == 3
|
||||
}
|
||||
|
||||
// IsClientError returns true when this ark service submit signed forfeit transactions default response has a 4xx status code
|
||||
func (o *ArkServiceSubmitSignedForfeitTransactionsDefault) IsClientError() bool {
|
||||
return o._statusCode/100 == 4
|
||||
}
|
||||
|
||||
// IsServerError returns true when this ark service submit signed forfeit transactions default response has a 5xx status code
|
||||
func (o *ArkServiceSubmitSignedForfeitTransactionsDefault) IsServerError() bool {
|
||||
return o._statusCode/100 == 5
|
||||
}
|
||||
|
||||
// IsCode returns true when this ark service submit signed forfeit transactions default response a status code equal to that given
|
||||
func (o *ArkServiceSubmitSignedForfeitTransactionsDefault) IsCode(code int) bool {
|
||||
return o._statusCode == code
|
||||
}
|
||||
|
||||
// Code gets the status code for the ark service submit signed forfeit transactions default response
|
||||
func (o *ArkServiceSubmitSignedForfeitTransactionsDefault) Code() int {
|
||||
return o._statusCode
|
||||
}
|
||||
|
||||
func (o *ArkServiceSubmitSignedForfeitTransactionsDefault) Error() string {
|
||||
payload, _ := json.Marshal(o.Payload)
|
||||
return fmt.Sprintf("[POST /v1/round/submitForfeitTxs][%d] ArkService_SubmitSignedForfeitTransactions default %s", o._statusCode, payload)
|
||||
}
|
||||
|
||||
func (o *ArkServiceSubmitSignedForfeitTransactionsDefault) String() string {
|
||||
payload, _ := json.Marshal(o.Payload)
|
||||
return fmt.Sprintf("[POST /v1/round/submitForfeitTxs][%d] ArkService_SubmitSignedForfeitTransactions default %s", o._statusCode, payload)
|
||||
}
|
||||
|
||||
func (o *ArkServiceSubmitSignedForfeitTransactionsDefault) GetPayload() *models.RPCStatus {
|
||||
return o.Payload
|
||||
}
|
||||
|
||||
func (o *ArkServiceSubmitSignedForfeitTransactionsDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
|
||||
|
||||
o.Payload = new(models.RPCStatus)
|
||||
|
||||
// response payload
|
||||
if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
@@ -1,112 +0,0 @@
|
||||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
package models
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the swagger generate command
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/go-openapi/errors"
|
||||
"github.com/go-openapi/strfmt"
|
||||
"github.com/go-openapi/swag"
|
||||
)
|
||||
|
||||
// V1AsyncPaymentInput v1 async payment input
|
||||
//
|
||||
// swagger:model v1AsyncPaymentInput
|
||||
type V1AsyncPaymentInput struct {
|
||||
|
||||
// forfeit leaf hash
|
||||
ForfeitLeafHash string `json:"forfeitLeafHash,omitempty"`
|
||||
|
||||
// input
|
||||
Input *V1Input `json:"input,omitempty"`
|
||||
}
|
||||
|
||||
// Validate validates this v1 async payment input
|
||||
func (m *V1AsyncPaymentInput) Validate(formats strfmt.Registry) error {
|
||||
var res []error
|
||||
|
||||
if err := m.validateInput(formats); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
if len(res) > 0 {
|
||||
return errors.CompositeValidationError(res...)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *V1AsyncPaymentInput) validateInput(formats strfmt.Registry) error {
|
||||
if swag.IsZero(m.Input) { // not required
|
||||
return nil
|
||||
}
|
||||
|
||||
if m.Input != nil {
|
||||
if err := m.Input.Validate(formats); err != nil {
|
||||
if ve, ok := err.(*errors.Validation); ok {
|
||||
return ve.ValidateName("input")
|
||||
} else if ce, ok := err.(*errors.CompositeError); ok {
|
||||
return ce.ValidateName("input")
|
||||
}
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// ContextValidate validate this v1 async payment input based on the context it is used
|
||||
func (m *V1AsyncPaymentInput) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
|
||||
var res []error
|
||||
|
||||
if err := m.contextValidateInput(ctx, formats); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
if len(res) > 0 {
|
||||
return errors.CompositeValidationError(res...)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *V1AsyncPaymentInput) contextValidateInput(ctx context.Context, formats strfmt.Registry) error {
|
||||
|
||||
if m.Input != nil {
|
||||
|
||||
if swag.IsZero(m.Input) { // not required
|
||||
return nil
|
||||
}
|
||||
|
||||
if err := m.Input.ContextValidate(ctx, formats); err != nil {
|
||||
if ve, ok := err.(*errors.Validation); ok {
|
||||
return ve.ValidateName("input")
|
||||
} else if ce, ok := err.(*errors.CompositeError); ok {
|
||||
return ce.ValidateName("input")
|
||||
}
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// MarshalBinary interface implementation
|
||||
func (m *V1AsyncPaymentInput) MarshalBinary() ([]byte, error) {
|
||||
if m == nil {
|
||||
return nil, nil
|
||||
}
|
||||
return swag.WriteJSON(m)
|
||||
}
|
||||
|
||||
// UnmarshalBinary interface implementation
|
||||
func (m *V1AsyncPaymentInput) UnmarshalBinary(b []byte) error {
|
||||
var res V1AsyncPaymentInput
|
||||
if err := swag.ReadJSON(b, &res); err != nil {
|
||||
return err
|
||||
}
|
||||
*m = res
|
||||
return nil
|
||||
}
|
||||
@@ -1,56 +0,0 @@
|
||||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
package models
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the swagger generate command
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/go-openapi/strfmt"
|
||||
"github.com/go-openapi/swag"
|
||||
)
|
||||
|
||||
// V1BoardingInput v1 boarding input
|
||||
//
|
||||
// swagger:model v1BoardingInput
|
||||
type V1BoardingInput struct {
|
||||
|
||||
// descriptor
|
||||
Descriptor string `json:"descriptor,omitempty"`
|
||||
|
||||
// txid
|
||||
Txid string `json:"txid,omitempty"`
|
||||
|
||||
// vout
|
||||
Vout int64 `json:"vout,omitempty"`
|
||||
}
|
||||
|
||||
// Validate validates this v1 boarding input
|
||||
func (m *V1BoardingInput) Validate(formats strfmt.Registry) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// ContextValidate validates this v1 boarding input based on context it is used
|
||||
func (m *V1BoardingInput) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// MarshalBinary interface implementation
|
||||
func (m *V1BoardingInput) MarshalBinary() ([]byte, error) {
|
||||
if m == nil {
|
||||
return nil, nil
|
||||
}
|
||||
return swag.WriteJSON(m)
|
||||
}
|
||||
|
||||
// UnmarshalBinary interface implementation
|
||||
func (m *V1BoardingInput) UnmarshalBinary(b []byte) error {
|
||||
var res V1BoardingInput
|
||||
if err := swag.ReadJSON(b, &res); err != nil {
|
||||
return err
|
||||
}
|
||||
*m = res
|
||||
return nil
|
||||
}
|
||||
@@ -1,124 +0,0 @@
|
||||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
package models
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the swagger generate command
|
||||
|
||||
import (
|
||||
"context"
|
||||
"strconv"
|
||||
|
||||
"github.com/go-openapi/errors"
|
||||
"github.com/go-openapi/strfmt"
|
||||
"github.com/go-openapi/swag"
|
||||
)
|
||||
|
||||
// V1ClaimPaymentRequest v1 claim payment request
|
||||
//
|
||||
// swagger:model v1ClaimPaymentRequest
|
||||
type V1ClaimPaymentRequest struct {
|
||||
|
||||
// Mocks wabisabi's credentials.
|
||||
ID string `json:"id,omitempty"`
|
||||
|
||||
// List of receivers for a registered payment.
|
||||
Outputs []*V1Output `json:"outputs"`
|
||||
}
|
||||
|
||||
// Validate validates this v1 claim payment request
|
||||
func (m *V1ClaimPaymentRequest) Validate(formats strfmt.Registry) error {
|
||||
var res []error
|
||||
|
||||
if err := m.validateOutputs(formats); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
if len(res) > 0 {
|
||||
return errors.CompositeValidationError(res...)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *V1ClaimPaymentRequest) validateOutputs(formats strfmt.Registry) error {
|
||||
if swag.IsZero(m.Outputs) { // not required
|
||||
return nil
|
||||
}
|
||||
|
||||
for i := 0; i < len(m.Outputs); i++ {
|
||||
if swag.IsZero(m.Outputs[i]) { // not required
|
||||
continue
|
||||
}
|
||||
|
||||
if m.Outputs[i] != nil {
|
||||
if err := m.Outputs[i].Validate(formats); err != nil {
|
||||
if ve, ok := err.(*errors.Validation); ok {
|
||||
return ve.ValidateName("outputs" + "." + strconv.Itoa(i))
|
||||
} else if ce, ok := err.(*errors.CompositeError); ok {
|
||||
return ce.ValidateName("outputs" + "." + strconv.Itoa(i))
|
||||
}
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// ContextValidate validate this v1 claim payment request based on the context it is used
|
||||
func (m *V1ClaimPaymentRequest) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
|
||||
var res []error
|
||||
|
||||
if err := m.contextValidateOutputs(ctx, formats); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
if len(res) > 0 {
|
||||
return errors.CompositeValidationError(res...)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *V1ClaimPaymentRequest) contextValidateOutputs(ctx context.Context, formats strfmt.Registry) error {
|
||||
|
||||
for i := 0; i < len(m.Outputs); i++ {
|
||||
|
||||
if m.Outputs[i] != nil {
|
||||
|
||||
if swag.IsZero(m.Outputs[i]) { // not required
|
||||
return nil
|
||||
}
|
||||
|
||||
if err := m.Outputs[i].ContextValidate(ctx, formats); err != nil {
|
||||
if ve, ok := err.(*errors.Validation); ok {
|
||||
return ve.ValidateName("outputs" + "." + strconv.Itoa(i))
|
||||
} else if ce, ok := err.(*errors.CompositeError); ok {
|
||||
return ce.ValidateName("outputs" + "." + strconv.Itoa(i))
|
||||
}
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// MarshalBinary interface implementation
|
||||
func (m *V1ClaimPaymentRequest) MarshalBinary() ([]byte, error) {
|
||||
if m == nil {
|
||||
return nil, nil
|
||||
}
|
||||
return swag.WriteJSON(m)
|
||||
}
|
||||
|
||||
// UnmarshalBinary interface implementation
|
||||
func (m *V1ClaimPaymentRequest) UnmarshalBinary(b []byte) error {
|
||||
var res V1ClaimPaymentRequest
|
||||
if err := swag.ReadJSON(b, &res); err != nil {
|
||||
return err
|
||||
}
|
||||
*m = res
|
||||
return nil
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
package models
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the swagger generate command
|
||||
|
||||
// V1ClaimPaymentResponse v1 claim payment response
|
||||
//
|
||||
// swagger:model v1ClaimPaymentResponse
|
||||
type V1ClaimPaymentResponse interface{}
|
||||
@@ -1,11 +0,0 @@
|
||||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
package models
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the swagger generate command
|
||||
|
||||
// V1CompletePaymentResponse v1 complete payment response
|
||||
//
|
||||
// swagger:model v1CompletePaymentResponse
|
||||
type V1CompletePaymentResponse interface{}
|
||||
@@ -1,183 +0,0 @@
|
||||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
package models
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the swagger generate command
|
||||
|
||||
import (
|
||||
"context"
|
||||
"strconv"
|
||||
|
||||
"github.com/go-openapi/errors"
|
||||
"github.com/go-openapi/strfmt"
|
||||
"github.com/go-openapi/swag"
|
||||
)
|
||||
|
||||
// V1CreatePaymentRequest v1 create payment request
|
||||
//
|
||||
// swagger:model v1CreatePaymentRequest
|
||||
type V1CreatePaymentRequest struct {
|
||||
|
||||
// inputs
|
||||
Inputs []*V1AsyncPaymentInput `json:"inputs"`
|
||||
|
||||
// outputs
|
||||
Outputs []*V1Output `json:"outputs"`
|
||||
}
|
||||
|
||||
// Validate validates this v1 create payment request
|
||||
func (m *V1CreatePaymentRequest) Validate(formats strfmt.Registry) error {
|
||||
var res []error
|
||||
|
||||
if err := m.validateInputs(formats); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
if err := m.validateOutputs(formats); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
if len(res) > 0 {
|
||||
return errors.CompositeValidationError(res...)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *V1CreatePaymentRequest) validateInputs(formats strfmt.Registry) error {
|
||||
if swag.IsZero(m.Inputs) { // not required
|
||||
return nil
|
||||
}
|
||||
|
||||
for i := 0; i < len(m.Inputs); i++ {
|
||||
if swag.IsZero(m.Inputs[i]) { // not required
|
||||
continue
|
||||
}
|
||||
|
||||
if m.Inputs[i] != nil {
|
||||
if err := m.Inputs[i].Validate(formats); err != nil {
|
||||
if ve, ok := err.(*errors.Validation); ok {
|
||||
return ve.ValidateName("inputs" + "." + strconv.Itoa(i))
|
||||
} else if ce, ok := err.(*errors.CompositeError); ok {
|
||||
return ce.ValidateName("inputs" + "." + strconv.Itoa(i))
|
||||
}
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *V1CreatePaymentRequest) validateOutputs(formats strfmt.Registry) error {
|
||||
if swag.IsZero(m.Outputs) { // not required
|
||||
return nil
|
||||
}
|
||||
|
||||
for i := 0; i < len(m.Outputs); i++ {
|
||||
if swag.IsZero(m.Outputs[i]) { // not required
|
||||
continue
|
||||
}
|
||||
|
||||
if m.Outputs[i] != nil {
|
||||
if err := m.Outputs[i].Validate(formats); err != nil {
|
||||
if ve, ok := err.(*errors.Validation); ok {
|
||||
return ve.ValidateName("outputs" + "." + strconv.Itoa(i))
|
||||
} else if ce, ok := err.(*errors.CompositeError); ok {
|
||||
return ce.ValidateName("outputs" + "." + strconv.Itoa(i))
|
||||
}
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// ContextValidate validate this v1 create payment request based on the context it is used
|
||||
func (m *V1CreatePaymentRequest) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
|
||||
var res []error
|
||||
|
||||
if err := m.contextValidateInputs(ctx, formats); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
if err := m.contextValidateOutputs(ctx, formats); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
if len(res) > 0 {
|
||||
return errors.CompositeValidationError(res...)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *V1CreatePaymentRequest) contextValidateInputs(ctx context.Context, formats strfmt.Registry) error {
|
||||
|
||||
for i := 0; i < len(m.Inputs); i++ {
|
||||
|
||||
if m.Inputs[i] != nil {
|
||||
|
||||
if swag.IsZero(m.Inputs[i]) { // not required
|
||||
return nil
|
||||
}
|
||||
|
||||
if err := m.Inputs[i].ContextValidate(ctx, formats); err != nil {
|
||||
if ve, ok := err.(*errors.Validation); ok {
|
||||
return ve.ValidateName("inputs" + "." + strconv.Itoa(i))
|
||||
} else if ce, ok := err.(*errors.CompositeError); ok {
|
||||
return ce.ValidateName("inputs" + "." + strconv.Itoa(i))
|
||||
}
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *V1CreatePaymentRequest) contextValidateOutputs(ctx context.Context, formats strfmt.Registry) error {
|
||||
|
||||
for i := 0; i < len(m.Outputs); i++ {
|
||||
|
||||
if m.Outputs[i] != nil {
|
||||
|
||||
if swag.IsZero(m.Outputs[i]) { // not required
|
||||
return nil
|
||||
}
|
||||
|
||||
if err := m.Outputs[i].ContextValidate(ctx, formats); err != nil {
|
||||
if ve, ok := err.(*errors.Validation); ok {
|
||||
return ve.ValidateName("outputs" + "." + strconv.Itoa(i))
|
||||
} else if ce, ok := err.(*errors.CompositeError); ok {
|
||||
return ce.ValidateName("outputs" + "." + strconv.Itoa(i))
|
||||
}
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// MarshalBinary interface implementation
|
||||
func (m *V1CreatePaymentRequest) MarshalBinary() ([]byte, error) {
|
||||
if m == nil {
|
||||
return nil, nil
|
||||
}
|
||||
return swag.WriteJSON(m)
|
||||
}
|
||||
|
||||
// UnmarshalBinary interface implementation
|
||||
func (m *V1CreatePaymentRequest) UnmarshalBinary(b []byte) error {
|
||||
var res V1CreatePaymentRequest
|
||||
if err := swag.ReadJSON(b, &res); err != nil {
|
||||
return err
|
||||
}
|
||||
*m = res
|
||||
return nil
|
||||
}
|
||||
@@ -1,50 +0,0 @@
|
||||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
package models
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the swagger generate command
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/go-openapi/strfmt"
|
||||
"github.com/go-openapi/swag"
|
||||
)
|
||||
|
||||
// V1CreatePaymentResponse v1 create payment response
|
||||
//
|
||||
// swagger:model v1CreatePaymentResponse
|
||||
type V1CreatePaymentResponse struct {
|
||||
|
||||
// signed only by the ASP
|
||||
SignedRedeemTx string `json:"signedRedeemTx,omitempty"`
|
||||
}
|
||||
|
||||
// Validate validates this v1 create payment response
|
||||
func (m *V1CreatePaymentResponse) Validate(formats strfmt.Registry) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// ContextValidate validates this v1 create payment response based on context it is used
|
||||
func (m *V1CreatePaymentResponse) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// MarshalBinary interface implementation
|
||||
func (m *V1CreatePaymentResponse) MarshalBinary() ([]byte, error) {
|
||||
if m == nil {
|
||||
return nil, nil
|
||||
}
|
||||
return swag.WriteJSON(m)
|
||||
}
|
||||
|
||||
// UnmarshalBinary interface implementation
|
||||
func (m *V1CreatePaymentResponse) UnmarshalBinary(b []byte) error {
|
||||
var res V1CreatePaymentResponse
|
||||
if err := swag.ReadJSON(b, &res); err != nil {
|
||||
return err
|
||||
}
|
||||
*m = res
|
||||
return nil
|
||||
}
|
||||
@@ -1,53 +0,0 @@
|
||||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
package models
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the swagger generate command
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/go-openapi/strfmt"
|
||||
"github.com/go-openapi/swag"
|
||||
)
|
||||
|
||||
// V1FinalizePaymentRequest v1 finalize payment request
|
||||
//
|
||||
// swagger:model v1FinalizePaymentRequest
|
||||
type V1FinalizePaymentRequest struct {
|
||||
|
||||
// Forfeit txs signed by the user.
|
||||
SignedForfeitTxs []string `json:"signedForfeitTxs"`
|
||||
|
||||
// If payment has boarding input, the user must sign the associated inputs.
|
||||
SignedRoundTx string `json:"signedRoundTx,omitempty"`
|
||||
}
|
||||
|
||||
// Validate validates this v1 finalize payment request
|
||||
func (m *V1FinalizePaymentRequest) Validate(formats strfmt.Registry) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// ContextValidate validates this v1 finalize payment request based on context it is used
|
||||
func (m *V1FinalizePaymentRequest) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// MarshalBinary interface implementation
|
||||
func (m *V1FinalizePaymentRequest) MarshalBinary() ([]byte, error) {
|
||||
if m == nil {
|
||||
return nil, nil
|
||||
}
|
||||
return swag.WriteJSON(m)
|
||||
}
|
||||
|
||||
// UnmarshalBinary interface implementation
|
||||
func (m *V1FinalizePaymentRequest) UnmarshalBinary(b []byte) error {
|
||||
var res V1FinalizePaymentRequest
|
||||
if err := swag.ReadJSON(b, &res); err != nil {
|
||||
return err
|
||||
}
|
||||
*m = res
|
||||
return nil
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
package models
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the swagger generate command
|
||||
|
||||
// V1FinalizePaymentResponse v1 finalize payment response
|
||||
//
|
||||
// swagger:model v1FinalizePaymentResponse
|
||||
type V1FinalizePaymentResponse interface{}
|
||||
@@ -8,6 +8,7 @@ package models
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/go-openapi/errors"
|
||||
"github.com/go-openapi/strfmt"
|
||||
"github.com/go-openapi/swag"
|
||||
)
|
||||
@@ -26,6 +27,9 @@ type V1GetInfoResponse struct {
|
||||
// forfeit address
|
||||
ForfeitAddress string `json:"forfeitAddress,omitempty"`
|
||||
|
||||
// market hour
|
||||
MarketHour *V1MarketHour `json:"marketHour,omitempty"`
|
||||
|
||||
// network
|
||||
Network string `json:"network,omitempty"`
|
||||
|
||||
@@ -47,11 +51,69 @@ type V1GetInfoResponse struct {
|
||||
|
||||
// Validate validates this v1 get info response
|
||||
func (m *V1GetInfoResponse) Validate(formats strfmt.Registry) error {
|
||||
var res []error
|
||||
|
||||
if err := m.validateMarketHour(formats); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
if len(res) > 0 {
|
||||
return errors.CompositeValidationError(res...)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// ContextValidate validates this v1 get info response based on context it is used
|
||||
func (m *V1GetInfoResponse) validateMarketHour(formats strfmt.Registry) error {
|
||||
if swag.IsZero(m.MarketHour) { // not required
|
||||
return nil
|
||||
}
|
||||
|
||||
if m.MarketHour != nil {
|
||||
if err := m.MarketHour.Validate(formats); err != nil {
|
||||
if ve, ok := err.(*errors.Validation); ok {
|
||||
return ve.ValidateName("marketHour")
|
||||
} else if ce, ok := err.(*errors.CompositeError); ok {
|
||||
return ce.ValidateName("marketHour")
|
||||
}
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// ContextValidate validate this v1 get info response based on the context it is used
|
||||
func (m *V1GetInfoResponse) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
|
||||
var res []error
|
||||
|
||||
if err := m.contextValidateMarketHour(ctx, formats); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
if len(res) > 0 {
|
||||
return errors.CompositeValidationError(res...)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *V1GetInfoResponse) contextValidateMarketHour(ctx context.Context, formats strfmt.Registry) error {
|
||||
|
||||
if m.MarketHour != nil {
|
||||
|
||||
if swag.IsZero(m.MarketHour) { // not required
|
||||
return nil
|
||||
}
|
||||
|
||||
if err := m.MarketHour.ContextValidate(ctx, formats); err != nil {
|
||||
if ve, ok := err.(*errors.Validation); ok {
|
||||
return ve.ValidateName("marketHour")
|
||||
} else if ce, ok := err.(*errors.CompositeError); ok {
|
||||
return ce.ValidateName("marketHour")
|
||||
}
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
100
pkg/client-sdk/client/rest/service/models/v1_market_hour.go
Normal file
100
pkg/client-sdk/client/rest/service/models/v1_market_hour.go
Normal file
@@ -0,0 +1,100 @@
|
||||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
package models
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the swagger generate command
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/go-openapi/errors"
|
||||
"github.com/go-openapi/strfmt"
|
||||
"github.com/go-openapi/swag"
|
||||
"github.com/go-openapi/validate"
|
||||
)
|
||||
|
||||
// V1MarketHour v1 market hour
|
||||
//
|
||||
// swagger:model v1MarketHour
|
||||
type V1MarketHour struct {
|
||||
|
||||
// next end time
|
||||
// Format: date-time
|
||||
NextEndTime strfmt.DateTime `json:"nextEndTime,omitempty"`
|
||||
|
||||
// next start time
|
||||
// Format: date-time
|
||||
NextStartTime strfmt.DateTime `json:"nextStartTime,omitempty"`
|
||||
|
||||
// period
|
||||
Period string `json:"period,omitempty"`
|
||||
|
||||
// round interval
|
||||
RoundInterval string `json:"roundInterval,omitempty"`
|
||||
}
|
||||
|
||||
// Validate validates this v1 market hour
|
||||
func (m *V1MarketHour) Validate(formats strfmt.Registry) error {
|
||||
var res []error
|
||||
|
||||
if err := m.validateNextEndTime(formats); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
if err := m.validateNextStartTime(formats); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
if len(res) > 0 {
|
||||
return errors.CompositeValidationError(res...)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *V1MarketHour) validateNextEndTime(formats strfmt.Registry) error {
|
||||
if swag.IsZero(m.NextEndTime) { // not required
|
||||
return nil
|
||||
}
|
||||
|
||||
if err := validate.FormatOf("nextEndTime", "body", "date-time", m.NextEndTime.String(), formats); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *V1MarketHour) validateNextStartTime(formats strfmt.Registry) error {
|
||||
if swag.IsZero(m.NextStartTime) { // not required
|
||||
return nil
|
||||
}
|
||||
|
||||
if err := validate.FormatOf("nextStartTime", "body", "date-time", m.NextStartTime.String(), formats); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// ContextValidate validates this v1 market hour based on context it is used
|
||||
func (m *V1MarketHour) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// MarshalBinary interface implementation
|
||||
func (m *V1MarketHour) MarshalBinary() ([]byte, error) {
|
||||
if m == nil {
|
||||
return nil, nil
|
||||
}
|
||||
return swag.WriteJSON(m)
|
||||
}
|
||||
|
||||
// UnmarshalBinary interface implementation
|
||||
func (m *V1MarketHour) UnmarshalBinary(b []byte) error {
|
||||
var res V1MarketHour
|
||||
if err := swag.ReadJSON(b, &res); err != nil {
|
||||
return err
|
||||
}
|
||||
*m = res
|
||||
return nil
|
||||
}
|
||||
@@ -1,50 +0,0 @@
|
||||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
package models
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the swagger generate command
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/go-openapi/strfmt"
|
||||
"github.com/go-openapi/swag"
|
||||
)
|
||||
|
||||
// V1PendingPayment v1 pending payment
|
||||
//
|
||||
// swagger:model v1PendingPayment
|
||||
type V1PendingPayment struct {
|
||||
|
||||
// redeem tx
|
||||
RedeemTx string `json:"redeemTx,omitempty"`
|
||||
}
|
||||
|
||||
// Validate validates this v1 pending payment
|
||||
func (m *V1PendingPayment) Validate(formats strfmt.Registry) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// ContextValidate validates this v1 pending payment based on context it is used
|
||||
func (m *V1PendingPayment) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// MarshalBinary interface implementation
|
||||
func (m *V1PendingPayment) MarshalBinary() ([]byte, error) {
|
||||
if m == nil {
|
||||
return nil, nil
|
||||
}
|
||||
return swag.WriteJSON(m)
|
||||
}
|
||||
|
||||
// UnmarshalBinary interface implementation
|
||||
func (m *V1PendingPayment) UnmarshalBinary(b []byte) error {
|
||||
var res V1PendingPayment
|
||||
if err := swag.ReadJSON(b, &res); err != nil {
|
||||
return err
|
||||
}
|
||||
*m = res
|
||||
return nil
|
||||
}
|
||||
@@ -1,124 +0,0 @@
|
||||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
package models
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the swagger generate command
|
||||
|
||||
import (
|
||||
"context"
|
||||
"strconv"
|
||||
|
||||
"github.com/go-openapi/errors"
|
||||
"github.com/go-openapi/strfmt"
|
||||
"github.com/go-openapi/swag"
|
||||
)
|
||||
|
||||
// V1RegisterPaymentRequest v1 register payment request
|
||||
//
|
||||
// swagger:model v1RegisterPaymentRequest
|
||||
type V1RegisterPaymentRequest struct {
|
||||
|
||||
// ephemeral pubkey
|
||||
EphemeralPubkey string `json:"ephemeralPubkey,omitempty"`
|
||||
|
||||
// inputs
|
||||
Inputs []*V1Input `json:"inputs"`
|
||||
}
|
||||
|
||||
// Validate validates this v1 register payment request
|
||||
func (m *V1RegisterPaymentRequest) Validate(formats strfmt.Registry) error {
|
||||
var res []error
|
||||
|
||||
if err := m.validateInputs(formats); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
if len(res) > 0 {
|
||||
return errors.CompositeValidationError(res...)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *V1RegisterPaymentRequest) validateInputs(formats strfmt.Registry) error {
|
||||
if swag.IsZero(m.Inputs) { // not required
|
||||
return nil
|
||||
}
|
||||
|
||||
for i := 0; i < len(m.Inputs); i++ {
|
||||
if swag.IsZero(m.Inputs[i]) { // not required
|
||||
continue
|
||||
}
|
||||
|
||||
if m.Inputs[i] != nil {
|
||||
if err := m.Inputs[i].Validate(formats); err != nil {
|
||||
if ve, ok := err.(*errors.Validation); ok {
|
||||
return ve.ValidateName("inputs" + "." + strconv.Itoa(i))
|
||||
} else if ce, ok := err.(*errors.CompositeError); ok {
|
||||
return ce.ValidateName("inputs" + "." + strconv.Itoa(i))
|
||||
}
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// ContextValidate validate this v1 register payment request based on the context it is used
|
||||
func (m *V1RegisterPaymentRequest) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
|
||||
var res []error
|
||||
|
||||
if err := m.contextValidateInputs(ctx, formats); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
if len(res) > 0 {
|
||||
return errors.CompositeValidationError(res...)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *V1RegisterPaymentRequest) contextValidateInputs(ctx context.Context, formats strfmt.Registry) error {
|
||||
|
||||
for i := 0; i < len(m.Inputs); i++ {
|
||||
|
||||
if m.Inputs[i] != nil {
|
||||
|
||||
if swag.IsZero(m.Inputs[i]) { // not required
|
||||
return nil
|
||||
}
|
||||
|
||||
if err := m.Inputs[i].ContextValidate(ctx, formats); err != nil {
|
||||
if ve, ok := err.(*errors.Validation); ok {
|
||||
return ve.ValidateName("inputs" + "." + strconv.Itoa(i))
|
||||
} else if ce, ok := err.(*errors.CompositeError); ok {
|
||||
return ce.ValidateName("inputs" + "." + strconv.Itoa(i))
|
||||
}
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// MarshalBinary interface implementation
|
||||
func (m *V1RegisterPaymentRequest) MarshalBinary() ([]byte, error) {
|
||||
if m == nil {
|
||||
return nil, nil
|
||||
}
|
||||
return swag.WriteJSON(m)
|
||||
}
|
||||
|
||||
// UnmarshalBinary interface implementation
|
||||
func (m *V1RegisterPaymentRequest) UnmarshalBinary(b []byte) error {
|
||||
var res V1RegisterPaymentRequest
|
||||
if err := swag.ReadJSON(b, &res); err != nil {
|
||||
return err
|
||||
}
|
||||
*m = res
|
||||
return nil
|
||||
}
|
||||
@@ -1,50 +0,0 @@
|
||||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
package models
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the swagger generate command
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/go-openapi/strfmt"
|
||||
"github.com/go-openapi/swag"
|
||||
)
|
||||
|
||||
// V1RegisterPaymentResponse v1 register payment response
|
||||
//
|
||||
// swagger:model v1RegisterPaymentResponse
|
||||
type V1RegisterPaymentResponse struct {
|
||||
|
||||
// Mocks wabisabi's credentials.
|
||||
ID string `json:"id,omitempty"`
|
||||
}
|
||||
|
||||
// Validate validates this v1 register payment response
|
||||
func (m *V1RegisterPaymentResponse) Validate(formats strfmt.Registry) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// ContextValidate validates this v1 register payment response based on context it is used
|
||||
func (m *V1RegisterPaymentResponse) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// MarshalBinary interface implementation
|
||||
func (m *V1RegisterPaymentResponse) MarshalBinary() ([]byte, error) {
|
||||
if m == nil {
|
||||
return nil, nil
|
||||
}
|
||||
return swag.WriteJSON(m)
|
||||
}
|
||||
|
||||
// UnmarshalBinary interface implementation
|
||||
func (m *V1RegisterPaymentResponse) UnmarshalBinary(b []byte) error {
|
||||
var res V1RegisterPaymentResponse
|
||||
if err := swag.ReadJSON(b, &res); err != nil {
|
||||
return err
|
||||
}
|
||||
*m = res
|
||||
return nil
|
||||
}
|
||||
@@ -1,56 +0,0 @@
|
||||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
package models
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the swagger generate command
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/go-openapi/strfmt"
|
||||
"github.com/go-openapi/swag"
|
||||
)
|
||||
|
||||
// V1SendTreeNoncesRequest v1 send tree nonces request
|
||||
//
|
||||
// swagger:model v1SendTreeNoncesRequest
|
||||
type V1SendTreeNoncesRequest struct {
|
||||
|
||||
// public key
|
||||
PublicKey string `json:"publicKey,omitempty"`
|
||||
|
||||
// round Id
|
||||
RoundID string `json:"roundId,omitempty"`
|
||||
|
||||
// tree nonces
|
||||
TreeNonces string `json:"treeNonces,omitempty"`
|
||||
}
|
||||
|
||||
// Validate validates this v1 send tree nonces request
|
||||
func (m *V1SendTreeNoncesRequest) Validate(formats strfmt.Registry) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// ContextValidate validates this v1 send tree nonces request based on context it is used
|
||||
func (m *V1SendTreeNoncesRequest) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// MarshalBinary interface implementation
|
||||
func (m *V1SendTreeNoncesRequest) MarshalBinary() ([]byte, error) {
|
||||
if m == nil {
|
||||
return nil, nil
|
||||
}
|
||||
return swag.WriteJSON(m)
|
||||
}
|
||||
|
||||
// UnmarshalBinary interface implementation
|
||||
func (m *V1SendTreeNoncesRequest) UnmarshalBinary(b []byte) error {
|
||||
var res V1SendTreeNoncesRequest
|
||||
if err := swag.ReadJSON(b, &res); err != nil {
|
||||
return err
|
||||
}
|
||||
*m = res
|
||||
return nil
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
package models
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the swagger generate command
|
||||
|
||||
// V1SendTreeNoncesResponse v1 send tree nonces response
|
||||
//
|
||||
// swagger:model v1SendTreeNoncesResponse
|
||||
type V1SendTreeNoncesResponse interface{}
|
||||
@@ -1,56 +0,0 @@
|
||||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
package models
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the swagger generate command
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/go-openapi/strfmt"
|
||||
"github.com/go-openapi/swag"
|
||||
)
|
||||
|
||||
// V1SendTreeSignaturesRequest v1 send tree signatures request
|
||||
//
|
||||
// swagger:model v1SendTreeSignaturesRequest
|
||||
type V1SendTreeSignaturesRequest struct {
|
||||
|
||||
// public key
|
||||
PublicKey string `json:"publicKey,omitempty"`
|
||||
|
||||
// round Id
|
||||
RoundID string `json:"roundId,omitempty"`
|
||||
|
||||
// tree signatures
|
||||
TreeSignatures string `json:"treeSignatures,omitempty"`
|
||||
}
|
||||
|
||||
// Validate validates this v1 send tree signatures request
|
||||
func (m *V1SendTreeSignaturesRequest) Validate(formats strfmt.Registry) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// ContextValidate validates this v1 send tree signatures request based on context it is used
|
||||
func (m *V1SendTreeSignaturesRequest) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// MarshalBinary interface implementation
|
||||
func (m *V1SendTreeSignaturesRequest) MarshalBinary() ([]byte, error) {
|
||||
if m == nil {
|
||||
return nil, nil
|
||||
}
|
||||
return swag.WriteJSON(m)
|
||||
}
|
||||
|
||||
// UnmarshalBinary interface implementation
|
||||
func (m *V1SendTreeSignaturesRequest) UnmarshalBinary(b []byte) error {
|
||||
var res V1SendTreeSignaturesRequest
|
||||
if err := swag.ReadJSON(b, &res); err != nil {
|
||||
return err
|
||||
}
|
||||
*m = res
|
||||
return nil
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
package models
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the swagger generate command
|
||||
|
||||
// V1SendTreeSignaturesResponse v1 send tree signatures response
|
||||
//
|
||||
// swagger:model v1SendTreeSignaturesResponse
|
||||
type V1SendTreeSignaturesResponse interface{}
|
||||
@@ -0,0 +1,50 @@
|
||||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
package models
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the swagger generate command
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/go-openapi/strfmt"
|
||||
"github.com/go-openapi/swag"
|
||||
)
|
||||
|
||||
// V1SubmitRedeemTxRequest v1 submit redeem tx request
|
||||
//
|
||||
// swagger:model v1SubmitRedeemTxRequest
|
||||
type V1SubmitRedeemTxRequest struct {
|
||||
|
||||
// redeem tx
|
||||
RedeemTx string `json:"redeemTx,omitempty"`
|
||||
}
|
||||
|
||||
// Validate validates this v1 submit redeem tx request
|
||||
func (m *V1SubmitRedeemTxRequest) Validate(formats strfmt.Registry) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// ContextValidate validates this v1 submit redeem tx request based on context it is used
|
||||
func (m *V1SubmitRedeemTxRequest) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// MarshalBinary interface implementation
|
||||
func (m *V1SubmitRedeemTxRequest) MarshalBinary() ([]byte, error) {
|
||||
if m == nil {
|
||||
return nil, nil
|
||||
}
|
||||
return swag.WriteJSON(m)
|
||||
}
|
||||
|
||||
// UnmarshalBinary interface implementation
|
||||
func (m *V1SubmitRedeemTxRequest) UnmarshalBinary(b []byte) error {
|
||||
var res V1SubmitRedeemTxRequest
|
||||
if err := swag.ReadJSON(b, &res); err != nil {
|
||||
return err
|
||||
}
|
||||
*m = res
|
||||
return nil
|
||||
}
|
||||
@@ -12,27 +12,27 @@ import (
|
||||
"github.com/go-openapi/swag"
|
||||
)
|
||||
|
||||
// V1CompletePaymentRequest v1 complete payment request
|
||||
// V1SubmitRedeemTxResponse v1 submit redeem tx response
|
||||
//
|
||||
// swagger:model v1CompletePaymentRequest
|
||||
type V1CompletePaymentRequest struct {
|
||||
// swagger:model v1SubmitRedeemTxResponse
|
||||
type V1SubmitRedeemTxResponse struct {
|
||||
|
||||
// signed redeem tx
|
||||
SignedRedeemTx string `json:"signedRedeemTx,omitempty"`
|
||||
}
|
||||
|
||||
// Validate validates this v1 complete payment request
|
||||
func (m *V1CompletePaymentRequest) Validate(formats strfmt.Registry) error {
|
||||
// Validate validates this v1 submit redeem tx response
|
||||
func (m *V1SubmitRedeemTxResponse) Validate(formats strfmt.Registry) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// ContextValidate validates this v1 complete payment request based on context it is used
|
||||
func (m *V1CompletePaymentRequest) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
|
||||
// ContextValidate validates this v1 submit redeem tx response based on context it is used
|
||||
func (m *V1SubmitRedeemTxResponse) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// MarshalBinary interface implementation
|
||||
func (m *V1CompletePaymentRequest) MarshalBinary() ([]byte, error) {
|
||||
func (m *V1SubmitRedeemTxResponse) MarshalBinary() ([]byte, error) {
|
||||
if m == nil {
|
||||
return nil, nil
|
||||
}
|
||||
@@ -40,8 +40,8 @@ func (m *V1CompletePaymentRequest) MarshalBinary() ([]byte, error) {
|
||||
}
|
||||
|
||||
// UnmarshalBinary interface implementation
|
||||
func (m *V1CompletePaymentRequest) UnmarshalBinary(b []byte) error {
|
||||
var res V1CompletePaymentRequest
|
||||
func (m *V1SubmitRedeemTxResponse) UnmarshalBinary(b []byte) error {
|
||||
var res V1SubmitRedeemTxResponse
|
||||
if err := swag.ReadJSON(b, &res); err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -1,53 +0,0 @@
|
||||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
package models
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the swagger generate command
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/go-openapi/strfmt"
|
||||
"github.com/go-openapi/swag"
|
||||
)
|
||||
|
||||
// V1SubmitSignedForfeitTransactionsRequest v1 submit signed forfeit transactions request
|
||||
//
|
||||
// swagger:model v1SubmitSignedForfeitTransactionsRequest
|
||||
type V1SubmitSignedForfeitTransactionsRequest struct {
|
||||
|
||||
// Forfeit txs signed by the user.
|
||||
SignedForfeitTxs []string `json:"signedForfeitTxs"`
|
||||
|
||||
// If payment has boarding input, the user must sign the associated inputs.
|
||||
SignedRoundTx string `json:"signedRoundTx,omitempty"`
|
||||
}
|
||||
|
||||
// Validate validates this v1 submit signed forfeit transactions request
|
||||
func (m *V1SubmitSignedForfeitTransactionsRequest) Validate(formats strfmt.Registry) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// ContextValidate validates this v1 submit signed forfeit transactions request based on context it is used
|
||||
func (m *V1SubmitSignedForfeitTransactionsRequest) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// MarshalBinary interface implementation
|
||||
func (m *V1SubmitSignedForfeitTransactionsRequest) MarshalBinary() ([]byte, error) {
|
||||
if m == nil {
|
||||
return nil, nil
|
||||
}
|
||||
return swag.WriteJSON(m)
|
||||
}
|
||||
|
||||
// UnmarshalBinary interface implementation
|
||||
func (m *V1SubmitSignedForfeitTransactionsRequest) UnmarshalBinary(b []byte) error {
|
||||
var res V1SubmitSignedForfeitTransactionsRequest
|
||||
if err := swag.ReadJSON(b, &res); err != nil {
|
||||
return err
|
||||
}
|
||||
*m = res
|
||||
return nil
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
package models
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the swagger generate command
|
||||
|
||||
// V1SubmitSignedForfeitTransactionsResponse v1 submit signed forfeit transactions response
|
||||
//
|
||||
// swagger:model v1SubmitSignedForfeitTransactionsResponse
|
||||
type V1SubmitSignedForfeitTransactionsResponse interface{}
|
||||
@@ -1,53 +0,0 @@
|
||||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
package models
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the swagger generate command
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/go-openapi/strfmt"
|
||||
"github.com/go-openapi/swag"
|
||||
)
|
||||
|
||||
// V1VtxoInput v1 vtxo input
|
||||
//
|
||||
// swagger:model v1VtxoInput
|
||||
type V1VtxoInput struct {
|
||||
|
||||
// txid
|
||||
Txid string `json:"txid,omitempty"`
|
||||
|
||||
// vout
|
||||
Vout int64 `json:"vout,omitempty"`
|
||||
}
|
||||
|
||||
// Validate validates this v1 vtxo input
|
||||
func (m *V1VtxoInput) Validate(formats strfmt.Registry) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// ContextValidate validates this v1 vtxo input based on context it is used
|
||||
func (m *V1VtxoInput) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// MarshalBinary interface implementation
|
||||
func (m *V1VtxoInput) MarshalBinary() ([]byte, error) {
|
||||
if m == nil {
|
||||
return nil, nil
|
||||
}
|
||||
return swag.WriteJSON(m)
|
||||
}
|
||||
|
||||
// UnmarshalBinary interface implementation
|
||||
func (m *V1VtxoInput) UnmarshalBinary(b []byte) error {
|
||||
var res V1VtxoInput
|
||||
if err := swag.ReadJSON(b, &res); err != nil {
|
||||
return err
|
||||
}
|
||||
*m = res
|
||||
return nil
|
||||
}
|
||||
@@ -1467,7 +1467,7 @@ func (a *covenantArkClient) createAndSignForfeits(
|
||||
ControlBlock: *ctrlBlock,
|
||||
}
|
||||
|
||||
feeAmount, err := common.ComputeForfeitMinRelayFee(
|
||||
feeAmount, err := common.ComputeForfeitTxFee(
|
||||
feeRate,
|
||||
&waddrmgr.Tapscript{
|
||||
RevealedScript: leafProof.Script,
|
||||
|
||||
@@ -978,7 +978,6 @@ func (a *covenantlessArkClient) SendAsync(
|
||||
|
||||
expectedAspPubKey := schnorr.SerializePubKey(a.AspPubkey)
|
||||
|
||||
receiversOutput := make([]client.Output, 0)
|
||||
sumOfReceivers := uint64(0)
|
||||
|
||||
for _, receiver := range receivers {
|
||||
@@ -997,10 +996,6 @@ func (a *covenantlessArkClient) SendAsync(
|
||||
return "", fmt.Errorf("invalid amount (%d), must be greater than dust %d", receiver.Amount(), a.Dust)
|
||||
}
|
||||
|
||||
receiversOutput = append(receiversOutput, client.Output{
|
||||
Address: receiver.To(),
|
||||
Amount: receiver.Amount(),
|
||||
})
|
||||
sumOfReceivers += receiver.Amount()
|
||||
}
|
||||
|
||||
@@ -1038,14 +1033,10 @@ func (a *covenantlessArkClient) SendAsync(
|
||||
}
|
||||
|
||||
if changeAmount > 0 {
|
||||
changeReceiver := client.Output{
|
||||
Address: offchainAddrs[0].Address,
|
||||
Amount: changeAmount,
|
||||
}
|
||||
receiversOutput = append(receiversOutput, changeReceiver)
|
||||
receivers = append(receivers, NewBitcoinReceiver(offchainAddrs[0].Address, changeAmount))
|
||||
}
|
||||
|
||||
inputs := make([]client.AsyncPaymentInput, 0, len(selectedCoins))
|
||||
inputs := make([]redeemTxInput, 0, len(selectedCoins))
|
||||
|
||||
for _, coin := range selectedCoins {
|
||||
vtxoScript, err := bitcointree.ParseVtxoScript(coin.Tapscripts)
|
||||
@@ -1062,33 +1053,25 @@ func (a *covenantlessArkClient) SendAsync(
|
||||
|
||||
forfeitLeaf := txscript.NewBaseTapLeaf(forfeitScript)
|
||||
|
||||
inputs = append(inputs, client.AsyncPaymentInput{
|
||||
Input: client.Input{
|
||||
Outpoint: client.Outpoint{
|
||||
Txid: coin.Txid,
|
||||
VOut: coin.VOut,
|
||||
},
|
||||
Tapscripts: coin.Tapscripts,
|
||||
},
|
||||
ForfeitLeafHash: forfeitLeaf.TapHash(),
|
||||
inputs = append(inputs, redeemTxInput{
|
||||
coin,
|
||||
forfeitLeaf.TapHash(),
|
||||
})
|
||||
}
|
||||
|
||||
redeemTx, err := a.client.CreatePayment(ctx, inputs, receiversOutput)
|
||||
feeRate := chainfee.FeePerKwFloor
|
||||
redeemTx, err := buildRedeemTx(inputs, receivers, feeRate.FeePerVByte())
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
// TODO verify the redeem tx signature
|
||||
|
||||
signedRedeemTx, err := a.wallet.SignTransaction(ctx, a.explorer, redeemTx)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
if err = a.client.CompletePayment(
|
||||
ctx, signedRedeemTx,
|
||||
); err != nil {
|
||||
signedRedeemTx, err = a.client.SubmitRedeemTx(ctx, signedRedeemTx)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
@@ -2119,7 +2102,7 @@ func (a *covenantlessArkClient) createAndSignForfeits(
|
||||
return nil, err
|
||||
}
|
||||
|
||||
feeAmount, err := common.ComputeForfeitMinRelayFee(
|
||||
feeAmount, err := common.ComputeForfeitTxFee(
|
||||
feeRate,
|
||||
&waddrmgr.Tapscript{
|
||||
RevealedScript: leafProof.Script,
|
||||
@@ -2605,3 +2588,113 @@ func vtxosToTxsCovenantless(
|
||||
|
||||
return txs, nil
|
||||
}
|
||||
|
||||
type redeemTxInput struct {
|
||||
client.TapscriptsVtxo
|
||||
ForfeitLeafHash chainhash.Hash
|
||||
}
|
||||
|
||||
func buildRedeemTx(
|
||||
vtxos []redeemTxInput,
|
||||
receivers []Receiver,
|
||||
feeRate chainfee.SatPerVByte,
|
||||
) (string, error) {
|
||||
if len(vtxos) <= 0 {
|
||||
return "", fmt.Errorf("missing vtxos")
|
||||
}
|
||||
|
||||
ins := make([]common.VtxoInput, 0, len(vtxos))
|
||||
|
||||
for _, vtxo := range vtxos {
|
||||
if len(vtxo.Tapscripts) <= 0 {
|
||||
return "", fmt.Errorf("missing tapscripts for vtxo %s", vtxo.Vtxo.Txid)
|
||||
}
|
||||
|
||||
vtxoTxID, err := chainhash.NewHashFromStr(vtxo.Txid)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
vtxoOutpoint := &wire.OutPoint{
|
||||
Hash: *vtxoTxID,
|
||||
Index: vtxo.VOut,
|
||||
}
|
||||
|
||||
vtxoScript, err := bitcointree.ParseVtxoScript(vtxo.Tapscripts)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
_, vtxoTree, err := vtxoScript.TapTree()
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
leafProof, err := vtxoTree.GetTaprootMerkleProof(vtxo.ForfeitLeafHash)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
ctrlBlock, err := txscript.ParseControlBlock(leafProof.ControlBlock)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
closure, err := tree.DecodeClosure(leafProof.Script)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
tapscript := &waddrmgr.Tapscript{
|
||||
RevealedScript: leafProof.Script,
|
||||
ControlBlock: ctrlBlock,
|
||||
}
|
||||
|
||||
ins = append(ins, common.VtxoInput{
|
||||
Outpoint: vtxoOutpoint,
|
||||
Tapscript: tapscript,
|
||||
Amount: int64(vtxo.Amount),
|
||||
WitnessSize: closure.WitnessSize(),
|
||||
})
|
||||
}
|
||||
|
||||
fees, err := common.ComputeRedeemTxFee(feeRate.FeePerKVByte(), ins, len(receivers))
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
if fees >= int64(receivers[len(receivers)-1].Amount()) {
|
||||
return "", fmt.Errorf("redeem tx fee is higher than the amount of the change receiver")
|
||||
}
|
||||
|
||||
outs := make([]*wire.TxOut, 0, len(receivers))
|
||||
|
||||
for i, receiver := range receivers {
|
||||
if receiver.IsOnchain() {
|
||||
return "", fmt.Errorf("receiver %d is onchain", i)
|
||||
}
|
||||
|
||||
addr, err := common.DecodeAddress(receiver.To())
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
newVtxoScript, err := common.P2TRScript(addr.VtxoTapKey)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
// Deduct the min relay fee from the very last receiver which is supposed
|
||||
// to be the change in case it's not a send-all.
|
||||
value := receiver.Amount()
|
||||
if i == len(receivers)-1 {
|
||||
value -= uint64(fees)
|
||||
}
|
||||
outs = append(outs, &wire.TxOut{
|
||||
Value: int64(value),
|
||||
PkScript: newVtxoScript,
|
||||
})
|
||||
}
|
||||
|
||||
return bitcointree.BuildRedeemTx(ins, outs, fees)
|
||||
}
|
||||
|
||||
@@ -370,11 +370,7 @@ func (s *covenantService) UpdatePaymentStatus(_ context.Context, id string) erro
|
||||
return s.paymentRequests.updatePingTimestamp(id)
|
||||
}
|
||||
|
||||
func (s *covenantService) CompleteAsyncPayment(ctx context.Context, redeemTx string) error {
|
||||
return fmt.Errorf("unimplemented")
|
||||
}
|
||||
|
||||
func (s *covenantService) CreateAsyncPayment(_ context.Context, _ []AsyncPaymentInput, _ []domain.Receiver) (string, error) {
|
||||
func (s *covenantService) SubmitRedeemTx(context.Context, string) (string, error) {
|
||||
return "", fmt.Errorf("unimplemented")
|
||||
}
|
||||
|
||||
|
||||
@@ -22,7 +22,9 @@ import (
|
||||
"github.com/btcsuite/btcd/chaincfg/chainhash"
|
||||
"github.com/btcsuite/btcd/txscript"
|
||||
"github.com/btcsuite/btcd/wire"
|
||||
"github.com/btcsuite/btcwallet/waddrmgr"
|
||||
"github.com/decred/dcrd/dcrec/secp256k1/v4"
|
||||
"github.com/lightningnetwork/lnd/lnwallet/chainfee"
|
||||
log "github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
@@ -55,7 +57,6 @@ type covenantlessService struct {
|
||||
currentRoundLock sync.Mutex
|
||||
currentRound *domain.Round
|
||||
treeSigningSessions map[string]*musigSigningSession
|
||||
asyncPaymentsCache map[string]asyncPaymentData
|
||||
}
|
||||
|
||||
func NewCovenantlessService(
|
||||
@@ -103,7 +104,6 @@ func NewCovenantlessService(
|
||||
eventsCh: make(chan domain.RoundEvent),
|
||||
transactionEventsCh: make(chan TransactionEvent),
|
||||
currentRoundLock: sync.Mutex{},
|
||||
asyncPaymentsCache: make(map[string]asyncPaymentData),
|
||||
treeSigningSessions: make(map[string]*musigSigningSession),
|
||||
boardingExitDelay: boardingExitDelay,
|
||||
nostrDefaultRelays: nostrDefaultRelays,
|
||||
@@ -168,65 +168,95 @@ func (s *covenantlessService) Stop() {
|
||||
close(s.eventsCh)
|
||||
}
|
||||
|
||||
func (s *covenantlessService) CompleteAsyncPayment(
|
||||
func (s *covenantlessService) SubmitRedeemTx(
|
||||
ctx context.Context, redeemTx string,
|
||||
) error {
|
||||
) (string, error) {
|
||||
redeemPtx, err := psbt.NewFromRawBytes(strings.NewReader(redeemTx), true)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to parse redeem tx: %s", err)
|
||||
}
|
||||
redeemTxid := redeemPtx.UnsignedTx.TxID()
|
||||
|
||||
asyncPayData, ok := s.asyncPaymentsCache[redeemTxid]
|
||||
if !ok {
|
||||
return fmt.Errorf("async payment not found")
|
||||
return "", fmt.Errorf("failed to parse redeem tx: %s", err)
|
||||
}
|
||||
|
||||
vtxoRepo := s.repoManager.Vtxos()
|
||||
|
||||
for _, tx := range []string{redeemTx} {
|
||||
ptx, err := psbt.NewFromRawBytes(strings.NewReader(tx), true)
|
||||
expiration := int64(0)
|
||||
roundTxid := ""
|
||||
|
||||
ins := make([]common.VtxoInput, 0)
|
||||
|
||||
ptx, err := psbt.NewFromRawBytes(strings.NewReader(redeemTx), true)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to parse tx: %s", err)
|
||||
return "", fmt.Errorf("failed to parse redeem tx: %s", err)
|
||||
}
|
||||
|
||||
spentVtxoKeys := make([]domain.VtxoKey, 0, len(ptx.Inputs))
|
||||
for _, input := range ptx.UnsignedTx.TxIn {
|
||||
spentVtxoKeys = append(spentVtxoKeys, domain.VtxoKey{
|
||||
Txid: input.PreviousOutPoint.Hash.String(),
|
||||
VOut: input.PreviousOutPoint.Index,
|
||||
})
|
||||
}
|
||||
|
||||
spentVtxos, err := vtxoRepo.GetVtxos(ctx, spentVtxoKeys)
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("failed to get vtxos: %s", err)
|
||||
}
|
||||
|
||||
if len(spentVtxos) != len(spentVtxoKeys) {
|
||||
return "", fmt.Errorf("some vtxos not found")
|
||||
}
|
||||
|
||||
vtxoMap := make(map[wire.OutPoint]domain.Vtxo)
|
||||
for _, vtxo := range spentVtxos {
|
||||
hash, err := chainhash.NewHashFromStr(vtxo.Txid)
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("failed to parse vtxo txid: %s", err)
|
||||
}
|
||||
vtxoMap[wire.OutPoint{Hash: *hash, Index: vtxo.VOut}] = vtxo
|
||||
}
|
||||
|
||||
sumOfInputs := int64(0)
|
||||
for inputIndex, input := range ptx.Inputs {
|
||||
if input.WitnessUtxo == nil {
|
||||
return fmt.Errorf("missing witness utxo")
|
||||
return "", fmt.Errorf("missing witness utxo")
|
||||
}
|
||||
|
||||
if len(input.TaprootLeafScript) == 0 {
|
||||
return fmt.Errorf("missing tapscript leaf")
|
||||
return "", fmt.Errorf("missing tapscript leaf")
|
||||
}
|
||||
|
||||
tapscript := input.TaprootLeafScript[0]
|
||||
|
||||
if len(input.TaprootScriptSpendSig) == 0 {
|
||||
return fmt.Errorf("missing tapscript spend sig")
|
||||
return "", fmt.Errorf("missing tapscript spend sig")
|
||||
}
|
||||
|
||||
vtxoOutpoint := ptx.UnsignedTx.TxIn[inputIndex].PreviousOutPoint
|
||||
outpoint := ptx.UnsignedTx.TxIn[inputIndex].PreviousOutPoint
|
||||
|
||||
// verify that the vtxo is spendable
|
||||
|
||||
vtxos, err := vtxoRepo.GetVtxos(ctx, []domain.VtxoKey{{Txid: vtxoOutpoint.Hash.String(), VOut: vtxoOutpoint.Index}})
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to get vtxo: %s", err)
|
||||
vtxo, exists := vtxoMap[outpoint]
|
||||
if !exists {
|
||||
return "", fmt.Errorf("vtxo not found")
|
||||
}
|
||||
|
||||
if len(vtxos) == 0 {
|
||||
return fmt.Errorf("vtxo not found")
|
||||
}
|
||||
// make sure we don't use the same vtxo twice
|
||||
delete(vtxoMap, outpoint)
|
||||
|
||||
vtxo := vtxos[0]
|
||||
if vtxo.Spent {
|
||||
return fmt.Errorf("vtxo already spent")
|
||||
return "", fmt.Errorf("vtxo already spent")
|
||||
}
|
||||
|
||||
if vtxo.Redeemed {
|
||||
return fmt.Errorf("vtxo already redeemed")
|
||||
return "", fmt.Errorf("vtxo already redeemed")
|
||||
}
|
||||
|
||||
if vtxo.Swept {
|
||||
return fmt.Errorf("vtxo already swept")
|
||||
return "", fmt.Errorf("vtxo already swept")
|
||||
}
|
||||
|
||||
sumOfInputs += input.WitnessUtxo.Value
|
||||
|
||||
if inputIndex == 0 || vtxo.ExpireAt < expiration {
|
||||
roundTxid = vtxo.RoundTxid
|
||||
expiration = vtxo.ExpireAt
|
||||
}
|
||||
|
||||
// verify that the user signs a forfeit closure
|
||||
@@ -238,7 +268,7 @@ func (s *covenantlessService) CompleteAsyncPayment(
|
||||
if !bytes.Equal(sig.XOnlyPubKey, aspXOnlyPubKey) {
|
||||
parsed, err := schnorr.ParsePubKey(sig.XOnlyPubKey)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to parse pubkey: %s", err)
|
||||
return "", fmt.Errorf("failed to parse pubkey: %s", err)
|
||||
}
|
||||
userPubKey = parsed
|
||||
break
|
||||
@@ -246,167 +276,166 @@ func (s *covenantlessService) CompleteAsyncPayment(
|
||||
}
|
||||
|
||||
if userPubKey == nil {
|
||||
return fmt.Errorf("redeem transaction is not signed")
|
||||
return "", fmt.Errorf("redeem transaction is not signed")
|
||||
}
|
||||
|
||||
vtxoPublicKeyBytes, err := hex.DecodeString(vtxo.Pubkey)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to decode vtxo pubkey: %s", err)
|
||||
return "", fmt.Errorf("failed to decode vtxo pubkey: %s", err)
|
||||
}
|
||||
|
||||
vtxoTapKey, err := schnorr.ParsePubKey(vtxoPublicKeyBytes)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to parse vtxo pubkey: %s", err)
|
||||
return "", fmt.Errorf("failed to parse vtxo pubkey: %s", err)
|
||||
}
|
||||
|
||||
// verify witness utxo
|
||||
pkscript, err := common.P2TRScript(vtxoTapKey)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to get pkscript: %s", err)
|
||||
return "", fmt.Errorf("failed to get pkscript: %s", err)
|
||||
}
|
||||
|
||||
if !bytes.Equal(input.WitnessUtxo.PkScript, pkscript) {
|
||||
return fmt.Errorf("witness utxo script mismatch")
|
||||
return "", fmt.Errorf("witness utxo script mismatch")
|
||||
}
|
||||
|
||||
if input.WitnessUtxo.Value != int64(vtxo.Amount) {
|
||||
return fmt.Errorf("witness utxo value mismatch")
|
||||
}
|
||||
return "", fmt.Errorf("witness utxo value mismatch")
|
||||
}
|
||||
|
||||
// verify the tapscript signatures
|
||||
if valid, err := s.builder.VerifyTapscriptPartialSigs(tx); err != nil || !valid {
|
||||
return fmt.Errorf("invalid tx signature: %s", err)
|
||||
}
|
||||
ctrlBlock, err := txscript.ParseControlBlock(tapscript.ControlBlock)
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("failed to parse control block: %s", err)
|
||||
}
|
||||
|
||||
spentVtxos := make([]domain.VtxoKey, 0)
|
||||
for _, in := range redeemPtx.UnsignedTx.TxIn {
|
||||
spentVtxos = append(spentVtxos, domain.VtxoKey{
|
||||
Txid: in.PreviousOutPoint.Hash.String(),
|
||||
VOut: in.PreviousOutPoint.Index,
|
||||
ins = append(ins, common.VtxoInput{
|
||||
Outpoint: &outpoint,
|
||||
Tapscript: &waddrmgr.Tapscript{
|
||||
ControlBlock: ctrlBlock,
|
||||
RevealedScript: tapscript.Script,
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
vtxos := make([]domain.Vtxo, 0, len(asyncPayData.receivers))
|
||||
dust, err := s.wallet.GetDustAmount(ctx)
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("failed to get dust threshold: %s", err)
|
||||
}
|
||||
|
||||
for outIndex, out := range redeemPtx.UnsignedTx.TxOut {
|
||||
outputs := ptx.UnsignedTx.TxOut
|
||||
|
||||
sumOfOutputs := int64(0)
|
||||
for _, out := range outputs {
|
||||
sumOfOutputs += out.Value
|
||||
if out.Value < int64(dust) {
|
||||
return "", fmt.Errorf("output value is less than dust threshold")
|
||||
}
|
||||
}
|
||||
|
||||
fees := sumOfInputs - sumOfOutputs
|
||||
if fees < 0 {
|
||||
return "", fmt.Errorf("invalid fees, inputs are less than outputs")
|
||||
}
|
||||
|
||||
minFeeRate := s.wallet.MinRelayFeeRate(ctx)
|
||||
|
||||
minFees, err := common.ComputeRedeemTxFee(chainfee.SatPerKVByte(minFeeRate), ins, len(outputs))
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("failed to compute min fees: %s", err)
|
||||
}
|
||||
|
||||
if fees < minFees {
|
||||
return "", fmt.Errorf("min relay fee not met, %d < %d", fees, minFees)
|
||||
}
|
||||
|
||||
// recompute redeem tx
|
||||
rebuiltRedeemTx, err := bitcointree.BuildRedeemTx(ins, outputs, fees)
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("failed to rebuild redeem tx: %s", err)
|
||||
}
|
||||
|
||||
rebuiltPtx, err := psbt.NewFromRawBytes(strings.NewReader(rebuiltRedeemTx), true)
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("failed to parse rebuilt redeem tx: %s", err)
|
||||
}
|
||||
|
||||
rebuiltTxid := rebuiltPtx.UnsignedTx.TxID()
|
||||
redeemTxid := redeemPtx.UnsignedTx.TxID()
|
||||
if rebuiltTxid != redeemTxid {
|
||||
return "", fmt.Errorf("invalid redeem tx")
|
||||
}
|
||||
|
||||
// verify the tapscript signatures
|
||||
if valid, err := s.builder.VerifyTapscriptPartialSigs(redeemTx); err != nil || !valid {
|
||||
return "", fmt.Errorf("invalid tx signature: %s", err)
|
||||
}
|
||||
|
||||
if expiration == 0 {
|
||||
return "", fmt.Errorf("no valid vtxo found")
|
||||
}
|
||||
|
||||
if roundTxid == "" {
|
||||
return "", fmt.Errorf("no valid vtxo found")
|
||||
}
|
||||
|
||||
newVtxos := make([]domain.Vtxo, 0, len(redeemPtx.UnsignedTx.TxOut))
|
||||
|
||||
for outIndex, out := range outputs {
|
||||
vtxoTapKey, err := schnorr.ParsePubKey(out.PkScript[2:])
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to parse vtxo taproot key: %s", err)
|
||||
return "", fmt.Errorf("failed to parse vtxo taproot key: %s", err)
|
||||
}
|
||||
|
||||
vtxoPubkey := hex.EncodeToString(schnorr.SerializePubKey(vtxoTapKey))
|
||||
|
||||
vtxos = append(vtxos, domain.Vtxo{
|
||||
newVtxos = append(newVtxos, domain.Vtxo{
|
||||
VtxoKey: domain.VtxoKey{
|
||||
Txid: redeemTxid,
|
||||
VOut: uint32(outIndex),
|
||||
},
|
||||
Pubkey: vtxoPubkey,
|
||||
Amount: uint64(out.Value),
|
||||
ExpireAt: asyncPayData.expireAt,
|
||||
RoundTxid: asyncPayData.roundTxid,
|
||||
ExpireAt: expiration,
|
||||
RoundTxid: roundTxid,
|
||||
RedeemTx: redeemTx,
|
||||
CreatedAt: time.Now().Unix(),
|
||||
})
|
||||
}
|
||||
|
||||
if err := s.repoManager.Vtxos().AddVtxos(ctx, vtxos); err != nil {
|
||||
return fmt.Errorf("failed to add vtxos: %s", err)
|
||||
// sign the redeem tx
|
||||
|
||||
signedRedeemTx, err := s.wallet.SignTransactionTapscript(ctx, redeemTx, nil)
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("failed to sign redeem tx: %s", err)
|
||||
}
|
||||
log.Infof("added %d vtxos", len(vtxos))
|
||||
if err := s.startWatchingVtxos(vtxos); err != nil {
|
||||
|
||||
// create new vtxos, update spent vtxos state
|
||||
|
||||
if err := s.repoManager.Vtxos().AddVtxos(ctx, newVtxos); err != nil {
|
||||
return "", fmt.Errorf("failed to add vtxos: %s", err)
|
||||
}
|
||||
log.Infof("added %d vtxos", len(newVtxos))
|
||||
if err := s.startWatchingVtxos(newVtxos); err != nil {
|
||||
log.WithError(err).Warn(
|
||||
"failed to start watching vtxos",
|
||||
)
|
||||
}
|
||||
log.Debugf("started watching %d vtxos", len(vtxos))
|
||||
log.Debugf("started watching %d vtxos", len(newVtxos))
|
||||
|
||||
if err := s.repoManager.Vtxos().SpendVtxos(ctx, spentVtxos, redeemTxid); err != nil {
|
||||
return fmt.Errorf("failed to spend vtxo: %s", err)
|
||||
if err := s.repoManager.Vtxos().SpendVtxos(ctx, spentVtxoKeys, redeemTxid); err != nil {
|
||||
return "", fmt.Errorf("failed to spend vtxo: %s", err)
|
||||
}
|
||||
log.Infof("spent %d vtxos", len(spentVtxos))
|
||||
|
||||
delete(s.asyncPaymentsCache, redeemTxid)
|
||||
|
||||
go func() {
|
||||
s.transactionEventsCh <- RedeemTransactionEvent{
|
||||
AsyncTxID: redeemTxid,
|
||||
SpentVtxos: spentVtxos,
|
||||
SpendableVtxos: vtxos,
|
||||
SpentVtxos: spentVtxoKeys,
|
||||
SpendableVtxos: newVtxos,
|
||||
}
|
||||
}()
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *covenantlessService) CreateAsyncPayment(
|
||||
ctx context.Context, inputs []AsyncPaymentInput, receivers []domain.Receiver,
|
||||
) (string, error) {
|
||||
vtxosKeys := make([]domain.VtxoKey, 0, len(inputs))
|
||||
scripts := make(map[domain.VtxoKey][]string)
|
||||
forfeitLeaves := make(map[domain.VtxoKey]chainhash.Hash)
|
||||
|
||||
for _, in := range inputs {
|
||||
vtxosKeys = append(vtxosKeys, in.VtxoKey)
|
||||
scripts[in.VtxoKey] = in.Tapscripts
|
||||
forfeitLeaves[in.VtxoKey] = in.ForfeitLeafHash
|
||||
}
|
||||
|
||||
vtxos, err := s.repoManager.Vtxos().GetVtxos(ctx, vtxosKeys)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
if len(vtxos) <= 0 {
|
||||
return "", fmt.Errorf("vtxos not found")
|
||||
}
|
||||
|
||||
vtxosInputs := make([]domain.Vtxo, 0, len(inputs))
|
||||
|
||||
expiration := vtxos[0].ExpireAt
|
||||
roundTxid := vtxos[0].RoundTxid
|
||||
|
||||
for _, vtxo := range vtxos {
|
||||
if vtxo.Spent {
|
||||
return "", fmt.Errorf("all vtxos must be unspent")
|
||||
}
|
||||
|
||||
if vtxo.Redeemed {
|
||||
return "", fmt.Errorf("all vtxos must be redeemed")
|
||||
}
|
||||
|
||||
if vtxo.Swept {
|
||||
return "", fmt.Errorf("all vtxos must be swept")
|
||||
}
|
||||
|
||||
if vtxo.ExpireAt < expiration {
|
||||
roundTxid = vtxo.RoundTxid
|
||||
expiration = vtxo.ExpireAt
|
||||
}
|
||||
|
||||
vtxosInputs = append(vtxosInputs, vtxo)
|
||||
}
|
||||
|
||||
redeemTx, err := s.builder.BuildAsyncPaymentTransactions(
|
||||
vtxosInputs, scripts, forfeitLeaves, receivers,
|
||||
)
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("failed to build async payment txs: %s", err)
|
||||
}
|
||||
|
||||
redeemPtx, err := psbt.NewFromRawBytes(strings.NewReader(redeemTx), true)
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("failed to parse redeem tx: %s", err)
|
||||
}
|
||||
|
||||
s.asyncPaymentsCache[redeemPtx.UnsignedTx.TxID()] = asyncPaymentData{
|
||||
receivers: receivers,
|
||||
expireAt: expiration,
|
||||
roundTxid: roundTxid,
|
||||
}
|
||||
|
||||
return redeemTx, nil
|
||||
return signedRedeemTx, nil
|
||||
}
|
||||
|
||||
func (s *covenantlessService) GetBoardingAddress(
|
||||
@@ -1798,12 +1827,6 @@ func findForfeitTxBitcoin(
|
||||
return "", fmt.Errorf("forfeit tx not found")
|
||||
}
|
||||
|
||||
type asyncPaymentData struct {
|
||||
receivers []domain.Receiver
|
||||
expireAt int64
|
||||
roundTxid string
|
||||
}
|
||||
|
||||
// musigSigningSession holds the state of ephemeral nonces and signatures in order to coordinate the signing of the tree
|
||||
type musigSigningSession struct {
|
||||
lock sync.Mutex
|
||||
|
||||
@@ -7,7 +7,6 @@ import (
|
||||
"github.com/ark-network/ark/common/note"
|
||||
"github.com/ark-network/ark/server/internal/core/domain"
|
||||
"github.com/ark-network/ark/server/internal/core/ports"
|
||||
"github.com/btcsuite/btcd/chaincfg/chainhash"
|
||||
"github.com/decred/dcrd/dcrec/secp256k1/v4"
|
||||
)
|
||||
|
||||
@@ -15,11 +14,6 @@ var (
|
||||
paymentsThreshold = int64(128)
|
||||
)
|
||||
|
||||
type AsyncPaymentInput struct {
|
||||
ports.Input
|
||||
ForfeitLeafHash chainhash.Hash
|
||||
}
|
||||
|
||||
type Service interface {
|
||||
Start() error
|
||||
Stop()
|
||||
@@ -37,13 +31,7 @@ type Service interface {
|
||||
ctx context.Context, address string,
|
||||
) (spendableVtxos, spentVtxos []domain.Vtxo, err error)
|
||||
GetInfo(ctx context.Context) (*ServiceInfo, error)
|
||||
// Async payments
|
||||
CreateAsyncPayment(
|
||||
ctx context.Context, inputs []AsyncPaymentInput, receivers []domain.Receiver,
|
||||
) (string, error)
|
||||
CompleteAsyncPayment(
|
||||
ctx context.Context, redeemTx string,
|
||||
) error
|
||||
SubmitRedeemTx(ctx context.Context, redeemTx string) (string, error)
|
||||
GetBoardingAddress(
|
||||
ctx context.Context, userPubkey *secp256k1.PublicKey,
|
||||
) (address string, scripts []string, err error)
|
||||
|
||||
@@ -52,12 +52,6 @@ type TxBuilder interface {
|
||||
VerifyTapscriptPartialSigs(tx string) (valid bool, err error)
|
||||
// FindLeaves returns all the leaves txs that are reachable from the given outpoint
|
||||
FindLeaves(congestionTree tree.CongestionTree, fromtxid string, vout uint32) (leaves []tree.Node, err error)
|
||||
BuildAsyncPaymentTransactions(
|
||||
vtxosToSpend []domain.Vtxo,
|
||||
scripts map[domain.VtxoKey][]string,
|
||||
forfeitsLeaves map[domain.VtxoKey]chainhash.Hash,
|
||||
receivers []domain.Receiver,
|
||||
) (string, error)
|
||||
VerifyAndCombinePartialTx(dest string, src string) (string, error)
|
||||
GetTxID(tx string) (string, error)
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ type WalletService interface {
|
||||
SignTransaction(
|
||||
ctx context.Context, partialTx string, extractRawTx bool,
|
||||
) (string, error)
|
||||
SignTransactionTapscript(ctx context.Context, pset string, inputIndexes []int) (string, error) // inputIndexes == nil means sign all inputs
|
||||
SignTransactionTapscript(ctx context.Context, partialTx string, inputIndexes []int) (string, error) // inputIndexes == nil means sign all inputs
|
||||
SelectUtxos(ctx context.Context, asset string, amount uint64) ([]TxInput, uint64, error)
|
||||
BroadcastTransaction(ctx context.Context, txHex string) (string, error)
|
||||
WaitForSync(ctx context.Context, txid string) error
|
||||
|
||||
@@ -202,7 +202,7 @@ func (b *txBuilder) VerifyForfeitTxs(vtxos []domain.Vtxo, connectors []string, f
|
||||
|
||||
vtxoTapscript := firstForfeit.Inputs[1].TapLeafScript[0]
|
||||
|
||||
minFee, err := common.ComputeForfeitMinRelayFee(
|
||||
minFee, err := common.ComputeForfeitTxFee(
|
||||
minRate,
|
||||
&waddrmgr.Tapscript{
|
||||
RevealedScript: vtxoTapscript.Script,
|
||||
@@ -669,15 +669,6 @@ func (b *txBuilder) FindLeaves(
|
||||
return foundLeaves, nil
|
||||
}
|
||||
|
||||
func (b *txBuilder) BuildAsyncPaymentTransactions(
|
||||
_ []domain.Vtxo,
|
||||
_ map[domain.VtxoKey][]string,
|
||||
_ map[domain.VtxoKey]chainhash.Hash,
|
||||
_ []domain.Receiver,
|
||||
) (string, error) {
|
||||
return "", fmt.Errorf("not implemented")
|
||||
}
|
||||
|
||||
func (b *txBuilder) createPoolTx(
|
||||
sharedOutputAmount uint64,
|
||||
sharedOutputScript []byte,
|
||||
|
||||
@@ -22,8 +22,6 @@ import (
|
||||
"github.com/btcsuite/btcd/wire"
|
||||
"github.com/btcsuite/btcwallet/waddrmgr"
|
||||
"github.com/decred/dcrd/dcrec/secp256k1/v4"
|
||||
"github.com/lightningnetwork/lnd/input"
|
||||
"github.com/lightningnetwork/lnd/lntypes"
|
||||
)
|
||||
|
||||
type txBuilder struct {
|
||||
@@ -366,7 +364,7 @@ func (b *txBuilder) VerifyForfeitTxs(vtxos []domain.Vtxo, connectors []string, f
|
||||
return nil, err
|
||||
}
|
||||
|
||||
minFee, err := common.ComputeForfeitMinRelayFee(
|
||||
minFee, err := common.ComputeForfeitTxFee(
|
||||
minRate,
|
||||
&waddrmgr.Tapscript{
|
||||
RevealedScript: vtxoTapscript.Script,
|
||||
@@ -645,173 +643,6 @@ func (b *txBuilder) FindLeaves(congestionTree tree.CongestionTree, fromtxid stri
|
||||
return foundLeaves, nil
|
||||
}
|
||||
|
||||
func (b *txBuilder) BuildAsyncPaymentTransactions(
|
||||
vtxos []domain.Vtxo,
|
||||
scripts map[domain.VtxoKey][]string,
|
||||
forfeitsLeaves map[domain.VtxoKey]chainhash.Hash,
|
||||
receivers []domain.Receiver,
|
||||
) (string, error) {
|
||||
if len(vtxos) <= 0 {
|
||||
return "", fmt.Errorf("missing vtxos")
|
||||
}
|
||||
|
||||
ins := make([]*wire.OutPoint, 0, len(vtxos))
|
||||
outs := make([]*wire.TxOut, 0, len(receivers))
|
||||
witnessUtxos := make(map[int]*wire.TxOut)
|
||||
tapscripts := make(map[int]*psbt.TaprootTapLeafScript)
|
||||
|
||||
redeemTxWeightEstimator := &input.TxWeightEstimator{}
|
||||
for index, vtxo := range vtxos {
|
||||
vtxoTapscripts, ok := scripts[vtxo.VtxoKey]
|
||||
if !ok {
|
||||
return "", fmt.Errorf("missing scripts for vtxo %s", vtxo.VtxoKey)
|
||||
}
|
||||
|
||||
forfeitLeafHash, ok := forfeitsLeaves[vtxo.VtxoKey]
|
||||
if !ok {
|
||||
return "", fmt.Errorf("missing forfeit leaf hash for vtxo %s", vtxo.VtxoKey)
|
||||
}
|
||||
|
||||
if vtxo.Spent || vtxo.Redeemed || vtxo.Swept {
|
||||
return "", fmt.Errorf("all vtxos must be unspent")
|
||||
}
|
||||
|
||||
vtxoTxID, err := chainhash.NewHashFromStr(vtxo.Txid)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
vtxoOutpoint := &wire.OutPoint{
|
||||
Hash: *vtxoTxID,
|
||||
Index: vtxo.VOut,
|
||||
}
|
||||
|
||||
vtxoScript, err := bitcointree.ParseVtxoScript(vtxoTapscripts)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
vtxoTapKey, vtxoTree, err := vtxoScript.TapTree()
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
vtxoOutputScript, err := common.P2TRScript(vtxoTapKey)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
witnessUtxos[index] = &wire.TxOut{
|
||||
Value: int64(vtxo.Amount),
|
||||
PkScript: vtxoOutputScript,
|
||||
}
|
||||
|
||||
leafProof, err := vtxoTree.GetTaprootMerkleProof(forfeitLeafHash)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
tapscripts[index] = &psbt.TaprootTapLeafScript{
|
||||
ControlBlock: leafProof.ControlBlock,
|
||||
Script: leafProof.Script,
|
||||
LeafVersion: txscript.BaseLeafVersion,
|
||||
}
|
||||
|
||||
ctrlBlock, err := txscript.ParseControlBlock(leafProof.ControlBlock)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
closure, err := tree.DecodeClosure(leafProof.Script)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
redeemTxWeightEstimator.AddTapscriptInput(lntypes.WeightUnit(closure.WitnessSize()), &waddrmgr.Tapscript{
|
||||
RevealedScript: leafProof.Script,
|
||||
ControlBlock: ctrlBlock,
|
||||
})
|
||||
|
||||
ins = append(ins, vtxoOutpoint)
|
||||
}
|
||||
|
||||
for range receivers {
|
||||
redeemTxWeightEstimator.AddP2TROutput()
|
||||
}
|
||||
|
||||
redeemTxMinRelayFee, err := b.wallet.MinRelayFee(context.Background(), uint64(redeemTxWeightEstimator.VSize()))
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
if redeemTxMinRelayFee >= receivers[len(receivers)-1].Amount {
|
||||
return "", fmt.Errorf("redeem tx fee is higher than the amount of the change receiver")
|
||||
}
|
||||
|
||||
for i, receiver := range receivers {
|
||||
if receiver.IsOnchain() {
|
||||
return "", fmt.Errorf("receiver %d is onchain", i)
|
||||
}
|
||||
|
||||
pubkeyBytes, err := hex.DecodeString(receiver.Pubkey)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
pubkey, err := schnorr.ParsePubKey(pubkeyBytes)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
newVtxoScript, err := common.P2TRScript(pubkey)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
// Deduct the min relay fee from the very last receiver which is supposed
|
||||
// to be the change in case it's not a send-all.
|
||||
value := receiver.Amount
|
||||
if i == len(receivers)-1 {
|
||||
value -= redeemTxMinRelayFee
|
||||
}
|
||||
outs = append(outs, &wire.TxOut{
|
||||
Value: int64(value),
|
||||
PkScript: newVtxoScript,
|
||||
})
|
||||
}
|
||||
|
||||
sequences := make([]uint32, len(ins))
|
||||
for i := range sequences {
|
||||
sequences[i] = wire.MaxTxInSequenceNum
|
||||
}
|
||||
|
||||
redeemPtx, err := psbt.New(
|
||||
ins, outs, 2, 0, sequences,
|
||||
)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
for i := range redeemPtx.Inputs {
|
||||
redeemPtx.Inputs[i].WitnessUtxo = witnessUtxos[i]
|
||||
redeemPtx.Inputs[i].TaprootLeafScript = []*psbt.TaprootTapLeafScript{tapscripts[i]}
|
||||
}
|
||||
|
||||
redeemTx, err := redeemPtx.B64Encode()
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
signedRedeemTx, err := b.wallet.SignTransactionTapscript(
|
||||
context.Background(), redeemTx, nil,
|
||||
)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
return signedRedeemTx, nil
|
||||
}
|
||||
|
||||
// TODO use lnd CoinSelect to craft the pool tx
|
||||
func (b *txBuilder) createRoundTx(
|
||||
sharedOutputAmount int64,
|
||||
|
||||
@@ -3,11 +3,12 @@ package handlers
|
||||
import (
|
||||
"context"
|
||||
"encoding/hex"
|
||||
"google.golang.org/protobuf/types/known/durationpb"
|
||||
"google.golang.org/protobuf/types/known/timestamppb"
|
||||
"fmt"
|
||||
"sync"
|
||||
|
||||
"google.golang.org/protobuf/types/known/durationpb"
|
||||
"google.golang.org/protobuf/types/known/timestamppb"
|
||||
|
||||
arkv1 "github.com/ark-network/ark/api-spec/protobuf/gen/ark/v1"
|
||||
"github.com/ark-network/ark/common/bitcointree"
|
||||
"github.com/ark-network/ark/common/descriptor"
|
||||
@@ -309,61 +310,25 @@ func (h *handler) Ping(
|
||||
return &arkv1.PingResponse{}, nil
|
||||
}
|
||||
|
||||
func (h *handler) CreatePayment(
|
||||
ctx context.Context, req *arkv1.CreatePaymentRequest,
|
||||
) (*arkv1.CreatePaymentResponse, error) {
|
||||
inputs, err := parseAsyncPaymentInputs(req.GetInputs())
|
||||
if err != nil {
|
||||
return nil, status.Error(codes.InvalidArgument, err.Error())
|
||||
func (h *handler) SubmitRedeemTx(
|
||||
ctx context.Context, req *arkv1.SubmitRedeemTxRequest,
|
||||
) (*arkv1.SubmitRedeemTxResponse, error) {
|
||||
if req.GetRedeemTx() == "" {
|
||||
return nil, status.Error(codes.InvalidArgument, "missing redeem tx")
|
||||
}
|
||||
|
||||
receivers, err := parseReceivers(req.GetOutputs())
|
||||
if err != nil {
|
||||
return nil, status.Error(codes.InvalidArgument, err.Error())
|
||||
}
|
||||
|
||||
for _, receiver := range receivers {
|
||||
if receiver.Amount <= 0 {
|
||||
return nil, status.Error(codes.InvalidArgument, "output amount must be greater than 0")
|
||||
}
|
||||
|
||||
if len(receiver.OnchainAddress) <= 0 && len(receiver.Pubkey) <= 0 {
|
||||
return nil, status.Error(codes.InvalidArgument, "missing address")
|
||||
}
|
||||
|
||||
if receiver.IsOnchain() {
|
||||
return nil, status.Error(codes.InvalidArgument, "onchain outputs are not supported as async payment destination")
|
||||
}
|
||||
}
|
||||
|
||||
redeemTx, err := h.svc.CreateAsyncPayment(
|
||||
ctx, inputs, receivers,
|
||||
signedRedeemTx, err := h.svc.SubmitRedeemTx(
|
||||
ctx, req.GetRedeemTx(),
|
||||
)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &arkv1.CreatePaymentResponse{
|
||||
SignedRedeemTx: redeemTx,
|
||||
return &arkv1.SubmitRedeemTxResponse{
|
||||
SignedRedeemTx: signedRedeemTx,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (h *handler) CompletePayment(
|
||||
ctx context.Context, req *arkv1.CompletePaymentRequest,
|
||||
) (*arkv1.CompletePaymentResponse, error) {
|
||||
if req.GetSignedRedeemTx() == "" {
|
||||
return nil, status.Error(codes.InvalidArgument, "missing signed redeem tx")
|
||||
}
|
||||
|
||||
if err := h.svc.CompleteAsyncPayment(
|
||||
ctx, req.GetSignedRedeemTx(),
|
||||
); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &arkv1.CompletePaymentResponse{}, nil
|
||||
}
|
||||
|
||||
func (h *handler) GetRound(
|
||||
ctx context.Context, req *arkv1.GetRoundRequest,
|
||||
) (*arkv1.GetRoundResponse, error) {
|
||||
|
||||
@@ -12,7 +12,6 @@ import (
|
||||
"github.com/ark-network/ark/server/internal/core/domain"
|
||||
"github.com/ark-network/ark/server/internal/core/ports"
|
||||
"github.com/btcsuite/btcd/btcec/v2/schnorr"
|
||||
"github.com/btcsuite/btcd/chaincfg/chainhash"
|
||||
"github.com/btcsuite/btcd/txscript"
|
||||
)
|
||||
|
||||
@@ -25,33 +24,6 @@ func parseAddress(addr string) (*common.Address, error) {
|
||||
return common.DecodeAddress(addr)
|
||||
}
|
||||
|
||||
func parseAsyncPaymentInputs(ins []*arkv1.AsyncPaymentInput) ([]application.AsyncPaymentInput, error) {
|
||||
if len(ins) <= 0 {
|
||||
return nil, fmt.Errorf("missing inputs")
|
||||
}
|
||||
|
||||
inputs := make([]application.AsyncPaymentInput, 0, len(ins))
|
||||
for _, input := range ins {
|
||||
forfeitLeafHash, err := chainhash.NewHashFromStr(input.GetForfeitLeafHash())
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("invalid forfeit leaf hash: %s", err)
|
||||
}
|
||||
|
||||
inputs = append(inputs, application.AsyncPaymentInput{
|
||||
Input: ports.Input{
|
||||
VtxoKey: domain.VtxoKey{
|
||||
Txid: input.GetInput().GetOutpoint().GetTxid(),
|
||||
VOut: input.GetInput().GetOutpoint().GetVout(),
|
||||
},
|
||||
Tapscripts: input.GetInput().GetTapscripts().GetScripts(),
|
||||
},
|
||||
ForfeitLeafHash: *forfeitLeafHash,
|
||||
})
|
||||
}
|
||||
|
||||
return inputs, nil
|
||||
}
|
||||
|
||||
func parseNotes(notes []string) ([]note.Note, error) {
|
||||
if len(notes) <= 0 {
|
||||
return nil, fmt.Errorf("missing notes")
|
||||
|
||||
@@ -145,11 +145,7 @@ func Whitelist() map[string][]bakery.Op {
|
||||
Entity: EntityArk,
|
||||
Action: "read",
|
||||
}},
|
||||
fmt.Sprintf("/%s/CreatePayment", arkv1.ArkService_ServiceDesc.ServiceName): {{
|
||||
Entity: EntityArk,
|
||||
Action: "write",
|
||||
}},
|
||||
fmt.Sprintf("/%s/CompletePayment", arkv1.ArkService_ServiceDesc.ServiceName): {{
|
||||
fmt.Sprintf("/%s/SubmitRedeemTx", arkv1.ArkService_ServiceDesc.ServiceName): {{
|
||||
Entity: EntityArk,
|
||||
Action: "write",
|
||||
}},
|
||||
|
||||
Reference in New Issue
Block a user