mirror of
https://github.com/aljazceru/ark.git
synced 2026-02-23 12:12:49 +01:00
Drop unconditional forfeits txs in offline payment (#344)
* remove unconditionnal forfeit tx * fix sqlite vtxo repo * remove pendingData struct * delete uncond_forfeits_tx table
This commit is contained in:
@@ -42,9 +42,9 @@ type ASPClient interface {
|
||||
Ping(ctx context.Context, paymentID string) (RoundEvent, error)
|
||||
CreatePayment(
|
||||
ctx context.Context, inputs []Input, outputs []Output,
|
||||
) (string, []string, error)
|
||||
) (string, error)
|
||||
CompletePayment(
|
||||
ctx context.Context, signedRedeemTx string, signedUnconditionalForfeitTxs []string,
|
||||
ctx context.Context, signedRedeemTx string,
|
||||
) error
|
||||
ListVtxos(ctx context.Context, addr string) ([]Vtxo, []Vtxo, error)
|
||||
GetRound(ctx context.Context, txID string) (*Round, error)
|
||||
@@ -80,14 +80,13 @@ type Input struct {
|
||||
|
||||
type Vtxo struct {
|
||||
Outpoint
|
||||
Descriptor string
|
||||
Amount uint64
|
||||
RoundTxid string
|
||||
ExpiresAt *time.Time
|
||||
RedeemTx string
|
||||
UnconditionalForfeitTxs []string
|
||||
Pending bool
|
||||
SpentBy string
|
||||
Descriptor string
|
||||
Amount uint64
|
||||
RoundTxid string
|
||||
ExpiresAt *time.Time
|
||||
RedeemTx string
|
||||
Pending bool
|
||||
SpentBy string
|
||||
}
|
||||
|
||||
type Output struct {
|
||||
|
||||
@@ -238,24 +238,23 @@ func (a *grpcClient) Ping(
|
||||
|
||||
func (a *grpcClient) CreatePayment(
|
||||
ctx context.Context, inputs []client.Input, outputs []client.Output,
|
||||
) (string, []string, error) {
|
||||
) (string, error) {
|
||||
req := &arkv1.CreatePaymentRequest{
|
||||
Inputs: ins(inputs).toProto(),
|
||||
Outputs: outs(outputs).toProto(),
|
||||
}
|
||||
resp, err := a.svc.CreatePayment(ctx, req)
|
||||
if err != nil {
|
||||
return "", nil, err
|
||||
return "", err
|
||||
}
|
||||
return resp.SignedRedeemTx, resp.UsignedUnconditionalForfeitTxs, nil
|
||||
return resp.SignedRedeemTx, nil
|
||||
}
|
||||
|
||||
func (a *grpcClient) CompletePayment(
|
||||
ctx context.Context, redeemTx string, signedForfeitTxs []string,
|
||||
ctx context.Context, redeemTx string,
|
||||
) error {
|
||||
req := &arkv1.CompletePaymentRequest{
|
||||
SignedRedeemTx: redeemTx,
|
||||
SignedUnconditionalForfeitTxs: signedForfeitTxs,
|
||||
SignedRedeemTx: redeemTx,
|
||||
}
|
||||
_, err := a.svc.CompletePayment(ctx, req)
|
||||
return err
|
||||
|
||||
@@ -118,25 +118,18 @@ func (v vtxo) toVtxo() client.Vtxo {
|
||||
t := time.Unix(v.GetExpireAt(), 0)
|
||||
expiresAt = &t
|
||||
}
|
||||
var redeemTx string
|
||||
var uncondForfeitTxs []string
|
||||
if v.GetPendingData() != nil {
|
||||
redeemTx = v.GetPendingData().GetRedeemTx()
|
||||
uncondForfeitTxs = v.GetPendingData().GetUnconditionalForfeitTxs()
|
||||
}
|
||||
return client.Vtxo{
|
||||
Outpoint: client.Outpoint{
|
||||
Txid: v.GetOutpoint().GetTxid(),
|
||||
VOut: v.GetOutpoint().GetVout(),
|
||||
},
|
||||
Amount: v.GetAmount(),
|
||||
RoundTxid: v.GetRoundTxid(),
|
||||
ExpiresAt: expiresAt,
|
||||
Pending: v.GetPending(),
|
||||
RedeemTx: redeemTx,
|
||||
UnconditionalForfeitTxs: uncondForfeitTxs,
|
||||
SpentBy: v.GetSpentBy(),
|
||||
Descriptor: v.GetDescriptor_(),
|
||||
Amount: v.GetAmount(),
|
||||
RoundTxid: v.GetRoundTxid(),
|
||||
ExpiresAt: expiresAt,
|
||||
Pending: v.GetPending(),
|
||||
RedeemTx: v.GetRedeemTx(),
|
||||
SpentBy: v.GetSpentBy(),
|
||||
Descriptor: v.GetDescriptor_(),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -338,7 +338,7 @@ func (a *restClient) Ping(
|
||||
|
||||
func (a *restClient) CreatePayment(
|
||||
ctx context.Context, inputs []client.Input, outputs []client.Output,
|
||||
) (string, []string, error) {
|
||||
) (string, error) {
|
||||
ins := make([]*models.V1Input, 0, len(inputs))
|
||||
for _, i := range inputs {
|
||||
ins = append(ins, &models.V1Input{
|
||||
@@ -365,21 +365,19 @@ func (a *restClient) CreatePayment(
|
||||
ark_service.NewArkServiceCreatePaymentParams().WithBody(&body),
|
||||
)
|
||||
if err != nil {
|
||||
return "", nil, err
|
||||
return "", err
|
||||
}
|
||||
return resp.GetPayload().SignedRedeemTx, resp.GetPayload().UsignedUnconditionalForfeitTxs, nil
|
||||
return resp.GetPayload().SignedRedeemTx, nil
|
||||
}
|
||||
|
||||
func (a *restClient) CompletePayment(
|
||||
ctx context.Context, signedRedeemTx string, signedUncondForfeitTxs []string,
|
||||
ctx context.Context, signedRedeemTx string,
|
||||
) error {
|
||||
req := &arkv1.CompletePaymentRequest{
|
||||
SignedRedeemTx: signedRedeemTx,
|
||||
SignedUnconditionalForfeitTxs: signedUncondForfeitTxs,
|
||||
SignedRedeemTx: signedRedeemTx,
|
||||
}
|
||||
body := models.V1CompletePaymentRequest{
|
||||
SignedRedeemTx: req.GetSignedRedeemTx(),
|
||||
SignedUnconditionalForfeitTxs: req.GetSignedUnconditionalForfeitTxs(),
|
||||
SignedRedeemTx: req.GetSignedRedeemTx(),
|
||||
}
|
||||
_, err := a.svc.ArkServiceCompletePayment(
|
||||
ark_service.NewArkServiceCompletePaymentParams().WithBody(&body),
|
||||
@@ -492,26 +490,18 @@ func (a *restClient) ListVtxos(
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
var redeemTx string
|
||||
var uncondForfeitTxs []string
|
||||
if v.PendingData != nil {
|
||||
redeemTx = v.PendingData.RedeemTx
|
||||
uncondForfeitTxs = v.PendingData.UnconditionalForfeitTxs
|
||||
}
|
||||
|
||||
spendableVtxos = append(spendableVtxos, client.Vtxo{
|
||||
Outpoint: client.Outpoint{
|
||||
Txid: v.Outpoint.Txid,
|
||||
VOut: uint32(v.Outpoint.Vout),
|
||||
},
|
||||
Amount: uint64(amount),
|
||||
RoundTxid: v.RoundTxid,
|
||||
ExpiresAt: expiresAt,
|
||||
Pending: v.Pending,
|
||||
RedeemTx: redeemTx,
|
||||
UnconditionalForfeitTxs: uncondForfeitTxs,
|
||||
SpentBy: v.SpentBy,
|
||||
Descriptor: v.Descriptor,
|
||||
Amount: uint64(amount),
|
||||
RoundTxid: v.RoundTxid,
|
||||
ExpiresAt: expiresAt,
|
||||
Pending: v.Pending,
|
||||
RedeemTx: v.RedeemTx,
|
||||
SpentBy: v.SpentBy,
|
||||
Descriptor: v.Descriptor,
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -68,6 +68,8 @@ type ClientService interface {
|
||||
|
||||
ArkServiceGetRoundByID(params *ArkServiceGetRoundByIDParams, opts ...ClientOption) (*ArkServiceGetRoundByIDOK, error)
|
||||
|
||||
ArkServiceGetTransactionsStream(params *ArkServiceGetTransactionsStreamParams, opts ...ClientOption) (*ArkServiceGetTransactionsStreamOK, error)
|
||||
|
||||
ArkServiceListVtxos(params *ArkServiceListVtxosParams, opts ...ClientOption) (*ArkServiceListVtxosOK, error)
|
||||
|
||||
ArkServicePing(params *ArkServicePingParams, opts ...ClientOption) (*ArkServicePingOK, error)
|
||||
@@ -344,6 +346,43 @@ func (a *Client) ArkServiceGetRoundByID(params *ArkServiceGetRoundByIDParams, op
|
||||
return nil, runtime.NewAPIError("unexpected success response: content available as default response in error", unexpectedSuccess, unexpectedSuccess.Code())
|
||||
}
|
||||
|
||||
/*
|
||||
ArkServiceGetTransactionsStream ark service get transactions stream API
|
||||
*/
|
||||
func (a *Client) ArkServiceGetTransactionsStream(params *ArkServiceGetTransactionsStreamParams, opts ...ClientOption) (*ArkServiceGetTransactionsStreamOK, error) {
|
||||
// TODO: Validate the params before sending
|
||||
if params == nil {
|
||||
params = NewArkServiceGetTransactionsStreamParams()
|
||||
}
|
||||
op := &runtime.ClientOperation{
|
||||
ID: "ArkService_GetTransactionsStream",
|
||||
Method: "GET",
|
||||
PathPattern: "/v1/transactions",
|
||||
ProducesMediaTypes: []string{"application/json"},
|
||||
ConsumesMediaTypes: []string{"application/json"},
|
||||
Schemes: []string{"http"},
|
||||
Params: params,
|
||||
Reader: &ArkServiceGetTransactionsStreamReader{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.(*ArkServiceGetTransactionsStreamOK)
|
||||
if ok {
|
||||
return success, nil
|
||||
}
|
||||
// unexpected success response
|
||||
unexpectedSuccess := result.(*ArkServiceGetTransactionsStreamDefault)
|
||||
return nil, runtime.NewAPIError("unexpected success response: content available as default response in error", unexpectedSuccess, unexpectedSuccess.Code())
|
||||
}
|
||||
|
||||
/*
|
||||
ArkServiceListVtxos ark service list vtxos API
|
||||
*/
|
||||
|
||||
@@ -0,0 +1,128 @@
|
||||
// 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"
|
||||
)
|
||||
|
||||
// NewArkServiceGetTransactionsStreamParams creates a new ArkServiceGetTransactionsStreamParams 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 NewArkServiceGetTransactionsStreamParams() *ArkServiceGetTransactionsStreamParams {
|
||||
return &ArkServiceGetTransactionsStreamParams{
|
||||
timeout: cr.DefaultTimeout,
|
||||
}
|
||||
}
|
||||
|
||||
// NewArkServiceGetTransactionsStreamParamsWithTimeout creates a new ArkServiceGetTransactionsStreamParams object
|
||||
// with the ability to set a timeout on a request.
|
||||
func NewArkServiceGetTransactionsStreamParamsWithTimeout(timeout time.Duration) *ArkServiceGetTransactionsStreamParams {
|
||||
return &ArkServiceGetTransactionsStreamParams{
|
||||
timeout: timeout,
|
||||
}
|
||||
}
|
||||
|
||||
// NewArkServiceGetTransactionsStreamParamsWithContext creates a new ArkServiceGetTransactionsStreamParams object
|
||||
// with the ability to set a context for a request.
|
||||
func NewArkServiceGetTransactionsStreamParamsWithContext(ctx context.Context) *ArkServiceGetTransactionsStreamParams {
|
||||
return &ArkServiceGetTransactionsStreamParams{
|
||||
Context: ctx,
|
||||
}
|
||||
}
|
||||
|
||||
// NewArkServiceGetTransactionsStreamParamsWithHTTPClient creates a new ArkServiceGetTransactionsStreamParams object
|
||||
// with the ability to set a custom HTTPClient for a request.
|
||||
func NewArkServiceGetTransactionsStreamParamsWithHTTPClient(client *http.Client) *ArkServiceGetTransactionsStreamParams {
|
||||
return &ArkServiceGetTransactionsStreamParams{
|
||||
HTTPClient: client,
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
ArkServiceGetTransactionsStreamParams contains all the parameters to send to the API endpoint
|
||||
|
||||
for the ark service get transactions stream operation.
|
||||
|
||||
Typically these are written to a http.Request.
|
||||
*/
|
||||
type ArkServiceGetTransactionsStreamParams struct {
|
||||
timeout time.Duration
|
||||
Context context.Context
|
||||
HTTPClient *http.Client
|
||||
}
|
||||
|
||||
// WithDefaults hydrates default values in the ark service get transactions stream params (not the query body).
|
||||
//
|
||||
// All values with no default are reset to their zero value.
|
||||
func (o *ArkServiceGetTransactionsStreamParams) WithDefaults() *ArkServiceGetTransactionsStreamParams {
|
||||
o.SetDefaults()
|
||||
return o
|
||||
}
|
||||
|
||||
// SetDefaults hydrates default values in the ark service get transactions stream params (not the query body).
|
||||
//
|
||||
// All values with no default are reset to their zero value.
|
||||
func (o *ArkServiceGetTransactionsStreamParams) SetDefaults() {
|
||||
// no default values defined for this parameter
|
||||
}
|
||||
|
||||
// WithTimeout adds the timeout to the ark service get transactions stream params
|
||||
func (o *ArkServiceGetTransactionsStreamParams) WithTimeout(timeout time.Duration) *ArkServiceGetTransactionsStreamParams {
|
||||
o.SetTimeout(timeout)
|
||||
return o
|
||||
}
|
||||
|
||||
// SetTimeout adds the timeout to the ark service get transactions stream params
|
||||
func (o *ArkServiceGetTransactionsStreamParams) SetTimeout(timeout time.Duration) {
|
||||
o.timeout = timeout
|
||||
}
|
||||
|
||||
// WithContext adds the context to the ark service get transactions stream params
|
||||
func (o *ArkServiceGetTransactionsStreamParams) WithContext(ctx context.Context) *ArkServiceGetTransactionsStreamParams {
|
||||
o.SetContext(ctx)
|
||||
return o
|
||||
}
|
||||
|
||||
// SetContext adds the context to the ark service get transactions stream params
|
||||
func (o *ArkServiceGetTransactionsStreamParams) SetContext(ctx context.Context) {
|
||||
o.Context = ctx
|
||||
}
|
||||
|
||||
// WithHTTPClient adds the HTTPClient to the ark service get transactions stream params
|
||||
func (o *ArkServiceGetTransactionsStreamParams) WithHTTPClient(client *http.Client) *ArkServiceGetTransactionsStreamParams {
|
||||
o.SetHTTPClient(client)
|
||||
return o
|
||||
}
|
||||
|
||||
// SetHTTPClient adds the HTTPClient to the ark service get transactions stream params
|
||||
func (o *ArkServiceGetTransactionsStreamParams) SetHTTPClient(client *http.Client) {
|
||||
o.HTTPClient = client
|
||||
}
|
||||
|
||||
// WriteToRequest writes these params to a swagger request
|
||||
func (o *ArkServiceGetTransactionsStreamParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {
|
||||
|
||||
if err := r.SetTimeout(o.timeout); err != nil {
|
||||
return err
|
||||
}
|
||||
var res []error
|
||||
|
||||
if len(res) > 0 {
|
||||
return errors.CompositeValidationError(res...)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -0,0 +1,337 @@
|
||||
// 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"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io"
|
||||
|
||||
"github.com/go-openapi/errors"
|
||||
"github.com/go-openapi/runtime"
|
||||
"github.com/go-openapi/strfmt"
|
||||
"github.com/go-openapi/swag"
|
||||
|
||||
"github.com/ark-network/ark/pkg/client-sdk/client/rest/service/models"
|
||||
)
|
||||
|
||||
// ArkServiceGetTransactionsStreamReader is a Reader for the ArkServiceGetTransactionsStream structure.
|
||||
type ArkServiceGetTransactionsStreamReader struct {
|
||||
formats strfmt.Registry
|
||||
}
|
||||
|
||||
// ReadResponse reads a server response into the received o.
|
||||
func (o *ArkServiceGetTransactionsStreamReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) {
|
||||
switch response.Code() {
|
||||
case 200:
|
||||
result := NewArkServiceGetTransactionsStreamOK()
|
||||
if err := result.readResponse(response, consumer, o.formats); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return result, nil
|
||||
default:
|
||||
result := NewArkServiceGetTransactionsStreamDefault(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
|
||||
}
|
||||
}
|
||||
|
||||
// NewArkServiceGetTransactionsStreamOK creates a ArkServiceGetTransactionsStreamOK with default headers values
|
||||
func NewArkServiceGetTransactionsStreamOK() *ArkServiceGetTransactionsStreamOK {
|
||||
return &ArkServiceGetTransactionsStreamOK{}
|
||||
}
|
||||
|
||||
/*
|
||||
ArkServiceGetTransactionsStreamOK describes a response with status code 200, with default header values.
|
||||
|
||||
A successful response.(streaming responses)
|
||||
*/
|
||||
type ArkServiceGetTransactionsStreamOK struct {
|
||||
Payload *ArkServiceGetTransactionsStreamOKBody
|
||||
}
|
||||
|
||||
// IsSuccess returns true when this ark service get transactions stream o k response has a 2xx status code
|
||||
func (o *ArkServiceGetTransactionsStreamOK) IsSuccess() bool {
|
||||
return true
|
||||
}
|
||||
|
||||
// IsRedirect returns true when this ark service get transactions stream o k response has a 3xx status code
|
||||
func (o *ArkServiceGetTransactionsStreamOK) IsRedirect() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
// IsClientError returns true when this ark service get transactions stream o k response has a 4xx status code
|
||||
func (o *ArkServiceGetTransactionsStreamOK) IsClientError() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
// IsServerError returns true when this ark service get transactions stream o k response has a 5xx status code
|
||||
func (o *ArkServiceGetTransactionsStreamOK) IsServerError() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
// IsCode returns true when this ark service get transactions stream o k response a status code equal to that given
|
||||
func (o *ArkServiceGetTransactionsStreamOK) IsCode(code int) bool {
|
||||
return code == 200
|
||||
}
|
||||
|
||||
// Code gets the status code for the ark service get transactions stream o k response
|
||||
func (o *ArkServiceGetTransactionsStreamOK) Code() int {
|
||||
return 200
|
||||
}
|
||||
|
||||
func (o *ArkServiceGetTransactionsStreamOK) Error() string {
|
||||
payload, _ := json.Marshal(o.Payload)
|
||||
return fmt.Sprintf("[GET /v1/transactions][%d] arkServiceGetTransactionsStreamOK %s", 200, payload)
|
||||
}
|
||||
|
||||
func (o *ArkServiceGetTransactionsStreamOK) String() string {
|
||||
payload, _ := json.Marshal(o.Payload)
|
||||
return fmt.Sprintf("[GET /v1/transactions][%d] arkServiceGetTransactionsStreamOK %s", 200, payload)
|
||||
}
|
||||
|
||||
func (o *ArkServiceGetTransactionsStreamOK) GetPayload() *ArkServiceGetTransactionsStreamOKBody {
|
||||
return o.Payload
|
||||
}
|
||||
|
||||
func (o *ArkServiceGetTransactionsStreamOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
|
||||
|
||||
o.Payload = new(ArkServiceGetTransactionsStreamOKBody)
|
||||
|
||||
// response payload
|
||||
if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// NewArkServiceGetTransactionsStreamDefault creates a ArkServiceGetTransactionsStreamDefault with default headers values
|
||||
func NewArkServiceGetTransactionsStreamDefault(code int) *ArkServiceGetTransactionsStreamDefault {
|
||||
return &ArkServiceGetTransactionsStreamDefault{
|
||||
_statusCode: code,
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
ArkServiceGetTransactionsStreamDefault describes a response with status code -1, with default header values.
|
||||
|
||||
An unexpected error response.
|
||||
*/
|
||||
type ArkServiceGetTransactionsStreamDefault struct {
|
||||
_statusCode int
|
||||
|
||||
Payload *models.RPCStatus
|
||||
}
|
||||
|
||||
// IsSuccess returns true when this ark service get transactions stream default response has a 2xx status code
|
||||
func (o *ArkServiceGetTransactionsStreamDefault) IsSuccess() bool {
|
||||
return o._statusCode/100 == 2
|
||||
}
|
||||
|
||||
// IsRedirect returns true when this ark service get transactions stream default response has a 3xx status code
|
||||
func (o *ArkServiceGetTransactionsStreamDefault) IsRedirect() bool {
|
||||
return o._statusCode/100 == 3
|
||||
}
|
||||
|
||||
// IsClientError returns true when this ark service get transactions stream default response has a 4xx status code
|
||||
func (o *ArkServiceGetTransactionsStreamDefault) IsClientError() bool {
|
||||
return o._statusCode/100 == 4
|
||||
}
|
||||
|
||||
// IsServerError returns true when this ark service get transactions stream default response has a 5xx status code
|
||||
func (o *ArkServiceGetTransactionsStreamDefault) IsServerError() bool {
|
||||
return o._statusCode/100 == 5
|
||||
}
|
||||
|
||||
// IsCode returns true when this ark service get transactions stream default response a status code equal to that given
|
||||
func (o *ArkServiceGetTransactionsStreamDefault) IsCode(code int) bool {
|
||||
return o._statusCode == code
|
||||
}
|
||||
|
||||
// Code gets the status code for the ark service get transactions stream default response
|
||||
func (o *ArkServiceGetTransactionsStreamDefault) Code() int {
|
||||
return o._statusCode
|
||||
}
|
||||
|
||||
func (o *ArkServiceGetTransactionsStreamDefault) Error() string {
|
||||
payload, _ := json.Marshal(o.Payload)
|
||||
return fmt.Sprintf("[GET /v1/transactions][%d] ArkService_GetTransactionsStream default %s", o._statusCode, payload)
|
||||
}
|
||||
|
||||
func (o *ArkServiceGetTransactionsStreamDefault) String() string {
|
||||
payload, _ := json.Marshal(o.Payload)
|
||||
return fmt.Sprintf("[GET /v1/transactions][%d] ArkService_GetTransactionsStream default %s", o._statusCode, payload)
|
||||
}
|
||||
|
||||
func (o *ArkServiceGetTransactionsStreamDefault) GetPayload() *models.RPCStatus {
|
||||
return o.Payload
|
||||
}
|
||||
|
||||
func (o *ArkServiceGetTransactionsStreamDefault) 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
|
||||
}
|
||||
|
||||
/*
|
||||
ArkServiceGetTransactionsStreamOKBody Stream result of v1GetTransactionsStreamResponse
|
||||
swagger:model ArkServiceGetTransactionsStreamOKBody
|
||||
*/
|
||||
type ArkServiceGetTransactionsStreamOKBody struct {
|
||||
|
||||
// error
|
||||
Error *models.RPCStatus `json:"error,omitempty"`
|
||||
|
||||
// result
|
||||
Result *models.V1GetTransactionsStreamResponse `json:"result,omitempty"`
|
||||
}
|
||||
|
||||
// Validate validates this ark service get transactions stream o k body
|
||||
func (o *ArkServiceGetTransactionsStreamOKBody) Validate(formats strfmt.Registry) error {
|
||||
var res []error
|
||||
|
||||
if err := o.validateError(formats); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
if err := o.validateResult(formats); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
if len(res) > 0 {
|
||||
return errors.CompositeValidationError(res...)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (o *ArkServiceGetTransactionsStreamOKBody) validateError(formats strfmt.Registry) error {
|
||||
if swag.IsZero(o.Error) { // not required
|
||||
return nil
|
||||
}
|
||||
|
||||
if o.Error != nil {
|
||||
if err := o.Error.Validate(formats); err != nil {
|
||||
if ve, ok := err.(*errors.Validation); ok {
|
||||
return ve.ValidateName("arkServiceGetTransactionsStreamOK" + "." + "error")
|
||||
} else if ce, ok := err.(*errors.CompositeError); ok {
|
||||
return ce.ValidateName("arkServiceGetTransactionsStreamOK" + "." + "error")
|
||||
}
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (o *ArkServiceGetTransactionsStreamOKBody) validateResult(formats strfmt.Registry) error {
|
||||
if swag.IsZero(o.Result) { // not required
|
||||
return nil
|
||||
}
|
||||
|
||||
if o.Result != nil {
|
||||
if err := o.Result.Validate(formats); err != nil {
|
||||
if ve, ok := err.(*errors.Validation); ok {
|
||||
return ve.ValidateName("arkServiceGetTransactionsStreamOK" + "." + "result")
|
||||
} else if ce, ok := err.(*errors.CompositeError); ok {
|
||||
return ce.ValidateName("arkServiceGetTransactionsStreamOK" + "." + "result")
|
||||
}
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// ContextValidate validate this ark service get transactions stream o k body based on the context it is used
|
||||
func (o *ArkServiceGetTransactionsStreamOKBody) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
|
||||
var res []error
|
||||
|
||||
if err := o.contextValidateError(ctx, formats); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
if err := o.contextValidateResult(ctx, formats); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
if len(res) > 0 {
|
||||
return errors.CompositeValidationError(res...)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (o *ArkServiceGetTransactionsStreamOKBody) contextValidateError(ctx context.Context, formats strfmt.Registry) error {
|
||||
|
||||
if o.Error != nil {
|
||||
|
||||
if swag.IsZero(o.Error) { // not required
|
||||
return nil
|
||||
}
|
||||
|
||||
if err := o.Error.ContextValidate(ctx, formats); err != nil {
|
||||
if ve, ok := err.(*errors.Validation); ok {
|
||||
return ve.ValidateName("arkServiceGetTransactionsStreamOK" + "." + "error")
|
||||
} else if ce, ok := err.(*errors.CompositeError); ok {
|
||||
return ce.ValidateName("arkServiceGetTransactionsStreamOK" + "." + "error")
|
||||
}
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (o *ArkServiceGetTransactionsStreamOKBody) contextValidateResult(ctx context.Context, formats strfmt.Registry) error {
|
||||
|
||||
if o.Result != nil {
|
||||
|
||||
if swag.IsZero(o.Result) { // not required
|
||||
return nil
|
||||
}
|
||||
|
||||
if err := o.Result.ContextValidate(ctx, formats); err != nil {
|
||||
if ve, ok := err.(*errors.Validation); ok {
|
||||
return ve.ValidateName("arkServiceGetTransactionsStreamOK" + "." + "result")
|
||||
} else if ce, ok := err.(*errors.CompositeError); ok {
|
||||
return ce.ValidateName("arkServiceGetTransactionsStreamOK" + "." + "result")
|
||||
}
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// MarshalBinary interface implementation
|
||||
func (o *ArkServiceGetTransactionsStreamOKBody) MarshalBinary() ([]byte, error) {
|
||||
if o == nil {
|
||||
return nil, nil
|
||||
}
|
||||
return swag.WriteJSON(o)
|
||||
}
|
||||
|
||||
// UnmarshalBinary interface implementation
|
||||
func (o *ArkServiceGetTransactionsStreamOKBody) UnmarshalBinary(b []byte) error {
|
||||
var res ArkServiceGetTransactionsStreamOKBody
|
||||
if err := swag.ReadJSON(b, &res); err != nil {
|
||||
return err
|
||||
}
|
||||
*o = res
|
||||
return nil
|
||||
}
|
||||
@@ -19,9 +19,6 @@ type V1CompletePaymentRequest struct {
|
||||
|
||||
// signed redeem tx
|
||||
SignedRedeemTx string `json:"signedRedeemTx,omitempty"`
|
||||
|
||||
// signed unconditional forfeit txs
|
||||
SignedUnconditionalForfeitTxs []string `json:"signedUnconditionalForfeitTxs"`
|
||||
}
|
||||
|
||||
// Validate validates this v1 complete payment request
|
||||
|
||||
@@ -19,9 +19,6 @@ type V1CreatePaymentResponse struct {
|
||||
|
||||
// signed only by the ASP
|
||||
SignedRedeemTx string `json:"signedRedeemTx,omitempty"`
|
||||
|
||||
// usigned unconditional forfeit txs
|
||||
UsignedUnconditionalForfeitTxs []string `json:"usignedUnconditionalForfeitTxs"`
|
||||
}
|
||||
|
||||
// Validate validates this v1 create payment response
|
||||
|
||||
@@ -0,0 +1,160 @@
|
||||
// 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"
|
||||
)
|
||||
|
||||
// V1GetTransactionsStreamResponse v1 get transactions stream response
|
||||
//
|
||||
// swagger:model v1GetTransactionsStreamResponse
|
||||
type V1GetTransactionsStreamResponse struct {
|
||||
|
||||
// redeem
|
||||
Redeem *V1RedeemTransaction `json:"redeem,omitempty"`
|
||||
|
||||
// round
|
||||
Round *V1RoundTransaction `json:"round,omitempty"`
|
||||
}
|
||||
|
||||
// Validate validates this v1 get transactions stream response
|
||||
func (m *V1GetTransactionsStreamResponse) Validate(formats strfmt.Registry) error {
|
||||
var res []error
|
||||
|
||||
if err := m.validateRedeem(formats); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
if err := m.validateRound(formats); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
if len(res) > 0 {
|
||||
return errors.CompositeValidationError(res...)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *V1GetTransactionsStreamResponse) validateRedeem(formats strfmt.Registry) error {
|
||||
if swag.IsZero(m.Redeem) { // not required
|
||||
return nil
|
||||
}
|
||||
|
||||
if m.Redeem != nil {
|
||||
if err := m.Redeem.Validate(formats); err != nil {
|
||||
if ve, ok := err.(*errors.Validation); ok {
|
||||
return ve.ValidateName("redeem")
|
||||
} else if ce, ok := err.(*errors.CompositeError); ok {
|
||||
return ce.ValidateName("redeem")
|
||||
}
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *V1GetTransactionsStreamResponse) validateRound(formats strfmt.Registry) error {
|
||||
if swag.IsZero(m.Round) { // not required
|
||||
return nil
|
||||
}
|
||||
|
||||
if m.Round != nil {
|
||||
if err := m.Round.Validate(formats); err != nil {
|
||||
if ve, ok := err.(*errors.Validation); ok {
|
||||
return ve.ValidateName("round")
|
||||
} else if ce, ok := err.(*errors.CompositeError); ok {
|
||||
return ce.ValidateName("round")
|
||||
}
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// ContextValidate validate this v1 get transactions stream response based on the context it is used
|
||||
func (m *V1GetTransactionsStreamResponse) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
|
||||
var res []error
|
||||
|
||||
if err := m.contextValidateRedeem(ctx, formats); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
if err := m.contextValidateRound(ctx, formats); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
if len(res) > 0 {
|
||||
return errors.CompositeValidationError(res...)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *V1GetTransactionsStreamResponse) contextValidateRedeem(ctx context.Context, formats strfmt.Registry) error {
|
||||
|
||||
if m.Redeem != nil {
|
||||
|
||||
if swag.IsZero(m.Redeem) { // not required
|
||||
return nil
|
||||
}
|
||||
|
||||
if err := m.Redeem.ContextValidate(ctx, formats); err != nil {
|
||||
if ve, ok := err.(*errors.Validation); ok {
|
||||
return ve.ValidateName("redeem")
|
||||
} else if ce, ok := err.(*errors.CompositeError); ok {
|
||||
return ce.ValidateName("redeem")
|
||||
}
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *V1GetTransactionsStreamResponse) contextValidateRound(ctx context.Context, formats strfmt.Registry) error {
|
||||
|
||||
if m.Round != nil {
|
||||
|
||||
if swag.IsZero(m.Round) { // not required
|
||||
return nil
|
||||
}
|
||||
|
||||
if err := m.Round.ContextValidate(ctx, formats); err != nil {
|
||||
if ve, ok := err.(*errors.Validation); ok {
|
||||
return ve.ValidateName("round")
|
||||
} else if ce, ok := err.(*errors.CompositeError); ok {
|
||||
return ce.ValidateName("round")
|
||||
}
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// MarshalBinary interface implementation
|
||||
func (m *V1GetTransactionsStreamResponse) MarshalBinary() ([]byte, error) {
|
||||
if m == nil {
|
||||
return nil, nil
|
||||
}
|
||||
return swag.WriteJSON(m)
|
||||
}
|
||||
|
||||
// UnmarshalBinary interface implementation
|
||||
func (m *V1GetTransactionsStreamResponse) UnmarshalBinary(b []byte) error {
|
||||
var res V1GetTransactionsStreamResponse
|
||||
if err := swag.ReadJSON(b, &res); err != nil {
|
||||
return err
|
||||
}
|
||||
*m = res
|
||||
return nil
|
||||
}
|
||||
@@ -19,9 +19,6 @@ type V1PendingPayment struct {
|
||||
|
||||
// redeem tx
|
||||
RedeemTx string `json:"redeemTx,omitempty"`
|
||||
|
||||
// unconditional forfeit txs
|
||||
UnconditionalForfeitTxs []string `json:"unconditionalForfeitTxs"`
|
||||
}
|
||||
|
||||
// Validate validates this v1 pending payment
|
||||
|
||||
@@ -0,0 +1,186 @@
|
||||
// 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"
|
||||
)
|
||||
|
||||
// V1RedeemTransaction v1 redeem transaction
|
||||
//
|
||||
// swagger:model v1RedeemTransaction
|
||||
type V1RedeemTransaction struct {
|
||||
|
||||
// spendable vtxos
|
||||
SpendableVtxos []*V1Vtxo `json:"spendableVtxos"`
|
||||
|
||||
// spent vtxos
|
||||
SpentVtxos []*V1Outpoint `json:"spentVtxos"`
|
||||
|
||||
// txid
|
||||
Txid string `json:"txid,omitempty"`
|
||||
}
|
||||
|
||||
// Validate validates this v1 redeem transaction
|
||||
func (m *V1RedeemTransaction) Validate(formats strfmt.Registry) error {
|
||||
var res []error
|
||||
|
||||
if err := m.validateSpendableVtxos(formats); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
if err := m.validateSpentVtxos(formats); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
if len(res) > 0 {
|
||||
return errors.CompositeValidationError(res...)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *V1RedeemTransaction) validateSpendableVtxos(formats strfmt.Registry) error {
|
||||
if swag.IsZero(m.SpendableVtxos) { // not required
|
||||
return nil
|
||||
}
|
||||
|
||||
for i := 0; i < len(m.SpendableVtxos); i++ {
|
||||
if swag.IsZero(m.SpendableVtxos[i]) { // not required
|
||||
continue
|
||||
}
|
||||
|
||||
if m.SpendableVtxos[i] != nil {
|
||||
if err := m.SpendableVtxos[i].Validate(formats); err != nil {
|
||||
if ve, ok := err.(*errors.Validation); ok {
|
||||
return ve.ValidateName("spendableVtxos" + "." + strconv.Itoa(i))
|
||||
} else if ce, ok := err.(*errors.CompositeError); ok {
|
||||
return ce.ValidateName("spendableVtxos" + "." + strconv.Itoa(i))
|
||||
}
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *V1RedeemTransaction) validateSpentVtxos(formats strfmt.Registry) error {
|
||||
if swag.IsZero(m.SpentVtxos) { // not required
|
||||
return nil
|
||||
}
|
||||
|
||||
for i := 0; i < len(m.SpentVtxos); i++ {
|
||||
if swag.IsZero(m.SpentVtxos[i]) { // not required
|
||||
continue
|
||||
}
|
||||
|
||||
if m.SpentVtxos[i] != nil {
|
||||
if err := m.SpentVtxos[i].Validate(formats); err != nil {
|
||||
if ve, ok := err.(*errors.Validation); ok {
|
||||
return ve.ValidateName("spentVtxos" + "." + strconv.Itoa(i))
|
||||
} else if ce, ok := err.(*errors.CompositeError); ok {
|
||||
return ce.ValidateName("spentVtxos" + "." + strconv.Itoa(i))
|
||||
}
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// ContextValidate validate this v1 redeem transaction based on the context it is used
|
||||
func (m *V1RedeemTransaction) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
|
||||
var res []error
|
||||
|
||||
if err := m.contextValidateSpendableVtxos(ctx, formats); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
if err := m.contextValidateSpentVtxos(ctx, formats); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
if len(res) > 0 {
|
||||
return errors.CompositeValidationError(res...)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *V1RedeemTransaction) contextValidateSpendableVtxos(ctx context.Context, formats strfmt.Registry) error {
|
||||
|
||||
for i := 0; i < len(m.SpendableVtxos); i++ {
|
||||
|
||||
if m.SpendableVtxos[i] != nil {
|
||||
|
||||
if swag.IsZero(m.SpendableVtxos[i]) { // not required
|
||||
return nil
|
||||
}
|
||||
|
||||
if err := m.SpendableVtxos[i].ContextValidate(ctx, formats); err != nil {
|
||||
if ve, ok := err.(*errors.Validation); ok {
|
||||
return ve.ValidateName("spendableVtxos" + "." + strconv.Itoa(i))
|
||||
} else if ce, ok := err.(*errors.CompositeError); ok {
|
||||
return ce.ValidateName("spendableVtxos" + "." + strconv.Itoa(i))
|
||||
}
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *V1RedeemTransaction) contextValidateSpentVtxos(ctx context.Context, formats strfmt.Registry) error {
|
||||
|
||||
for i := 0; i < len(m.SpentVtxos); i++ {
|
||||
|
||||
if m.SpentVtxos[i] != nil {
|
||||
|
||||
if swag.IsZero(m.SpentVtxos[i]) { // not required
|
||||
return nil
|
||||
}
|
||||
|
||||
if err := m.SpentVtxos[i].ContextValidate(ctx, formats); err != nil {
|
||||
if ve, ok := err.(*errors.Validation); ok {
|
||||
return ve.ValidateName("spentVtxos" + "." + strconv.Itoa(i))
|
||||
} else if ce, ok := err.(*errors.CompositeError); ok {
|
||||
return ce.ValidateName("spentVtxos" + "." + strconv.Itoa(i))
|
||||
}
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// MarshalBinary interface implementation
|
||||
func (m *V1RedeemTransaction) MarshalBinary() ([]byte, error) {
|
||||
if m == nil {
|
||||
return nil, nil
|
||||
}
|
||||
return swag.WriteJSON(m)
|
||||
}
|
||||
|
||||
// UnmarshalBinary interface implementation
|
||||
func (m *V1RedeemTransaction) UnmarshalBinary(b []byte) error {
|
||||
var res V1RedeemTransaction
|
||||
if err := swag.ReadJSON(b, &res); err != nil {
|
||||
return err
|
||||
}
|
||||
*m = res
|
||||
return nil
|
||||
}
|
||||
@@ -0,0 +1,248 @@
|
||||
// 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"
|
||||
)
|
||||
|
||||
// V1RoundTransaction v1 round transaction
|
||||
//
|
||||
// swagger:model v1RoundTransaction
|
||||
type V1RoundTransaction struct {
|
||||
|
||||
// claimed boarding utxos
|
||||
ClaimedBoardingUtxos []*V1Outpoint `json:"claimedBoardingUtxos"`
|
||||
|
||||
// spendable vtxos
|
||||
SpendableVtxos []*V1Vtxo `json:"spendableVtxos"`
|
||||
|
||||
// spent vtxos
|
||||
SpentVtxos []*V1Outpoint `json:"spentVtxos"`
|
||||
|
||||
// txid
|
||||
Txid string `json:"txid,omitempty"`
|
||||
}
|
||||
|
||||
// Validate validates this v1 round transaction
|
||||
func (m *V1RoundTransaction) Validate(formats strfmt.Registry) error {
|
||||
var res []error
|
||||
|
||||
if err := m.validateClaimedBoardingUtxos(formats); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
if err := m.validateSpendableVtxos(formats); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
if err := m.validateSpentVtxos(formats); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
if len(res) > 0 {
|
||||
return errors.CompositeValidationError(res...)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *V1RoundTransaction) validateClaimedBoardingUtxos(formats strfmt.Registry) error {
|
||||
if swag.IsZero(m.ClaimedBoardingUtxos) { // not required
|
||||
return nil
|
||||
}
|
||||
|
||||
for i := 0; i < len(m.ClaimedBoardingUtxos); i++ {
|
||||
if swag.IsZero(m.ClaimedBoardingUtxos[i]) { // not required
|
||||
continue
|
||||
}
|
||||
|
||||
if m.ClaimedBoardingUtxos[i] != nil {
|
||||
if err := m.ClaimedBoardingUtxos[i].Validate(formats); err != nil {
|
||||
if ve, ok := err.(*errors.Validation); ok {
|
||||
return ve.ValidateName("claimedBoardingUtxos" + "." + strconv.Itoa(i))
|
||||
} else if ce, ok := err.(*errors.CompositeError); ok {
|
||||
return ce.ValidateName("claimedBoardingUtxos" + "." + strconv.Itoa(i))
|
||||
}
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *V1RoundTransaction) validateSpendableVtxos(formats strfmt.Registry) error {
|
||||
if swag.IsZero(m.SpendableVtxos) { // not required
|
||||
return nil
|
||||
}
|
||||
|
||||
for i := 0; i < len(m.SpendableVtxos); i++ {
|
||||
if swag.IsZero(m.SpendableVtxos[i]) { // not required
|
||||
continue
|
||||
}
|
||||
|
||||
if m.SpendableVtxos[i] != nil {
|
||||
if err := m.SpendableVtxos[i].Validate(formats); err != nil {
|
||||
if ve, ok := err.(*errors.Validation); ok {
|
||||
return ve.ValidateName("spendableVtxos" + "." + strconv.Itoa(i))
|
||||
} else if ce, ok := err.(*errors.CompositeError); ok {
|
||||
return ce.ValidateName("spendableVtxos" + "." + strconv.Itoa(i))
|
||||
}
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *V1RoundTransaction) validateSpentVtxos(formats strfmt.Registry) error {
|
||||
if swag.IsZero(m.SpentVtxos) { // not required
|
||||
return nil
|
||||
}
|
||||
|
||||
for i := 0; i < len(m.SpentVtxos); i++ {
|
||||
if swag.IsZero(m.SpentVtxos[i]) { // not required
|
||||
continue
|
||||
}
|
||||
|
||||
if m.SpentVtxos[i] != nil {
|
||||
if err := m.SpentVtxos[i].Validate(formats); err != nil {
|
||||
if ve, ok := err.(*errors.Validation); ok {
|
||||
return ve.ValidateName("spentVtxos" + "." + strconv.Itoa(i))
|
||||
} else if ce, ok := err.(*errors.CompositeError); ok {
|
||||
return ce.ValidateName("spentVtxos" + "." + strconv.Itoa(i))
|
||||
}
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// ContextValidate validate this v1 round transaction based on the context it is used
|
||||
func (m *V1RoundTransaction) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
|
||||
var res []error
|
||||
|
||||
if err := m.contextValidateClaimedBoardingUtxos(ctx, formats); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
if err := m.contextValidateSpendableVtxos(ctx, formats); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
if err := m.contextValidateSpentVtxos(ctx, formats); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
if len(res) > 0 {
|
||||
return errors.CompositeValidationError(res...)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *V1RoundTransaction) contextValidateClaimedBoardingUtxos(ctx context.Context, formats strfmt.Registry) error {
|
||||
|
||||
for i := 0; i < len(m.ClaimedBoardingUtxos); i++ {
|
||||
|
||||
if m.ClaimedBoardingUtxos[i] != nil {
|
||||
|
||||
if swag.IsZero(m.ClaimedBoardingUtxos[i]) { // not required
|
||||
return nil
|
||||
}
|
||||
|
||||
if err := m.ClaimedBoardingUtxos[i].ContextValidate(ctx, formats); err != nil {
|
||||
if ve, ok := err.(*errors.Validation); ok {
|
||||
return ve.ValidateName("claimedBoardingUtxos" + "." + strconv.Itoa(i))
|
||||
} else if ce, ok := err.(*errors.CompositeError); ok {
|
||||
return ce.ValidateName("claimedBoardingUtxos" + "." + strconv.Itoa(i))
|
||||
}
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *V1RoundTransaction) contextValidateSpendableVtxos(ctx context.Context, formats strfmt.Registry) error {
|
||||
|
||||
for i := 0; i < len(m.SpendableVtxos); i++ {
|
||||
|
||||
if m.SpendableVtxos[i] != nil {
|
||||
|
||||
if swag.IsZero(m.SpendableVtxos[i]) { // not required
|
||||
return nil
|
||||
}
|
||||
|
||||
if err := m.SpendableVtxos[i].ContextValidate(ctx, formats); err != nil {
|
||||
if ve, ok := err.(*errors.Validation); ok {
|
||||
return ve.ValidateName("spendableVtxos" + "." + strconv.Itoa(i))
|
||||
} else if ce, ok := err.(*errors.CompositeError); ok {
|
||||
return ce.ValidateName("spendableVtxos" + "." + strconv.Itoa(i))
|
||||
}
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *V1RoundTransaction) contextValidateSpentVtxos(ctx context.Context, formats strfmt.Registry) error {
|
||||
|
||||
for i := 0; i < len(m.SpentVtxos); i++ {
|
||||
|
||||
if m.SpentVtxos[i] != nil {
|
||||
|
||||
if swag.IsZero(m.SpentVtxos[i]) { // not required
|
||||
return nil
|
||||
}
|
||||
|
||||
if err := m.SpentVtxos[i].ContextValidate(ctx, formats); err != nil {
|
||||
if ve, ok := err.(*errors.Validation); ok {
|
||||
return ve.ValidateName("spentVtxos" + "." + strconv.Itoa(i))
|
||||
} else if ce, ok := err.(*errors.CompositeError); ok {
|
||||
return ce.ValidateName("spentVtxos" + "." + strconv.Itoa(i))
|
||||
}
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// MarshalBinary interface implementation
|
||||
func (m *V1RoundTransaction) MarshalBinary() ([]byte, error) {
|
||||
if m == nil {
|
||||
return nil, nil
|
||||
}
|
||||
return swag.WriteJSON(m)
|
||||
}
|
||||
|
||||
// UnmarshalBinary interface implementation
|
||||
func (m *V1RoundTransaction) UnmarshalBinary(b []byte) error {
|
||||
var res V1RoundTransaction
|
||||
if err := swag.ReadJSON(b, &res); err != nil {
|
||||
return err
|
||||
}
|
||||
*m = res
|
||||
return nil
|
||||
}
|
||||
@@ -33,8 +33,8 @@ type V1Vtxo struct {
|
||||
// pending
|
||||
Pending bool `json:"pending,omitempty"`
|
||||
|
||||
// pending data
|
||||
PendingData *V1PendingPayment `json:"pendingData,omitempty"`
|
||||
// redeem tx
|
||||
RedeemTx string `json:"redeemTx,omitempty"`
|
||||
|
||||
// round txid
|
||||
RoundTxid string `json:"roundTxid,omitempty"`
|
||||
@@ -57,10 +57,6 @@ func (m *V1Vtxo) Validate(formats strfmt.Registry) error {
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
if err := m.validatePendingData(formats); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
if len(res) > 0 {
|
||||
return errors.CompositeValidationError(res...)
|
||||
}
|
||||
@@ -86,25 +82,6 @@ func (m *V1Vtxo) validateOutpoint(formats strfmt.Registry) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *V1Vtxo) validatePendingData(formats strfmt.Registry) error {
|
||||
if swag.IsZero(m.PendingData) { // not required
|
||||
return nil
|
||||
}
|
||||
|
||||
if m.PendingData != nil {
|
||||
if err := m.PendingData.Validate(formats); err != nil {
|
||||
if ve, ok := err.(*errors.Validation); ok {
|
||||
return ve.ValidateName("pendingData")
|
||||
} else if ce, ok := err.(*errors.CompositeError); ok {
|
||||
return ce.ValidateName("pendingData")
|
||||
}
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// ContextValidate validate this v1 vtxo based on the context it is used
|
||||
func (m *V1Vtxo) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
|
||||
var res []error
|
||||
@@ -113,10 +90,6 @@ func (m *V1Vtxo) ContextValidate(ctx context.Context, formats strfmt.Registry) e
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
if err := m.contextValidatePendingData(ctx, formats); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
if len(res) > 0 {
|
||||
return errors.CompositeValidationError(res...)
|
||||
}
|
||||
@@ -144,27 +117,6 @@ func (m *V1Vtxo) contextValidateOutpoint(ctx context.Context, formats strfmt.Reg
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *V1Vtxo) contextValidatePendingData(ctx context.Context, formats strfmt.Registry) error {
|
||||
|
||||
if m.PendingData != nil {
|
||||
|
||||
if swag.IsZero(m.PendingData) { // not required
|
||||
return nil
|
||||
}
|
||||
|
||||
if err := m.PendingData.ContextValidate(ctx, formats); err != nil {
|
||||
if ve, ok := err.(*errors.Validation); ok {
|
||||
return ve.ValidateName("pendingData")
|
||||
} else if ce, ok := err.(*errors.CompositeError); ok {
|
||||
return ce.ValidateName("pendingData")
|
||||
}
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// MarshalBinary interface implementation
|
||||
func (m *V1Vtxo) MarshalBinary() ([]byte, error) {
|
||||
if m == nil {
|
||||
|
||||
@@ -196,13 +196,12 @@ func loadFixtures(jsonStr string) (vtxos, map[string]struct{}, error) {
|
||||
Txid: vtxo.Outpoint.Txid,
|
||||
VOut: vtxo.Outpoint.Vout,
|
||||
},
|
||||
Amount: amount,
|
||||
RoundTxid: vtxo.PoolTxid,
|
||||
ExpiresAt: &expireAt,
|
||||
RedeemTx: vtxo.PendingData.RedeemTx,
|
||||
UnconditionalForfeitTxs: vtxo.PendingData.UnconditionalForfeitTxs,
|
||||
Pending: vtxo.Pending,
|
||||
SpentBy: vtxo.SpentBy,
|
||||
Amount: amount,
|
||||
RoundTxid: vtxo.PoolTxid,
|
||||
ExpiresAt: &expireAt,
|
||||
RedeemTx: vtxo.PendingData.RedeemTx,
|
||||
Pending: vtxo.Pending,
|
||||
SpentBy: vtxo.SpentBy,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -221,13 +220,12 @@ func loadFixtures(jsonStr string) (vtxos, map[string]struct{}, error) {
|
||||
Txid: vtxo.Outpoint.Txid,
|
||||
VOut: vtxo.Outpoint.Vout,
|
||||
},
|
||||
Amount: amount,
|
||||
RoundTxid: vtxo.PoolTxid,
|
||||
ExpiresAt: &expireAt,
|
||||
RedeemTx: vtxo.PendingData.RedeemTx,
|
||||
UnconditionalForfeitTxs: vtxo.PendingData.UnconditionalForfeitTxs,
|
||||
Pending: vtxo.Pending,
|
||||
SpentBy: vtxo.SpentBy,
|
||||
Amount: amount,
|
||||
RoundTxid: vtxo.PoolTxid,
|
||||
ExpiresAt: &expireAt,
|
||||
RedeemTx: vtxo.PendingData.RedeemTx,
|
||||
Pending: vtxo.Pending,
|
||||
SpentBy: vtxo.SpentBy,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -653,8 +653,7 @@ func (a *covenantlessArkClient) SendAsync(
|
||||
})
|
||||
}
|
||||
|
||||
redeemTx, unconditionalForfeitTxs, err := a.client.CreatePayment(
|
||||
ctx, inputs, receiversOutput)
|
||||
redeemTx, err := a.client.CreatePayment(ctx, inputs, receiversOutput)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
@@ -667,7 +666,7 @@ func (a *covenantlessArkClient) SendAsync(
|
||||
}
|
||||
|
||||
if err = a.client.CompletePayment(
|
||||
ctx, signedRedeemTx, unconditionalForfeitTxs,
|
||||
ctx, signedRedeemTx,
|
||||
); err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user