Update client sdk (#207)

* Add bitcoin networks

* Refactor client

* Refactor explorer

* Refactor store

* Refactor wallet

* Refactor sdk client

* Refactor wasm & Update examples

* Move common util funcs to internal/utils

* Move to constants for service types

* Add unit tests

* Parallelize tests

* Lint

* Add job to gh action

* go mod tidy

* Fixes

* Fixes

* Fix compose file

* Fixes

* Fixes after review:
* Drop factory pattern
* Drop password from ark client methods
* Make singlekey wallet manage store and wallet store instead of defining WalletStore as extension of Store
* Move constants to arksdk module
* Drop config and expect directory store and wallet as ark client factory args

* Fix

* Add constants for bitcoin/liquid explorer

* Fix test

* Fix wasm

* Rename client.Client to client.ASPClient

* Rename store.Store to store.ConfigStore

* Rename wallet.Wallet to wallet.WalletService

* Renamings

* Lint

* Fixes

* Move everything to internal/utils & move ComputeVtxoTaprootScript to common

* Go mod tidy
This commit is contained in:
Pietralberto Mazza
2024-07-30 16:08:23 +02:00
committed by GitHub
parent e45bff3c70
commit 89df461623
148 changed files with 8497 additions and 6466 deletions

View File

@@ -0,0 +1,60 @@
package client
import (
"context"
"time"
"github.com/ark-network/ark-sdk/explorer"
arkv1 "github.com/ark-network/ark/api-spec/protobuf/gen/ark/v1"
)
const (
GrpcClient = "grpc"
RestClient = "rest"
)
type RoundEventChannel struct {
Event *arkv1.GetEventStreamResponse
Err error
}
type Vtxo struct {
Amount uint64
Txid string
VOut uint32
RoundTxid string
ExpiresAt *time.Time
}
type ASPClient interface {
GetInfo(ctx context.Context) (*arkv1.GetInfoResponse, error)
ListVtxos(ctx context.Context, addr string) (*arkv1.ListVtxosResponse, error)
GetSpendableVtxos(
ctx context.Context, addr string, explorerSvc explorer.Explorer,
) ([]*Vtxo, error)
GetRound(ctx context.Context, txID string) (*arkv1.GetRoundResponse, error)
GetRoundByID(ctx context.Context, roundID string) (*arkv1.GetRoundByIdResponse, error)
GetRedeemBranches(
ctx context.Context, vtxos []*Vtxo, explorerSvc explorer.Explorer,
) (map[string]*RedeemBranch, error)
GetOffchainBalance(
ctx context.Context, addr string, explorerSvc explorer.Explorer,
) (uint64, map[int64]uint64, error)
Onboard(
ctx context.Context, req *arkv1.OnboardRequest,
) (*arkv1.OnboardResponse, error)
RegisterPayment(
ctx context.Context, req *arkv1.RegisterPaymentRequest,
) (*arkv1.RegisterPaymentResponse, error)
ClaimPayment(
ctx context.Context, req *arkv1.ClaimPaymentRequest,
) (*arkv1.ClaimPaymentResponse, error)
GetEventStream(
ctx context.Context, paymentID string, req *arkv1.GetEventStreamRequest,
) (<-chan RoundEventChannel, error)
Ping(ctx context.Context, req *arkv1.PingRequest) (*arkv1.PingResponse, error)
FinalizePayment(
ctx context.Context, req *arkv1.FinalizePaymentRequest,
) (*arkv1.FinalizePaymentResponse, error)
Close()
}

View File

@@ -0,0 +1,277 @@
package grpcclient
import (
"context"
"fmt"
"strings"
"time"
"github.com/ark-network/ark-sdk/client"
"github.com/ark-network/ark-sdk/explorer"
arkv1 "github.com/ark-network/ark/api-spec/protobuf/gen/ark/v1"
"github.com/ark-network/ark/common/tree"
"google.golang.org/grpc"
"google.golang.org/grpc/credentials"
"google.golang.org/grpc/credentials/insecure"
)
type grpcClient struct {
conn *grpc.ClientConn
svc arkv1.ArkServiceClient
eventsCh chan client.RoundEventChannel
}
func NewClient(aspUrl string) (client.ASPClient, error) {
if len(aspUrl) <= 0 {
return nil, fmt.Errorf("missing asp url")
}
creds := insecure.NewCredentials()
port := 80
if strings.HasPrefix(aspUrl, "https://") {
aspUrl = strings.TrimPrefix(aspUrl, "https://")
creds = credentials.NewTLS(nil)
port = 443
}
if !strings.Contains(aspUrl, ":") {
aspUrl = fmt.Sprintf("%s:%d", aspUrl, port)
}
conn, err := grpc.NewClient(aspUrl, grpc.WithTransportCredentials(creds))
if err != nil {
return nil, err
}
svc := arkv1.NewArkServiceClient(conn)
eventsCh := make(chan client.RoundEventChannel)
return &grpcClient{conn, svc, eventsCh}, nil
}
func (c *grpcClient) Close() {
//nolint:all
c.conn.Close()
}
func (a *grpcClient) GetEventStream(
ctx context.Context, paymentID string, req *arkv1.GetEventStreamRequest,
) (<-chan client.RoundEventChannel, error) {
stream, err := a.svc.GetEventStream(ctx, req)
if err != nil {
return nil, err
}
go func() {
defer close(a.eventsCh)
for {
resp, err := stream.Recv()
if err != nil {
a.eventsCh <- client.RoundEventChannel{Err: err}
return
}
a.eventsCh <- client.RoundEventChannel{Event: resp}
}
}()
return a.eventsCh, nil
}
func (a *grpcClient) GetInfo(ctx context.Context) (*arkv1.GetInfoResponse, error) {
return a.svc.GetInfo(ctx, &arkv1.GetInfoRequest{})
}
func (a *grpcClient) ListVtxos(
ctx context.Context,
addr string,
) (*arkv1.ListVtxosResponse, error) {
return a.svc.ListVtxos(ctx, &arkv1.ListVtxosRequest{Address: addr})
}
func (a *grpcClient) GetRound(
ctx context.Context, txID string,
) (*arkv1.GetRoundResponse, error) {
return a.svc.GetRound(ctx, &arkv1.GetRoundRequest{Txid: txID})
}
func (a *grpcClient) GetSpendableVtxos(
ctx context.Context, addr string, explorerSvc explorer.Explorer,
) ([]*client.Vtxo, error) {
allVtxos, err := a.ListVtxos(ctx, addr)
if err != nil {
return nil, err
}
vtxos := make([]*client.Vtxo, 0, len(allVtxos.GetSpendableVtxos()))
for _, v := range allVtxos.GetSpendableVtxos() {
var expireAt *time.Time
if v.ExpireAt > 0 {
t := time.Unix(v.ExpireAt, 0)
expireAt = &t
}
if v.Swept {
continue
}
vtxos = append(vtxos, &client.Vtxo{
Amount: v.Receiver.Amount,
Txid: v.Outpoint.Txid,
VOut: v.Outpoint.Vout,
RoundTxid: v.PoolTxid,
ExpiresAt: expireAt,
})
}
if explorerSvc == nil {
return vtxos, nil
}
redeemBranches, err := a.GetRedeemBranches(ctx, vtxos, explorerSvc)
if err != nil {
return nil, err
}
for vtxoTxid, branch := range redeemBranches {
expiration, err := branch.ExpiresAt()
if err != nil {
return nil, err
}
for i, vtxo := range vtxos {
if vtxo.Txid == vtxoTxid {
vtxos[i].ExpiresAt = expiration
break
}
}
}
return vtxos, nil
}
func (a *grpcClient) GetRedeemBranches(
ctx context.Context, vtxos []*client.Vtxo, explorerSvc explorer.Explorer,
) (map[string]*client.RedeemBranch, error) {
congestionTrees := make(map[string]tree.CongestionTree, 0)
redeemBranches := make(map[string]*client.RedeemBranch, 0)
for _, vtxo := range vtxos {
if _, ok := congestionTrees[vtxo.RoundTxid]; !ok {
round, err := a.GetRound(ctx, vtxo.RoundTxid)
if err != nil {
return nil, err
}
treeFromRound := round.GetRound().GetCongestionTree()
congestionTree, err := toCongestionTree(treeFromRound)
if err != nil {
return nil, err
}
congestionTrees[vtxo.RoundTxid] = congestionTree
}
redeemBranch, err := client.NewRedeemBranch(
explorerSvc, congestionTrees[vtxo.RoundTxid], vtxo,
)
if err != nil {
return nil, err
}
redeemBranches[vtxo.Txid] = redeemBranch
}
return redeemBranches, nil
}
func (a *grpcClient) GetOffchainBalance(
ctx context.Context, addr string, explorerSvc explorer.Explorer,
) (uint64, map[int64]uint64, error) {
amountByExpiration := make(map[int64]uint64, 0)
vtxos, err := a.GetSpendableVtxos(ctx, addr, explorerSvc)
if err != nil {
return 0, nil, err
}
var balance uint64
for _, vtxo := range vtxos {
balance += vtxo.Amount
if vtxo.ExpiresAt != nil {
expiration := vtxo.ExpiresAt.Unix()
if _, ok := amountByExpiration[expiration]; !ok {
amountByExpiration[expiration] = 0
}
amountByExpiration[expiration] += vtxo.Amount
}
}
return balance, amountByExpiration, nil
}
func (a *grpcClient) Onboard(
ctx context.Context, req *arkv1.OnboardRequest,
) (*arkv1.OnboardResponse, error) {
return a.svc.Onboard(ctx, req)
}
func (a *grpcClient) RegisterPayment(
ctx context.Context, req *arkv1.RegisterPaymentRequest,
) (*arkv1.RegisterPaymentResponse, error) {
return a.svc.RegisterPayment(ctx, req)
}
func (a *grpcClient) ClaimPayment(
ctx context.Context, req *arkv1.ClaimPaymentRequest,
) (*arkv1.ClaimPaymentResponse, error) {
return a.svc.ClaimPayment(ctx, req)
}
func (a *grpcClient) Ping(
ctx context.Context, req *arkv1.PingRequest,
) (*arkv1.PingResponse, error) {
return a.svc.Ping(ctx, req)
}
func (a *grpcClient) FinalizePayment(
ctx context.Context, req *arkv1.FinalizePaymentRequest,
) (*arkv1.FinalizePaymentResponse, error) {
return a.svc.FinalizePayment(ctx, req)
}
func (a *grpcClient) GetRoundByID(
ctx context.Context, roundID string,
) (*arkv1.GetRoundByIdResponse, error) {
return a.svc.GetRoundById(ctx, &arkv1.GetRoundByIdRequest{
Id: roundID,
})
}
func toCongestionTree(treeFromProto *arkv1.Tree) (tree.CongestionTree, error) {
levels := make(tree.CongestionTree, 0, len(treeFromProto.Levels))
for _, level := range treeFromProto.Levels {
nodes := make([]tree.Node, 0, len(level.Nodes))
for _, node := range level.Nodes {
nodes = append(nodes, tree.Node{
Txid: node.Txid,
Tx: node.Tx,
ParentTxid: node.ParentTxid,
Leaf: false,
})
}
levels = append(levels, nodes)
}
for j, treeLvl := range levels {
for i, node := range treeLvl {
if len(levels.Children(node.Txid)) == 0 {
levels[j][i].Leaf = true
}
}
}
return levels, nil
}

View File

@@ -0,0 +1,217 @@
package client
import (
"fmt"
"time"
"github.com/ark-network/ark-sdk/explorer"
"github.com/ark-network/ark/common/tree"
"github.com/btcsuite/btcd/btcec/v2/schnorr"
"github.com/decred/dcrd/dcrec/secp256k1/v4"
"github.com/vulpemventures/go-elements/psetv2"
"github.com/vulpemventures/go-elements/taproot"
)
type RedeemBranch struct {
vtxo *Vtxo
branch []*psetv2.Pset
internalKey *secp256k1.PublicKey
sweepClosure *taproot.TapElementsLeaf
lifetime time.Duration
explorer explorer.Explorer
}
func NewRedeemBranch(
explorer explorer.Explorer,
congestionTree tree.CongestionTree, vtxo *Vtxo,
) (*RedeemBranch, error) {
sweepClosure, seconds, err := findSweepClosure(congestionTree)
if err != nil {
return nil, err
}
lifetime, err := time.ParseDuration(fmt.Sprintf("%ds", seconds))
if err != nil {
return nil, err
}
nodes, err := congestionTree.Branch(vtxo.Txid)
if err != nil {
return nil, err
}
branch := make([]*psetv2.Pset, 0, len(nodes))
for _, node := range nodes {
pset, err := psetv2.NewPsetFromBase64(node.Tx)
if err != nil {
return nil, err
}
branch = append(branch, pset)
}
xOnlyKey := branch[0].Inputs[0].TapInternalKey
internalKey, err := schnorr.ParsePubKey(xOnlyKey)
if err != nil {
return nil, err
}
return &RedeemBranch{
vtxo: vtxo,
branch: branch,
internalKey: internalKey,
sweepClosure: sweepClosure,
lifetime: lifetime,
explorer: explorer,
}, nil
}
// RedeemPath returns the list of transactions to broadcast in order to access the vtxo output
func (r *RedeemBranch) RedeemPath() ([]string, error) {
transactions := make([]string, 0, len(r.branch))
offchainPath, err := r.OffchainPath()
if err != nil {
return nil, err
}
for _, pset := range offchainPath {
for i, input := range pset.Inputs {
if len(input.TapLeafScript) == 0 {
return nil, fmt.Errorf("tap leaf script not found on input #%d", i)
}
for _, leaf := range input.TapLeafScript {
closure, err := tree.DecodeClosure(leaf.Script)
if err != nil {
return nil, err
}
switch closure.(type) {
case *tree.UnrollClosure:
controlBlock, err := leaf.ControlBlock.ToBytes()
if err != nil {
return nil, err
}
unsignedTx, err := pset.UnsignedTx()
if err != nil {
return nil, err
}
unsignedTx.Inputs[i].Witness = [][]byte{
leaf.Script,
controlBlock[:],
}
hex, err := unsignedTx.ToHex()
if err != nil {
return nil, err
}
transactions = append(transactions, hex)
}
}
}
}
return transactions, nil
}
func (r *RedeemBranch) ExpiresAt() (*time.Time, error) {
lastKnownBlocktime := int64(0)
confirmed, blocktime, _ := r.explorer.GetTxBlockTime(r.vtxo.RoundTxid)
if confirmed {
lastKnownBlocktime = blocktime
} else {
expirationFromNow := time.Now().Add(time.Minute).Add(r.lifetime)
return &expirationFromNow, nil
}
for _, pset := range r.branch {
utx, _ := pset.UnsignedTx()
txid := utx.TxHash().String()
confirmed, blocktime, err := r.explorer.GetTxBlockTime(txid)
if err != nil {
break
}
if confirmed {
lastKnownBlocktime = blocktime
continue
}
break
}
t := time.Unix(lastKnownBlocktime, 0).Add(r.lifetime)
return &t, nil
}
// offchainPath checks for transactions of the branch onchain and returns only the offchain part
func (r *RedeemBranch) OffchainPath() ([]*psetv2.Pset, error) {
offchainPath := append([]*psetv2.Pset{}, r.branch...)
for i := len(r.branch) - 1; i >= 0; i-- {
pset := r.branch[i]
unsignedTx, err := pset.UnsignedTx()
if err != nil {
return nil, err
}
txHash := unsignedTx.TxHash().String()
_, err = r.explorer.GetTxHex(txHash)
if err != nil {
continue
}
// if no error, the tx exists onchain, so we can remove it (+ the parents) from the branch
if i == len(r.branch)-1 {
offchainPath = []*psetv2.Pset{}
} else {
offchainPath = r.branch[i+1:]
}
break
}
return offchainPath, nil
}
func findSweepClosure(
congestionTree tree.CongestionTree,
) (*taproot.TapElementsLeaf, uint, error) {
root, err := congestionTree.Root()
if err != nil {
return nil, 0, err
}
// find the sweep closure
tx, err := psetv2.NewPsetFromBase64(root.Tx)
if err != nil {
return nil, 0, err
}
var seconds uint
var sweepClosure *taproot.TapElementsLeaf
for _, tapLeaf := range tx.Inputs[0].TapLeafScript {
closure := &tree.CSVSigClosure{}
valid, err := closure.Decode(tapLeaf.Script)
if err != nil {
continue
}
if valid && closure.Seconds > seconds {
seconds = closure.Seconds
sweepClosure = &tapLeaf.TapElementsLeaf
}
}
if sweepClosure == nil {
return nil, 0, fmt.Errorf("sweep closure not found")
}
return sweepClosure, seconds, nil
}

View File

@@ -0,0 +1,672 @@
package restclient
import (
"context"
"fmt"
"net/url"
"strconv"
"time"
"github.com/ark-network/ark-sdk/client"
"github.com/ark-network/ark-sdk/client/rest/service/arkservice"
"github.com/ark-network/ark-sdk/client/rest/service/arkservice/ark_service"
"github.com/ark-network/ark-sdk/client/rest/service/models"
"github.com/ark-network/ark-sdk/explorer"
arkv1 "github.com/ark-network/ark/api-spec/protobuf/gen/ark/v1"
"github.com/ark-network/ark/common/tree"
httptransport "github.com/go-openapi/runtime/client"
"github.com/go-openapi/strfmt"
"github.com/vulpemventures/go-elements/psetv2"
)
type restClient struct {
svc ark_service.ClientService
eventsCh chan client.RoundEventChannel
requestTimeout time.Duration
}
func NewClient(aspUrl string) (client.ASPClient, error) {
if len(aspUrl) <= 0 {
return nil, fmt.Errorf("missing asp url")
}
svc, err := newRestClient(aspUrl)
if err != nil {
return nil, err
}
eventsCh := make(chan client.RoundEventChannel)
reqTimeout := 15 * time.Second
return &restClient{svc, eventsCh, reqTimeout}, nil
}
func (c *restClient) Close() {}
func (a *restClient) GetEventStream(
ctx context.Context, paymentID string, req *arkv1.GetEventStreamRequest,
) (<-chan client.RoundEventChannel, error) {
go func(payID string) {
defer close(a.eventsCh)
timeout := time.After(a.requestTimeout)
for {
select {
case <-timeout:
a.eventsCh <- client.RoundEventChannel{
Err: fmt.Errorf("timeout reached"),
}
return
default:
resp, err := a.Ping(ctx, &arkv1.PingRequest{
PaymentId: payID,
})
if err != nil {
a.eventsCh <- client.RoundEventChannel{
Err: err,
}
return
}
if resp.GetEvent() != nil {
levels := make([]*arkv1.TreeLevel, 0, len(resp.GetEvent().GetCongestionTree().GetLevels()))
for _, l := range resp.GetEvent().GetCongestionTree().GetLevels() {
nodes := make([]*arkv1.Node, 0, len(l.Nodes))
for _, n := range l.Nodes {
nodes = append(nodes, &arkv1.Node{
Txid: n.Txid,
Tx: n.Tx,
ParentTxid: n.ParentTxid,
})
}
levels = append(levels, &arkv1.TreeLevel{
Nodes: nodes,
})
}
a.eventsCh <- client.RoundEventChannel{
Event: &arkv1.GetEventStreamResponse{
Event: &arkv1.GetEventStreamResponse_RoundFinalization{
RoundFinalization: &arkv1.RoundFinalizationEvent{
Id: resp.GetEvent().GetId(),
PoolTx: resp.GetEvent().GetPoolTx(),
ForfeitTxs: resp.GetEvent().GetForfeitTxs(),
CongestionTree: &arkv1.Tree{
Levels: levels,
},
Connectors: resp.GetEvent().GetConnectors(),
},
},
},
}
for {
roundID := resp.GetEvent().GetId()
round, err := a.GetRoundByID(ctx, roundID)
if err != nil {
a.eventsCh <- client.RoundEventChannel{
Err: err,
}
return
}
if round.GetRound().GetStage() == arkv1.RoundStage_ROUND_STAGE_FINALIZED {
ptx, _ := psetv2.NewPsetFromBase64(round.GetRound().GetPoolTx())
utx, _ := ptx.UnsignedTx()
a.eventsCh <- client.RoundEventChannel{
Event: &arkv1.GetEventStreamResponse{
Event: &arkv1.GetEventStreamResponse_RoundFinalized{
RoundFinalized: &arkv1.RoundFinalizedEvent{
PoolTxid: utx.TxHash().String(),
},
},
},
}
return
}
if round.GetRound().GetStage() == arkv1.RoundStage_ROUND_STAGE_FAILED {
a.eventsCh <- client.RoundEventChannel{
Event: &arkv1.GetEventStreamResponse{
Event: &arkv1.GetEventStreamResponse_RoundFailed{
RoundFailed: &arkv1.RoundFailed{
Id: round.GetRound().GetId(),
},
},
},
}
return
}
time.Sleep(1 * time.Second)
}
}
time.Sleep(1 * time.Second)
}
}
}(paymentID)
return a.eventsCh, nil
}
func (a *restClient) GetInfo(
ctx context.Context,
) (*arkv1.GetInfoResponse, error) {
resp, err := a.svc.ArkServiceGetInfo(ark_service.NewArkServiceGetInfoParams())
if err != nil {
return nil, err
}
roundLifetime, err := strconv.Atoi(resp.Payload.RoundLifetime)
if err != nil {
return nil, err
}
unilateralExitDelay, err := strconv.Atoi(resp.Payload.UnilateralExitDelay)
if err != nil {
return nil, err
}
roundInterval, err := strconv.Atoi(resp.Payload.RoundInterval)
if err != nil {
return nil, err
}
minRelayFee, err := strconv.Atoi(resp.Payload.MinRelayFee)
if err != nil {
return nil, err
}
return &arkv1.GetInfoResponse{
Pubkey: resp.Payload.Pubkey,
RoundLifetime: int64(roundLifetime),
UnilateralExitDelay: int64(unilateralExitDelay),
RoundInterval: int64(roundInterval),
Network: resp.Payload.Network,
MinRelayFee: int64(minRelayFee),
}, nil
}
func (a *restClient) ListVtxos(
ctx context.Context, addr string,
) (*arkv1.ListVtxosResponse, error) {
resp, err := a.svc.ArkServiceListVtxos(
ark_service.NewArkServiceListVtxosParams().WithAddress(addr),
)
if err != nil {
return nil, err
}
vtxos := make([]*arkv1.Vtxo, 0, len(resp.Payload.SpendableVtxos))
for _, v := range resp.Payload.SpendableVtxos {
expAt, err := strconv.Atoi(v.ExpireAt)
if err != nil {
return nil, err
}
amount, err := strconv.Atoi(v.Receiver.Amount)
if err != nil {
return nil, err
}
vtxos = append(vtxos, &arkv1.Vtxo{
Outpoint: &arkv1.Input{
Txid: v.Outpoint.Txid,
Vout: uint32(v.Outpoint.Vout),
},
Receiver: &arkv1.Output{
Address: v.Receiver.Address,
Amount: uint64(amount),
},
Spent: v.Spent,
PoolTxid: v.PoolTxid,
SpentBy: v.SpentBy,
ExpireAt: int64(expAt),
Swept: v.Swept,
})
}
return &arkv1.ListVtxosResponse{
SpendableVtxos: vtxos,
}, nil
}
func (a *restClient) GetRound(
ctx context.Context, txID string,
) (*arkv1.GetRoundResponse, error) {
resp, err := a.svc.ArkServiceGetRound(
ark_service.NewArkServiceGetRoundParams().WithTxid(txID),
)
if err != nil {
return nil, err
}
start, err := strconv.Atoi(resp.Payload.Round.Start)
if err != nil {
return nil, err
}
end, err := strconv.Atoi(resp.Payload.Round.End)
if err != nil {
return nil, err
}
levels := make([]*arkv1.TreeLevel, 0, len(resp.Payload.Round.CongestionTree.Levels))
for _, l := range resp.Payload.Round.CongestionTree.Levels {
nodes := make([]*arkv1.Node, 0, len(l.Nodes))
for _, n := range l.Nodes {
nodes = append(nodes, &arkv1.Node{
Txid: n.Txid,
Tx: n.Tx,
ParentTxid: n.ParentTxid,
})
}
levels = append(levels, &arkv1.TreeLevel{
Nodes: nodes,
})
}
return &arkv1.GetRoundResponse{
Round: &arkv1.Round{
Id: resp.Payload.Round.ID,
Start: int64(start),
End: int64(end),
PoolTx: resp.Payload.Round.PoolTx,
CongestionTree: &arkv1.Tree{
Levels: levels,
},
ForfeitTxs: resp.Payload.Round.ForfeitTxs,
Connectors: resp.Payload.Round.Connectors,
},
}, nil
}
func (a *restClient) GetSpendableVtxos(
ctx context.Context, addr string, explorerSvc explorer.Explorer,
) ([]*client.Vtxo, error) {
allVtxos, err := a.ListVtxos(ctx, addr)
if err != nil {
return nil, err
}
vtxos := make([]*client.Vtxo, 0, len(allVtxos.GetSpendableVtxos()))
for _, v := range allVtxos.GetSpendableVtxos() {
var expireAt *time.Time
if v.ExpireAt > 0 {
t := time.Unix(v.ExpireAt, 0)
expireAt = &t
}
if v.Swept {
continue
}
vtxos = append(vtxos, &client.Vtxo{
Amount: v.Receiver.Amount,
Txid: v.Outpoint.Txid,
VOut: v.Outpoint.Vout,
RoundTxid: v.PoolTxid,
ExpiresAt: expireAt,
})
}
if explorerSvc == nil {
return vtxos, nil
}
redeemBranches, err := a.GetRedeemBranches(ctx, vtxos, explorerSvc)
if err != nil {
return nil, err
}
for vtxoTxid, branch := range redeemBranches {
expiration, err := branch.ExpiresAt()
if err != nil {
return nil, err
}
for i, vtxo := range vtxos {
if vtxo.Txid == vtxoTxid {
vtxos[i].ExpiresAt = expiration
break
}
}
}
return vtxos, nil
}
func (a *restClient) GetRedeemBranches(
ctx context.Context, vtxos []*client.Vtxo, explorerSvc explorer.Explorer,
) (map[string]*client.RedeemBranch, error) {
congestionTrees := make(map[string]tree.CongestionTree, 0)
redeemBranches := make(map[string]*client.RedeemBranch, 0)
for _, vtxo := range vtxos {
if _, ok := congestionTrees[vtxo.RoundTxid]; !ok {
round, err := a.GetRound(ctx, vtxo.RoundTxid)
if err != nil {
return nil, err
}
treeFromRound := round.GetRound().GetCongestionTree()
congestionTree, err := toCongestionTree(treeFromRound)
if err != nil {
return nil, err
}
congestionTrees[vtxo.RoundTxid] = congestionTree
}
redeemBranch, err := client.NewRedeemBranch(
explorerSvc, congestionTrees[vtxo.RoundTxid], vtxo,
)
if err != nil {
return nil, err
}
redeemBranches[vtxo.Txid] = redeemBranch
}
return redeemBranches, nil
}
func (a *restClient) GetOffchainBalance(
ctx context.Context, addr string, explorerSvc explorer.Explorer,
) (uint64, map[int64]uint64, error) {
amountByExpiration := make(map[int64]uint64, 0)
vtxos, err := a.GetSpendableVtxos(ctx, addr, explorerSvc)
if err != nil {
return 0, nil, err
}
var balance uint64
for _, vtxo := range vtxos {
balance += vtxo.Amount
if vtxo.ExpiresAt != nil {
expiration := vtxo.ExpiresAt.Unix()
if _, ok := amountByExpiration[expiration]; !ok {
amountByExpiration[expiration] = 0
}
amountByExpiration[expiration] += vtxo.Amount
}
}
return balance, amountByExpiration, nil
}
func (a *restClient) Onboard(
ctx context.Context, req *arkv1.OnboardRequest,
) (*arkv1.OnboardResponse, error) {
levels := make([]*models.V1TreeLevel, 0, len(req.GetCongestionTree().GetLevels()))
for _, l := range req.GetCongestionTree().GetLevels() {
nodes := make([]*models.V1Node, 0, len(l.GetNodes()))
for _, n := range l.GetNodes() {
nodes = append(nodes, &models.V1Node{
Txid: n.GetTxid(),
Tx: n.GetTx(),
ParentTxid: n.GetParentTxid(),
})
}
levels = append(levels, &models.V1TreeLevel{
Nodes: nodes,
})
}
congestionTree := models.V1Tree{
Levels: levels,
}
body := models.V1OnboardRequest{
BoardingTx: req.GetBoardingTx(),
CongestionTree: &congestionTree,
UserPubkey: req.GetUserPubkey(),
}
_, err := a.svc.ArkServiceOnboard(
ark_service.NewArkServiceOnboardParams().WithBody(&body),
)
if err != nil {
return nil, err
}
return &arkv1.OnboardResponse{}, nil
}
func (a *restClient) RegisterPayment(
ctx context.Context, req *arkv1.RegisterPaymentRequest,
) (*arkv1.RegisterPaymentResponse, error) {
inputs := make([]*models.V1Input, 0, len(req.GetInputs()))
for _, i := range req.GetInputs() {
inputs = append(inputs, &models.V1Input{
Txid: i.GetTxid(),
Vout: int64(i.GetVout()),
})
}
body := models.V1RegisterPaymentRequest{
Inputs: inputs,
}
resp, err := a.svc.ArkServiceRegisterPayment(
ark_service.NewArkServiceRegisterPaymentParams().WithBody(&body),
)
if err != nil {
return nil, err
}
return &arkv1.RegisterPaymentResponse{
Id: resp.Payload.ID,
}, nil
}
func (a *restClient) ClaimPayment(
ctx context.Context, req *arkv1.ClaimPaymentRequest,
) (*arkv1.ClaimPaymentResponse, error) {
outputs := make([]*models.V1Output, 0, len(req.GetOutputs()))
for _, o := range req.GetOutputs() {
outputs = append(outputs, &models.V1Output{
Address: o.GetAddress(),
Amount: strconv.Itoa(int(o.GetAmount())),
})
}
body := models.V1ClaimPaymentRequest{
ID: req.GetId(),
Outputs: outputs,
}
_, err := a.svc.ArkServiceClaimPayment(
ark_service.NewArkServiceClaimPaymentParams().WithBody(&body),
)
if err != nil {
return nil, err
}
return &arkv1.ClaimPaymentResponse{}, nil
}
func (a *restClient) Ping(
ctx context.Context, req *arkv1.PingRequest,
) (*arkv1.PingResponse, error) {
r := ark_service.NewArkServicePingParams()
r.SetPaymentID(req.GetPaymentId())
resp, err := a.svc.ArkServicePing(r)
if err != nil {
return nil, err
}
var event *arkv1.RoundFinalizationEvent
if resp.Payload.Event != nil &&
resp.Payload.Event.ID != "" &&
len(resp.Payload.Event.ForfeitTxs) > 0 &&
len(resp.Payload.Event.CongestionTree.Levels) > 0 &&
len(resp.Payload.Event.Connectors) > 0 &&
resp.Payload.Event.PoolTx != "" {
levels := make([]*arkv1.TreeLevel, 0, len(resp.Payload.Event.CongestionTree.Levels))
for _, l := range resp.Payload.Event.CongestionTree.Levels {
nodes := make([]*arkv1.Node, 0, len(l.Nodes))
for _, n := range l.Nodes {
nodes = append(nodes, &arkv1.Node{
Txid: n.Txid,
Tx: n.Tx,
ParentTxid: n.ParentTxid,
})
}
levels = append(levels, &arkv1.TreeLevel{
Nodes: nodes,
})
}
event = &arkv1.RoundFinalizationEvent{
Id: resp.Payload.Event.ID,
PoolTx: resp.Payload.Event.PoolTx,
ForfeitTxs: resp.Payload.Event.ForfeitTxs,
CongestionTree: &arkv1.Tree{
Levels: levels,
},
Connectors: resp.Payload.Event.Connectors,
}
}
return &arkv1.PingResponse{
ForfeitTxs: resp.Payload.ForfeitTxs,
Event: event,
}, nil
}
func (a *restClient) FinalizePayment(
ctx context.Context, req *arkv1.FinalizePaymentRequest,
) (*arkv1.FinalizePaymentResponse, error) {
body := models.V1FinalizePaymentRequest{
SignedForfeitTxs: req.GetSignedForfeitTxs(),
}
_, err := a.svc.ArkServiceFinalizePayment(
ark_service.NewArkServiceFinalizePaymentParams().WithBody(&body),
)
if err != nil {
return nil, err
}
return &arkv1.FinalizePaymentResponse{}, nil
}
func (a *restClient) GetRoundByID(
ctx context.Context, roundID string,
) (*arkv1.GetRoundByIdResponse, error) {
resp, err := a.svc.ArkServiceGetRoundByID(
ark_service.NewArkServiceGetRoundByIDParams().WithID(roundID),
)
if err != nil {
return nil, err
}
start, err := strconv.Atoi(resp.Payload.Round.Start)
if err != nil {
return nil, err
}
end, err := strconv.Atoi(resp.Payload.Round.End)
if err != nil {
return nil, err
}
levels := make([]*arkv1.TreeLevel, 0, len(resp.Payload.Round.CongestionTree.Levels))
for _, l := range resp.Payload.Round.CongestionTree.Levels {
nodes := make([]*arkv1.Node, 0, len(l.Nodes))
for _, n := range l.Nodes {
nodes = append(nodes, &arkv1.Node{
Txid: n.Txid,
Tx: n.Tx,
ParentTxid: n.ParentTxid,
})
}
levels = append(levels, &arkv1.TreeLevel{
Nodes: nodes,
})
}
stage := stageStrToInt(*resp.Payload.Round.Stage)
return &arkv1.GetRoundByIdResponse{
Round: &arkv1.Round{
Id: resp.Payload.Round.ID,
Start: int64(start),
End: int64(end),
PoolTx: resp.Payload.Round.PoolTx,
CongestionTree: &arkv1.Tree{
Levels: levels,
},
ForfeitTxs: resp.Payload.Round.ForfeitTxs,
Connectors: resp.Payload.Round.Connectors,
Stage: arkv1.RoundStage(stage),
},
}, nil
}
func newRestClient(
serviceURL string,
) (ark_service.ClientService, error) {
parsedURL, err := url.Parse(serviceURL)
if err != nil {
return nil, err
}
schemes := []string{parsedURL.Scheme}
host := parsedURL.Host
basePath := parsedURL.Path
if basePath == "" {
basePath = arkservice.DefaultBasePath
}
cfg := &arkservice.TransportConfig{
Host: host,
BasePath: basePath,
Schemes: schemes,
}
transport := httptransport.New(cfg.Host, cfg.BasePath, cfg.Schemes)
svc := arkservice.New(transport, strfmt.Default)
return svc.ArkService, nil
}
func stageStrToInt(stage models.V1RoundStage) int {
switch stage {
case models.V1RoundStageROUNDSTAGEUNSPECIFIED:
return 0
case models.V1RoundStageROUNDSTAGEREGISTRATION:
return 1
case models.V1RoundStageROUNDSTAGEFINALIZATION:
return 2
case models.V1RoundStageROUNDSTAGEFINALIZED:
return 3
case models.V1RoundStageROUNDSTAGEFAILED:
return 4
}
return -1
}
func toCongestionTree(treeFromProto *arkv1.Tree) (tree.CongestionTree, error) {
levels := make(tree.CongestionTree, 0, len(treeFromProto.Levels))
for _, level := range treeFromProto.Levels {
nodes := make([]tree.Node, 0, len(level.Nodes))
for _, node := range level.Nodes {
nodes = append(nodes, tree.Node{
Txid: node.Txid,
Tx: node.Tx,
ParentTxid: node.ParentTxid,
Leaf: false,
})
}
levels = append(levels, nodes)
}
for j, treeLvl := range levels {
for i, node := range treeLvl {
if len(levels.Children(node.Txid)) == 0 {
levels[j][i].Leaf = true
}
}
}
return levels, nil
}

View File

@@ -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-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
}

View File

@@ -0,0 +1,185 @@
// 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-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
}

View File

@@ -0,0 +1,492 @@
// 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 (
"github.com/go-openapi/runtime"
httptransport "github.com/go-openapi/runtime/client"
"github.com/go-openapi/strfmt"
)
// New creates a new ark service API client.
func New(transport runtime.ClientTransport, formats strfmt.Registry) ClientService {
return &Client{transport: transport, formats: formats}
}
// New creates a new ark service API client with basic auth credentials.
// It takes the following parameters:
// - host: http host (github.com).
// - basePath: any base path for the API client ("/v1", "/v3").
// - scheme: http scheme ("http", "https").
// - user: user for basic authentication header.
// - password: password for basic authentication header.
func NewClientWithBasicAuth(host, basePath, scheme, user, password string) ClientService {
transport := httptransport.New(host, basePath, []string{scheme})
transport.DefaultAuthentication = httptransport.BasicAuth(user, password)
return &Client{transport: transport, formats: strfmt.Default}
}
// New creates a new ark service API client with a bearer token for authentication.
// It takes the following parameters:
// - host: http host (github.com).
// - basePath: any base path for the API client ("/v1", "/v3").
// - scheme: http scheme ("http", "https").
// - bearerToken: bearer token for Bearer authentication header.
func NewClientWithBearerToken(host, basePath, scheme, bearerToken string) ClientService {
transport := httptransport.New(host, basePath, []string{scheme})
transport.DefaultAuthentication = httptransport.BearerToken(bearerToken)
return &Client{transport: transport, formats: strfmt.Default}
}
/*
Client for ark service API
*/
type Client struct {
transport runtime.ClientTransport
formats strfmt.Registry
}
// ClientOption may be used to customize the behavior of Client methods.
type ClientOption func(*runtime.ClientOperation)
// ClientService is the interface for Client methods
type ClientService interface {
ArkServiceClaimPayment(params *ArkServiceClaimPaymentParams, opts ...ClientOption) (*ArkServiceClaimPaymentOK, error)
ArkServiceFinalizePayment(params *ArkServiceFinalizePaymentParams, opts ...ClientOption) (*ArkServiceFinalizePaymentOK, error)
ArkServiceGetEventStream(params *ArkServiceGetEventStreamParams, opts ...ClientOption) (*ArkServiceGetEventStreamOK, error)
ArkServiceGetInfo(params *ArkServiceGetInfoParams, opts ...ClientOption) (*ArkServiceGetInfoOK, error)
ArkServiceGetRound(params *ArkServiceGetRoundParams, opts ...ClientOption) (*ArkServiceGetRoundOK, error)
ArkServiceGetRoundByID(params *ArkServiceGetRoundByIDParams, opts ...ClientOption) (*ArkServiceGetRoundByIDOK, error)
ArkServiceListVtxos(params *ArkServiceListVtxosParams, opts ...ClientOption) (*ArkServiceListVtxosOK, error)
ArkServiceOnboard(params *ArkServiceOnboardParams, opts ...ClientOption) (*ArkServiceOnboardOK, error)
ArkServicePing(params *ArkServicePingParams, opts ...ClientOption) (*ArkServicePingOK, error)
ArkServiceRegisterPayment(params *ArkServiceRegisterPaymentParams, opts ...ClientOption) (*ArkServiceRegisterPaymentOK, error)
ArkServiceTrustedOnboarding(params *ArkServiceTrustedOnboardingParams, opts ...ClientOption) (*ArkServiceTrustedOnboardingOK, error)
SetTransport(transport runtime.ClientTransport)
}
/*
ArkServiceClaimPayment ark service claim payment API
*/
func (a *Client) ArkServiceClaimPayment(params *ArkServiceClaimPaymentParams, opts ...ClientOption) (*ArkServiceClaimPaymentOK, error) {
// TODO: Validate the params before sending
if params == nil {
params = NewArkServiceClaimPaymentParams()
}
op := &runtime.ClientOperation{
ID: "ArkService_ClaimPayment",
Method: "POST",
PathPattern: "/v1/payment/claim",
ProducesMediaTypes: []string{"application/json"},
ConsumesMediaTypes: []string{"application/json"},
Schemes: []string{"http"},
Params: params,
Reader: &ArkServiceClaimPaymentReader{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.(*ArkServiceClaimPaymentOK)
if ok {
return success, nil
}
// unexpected success response
unexpectedSuccess := result.(*ArkServiceClaimPaymentDefault)
return nil, runtime.NewAPIError("unexpected success response: content available as default response in error", unexpectedSuccess, unexpectedSuccess.Code())
}
/*
ArkServiceFinalizePayment ark service finalize payment API
*/
func (a *Client) ArkServiceFinalizePayment(params *ArkServiceFinalizePaymentParams, opts ...ClientOption) (*ArkServiceFinalizePaymentOK, error) {
// TODO: Validate the params before sending
if params == nil {
params = NewArkServiceFinalizePaymentParams()
}
op := &runtime.ClientOperation{
ID: "ArkService_FinalizePayment",
Method: "POST",
PathPattern: "/v1/payment/finalize",
ProducesMediaTypes: []string{"application/json"},
ConsumesMediaTypes: []string{"application/json"},
Schemes: []string{"http"},
Params: params,
Reader: &ArkServiceFinalizePaymentReader{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.(*ArkServiceFinalizePaymentOK)
if ok {
return success, nil
}
// unexpected success response
unexpectedSuccess := result.(*ArkServiceFinalizePaymentDefault)
return nil, runtime.NewAPIError("unexpected success response: content available as default response in error", unexpectedSuccess, unexpectedSuccess.Code())
}
/*
ArkServiceGetEventStream ark service get event stream API
*/
func (a *Client) ArkServiceGetEventStream(params *ArkServiceGetEventStreamParams, opts ...ClientOption) (*ArkServiceGetEventStreamOK, error) {
// TODO: Validate the params before sending
if params == nil {
params = NewArkServiceGetEventStreamParams()
}
op := &runtime.ClientOperation{
ID: "ArkService_GetEventStream",
Method: "GET",
PathPattern: "/v1/events",
ProducesMediaTypes: []string{"application/json"},
ConsumesMediaTypes: []string{"application/json"},
Schemes: []string{"http"},
Params: params,
Reader: &ArkServiceGetEventStreamReader{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.(*ArkServiceGetEventStreamOK)
if ok {
return success, nil
}
// unexpected success response
unexpectedSuccess := result.(*ArkServiceGetEventStreamDefault)
return nil, runtime.NewAPIError("unexpected success response: content available as default response in error", unexpectedSuccess, unexpectedSuccess.Code())
}
/*
ArkServiceGetInfo ark service get info API
*/
func (a *Client) ArkServiceGetInfo(params *ArkServiceGetInfoParams, opts ...ClientOption) (*ArkServiceGetInfoOK, error) {
// TODO: Validate the params before sending
if params == nil {
params = NewArkServiceGetInfoParams()
}
op := &runtime.ClientOperation{
ID: "ArkService_GetInfo",
Method: "GET",
PathPattern: "/v1/info",
ProducesMediaTypes: []string{"application/json"},
ConsumesMediaTypes: []string{"application/json"},
Schemes: []string{"http"},
Params: params,
Reader: &ArkServiceGetInfoReader{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.(*ArkServiceGetInfoOK)
if ok {
return success, nil
}
// unexpected success response
unexpectedSuccess := result.(*ArkServiceGetInfoDefault)
return nil, runtime.NewAPIError("unexpected success response: content available as default response in error", unexpectedSuccess, unexpectedSuccess.Code())
}
/*
ArkServiceGetRound ts o d o b t c sign tree rpc
*/
func (a *Client) ArkServiceGetRound(params *ArkServiceGetRoundParams, opts ...ClientOption) (*ArkServiceGetRoundOK, error) {
// TODO: Validate the params before sending
if params == nil {
params = NewArkServiceGetRoundParams()
}
op := &runtime.ClientOperation{
ID: "ArkService_GetRound",
Method: "GET",
PathPattern: "/v1/round/{txid}",
ProducesMediaTypes: []string{"application/json"},
ConsumesMediaTypes: []string{"application/json"},
Schemes: []string{"http"},
Params: params,
Reader: &ArkServiceGetRoundReader{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.(*ArkServiceGetRoundOK)
if ok {
return success, nil
}
// unexpected success response
unexpectedSuccess := result.(*ArkServiceGetRoundDefault)
return nil, runtime.NewAPIError("unexpected success response: content available as default response in error", unexpectedSuccess, unexpectedSuccess.Code())
}
/*
ArkServiceGetRoundByID ark service get round by Id API
*/
func (a *Client) ArkServiceGetRoundByID(params *ArkServiceGetRoundByIDParams, opts ...ClientOption) (*ArkServiceGetRoundByIDOK, error) {
// TODO: Validate the params before sending
if params == nil {
params = NewArkServiceGetRoundByIDParams()
}
op := &runtime.ClientOperation{
ID: "ArkService_GetRoundById",
Method: "GET",
PathPattern: "/v1/round/id/{id}",
ProducesMediaTypes: []string{"application/json"},
ConsumesMediaTypes: []string{"application/json"},
Schemes: []string{"http"},
Params: params,
Reader: &ArkServiceGetRoundByIDReader{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.(*ArkServiceGetRoundByIDOK)
if ok {
return success, nil
}
// unexpected success response
unexpectedSuccess := result.(*ArkServiceGetRoundByIDDefault)
return nil, runtime.NewAPIError("unexpected success response: content available as default response in error", unexpectedSuccess, unexpectedSuccess.Code())
}
/*
ArkServiceListVtxos ark service list vtxos API
*/
func (a *Client) ArkServiceListVtxos(params *ArkServiceListVtxosParams, opts ...ClientOption) (*ArkServiceListVtxosOK, error) {
// TODO: Validate the params before sending
if params == nil {
params = NewArkServiceListVtxosParams()
}
op := &runtime.ClientOperation{
ID: "ArkService_ListVtxos",
Method: "GET",
PathPattern: "/v1/vtxos/{address}",
ProducesMediaTypes: []string{"application/json"},
ConsumesMediaTypes: []string{"application/json"},
Schemes: []string{"http"},
Params: params,
Reader: &ArkServiceListVtxosReader{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.(*ArkServiceListVtxosOK)
if ok {
return success, nil
}
// unexpected success response
unexpectedSuccess := result.(*ArkServiceListVtxosDefault)
return nil, runtime.NewAPIError("unexpected success response: content available as default response in error", unexpectedSuccess, unexpectedSuccess.Code())
}
/*
ArkServiceOnboard ark service onboard API
*/
func (a *Client) ArkServiceOnboard(params *ArkServiceOnboardParams, opts ...ClientOption) (*ArkServiceOnboardOK, error) {
// TODO: Validate the params before sending
if params == nil {
params = NewArkServiceOnboardParams()
}
op := &runtime.ClientOperation{
ID: "ArkService_Onboard",
Method: "POST",
PathPattern: "/v1/onboard",
ProducesMediaTypes: []string{"application/json"},
ConsumesMediaTypes: []string{"application/json"},
Schemes: []string{"http"},
Params: params,
Reader: &ArkServiceOnboardReader{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.(*ArkServiceOnboardOK)
if ok {
return success, nil
}
// unexpected success response
unexpectedSuccess := result.(*ArkServiceOnboardDefault)
return nil, runtime.NewAPIError("unexpected success response: content available as default response in error", unexpectedSuccess, unexpectedSuccess.Code())
}
/*
ArkServicePing ark service ping API
*/
func (a *Client) ArkServicePing(params *ArkServicePingParams, opts ...ClientOption) (*ArkServicePingOK, error) {
// TODO: Validate the params before sending
if params == nil {
params = NewArkServicePingParams()
}
op := &runtime.ClientOperation{
ID: "ArkService_Ping",
Method: "GET",
PathPattern: "/v1/ping/{paymentId}",
ProducesMediaTypes: []string{"application/json"},
ConsumesMediaTypes: []string{"application/json"},
Schemes: []string{"http"},
Params: params,
Reader: &ArkServicePingReader{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.(*ArkServicePingOK)
if ok {
return success, nil
}
// unexpected success response
unexpectedSuccess := result.(*ArkServicePingDefault)
return nil, runtime.NewAPIError("unexpected success response: content available as default response in error", unexpectedSuccess, unexpectedSuccess.Code())
}
/*
ArkServiceRegisterPayment ark service register payment API
*/
func (a *Client) ArkServiceRegisterPayment(params *ArkServiceRegisterPaymentParams, opts ...ClientOption) (*ArkServiceRegisterPaymentOK, error) {
// TODO: Validate the params before sending
if params == nil {
params = NewArkServiceRegisterPaymentParams()
}
op := &runtime.ClientOperation{
ID: "ArkService_RegisterPayment",
Method: "POST",
PathPattern: "/v1/payment/register",
ProducesMediaTypes: []string{"application/json"},
ConsumesMediaTypes: []string{"application/json"},
Schemes: []string{"http"},
Params: params,
Reader: &ArkServiceRegisterPaymentReader{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.(*ArkServiceRegisterPaymentOK)
if ok {
return success, nil
}
// unexpected success response
unexpectedSuccess := result.(*ArkServiceRegisterPaymentDefault)
return nil, runtime.NewAPIError("unexpected success response: content available as default response in error", unexpectedSuccess, unexpectedSuccess.Code())
}
/*
ArkServiceTrustedOnboarding ark service trusted onboarding API
*/
func (a *Client) ArkServiceTrustedOnboarding(params *ArkServiceTrustedOnboardingParams, opts ...ClientOption) (*ArkServiceTrustedOnboardingOK, error) {
// TODO: Validate the params before sending
if params == nil {
params = NewArkServiceTrustedOnboardingParams()
}
op := &runtime.ClientOperation{
ID: "ArkService_TrustedOnboarding",
Method: "POST",
PathPattern: "/v1/onboard/address",
ProducesMediaTypes: []string{"application/json"},
ConsumesMediaTypes: []string{"application/json"},
Schemes: []string{"http"},
Params: params,
Reader: &ArkServiceTrustedOnboardingReader{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.(*ArkServiceTrustedOnboardingOK)
if ok {
return success, nil
}
// unexpected success response
unexpectedSuccess := result.(*ArkServiceTrustedOnboardingDefault)
return nil, runtime.NewAPIError("unexpected success response: content available as default response in error", unexpectedSuccess, unexpectedSuccess.Code())
}
// SetTransport changes the transport on the client
func (a *Client) SetTransport(transport runtime.ClientTransport) {
a.transport = transport
}

View File

@@ -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-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
}

View File

@@ -0,0 +1,185 @@
// 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-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
}

View File

@@ -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"
)
// NewArkServiceGetEventStreamParams creates a new ArkServiceGetEventStreamParams 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 NewArkServiceGetEventStreamParams() *ArkServiceGetEventStreamParams {
return &ArkServiceGetEventStreamParams{
timeout: cr.DefaultTimeout,
}
}
// NewArkServiceGetEventStreamParamsWithTimeout creates a new ArkServiceGetEventStreamParams object
// with the ability to set a timeout on a request.
func NewArkServiceGetEventStreamParamsWithTimeout(timeout time.Duration) *ArkServiceGetEventStreamParams {
return &ArkServiceGetEventStreamParams{
timeout: timeout,
}
}
// NewArkServiceGetEventStreamParamsWithContext creates a new ArkServiceGetEventStreamParams object
// with the ability to set a context for a request.
func NewArkServiceGetEventStreamParamsWithContext(ctx context.Context) *ArkServiceGetEventStreamParams {
return &ArkServiceGetEventStreamParams{
Context: ctx,
}
}
// NewArkServiceGetEventStreamParamsWithHTTPClient creates a new ArkServiceGetEventStreamParams object
// with the ability to set a custom HTTPClient for a request.
func NewArkServiceGetEventStreamParamsWithHTTPClient(client *http.Client) *ArkServiceGetEventStreamParams {
return &ArkServiceGetEventStreamParams{
HTTPClient: client,
}
}
/*
ArkServiceGetEventStreamParams contains all the parameters to send to the API endpoint
for the ark service get event stream operation.
Typically these are written to a http.Request.
*/
type ArkServiceGetEventStreamParams struct {
timeout time.Duration
Context context.Context
HTTPClient *http.Client
}
// WithDefaults hydrates default values in the ark service get event stream params (not the query body).
//
// All values with no default are reset to their zero value.
func (o *ArkServiceGetEventStreamParams) WithDefaults() *ArkServiceGetEventStreamParams {
o.SetDefaults()
return o
}
// SetDefaults hydrates default values in the ark service get event stream params (not the query body).
//
// All values with no default are reset to their zero value.
func (o *ArkServiceGetEventStreamParams) SetDefaults() {
// no default values defined for this parameter
}
// WithTimeout adds the timeout to the ark service get event stream params
func (o *ArkServiceGetEventStreamParams) WithTimeout(timeout time.Duration) *ArkServiceGetEventStreamParams {
o.SetTimeout(timeout)
return o
}
// SetTimeout adds the timeout to the ark service get event stream params
func (o *ArkServiceGetEventStreamParams) SetTimeout(timeout time.Duration) {
o.timeout = timeout
}
// WithContext adds the context to the ark service get event stream params
func (o *ArkServiceGetEventStreamParams) WithContext(ctx context.Context) *ArkServiceGetEventStreamParams {
o.SetContext(ctx)
return o
}
// SetContext adds the context to the ark service get event stream params
func (o *ArkServiceGetEventStreamParams) SetContext(ctx context.Context) {
o.Context = ctx
}
// WithHTTPClient adds the HTTPClient to the ark service get event stream params
func (o *ArkServiceGetEventStreamParams) WithHTTPClient(client *http.Client) *ArkServiceGetEventStreamParams {
o.SetHTTPClient(client)
return o
}
// SetHTTPClient adds the HTTPClient to the ark service get event stream params
func (o *ArkServiceGetEventStreamParams) SetHTTPClient(client *http.Client) {
o.HTTPClient = client
}
// WriteToRequest writes these params to a swagger request
func (o *ArkServiceGetEventStreamParams) 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
}

View File

@@ -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-sdk/client/rest/service/models"
)
// ArkServiceGetEventStreamReader is a Reader for the ArkServiceGetEventStream structure.
type ArkServiceGetEventStreamReader struct {
formats strfmt.Registry
}
// ReadResponse reads a server response into the received o.
func (o *ArkServiceGetEventStreamReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) {
switch response.Code() {
case 200:
result := NewArkServiceGetEventStreamOK()
if err := result.readResponse(response, consumer, o.formats); err != nil {
return nil, err
}
return result, nil
default:
result := NewArkServiceGetEventStreamDefault(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
}
}
// NewArkServiceGetEventStreamOK creates a ArkServiceGetEventStreamOK with default headers values
func NewArkServiceGetEventStreamOK() *ArkServiceGetEventStreamOK {
return &ArkServiceGetEventStreamOK{}
}
/*
ArkServiceGetEventStreamOK describes a response with status code 200, with default header values.
A successful response.(streaming responses)
*/
type ArkServiceGetEventStreamOK struct {
Payload *ArkServiceGetEventStreamOKBody
}
// IsSuccess returns true when this ark service get event stream o k response has a 2xx status code
func (o *ArkServiceGetEventStreamOK) IsSuccess() bool {
return true
}
// IsRedirect returns true when this ark service get event stream o k response has a 3xx status code
func (o *ArkServiceGetEventStreamOK) IsRedirect() bool {
return false
}
// IsClientError returns true when this ark service get event stream o k response has a 4xx status code
func (o *ArkServiceGetEventStreamOK) IsClientError() bool {
return false
}
// IsServerError returns true when this ark service get event stream o k response has a 5xx status code
func (o *ArkServiceGetEventStreamOK) IsServerError() bool {
return false
}
// IsCode returns true when this ark service get event stream o k response a status code equal to that given
func (o *ArkServiceGetEventStreamOK) IsCode(code int) bool {
return code == 200
}
// Code gets the status code for the ark service get event stream o k response
func (o *ArkServiceGetEventStreamOK) Code() int {
return 200
}
func (o *ArkServiceGetEventStreamOK) Error() string {
payload, _ := json.Marshal(o.Payload)
return fmt.Sprintf("[GET /v1/events][%d] arkServiceGetEventStreamOK %s", 200, payload)
}
func (o *ArkServiceGetEventStreamOK) String() string {
payload, _ := json.Marshal(o.Payload)
return fmt.Sprintf("[GET /v1/events][%d] arkServiceGetEventStreamOK %s", 200, payload)
}
func (o *ArkServiceGetEventStreamOK) GetPayload() *ArkServiceGetEventStreamOKBody {
return o.Payload
}
func (o *ArkServiceGetEventStreamOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
o.Payload = new(ArkServiceGetEventStreamOKBody)
// response payload
if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF {
return err
}
return nil
}
// NewArkServiceGetEventStreamDefault creates a ArkServiceGetEventStreamDefault with default headers values
func NewArkServiceGetEventStreamDefault(code int) *ArkServiceGetEventStreamDefault {
return &ArkServiceGetEventStreamDefault{
_statusCode: code,
}
}
/*
ArkServiceGetEventStreamDefault describes a response with status code -1, with default header values.
An unexpected error response.
*/
type ArkServiceGetEventStreamDefault struct {
_statusCode int
Payload *models.RPCStatus
}
// IsSuccess returns true when this ark service get event stream default response has a 2xx status code
func (o *ArkServiceGetEventStreamDefault) IsSuccess() bool {
return o._statusCode/100 == 2
}
// IsRedirect returns true when this ark service get event stream default response has a 3xx status code
func (o *ArkServiceGetEventStreamDefault) IsRedirect() bool {
return o._statusCode/100 == 3
}
// IsClientError returns true when this ark service get event stream default response has a 4xx status code
func (o *ArkServiceGetEventStreamDefault) IsClientError() bool {
return o._statusCode/100 == 4
}
// IsServerError returns true when this ark service get event stream default response has a 5xx status code
func (o *ArkServiceGetEventStreamDefault) IsServerError() bool {
return o._statusCode/100 == 5
}
// IsCode returns true when this ark service get event stream default response a status code equal to that given
func (o *ArkServiceGetEventStreamDefault) IsCode(code int) bool {
return o._statusCode == code
}
// Code gets the status code for the ark service get event stream default response
func (o *ArkServiceGetEventStreamDefault) Code() int {
return o._statusCode
}
func (o *ArkServiceGetEventStreamDefault) Error() string {
payload, _ := json.Marshal(o.Payload)
return fmt.Sprintf("[GET /v1/events][%d] ArkService_GetEventStream default %s", o._statusCode, payload)
}
func (o *ArkServiceGetEventStreamDefault) String() string {
payload, _ := json.Marshal(o.Payload)
return fmt.Sprintf("[GET /v1/events][%d] ArkService_GetEventStream default %s", o._statusCode, payload)
}
func (o *ArkServiceGetEventStreamDefault) GetPayload() *models.RPCStatus {
return o.Payload
}
func (o *ArkServiceGetEventStreamDefault) 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
}
/*
ArkServiceGetEventStreamOKBody Stream result of v1GetEventStreamResponse
swagger:model ArkServiceGetEventStreamOKBody
*/
type ArkServiceGetEventStreamOKBody struct {
// error
Error *models.RPCStatus `json:"error,omitempty"`
// result
Result *models.V1GetEventStreamResponse `json:"result,omitempty"`
}
// Validate validates this ark service get event stream o k body
func (o *ArkServiceGetEventStreamOKBody) 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 *ArkServiceGetEventStreamOKBody) 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("arkServiceGetEventStreamOK" + "." + "error")
} else if ce, ok := err.(*errors.CompositeError); ok {
return ce.ValidateName("arkServiceGetEventStreamOK" + "." + "error")
}
return err
}
}
return nil
}
func (o *ArkServiceGetEventStreamOKBody) 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("arkServiceGetEventStreamOK" + "." + "result")
} else if ce, ok := err.(*errors.CompositeError); ok {
return ce.ValidateName("arkServiceGetEventStreamOK" + "." + "result")
}
return err
}
}
return nil
}
// ContextValidate validate this ark service get event stream o k body based on the context it is used
func (o *ArkServiceGetEventStreamOKBody) 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 *ArkServiceGetEventStreamOKBody) 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("arkServiceGetEventStreamOK" + "." + "error")
} else if ce, ok := err.(*errors.CompositeError); ok {
return ce.ValidateName("arkServiceGetEventStreamOK" + "." + "error")
}
return err
}
}
return nil
}
func (o *ArkServiceGetEventStreamOKBody) 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("arkServiceGetEventStreamOK" + "." + "result")
} else if ce, ok := err.(*errors.CompositeError); ok {
return ce.ValidateName("arkServiceGetEventStreamOK" + "." + "result")
}
return err
}
}
return nil
}
// MarshalBinary interface implementation
func (o *ArkServiceGetEventStreamOKBody) MarshalBinary() ([]byte, error) {
if o == nil {
return nil, nil
}
return swag.WriteJSON(o)
}
// UnmarshalBinary interface implementation
func (o *ArkServiceGetEventStreamOKBody) UnmarshalBinary(b []byte) error {
var res ArkServiceGetEventStreamOKBody
if err := swag.ReadJSON(b, &res); err != nil {
return err
}
*o = res
return nil
}

View File

@@ -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"
)
// NewArkServiceGetInfoParams creates a new ArkServiceGetInfoParams 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 NewArkServiceGetInfoParams() *ArkServiceGetInfoParams {
return &ArkServiceGetInfoParams{
timeout: cr.DefaultTimeout,
}
}
// NewArkServiceGetInfoParamsWithTimeout creates a new ArkServiceGetInfoParams object
// with the ability to set a timeout on a request.
func NewArkServiceGetInfoParamsWithTimeout(timeout time.Duration) *ArkServiceGetInfoParams {
return &ArkServiceGetInfoParams{
timeout: timeout,
}
}
// NewArkServiceGetInfoParamsWithContext creates a new ArkServiceGetInfoParams object
// with the ability to set a context for a request.
func NewArkServiceGetInfoParamsWithContext(ctx context.Context) *ArkServiceGetInfoParams {
return &ArkServiceGetInfoParams{
Context: ctx,
}
}
// NewArkServiceGetInfoParamsWithHTTPClient creates a new ArkServiceGetInfoParams object
// with the ability to set a custom HTTPClient for a request.
func NewArkServiceGetInfoParamsWithHTTPClient(client *http.Client) *ArkServiceGetInfoParams {
return &ArkServiceGetInfoParams{
HTTPClient: client,
}
}
/*
ArkServiceGetInfoParams contains all the parameters to send to the API endpoint
for the ark service get info operation.
Typically these are written to a http.Request.
*/
type ArkServiceGetInfoParams struct {
timeout time.Duration
Context context.Context
HTTPClient *http.Client
}
// WithDefaults hydrates default values in the ark service get info params (not the query body).
//
// All values with no default are reset to their zero value.
func (o *ArkServiceGetInfoParams) WithDefaults() *ArkServiceGetInfoParams {
o.SetDefaults()
return o
}
// SetDefaults hydrates default values in the ark service get info params (not the query body).
//
// All values with no default are reset to their zero value.
func (o *ArkServiceGetInfoParams) SetDefaults() {
// no default values defined for this parameter
}
// WithTimeout adds the timeout to the ark service get info params
func (o *ArkServiceGetInfoParams) WithTimeout(timeout time.Duration) *ArkServiceGetInfoParams {
o.SetTimeout(timeout)
return o
}
// SetTimeout adds the timeout to the ark service get info params
func (o *ArkServiceGetInfoParams) SetTimeout(timeout time.Duration) {
o.timeout = timeout
}
// WithContext adds the context to the ark service get info params
func (o *ArkServiceGetInfoParams) WithContext(ctx context.Context) *ArkServiceGetInfoParams {
o.SetContext(ctx)
return o
}
// SetContext adds the context to the ark service get info params
func (o *ArkServiceGetInfoParams) SetContext(ctx context.Context) {
o.Context = ctx
}
// WithHTTPClient adds the HTTPClient to the ark service get info params
func (o *ArkServiceGetInfoParams) WithHTTPClient(client *http.Client) *ArkServiceGetInfoParams {
o.SetHTTPClient(client)
return o
}
// SetHTTPClient adds the HTTPClient to the ark service get info params
func (o *ArkServiceGetInfoParams) SetHTTPClient(client *http.Client) {
o.HTTPClient = client
}
// WriteToRequest writes these params to a swagger request
func (o *ArkServiceGetInfoParams) 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
}

View File

@@ -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-sdk/client/rest/service/models"
)
// ArkServiceGetInfoReader is a Reader for the ArkServiceGetInfo structure.
type ArkServiceGetInfoReader struct {
formats strfmt.Registry
}
// ReadResponse reads a server response into the received o.
func (o *ArkServiceGetInfoReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) {
switch response.Code() {
case 200:
result := NewArkServiceGetInfoOK()
if err := result.readResponse(response, consumer, o.formats); err != nil {
return nil, err
}
return result, nil
default:
result := NewArkServiceGetInfoDefault(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
}
}
// NewArkServiceGetInfoOK creates a ArkServiceGetInfoOK with default headers values
func NewArkServiceGetInfoOK() *ArkServiceGetInfoOK {
return &ArkServiceGetInfoOK{}
}
/*
ArkServiceGetInfoOK describes a response with status code 200, with default header values.
A successful response.
*/
type ArkServiceGetInfoOK struct {
Payload *models.V1GetInfoResponse
}
// IsSuccess returns true when this ark service get info o k response has a 2xx status code
func (o *ArkServiceGetInfoOK) IsSuccess() bool {
return true
}
// IsRedirect returns true when this ark service get info o k response has a 3xx status code
func (o *ArkServiceGetInfoOK) IsRedirect() bool {
return false
}
// IsClientError returns true when this ark service get info o k response has a 4xx status code
func (o *ArkServiceGetInfoOK) IsClientError() bool {
return false
}
// IsServerError returns true when this ark service get info o k response has a 5xx status code
func (o *ArkServiceGetInfoOK) IsServerError() bool {
return false
}
// IsCode returns true when this ark service get info o k response a status code equal to that given
func (o *ArkServiceGetInfoOK) IsCode(code int) bool {
return code == 200
}
// Code gets the status code for the ark service get info o k response
func (o *ArkServiceGetInfoOK) Code() int {
return 200
}
func (o *ArkServiceGetInfoOK) Error() string {
payload, _ := json.Marshal(o.Payload)
return fmt.Sprintf("[GET /v1/info][%d] arkServiceGetInfoOK %s", 200, payload)
}
func (o *ArkServiceGetInfoOK) String() string {
payload, _ := json.Marshal(o.Payload)
return fmt.Sprintf("[GET /v1/info][%d] arkServiceGetInfoOK %s", 200, payload)
}
func (o *ArkServiceGetInfoOK) GetPayload() *models.V1GetInfoResponse {
return o.Payload
}
func (o *ArkServiceGetInfoOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
o.Payload = new(models.V1GetInfoResponse)
// response payload
if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF {
return err
}
return nil
}
// NewArkServiceGetInfoDefault creates a ArkServiceGetInfoDefault with default headers values
func NewArkServiceGetInfoDefault(code int) *ArkServiceGetInfoDefault {
return &ArkServiceGetInfoDefault{
_statusCode: code,
}
}
/*
ArkServiceGetInfoDefault describes a response with status code -1, with default header values.
An unexpected error response.
*/
type ArkServiceGetInfoDefault struct {
_statusCode int
Payload *models.RPCStatus
}
// IsSuccess returns true when this ark service get info default response has a 2xx status code
func (o *ArkServiceGetInfoDefault) IsSuccess() bool {
return o._statusCode/100 == 2
}
// IsRedirect returns true when this ark service get info default response has a 3xx status code
func (o *ArkServiceGetInfoDefault) IsRedirect() bool {
return o._statusCode/100 == 3
}
// IsClientError returns true when this ark service get info default response has a 4xx status code
func (o *ArkServiceGetInfoDefault) IsClientError() bool {
return o._statusCode/100 == 4
}
// IsServerError returns true when this ark service get info default response has a 5xx status code
func (o *ArkServiceGetInfoDefault) IsServerError() bool {
return o._statusCode/100 == 5
}
// IsCode returns true when this ark service get info default response a status code equal to that given
func (o *ArkServiceGetInfoDefault) IsCode(code int) bool {
return o._statusCode == code
}
// Code gets the status code for the ark service get info default response
func (o *ArkServiceGetInfoDefault) Code() int {
return o._statusCode
}
func (o *ArkServiceGetInfoDefault) Error() string {
payload, _ := json.Marshal(o.Payload)
return fmt.Sprintf("[GET /v1/info][%d] ArkService_GetInfo default %s", o._statusCode, payload)
}
func (o *ArkServiceGetInfoDefault) String() string {
payload, _ := json.Marshal(o.Payload)
return fmt.Sprintf("[GET /v1/info][%d] ArkService_GetInfo default %s", o._statusCode, payload)
}
func (o *ArkServiceGetInfoDefault) GetPayload() *models.RPCStatus {
return o.Payload
}
func (o *ArkServiceGetInfoDefault) 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
}

View File

@@ -0,0 +1,148 @@
// 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"
)
// NewArkServiceGetRoundByIDParams creates a new ArkServiceGetRoundByIDParams 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 NewArkServiceGetRoundByIDParams() *ArkServiceGetRoundByIDParams {
return &ArkServiceGetRoundByIDParams{
timeout: cr.DefaultTimeout,
}
}
// NewArkServiceGetRoundByIDParamsWithTimeout creates a new ArkServiceGetRoundByIDParams object
// with the ability to set a timeout on a request.
func NewArkServiceGetRoundByIDParamsWithTimeout(timeout time.Duration) *ArkServiceGetRoundByIDParams {
return &ArkServiceGetRoundByIDParams{
timeout: timeout,
}
}
// NewArkServiceGetRoundByIDParamsWithContext creates a new ArkServiceGetRoundByIDParams object
// with the ability to set a context for a request.
func NewArkServiceGetRoundByIDParamsWithContext(ctx context.Context) *ArkServiceGetRoundByIDParams {
return &ArkServiceGetRoundByIDParams{
Context: ctx,
}
}
// NewArkServiceGetRoundByIDParamsWithHTTPClient creates a new ArkServiceGetRoundByIDParams object
// with the ability to set a custom HTTPClient for a request.
func NewArkServiceGetRoundByIDParamsWithHTTPClient(client *http.Client) *ArkServiceGetRoundByIDParams {
return &ArkServiceGetRoundByIDParams{
HTTPClient: client,
}
}
/*
ArkServiceGetRoundByIDParams contains all the parameters to send to the API endpoint
for the ark service get round by Id operation.
Typically these are written to a http.Request.
*/
type ArkServiceGetRoundByIDParams struct {
// ID.
ID string
timeout time.Duration
Context context.Context
HTTPClient *http.Client
}
// WithDefaults hydrates default values in the ark service get round by Id params (not the query body).
//
// All values with no default are reset to their zero value.
func (o *ArkServiceGetRoundByIDParams) WithDefaults() *ArkServiceGetRoundByIDParams {
o.SetDefaults()
return o
}
// SetDefaults hydrates default values in the ark service get round by Id params (not the query body).
//
// All values with no default are reset to their zero value.
func (o *ArkServiceGetRoundByIDParams) SetDefaults() {
// no default values defined for this parameter
}
// WithTimeout adds the timeout to the ark service get round by Id params
func (o *ArkServiceGetRoundByIDParams) WithTimeout(timeout time.Duration) *ArkServiceGetRoundByIDParams {
o.SetTimeout(timeout)
return o
}
// SetTimeout adds the timeout to the ark service get round by Id params
func (o *ArkServiceGetRoundByIDParams) SetTimeout(timeout time.Duration) {
o.timeout = timeout
}
// WithContext adds the context to the ark service get round by Id params
func (o *ArkServiceGetRoundByIDParams) WithContext(ctx context.Context) *ArkServiceGetRoundByIDParams {
o.SetContext(ctx)
return o
}
// SetContext adds the context to the ark service get round by Id params
func (o *ArkServiceGetRoundByIDParams) SetContext(ctx context.Context) {
o.Context = ctx
}
// WithHTTPClient adds the HTTPClient to the ark service get round by Id params
func (o *ArkServiceGetRoundByIDParams) WithHTTPClient(client *http.Client) *ArkServiceGetRoundByIDParams {
o.SetHTTPClient(client)
return o
}
// SetHTTPClient adds the HTTPClient to the ark service get round by Id params
func (o *ArkServiceGetRoundByIDParams) SetHTTPClient(client *http.Client) {
o.HTTPClient = client
}
// WithID adds the id to the ark service get round by Id params
func (o *ArkServiceGetRoundByIDParams) WithID(id string) *ArkServiceGetRoundByIDParams {
o.SetID(id)
return o
}
// SetID adds the id to the ark service get round by Id params
func (o *ArkServiceGetRoundByIDParams) SetID(id string) {
o.ID = id
}
// WriteToRequest writes these params to a swagger request
func (o *ArkServiceGetRoundByIDParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {
if err := r.SetTimeout(o.timeout); err != nil {
return err
}
var res []error
// path param id
if err := r.SetPathParam("id", o.ID); err != nil {
return err
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}

View File

@@ -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-sdk/client/rest/service/models"
)
// ArkServiceGetRoundByIDReader is a Reader for the ArkServiceGetRoundByID structure.
type ArkServiceGetRoundByIDReader struct {
formats strfmt.Registry
}
// ReadResponse reads a server response into the received o.
func (o *ArkServiceGetRoundByIDReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) {
switch response.Code() {
case 200:
result := NewArkServiceGetRoundByIDOK()
if err := result.readResponse(response, consumer, o.formats); err != nil {
return nil, err
}
return result, nil
default:
result := NewArkServiceGetRoundByIDDefault(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
}
}
// NewArkServiceGetRoundByIDOK creates a ArkServiceGetRoundByIDOK with default headers values
func NewArkServiceGetRoundByIDOK() *ArkServiceGetRoundByIDOK {
return &ArkServiceGetRoundByIDOK{}
}
/*
ArkServiceGetRoundByIDOK describes a response with status code 200, with default header values.
A successful response.
*/
type ArkServiceGetRoundByIDOK struct {
Payload *models.V1GetRoundByIDResponse
}
// IsSuccess returns true when this ark service get round by Id o k response has a 2xx status code
func (o *ArkServiceGetRoundByIDOK) IsSuccess() bool {
return true
}
// IsRedirect returns true when this ark service get round by Id o k response has a 3xx status code
func (o *ArkServiceGetRoundByIDOK) IsRedirect() bool {
return false
}
// IsClientError returns true when this ark service get round by Id o k response has a 4xx status code
func (o *ArkServiceGetRoundByIDOK) IsClientError() bool {
return false
}
// IsServerError returns true when this ark service get round by Id o k response has a 5xx status code
func (o *ArkServiceGetRoundByIDOK) IsServerError() bool {
return false
}
// IsCode returns true when this ark service get round by Id o k response a status code equal to that given
func (o *ArkServiceGetRoundByIDOK) IsCode(code int) bool {
return code == 200
}
// Code gets the status code for the ark service get round by Id o k response
func (o *ArkServiceGetRoundByIDOK) Code() int {
return 200
}
func (o *ArkServiceGetRoundByIDOK) Error() string {
payload, _ := json.Marshal(o.Payload)
return fmt.Sprintf("[GET /v1/round/id/{id}][%d] arkServiceGetRoundByIdOK %s", 200, payload)
}
func (o *ArkServiceGetRoundByIDOK) String() string {
payload, _ := json.Marshal(o.Payload)
return fmt.Sprintf("[GET /v1/round/id/{id}][%d] arkServiceGetRoundByIdOK %s", 200, payload)
}
func (o *ArkServiceGetRoundByIDOK) GetPayload() *models.V1GetRoundByIDResponse {
return o.Payload
}
func (o *ArkServiceGetRoundByIDOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
o.Payload = new(models.V1GetRoundByIDResponse)
// response payload
if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF {
return err
}
return nil
}
// NewArkServiceGetRoundByIDDefault creates a ArkServiceGetRoundByIDDefault with default headers values
func NewArkServiceGetRoundByIDDefault(code int) *ArkServiceGetRoundByIDDefault {
return &ArkServiceGetRoundByIDDefault{
_statusCode: code,
}
}
/*
ArkServiceGetRoundByIDDefault describes a response with status code -1, with default header values.
An unexpected error response.
*/
type ArkServiceGetRoundByIDDefault struct {
_statusCode int
Payload *models.RPCStatus
}
// IsSuccess returns true when this ark service get round by Id default response has a 2xx status code
func (o *ArkServiceGetRoundByIDDefault) IsSuccess() bool {
return o._statusCode/100 == 2
}
// IsRedirect returns true when this ark service get round by Id default response has a 3xx status code
func (o *ArkServiceGetRoundByIDDefault) IsRedirect() bool {
return o._statusCode/100 == 3
}
// IsClientError returns true when this ark service get round by Id default response has a 4xx status code
func (o *ArkServiceGetRoundByIDDefault) IsClientError() bool {
return o._statusCode/100 == 4
}
// IsServerError returns true when this ark service get round by Id default response has a 5xx status code
func (o *ArkServiceGetRoundByIDDefault) IsServerError() bool {
return o._statusCode/100 == 5
}
// IsCode returns true when this ark service get round by Id default response a status code equal to that given
func (o *ArkServiceGetRoundByIDDefault) IsCode(code int) bool {
return o._statusCode == code
}
// Code gets the status code for the ark service get round by Id default response
func (o *ArkServiceGetRoundByIDDefault) Code() int {
return o._statusCode
}
func (o *ArkServiceGetRoundByIDDefault) Error() string {
payload, _ := json.Marshal(o.Payload)
return fmt.Sprintf("[GET /v1/round/id/{id}][%d] ArkService_GetRoundById default %s", o._statusCode, payload)
}
func (o *ArkServiceGetRoundByIDDefault) String() string {
payload, _ := json.Marshal(o.Payload)
return fmt.Sprintf("[GET /v1/round/id/{id}][%d] ArkService_GetRoundById default %s", o._statusCode, payload)
}
func (o *ArkServiceGetRoundByIDDefault) GetPayload() *models.RPCStatus {
return o.Payload
}
func (o *ArkServiceGetRoundByIDDefault) 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
}

View File

@@ -0,0 +1,148 @@
// 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"
)
// NewArkServiceGetRoundParams creates a new ArkServiceGetRoundParams 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 NewArkServiceGetRoundParams() *ArkServiceGetRoundParams {
return &ArkServiceGetRoundParams{
timeout: cr.DefaultTimeout,
}
}
// NewArkServiceGetRoundParamsWithTimeout creates a new ArkServiceGetRoundParams object
// with the ability to set a timeout on a request.
func NewArkServiceGetRoundParamsWithTimeout(timeout time.Duration) *ArkServiceGetRoundParams {
return &ArkServiceGetRoundParams{
timeout: timeout,
}
}
// NewArkServiceGetRoundParamsWithContext creates a new ArkServiceGetRoundParams object
// with the ability to set a context for a request.
func NewArkServiceGetRoundParamsWithContext(ctx context.Context) *ArkServiceGetRoundParams {
return &ArkServiceGetRoundParams{
Context: ctx,
}
}
// NewArkServiceGetRoundParamsWithHTTPClient creates a new ArkServiceGetRoundParams object
// with the ability to set a custom HTTPClient for a request.
func NewArkServiceGetRoundParamsWithHTTPClient(client *http.Client) *ArkServiceGetRoundParams {
return &ArkServiceGetRoundParams{
HTTPClient: client,
}
}
/*
ArkServiceGetRoundParams contains all the parameters to send to the API endpoint
for the ark service get round operation.
Typically these are written to a http.Request.
*/
type ArkServiceGetRoundParams struct {
// Txid.
Txid string
timeout time.Duration
Context context.Context
HTTPClient *http.Client
}
// WithDefaults hydrates default values in the ark service get round params (not the query body).
//
// All values with no default are reset to their zero value.
func (o *ArkServiceGetRoundParams) WithDefaults() *ArkServiceGetRoundParams {
o.SetDefaults()
return o
}
// SetDefaults hydrates default values in the ark service get round params (not the query body).
//
// All values with no default are reset to their zero value.
func (o *ArkServiceGetRoundParams) SetDefaults() {
// no default values defined for this parameter
}
// WithTimeout adds the timeout to the ark service get round params
func (o *ArkServiceGetRoundParams) WithTimeout(timeout time.Duration) *ArkServiceGetRoundParams {
o.SetTimeout(timeout)
return o
}
// SetTimeout adds the timeout to the ark service get round params
func (o *ArkServiceGetRoundParams) SetTimeout(timeout time.Duration) {
o.timeout = timeout
}
// WithContext adds the context to the ark service get round params
func (o *ArkServiceGetRoundParams) WithContext(ctx context.Context) *ArkServiceGetRoundParams {
o.SetContext(ctx)
return o
}
// SetContext adds the context to the ark service get round params
func (o *ArkServiceGetRoundParams) SetContext(ctx context.Context) {
o.Context = ctx
}
// WithHTTPClient adds the HTTPClient to the ark service get round params
func (o *ArkServiceGetRoundParams) WithHTTPClient(client *http.Client) *ArkServiceGetRoundParams {
o.SetHTTPClient(client)
return o
}
// SetHTTPClient adds the HTTPClient to the ark service get round params
func (o *ArkServiceGetRoundParams) SetHTTPClient(client *http.Client) {
o.HTTPClient = client
}
// WithTxid adds the txid to the ark service get round params
func (o *ArkServiceGetRoundParams) WithTxid(txid string) *ArkServiceGetRoundParams {
o.SetTxid(txid)
return o
}
// SetTxid adds the txid to the ark service get round params
func (o *ArkServiceGetRoundParams) SetTxid(txid string) {
o.Txid = txid
}
// WriteToRequest writes these params to a swagger request
func (o *ArkServiceGetRoundParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {
if err := r.SetTimeout(o.timeout); err != nil {
return err
}
var res []error
// path param txid
if err := r.SetPathParam("txid", o.Txid); err != nil {
return err
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}

View File

@@ -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-sdk/client/rest/service/models"
)
// ArkServiceGetRoundReader is a Reader for the ArkServiceGetRound structure.
type ArkServiceGetRoundReader struct {
formats strfmt.Registry
}
// ReadResponse reads a server response into the received o.
func (o *ArkServiceGetRoundReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) {
switch response.Code() {
case 200:
result := NewArkServiceGetRoundOK()
if err := result.readResponse(response, consumer, o.formats); err != nil {
return nil, err
}
return result, nil
default:
result := NewArkServiceGetRoundDefault(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
}
}
// NewArkServiceGetRoundOK creates a ArkServiceGetRoundOK with default headers values
func NewArkServiceGetRoundOK() *ArkServiceGetRoundOK {
return &ArkServiceGetRoundOK{}
}
/*
ArkServiceGetRoundOK describes a response with status code 200, with default header values.
A successful response.
*/
type ArkServiceGetRoundOK struct {
Payload *models.V1GetRoundResponse
}
// IsSuccess returns true when this ark service get round o k response has a 2xx status code
func (o *ArkServiceGetRoundOK) IsSuccess() bool {
return true
}
// IsRedirect returns true when this ark service get round o k response has a 3xx status code
func (o *ArkServiceGetRoundOK) IsRedirect() bool {
return false
}
// IsClientError returns true when this ark service get round o k response has a 4xx status code
func (o *ArkServiceGetRoundOK) IsClientError() bool {
return false
}
// IsServerError returns true when this ark service get round o k response has a 5xx status code
func (o *ArkServiceGetRoundOK) IsServerError() bool {
return false
}
// IsCode returns true when this ark service get round o k response a status code equal to that given
func (o *ArkServiceGetRoundOK) IsCode(code int) bool {
return code == 200
}
// Code gets the status code for the ark service get round o k response
func (o *ArkServiceGetRoundOK) Code() int {
return 200
}
func (o *ArkServiceGetRoundOK) Error() string {
payload, _ := json.Marshal(o.Payload)
return fmt.Sprintf("[GET /v1/round/{txid}][%d] arkServiceGetRoundOK %s", 200, payload)
}
func (o *ArkServiceGetRoundOK) String() string {
payload, _ := json.Marshal(o.Payload)
return fmt.Sprintf("[GET /v1/round/{txid}][%d] arkServiceGetRoundOK %s", 200, payload)
}
func (o *ArkServiceGetRoundOK) GetPayload() *models.V1GetRoundResponse {
return o.Payload
}
func (o *ArkServiceGetRoundOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
o.Payload = new(models.V1GetRoundResponse)
// response payload
if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF {
return err
}
return nil
}
// NewArkServiceGetRoundDefault creates a ArkServiceGetRoundDefault with default headers values
func NewArkServiceGetRoundDefault(code int) *ArkServiceGetRoundDefault {
return &ArkServiceGetRoundDefault{
_statusCode: code,
}
}
/*
ArkServiceGetRoundDefault describes a response with status code -1, with default header values.
An unexpected error response.
*/
type ArkServiceGetRoundDefault struct {
_statusCode int
Payload *models.RPCStatus
}
// IsSuccess returns true when this ark service get round default response has a 2xx status code
func (o *ArkServiceGetRoundDefault) IsSuccess() bool {
return o._statusCode/100 == 2
}
// IsRedirect returns true when this ark service get round default response has a 3xx status code
func (o *ArkServiceGetRoundDefault) IsRedirect() bool {
return o._statusCode/100 == 3
}
// IsClientError returns true when this ark service get round default response has a 4xx status code
func (o *ArkServiceGetRoundDefault) IsClientError() bool {
return o._statusCode/100 == 4
}
// IsServerError returns true when this ark service get round default response has a 5xx status code
func (o *ArkServiceGetRoundDefault) IsServerError() bool {
return o._statusCode/100 == 5
}
// IsCode returns true when this ark service get round default response a status code equal to that given
func (o *ArkServiceGetRoundDefault) IsCode(code int) bool {
return o._statusCode == code
}
// Code gets the status code for the ark service get round default response
func (o *ArkServiceGetRoundDefault) Code() int {
return o._statusCode
}
func (o *ArkServiceGetRoundDefault) Error() string {
payload, _ := json.Marshal(o.Payload)
return fmt.Sprintf("[GET /v1/round/{txid}][%d] ArkService_GetRound default %s", o._statusCode, payload)
}
func (o *ArkServiceGetRoundDefault) String() string {
payload, _ := json.Marshal(o.Payload)
return fmt.Sprintf("[GET /v1/round/{txid}][%d] ArkService_GetRound default %s", o._statusCode, payload)
}
func (o *ArkServiceGetRoundDefault) GetPayload() *models.RPCStatus {
return o.Payload
}
func (o *ArkServiceGetRoundDefault) 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
}

View File

@@ -0,0 +1,148 @@
// 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"
)
// NewArkServiceListVtxosParams creates a new ArkServiceListVtxosParams 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 NewArkServiceListVtxosParams() *ArkServiceListVtxosParams {
return &ArkServiceListVtxosParams{
timeout: cr.DefaultTimeout,
}
}
// NewArkServiceListVtxosParamsWithTimeout creates a new ArkServiceListVtxosParams object
// with the ability to set a timeout on a request.
func NewArkServiceListVtxosParamsWithTimeout(timeout time.Duration) *ArkServiceListVtxosParams {
return &ArkServiceListVtxosParams{
timeout: timeout,
}
}
// NewArkServiceListVtxosParamsWithContext creates a new ArkServiceListVtxosParams object
// with the ability to set a context for a request.
func NewArkServiceListVtxosParamsWithContext(ctx context.Context) *ArkServiceListVtxosParams {
return &ArkServiceListVtxosParams{
Context: ctx,
}
}
// NewArkServiceListVtxosParamsWithHTTPClient creates a new ArkServiceListVtxosParams object
// with the ability to set a custom HTTPClient for a request.
func NewArkServiceListVtxosParamsWithHTTPClient(client *http.Client) *ArkServiceListVtxosParams {
return &ArkServiceListVtxosParams{
HTTPClient: client,
}
}
/*
ArkServiceListVtxosParams contains all the parameters to send to the API endpoint
for the ark service list vtxos operation.
Typically these are written to a http.Request.
*/
type ArkServiceListVtxosParams struct {
// Address.
Address string
timeout time.Duration
Context context.Context
HTTPClient *http.Client
}
// WithDefaults hydrates default values in the ark service list vtxos params (not the query body).
//
// All values with no default are reset to their zero value.
func (o *ArkServiceListVtxosParams) WithDefaults() *ArkServiceListVtxosParams {
o.SetDefaults()
return o
}
// SetDefaults hydrates default values in the ark service list vtxos params (not the query body).
//
// All values with no default are reset to their zero value.
func (o *ArkServiceListVtxosParams) SetDefaults() {
// no default values defined for this parameter
}
// WithTimeout adds the timeout to the ark service list vtxos params
func (o *ArkServiceListVtxosParams) WithTimeout(timeout time.Duration) *ArkServiceListVtxosParams {
o.SetTimeout(timeout)
return o
}
// SetTimeout adds the timeout to the ark service list vtxos params
func (o *ArkServiceListVtxosParams) SetTimeout(timeout time.Duration) {
o.timeout = timeout
}
// WithContext adds the context to the ark service list vtxos params
func (o *ArkServiceListVtxosParams) WithContext(ctx context.Context) *ArkServiceListVtxosParams {
o.SetContext(ctx)
return o
}
// SetContext adds the context to the ark service list vtxos params
func (o *ArkServiceListVtxosParams) SetContext(ctx context.Context) {
o.Context = ctx
}
// WithHTTPClient adds the HTTPClient to the ark service list vtxos params
func (o *ArkServiceListVtxosParams) WithHTTPClient(client *http.Client) *ArkServiceListVtxosParams {
o.SetHTTPClient(client)
return o
}
// SetHTTPClient adds the HTTPClient to the ark service list vtxos params
func (o *ArkServiceListVtxosParams) SetHTTPClient(client *http.Client) {
o.HTTPClient = client
}
// WithAddress adds the address to the ark service list vtxos params
func (o *ArkServiceListVtxosParams) WithAddress(address string) *ArkServiceListVtxosParams {
o.SetAddress(address)
return o
}
// SetAddress adds the address to the ark service list vtxos params
func (o *ArkServiceListVtxosParams) SetAddress(address string) {
o.Address = address
}
// WriteToRequest writes these params to a swagger request
func (o *ArkServiceListVtxosParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {
if err := r.SetTimeout(o.timeout); err != nil {
return err
}
var res []error
// path param address
if err := r.SetPathParam("address", o.Address); err != nil {
return err
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}

View File

@@ -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-sdk/client/rest/service/models"
)
// ArkServiceListVtxosReader is a Reader for the ArkServiceListVtxos structure.
type ArkServiceListVtxosReader struct {
formats strfmt.Registry
}
// ReadResponse reads a server response into the received o.
func (o *ArkServiceListVtxosReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) {
switch response.Code() {
case 200:
result := NewArkServiceListVtxosOK()
if err := result.readResponse(response, consumer, o.formats); err != nil {
return nil, err
}
return result, nil
default:
result := NewArkServiceListVtxosDefault(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
}
}
// NewArkServiceListVtxosOK creates a ArkServiceListVtxosOK with default headers values
func NewArkServiceListVtxosOK() *ArkServiceListVtxosOK {
return &ArkServiceListVtxosOK{}
}
/*
ArkServiceListVtxosOK describes a response with status code 200, with default header values.
A successful response.
*/
type ArkServiceListVtxosOK struct {
Payload *models.V1ListVtxosResponse
}
// IsSuccess returns true when this ark service list vtxos o k response has a 2xx status code
func (o *ArkServiceListVtxosOK) IsSuccess() bool {
return true
}
// IsRedirect returns true when this ark service list vtxos o k response has a 3xx status code
func (o *ArkServiceListVtxosOK) IsRedirect() bool {
return false
}
// IsClientError returns true when this ark service list vtxos o k response has a 4xx status code
func (o *ArkServiceListVtxosOK) IsClientError() bool {
return false
}
// IsServerError returns true when this ark service list vtxos o k response has a 5xx status code
func (o *ArkServiceListVtxosOK) IsServerError() bool {
return false
}
// IsCode returns true when this ark service list vtxos o k response a status code equal to that given
func (o *ArkServiceListVtxosOK) IsCode(code int) bool {
return code == 200
}
// Code gets the status code for the ark service list vtxos o k response
func (o *ArkServiceListVtxosOK) Code() int {
return 200
}
func (o *ArkServiceListVtxosOK) Error() string {
payload, _ := json.Marshal(o.Payload)
return fmt.Sprintf("[GET /v1/vtxos/{address}][%d] arkServiceListVtxosOK %s", 200, payload)
}
func (o *ArkServiceListVtxosOK) String() string {
payload, _ := json.Marshal(o.Payload)
return fmt.Sprintf("[GET /v1/vtxos/{address}][%d] arkServiceListVtxosOK %s", 200, payload)
}
func (o *ArkServiceListVtxosOK) GetPayload() *models.V1ListVtxosResponse {
return o.Payload
}
func (o *ArkServiceListVtxosOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
o.Payload = new(models.V1ListVtxosResponse)
// response payload
if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF {
return err
}
return nil
}
// NewArkServiceListVtxosDefault creates a ArkServiceListVtxosDefault with default headers values
func NewArkServiceListVtxosDefault(code int) *ArkServiceListVtxosDefault {
return &ArkServiceListVtxosDefault{
_statusCode: code,
}
}
/*
ArkServiceListVtxosDefault describes a response with status code -1, with default header values.
An unexpected error response.
*/
type ArkServiceListVtxosDefault struct {
_statusCode int
Payload *models.RPCStatus
}
// IsSuccess returns true when this ark service list vtxos default response has a 2xx status code
func (o *ArkServiceListVtxosDefault) IsSuccess() bool {
return o._statusCode/100 == 2
}
// IsRedirect returns true when this ark service list vtxos default response has a 3xx status code
func (o *ArkServiceListVtxosDefault) IsRedirect() bool {
return o._statusCode/100 == 3
}
// IsClientError returns true when this ark service list vtxos default response has a 4xx status code
func (o *ArkServiceListVtxosDefault) IsClientError() bool {
return o._statusCode/100 == 4
}
// IsServerError returns true when this ark service list vtxos default response has a 5xx status code
func (o *ArkServiceListVtxosDefault) IsServerError() bool {
return o._statusCode/100 == 5
}
// IsCode returns true when this ark service list vtxos default response a status code equal to that given
func (o *ArkServiceListVtxosDefault) IsCode(code int) bool {
return o._statusCode == code
}
// Code gets the status code for the ark service list vtxos default response
func (o *ArkServiceListVtxosDefault) Code() int {
return o._statusCode
}
func (o *ArkServiceListVtxosDefault) Error() string {
payload, _ := json.Marshal(o.Payload)
return fmt.Sprintf("[GET /v1/vtxos/{address}][%d] ArkService_ListVtxos default %s", o._statusCode, payload)
}
func (o *ArkServiceListVtxosDefault) String() string {
payload, _ := json.Marshal(o.Payload)
return fmt.Sprintf("[GET /v1/vtxos/{address}][%d] ArkService_ListVtxos default %s", o._statusCode, payload)
}
func (o *ArkServiceListVtxosDefault) GetPayload() *models.RPCStatus {
return o.Payload
}
func (o *ArkServiceListVtxosDefault) 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
}

View File

@@ -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-sdk/client/rest/service/models"
)
// NewArkServiceOnboardParams creates a new ArkServiceOnboardParams 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 NewArkServiceOnboardParams() *ArkServiceOnboardParams {
return &ArkServiceOnboardParams{
timeout: cr.DefaultTimeout,
}
}
// NewArkServiceOnboardParamsWithTimeout creates a new ArkServiceOnboardParams object
// with the ability to set a timeout on a request.
func NewArkServiceOnboardParamsWithTimeout(timeout time.Duration) *ArkServiceOnboardParams {
return &ArkServiceOnboardParams{
timeout: timeout,
}
}
// NewArkServiceOnboardParamsWithContext creates a new ArkServiceOnboardParams object
// with the ability to set a context for a request.
func NewArkServiceOnboardParamsWithContext(ctx context.Context) *ArkServiceOnboardParams {
return &ArkServiceOnboardParams{
Context: ctx,
}
}
// NewArkServiceOnboardParamsWithHTTPClient creates a new ArkServiceOnboardParams object
// with the ability to set a custom HTTPClient for a request.
func NewArkServiceOnboardParamsWithHTTPClient(client *http.Client) *ArkServiceOnboardParams {
return &ArkServiceOnboardParams{
HTTPClient: client,
}
}
/*
ArkServiceOnboardParams contains all the parameters to send to the API endpoint
for the ark service onboard operation.
Typically these are written to a http.Request.
*/
type ArkServiceOnboardParams struct {
// Body.
Body *models.V1OnboardRequest
timeout time.Duration
Context context.Context
HTTPClient *http.Client
}
// WithDefaults hydrates default values in the ark service onboard params (not the query body).
//
// All values with no default are reset to their zero value.
func (o *ArkServiceOnboardParams) WithDefaults() *ArkServiceOnboardParams {
o.SetDefaults()
return o
}
// SetDefaults hydrates default values in the ark service onboard params (not the query body).
//
// All values with no default are reset to their zero value.
func (o *ArkServiceOnboardParams) SetDefaults() {
// no default values defined for this parameter
}
// WithTimeout adds the timeout to the ark service onboard params
func (o *ArkServiceOnboardParams) WithTimeout(timeout time.Duration) *ArkServiceOnboardParams {
o.SetTimeout(timeout)
return o
}
// SetTimeout adds the timeout to the ark service onboard params
func (o *ArkServiceOnboardParams) SetTimeout(timeout time.Duration) {
o.timeout = timeout
}
// WithContext adds the context to the ark service onboard params
func (o *ArkServiceOnboardParams) WithContext(ctx context.Context) *ArkServiceOnboardParams {
o.SetContext(ctx)
return o
}
// SetContext adds the context to the ark service onboard params
func (o *ArkServiceOnboardParams) SetContext(ctx context.Context) {
o.Context = ctx
}
// WithHTTPClient adds the HTTPClient to the ark service onboard params
func (o *ArkServiceOnboardParams) WithHTTPClient(client *http.Client) *ArkServiceOnboardParams {
o.SetHTTPClient(client)
return o
}
// SetHTTPClient adds the HTTPClient to the ark service onboard params
func (o *ArkServiceOnboardParams) SetHTTPClient(client *http.Client) {
o.HTTPClient = client
}
// WithBody adds the body to the ark service onboard params
func (o *ArkServiceOnboardParams) WithBody(body *models.V1OnboardRequest) *ArkServiceOnboardParams {
o.SetBody(body)
return o
}
// SetBody adds the body to the ark service onboard params
func (o *ArkServiceOnboardParams) SetBody(body *models.V1OnboardRequest) {
o.Body = body
}
// WriteToRequest writes these params to a swagger request
func (o *ArkServiceOnboardParams) 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
}

View File

@@ -0,0 +1,185 @@
// 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-sdk/client/rest/service/models"
)
// ArkServiceOnboardReader is a Reader for the ArkServiceOnboard structure.
type ArkServiceOnboardReader struct {
formats strfmt.Registry
}
// ReadResponse reads a server response into the received o.
func (o *ArkServiceOnboardReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) {
switch response.Code() {
case 200:
result := NewArkServiceOnboardOK()
if err := result.readResponse(response, consumer, o.formats); err != nil {
return nil, err
}
return result, nil
default:
result := NewArkServiceOnboardDefault(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
}
}
// NewArkServiceOnboardOK creates a ArkServiceOnboardOK with default headers values
func NewArkServiceOnboardOK() *ArkServiceOnboardOK {
return &ArkServiceOnboardOK{}
}
/*
ArkServiceOnboardOK describes a response with status code 200, with default header values.
A successful response.
*/
type ArkServiceOnboardOK struct {
Payload models.V1OnboardResponse
}
// IsSuccess returns true when this ark service onboard o k response has a 2xx status code
func (o *ArkServiceOnboardOK) IsSuccess() bool {
return true
}
// IsRedirect returns true when this ark service onboard o k response has a 3xx status code
func (o *ArkServiceOnboardOK) IsRedirect() bool {
return false
}
// IsClientError returns true when this ark service onboard o k response has a 4xx status code
func (o *ArkServiceOnboardOK) IsClientError() bool {
return false
}
// IsServerError returns true when this ark service onboard o k response has a 5xx status code
func (o *ArkServiceOnboardOK) IsServerError() bool {
return false
}
// IsCode returns true when this ark service onboard o k response a status code equal to that given
func (o *ArkServiceOnboardOK) IsCode(code int) bool {
return code == 200
}
// Code gets the status code for the ark service onboard o k response
func (o *ArkServiceOnboardOK) Code() int {
return 200
}
func (o *ArkServiceOnboardOK) Error() string {
payload, _ := json.Marshal(o.Payload)
return fmt.Sprintf("[POST /v1/onboard][%d] arkServiceOnboardOK %s", 200, payload)
}
func (o *ArkServiceOnboardOK) String() string {
payload, _ := json.Marshal(o.Payload)
return fmt.Sprintf("[POST /v1/onboard][%d] arkServiceOnboardOK %s", 200, payload)
}
func (o *ArkServiceOnboardOK) GetPayload() models.V1OnboardResponse {
return o.Payload
}
func (o *ArkServiceOnboardOK) 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
}
// NewArkServiceOnboardDefault creates a ArkServiceOnboardDefault with default headers values
func NewArkServiceOnboardDefault(code int) *ArkServiceOnboardDefault {
return &ArkServiceOnboardDefault{
_statusCode: code,
}
}
/*
ArkServiceOnboardDefault describes a response with status code -1, with default header values.
An unexpected error response.
*/
type ArkServiceOnboardDefault struct {
_statusCode int
Payload *models.RPCStatus
}
// IsSuccess returns true when this ark service onboard default response has a 2xx status code
func (o *ArkServiceOnboardDefault) IsSuccess() bool {
return o._statusCode/100 == 2
}
// IsRedirect returns true when this ark service onboard default response has a 3xx status code
func (o *ArkServiceOnboardDefault) IsRedirect() bool {
return o._statusCode/100 == 3
}
// IsClientError returns true when this ark service onboard default response has a 4xx status code
func (o *ArkServiceOnboardDefault) IsClientError() bool {
return o._statusCode/100 == 4
}
// IsServerError returns true when this ark service onboard default response has a 5xx status code
func (o *ArkServiceOnboardDefault) IsServerError() bool {
return o._statusCode/100 == 5
}
// IsCode returns true when this ark service onboard default response a status code equal to that given
func (o *ArkServiceOnboardDefault) IsCode(code int) bool {
return o._statusCode == code
}
// Code gets the status code for the ark service onboard default response
func (o *ArkServiceOnboardDefault) Code() int {
return o._statusCode
}
func (o *ArkServiceOnboardDefault) Error() string {
payload, _ := json.Marshal(o.Payload)
return fmt.Sprintf("[POST /v1/onboard][%d] ArkService_Onboard default %s", o._statusCode, payload)
}
func (o *ArkServiceOnboardDefault) String() string {
payload, _ := json.Marshal(o.Payload)
return fmt.Sprintf("[POST /v1/onboard][%d] ArkService_Onboard default %s", o._statusCode, payload)
}
func (o *ArkServiceOnboardDefault) GetPayload() *models.RPCStatus {
return o.Payload
}
func (o *ArkServiceOnboardDefault) 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
}

View File

@@ -0,0 +1,148 @@
// 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"
)
// NewArkServicePingParams creates a new ArkServicePingParams 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 NewArkServicePingParams() *ArkServicePingParams {
return &ArkServicePingParams{
timeout: cr.DefaultTimeout,
}
}
// NewArkServicePingParamsWithTimeout creates a new ArkServicePingParams object
// with the ability to set a timeout on a request.
func NewArkServicePingParamsWithTimeout(timeout time.Duration) *ArkServicePingParams {
return &ArkServicePingParams{
timeout: timeout,
}
}
// NewArkServicePingParamsWithContext creates a new ArkServicePingParams object
// with the ability to set a context for a request.
func NewArkServicePingParamsWithContext(ctx context.Context) *ArkServicePingParams {
return &ArkServicePingParams{
Context: ctx,
}
}
// NewArkServicePingParamsWithHTTPClient creates a new ArkServicePingParams object
// with the ability to set a custom HTTPClient for a request.
func NewArkServicePingParamsWithHTTPClient(client *http.Client) *ArkServicePingParams {
return &ArkServicePingParams{
HTTPClient: client,
}
}
/*
ArkServicePingParams contains all the parameters to send to the API endpoint
for the ark service ping operation.
Typically these are written to a http.Request.
*/
type ArkServicePingParams struct {
// PaymentID.
PaymentID string
timeout time.Duration
Context context.Context
HTTPClient *http.Client
}
// WithDefaults hydrates default values in the ark service ping params (not the query body).
//
// All values with no default are reset to their zero value.
func (o *ArkServicePingParams) WithDefaults() *ArkServicePingParams {
o.SetDefaults()
return o
}
// SetDefaults hydrates default values in the ark service ping params (not the query body).
//
// All values with no default are reset to their zero value.
func (o *ArkServicePingParams) SetDefaults() {
// no default values defined for this parameter
}
// WithTimeout adds the timeout to the ark service ping params
func (o *ArkServicePingParams) WithTimeout(timeout time.Duration) *ArkServicePingParams {
o.SetTimeout(timeout)
return o
}
// SetTimeout adds the timeout to the ark service ping params
func (o *ArkServicePingParams) SetTimeout(timeout time.Duration) {
o.timeout = timeout
}
// WithContext adds the context to the ark service ping params
func (o *ArkServicePingParams) WithContext(ctx context.Context) *ArkServicePingParams {
o.SetContext(ctx)
return o
}
// SetContext adds the context to the ark service ping params
func (o *ArkServicePingParams) SetContext(ctx context.Context) {
o.Context = ctx
}
// WithHTTPClient adds the HTTPClient to the ark service ping params
func (o *ArkServicePingParams) WithHTTPClient(client *http.Client) *ArkServicePingParams {
o.SetHTTPClient(client)
return o
}
// SetHTTPClient adds the HTTPClient to the ark service ping params
func (o *ArkServicePingParams) SetHTTPClient(client *http.Client) {
o.HTTPClient = client
}
// WithPaymentID adds the paymentID to the ark service ping params
func (o *ArkServicePingParams) WithPaymentID(paymentID string) *ArkServicePingParams {
o.SetPaymentID(paymentID)
return o
}
// SetPaymentID adds the paymentId to the ark service ping params
func (o *ArkServicePingParams) SetPaymentID(paymentID string) {
o.PaymentID = paymentID
}
// WriteToRequest writes these params to a swagger request
func (o *ArkServicePingParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {
if err := r.SetTimeout(o.timeout); err != nil {
return err
}
var res []error
// path param paymentId
if err := r.SetPathParam("paymentId", o.PaymentID); err != nil {
return err
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}

View File

@@ -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-sdk/client/rest/service/models"
)
// ArkServicePingReader is a Reader for the ArkServicePing structure.
type ArkServicePingReader struct {
formats strfmt.Registry
}
// ReadResponse reads a server response into the received o.
func (o *ArkServicePingReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) {
switch response.Code() {
case 200:
result := NewArkServicePingOK()
if err := result.readResponse(response, consumer, o.formats); err != nil {
return nil, err
}
return result, nil
default:
result := NewArkServicePingDefault(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
}
}
// NewArkServicePingOK creates a ArkServicePingOK with default headers values
func NewArkServicePingOK() *ArkServicePingOK {
return &ArkServicePingOK{}
}
/*
ArkServicePingOK describes a response with status code 200, with default header values.
A successful response.
*/
type ArkServicePingOK struct {
Payload *models.V1PingResponse
}
// IsSuccess returns true when this ark service ping o k response has a 2xx status code
func (o *ArkServicePingOK) IsSuccess() bool {
return true
}
// IsRedirect returns true when this ark service ping o k response has a 3xx status code
func (o *ArkServicePingOK) IsRedirect() bool {
return false
}
// IsClientError returns true when this ark service ping o k response has a 4xx status code
func (o *ArkServicePingOK) IsClientError() bool {
return false
}
// IsServerError returns true when this ark service ping o k response has a 5xx status code
func (o *ArkServicePingOK) IsServerError() bool {
return false
}
// IsCode returns true when this ark service ping o k response a status code equal to that given
func (o *ArkServicePingOK) IsCode(code int) bool {
return code == 200
}
// Code gets the status code for the ark service ping o k response
func (o *ArkServicePingOK) Code() int {
return 200
}
func (o *ArkServicePingOK) Error() string {
payload, _ := json.Marshal(o.Payload)
return fmt.Sprintf("[GET /v1/ping/{paymentId}][%d] arkServicePingOK %s", 200, payload)
}
func (o *ArkServicePingOK) String() string {
payload, _ := json.Marshal(o.Payload)
return fmt.Sprintf("[GET /v1/ping/{paymentId}][%d] arkServicePingOK %s", 200, payload)
}
func (o *ArkServicePingOK) GetPayload() *models.V1PingResponse {
return o.Payload
}
func (o *ArkServicePingOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
o.Payload = new(models.V1PingResponse)
// response payload
if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF {
return err
}
return nil
}
// NewArkServicePingDefault creates a ArkServicePingDefault with default headers values
func NewArkServicePingDefault(code int) *ArkServicePingDefault {
return &ArkServicePingDefault{
_statusCode: code,
}
}
/*
ArkServicePingDefault describes a response with status code -1, with default header values.
An unexpected error response.
*/
type ArkServicePingDefault struct {
_statusCode int
Payload *models.RPCStatus
}
// IsSuccess returns true when this ark service ping default response has a 2xx status code
func (o *ArkServicePingDefault) IsSuccess() bool {
return o._statusCode/100 == 2
}
// IsRedirect returns true when this ark service ping default response has a 3xx status code
func (o *ArkServicePingDefault) IsRedirect() bool {
return o._statusCode/100 == 3
}
// IsClientError returns true when this ark service ping default response has a 4xx status code
func (o *ArkServicePingDefault) IsClientError() bool {
return o._statusCode/100 == 4
}
// IsServerError returns true when this ark service ping default response has a 5xx status code
func (o *ArkServicePingDefault) IsServerError() bool {
return o._statusCode/100 == 5
}
// IsCode returns true when this ark service ping default response a status code equal to that given
func (o *ArkServicePingDefault) IsCode(code int) bool {
return o._statusCode == code
}
// Code gets the status code for the ark service ping default response
func (o *ArkServicePingDefault) Code() int {
return o._statusCode
}
func (o *ArkServicePingDefault) Error() string {
payload, _ := json.Marshal(o.Payload)
return fmt.Sprintf("[GET /v1/ping/{paymentId}][%d] ArkService_Ping default %s", o._statusCode, payload)
}
func (o *ArkServicePingDefault) String() string {
payload, _ := json.Marshal(o.Payload)
return fmt.Sprintf("[GET /v1/ping/{paymentId}][%d] ArkService_Ping default %s", o._statusCode, payload)
}
func (o *ArkServicePingDefault) GetPayload() *models.RPCStatus {
return o.Payload
}
func (o *ArkServicePingDefault) 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
}

View File

@@ -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-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
}

View File

@@ -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-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
}

View File

@@ -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-sdk/client/rest/service/models"
)
// NewArkServiceTrustedOnboardingParams creates a new ArkServiceTrustedOnboardingParams 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 NewArkServiceTrustedOnboardingParams() *ArkServiceTrustedOnboardingParams {
return &ArkServiceTrustedOnboardingParams{
timeout: cr.DefaultTimeout,
}
}
// NewArkServiceTrustedOnboardingParamsWithTimeout creates a new ArkServiceTrustedOnboardingParams object
// with the ability to set a timeout on a request.
func NewArkServiceTrustedOnboardingParamsWithTimeout(timeout time.Duration) *ArkServiceTrustedOnboardingParams {
return &ArkServiceTrustedOnboardingParams{
timeout: timeout,
}
}
// NewArkServiceTrustedOnboardingParamsWithContext creates a new ArkServiceTrustedOnboardingParams object
// with the ability to set a context for a request.
func NewArkServiceTrustedOnboardingParamsWithContext(ctx context.Context) *ArkServiceTrustedOnboardingParams {
return &ArkServiceTrustedOnboardingParams{
Context: ctx,
}
}
// NewArkServiceTrustedOnboardingParamsWithHTTPClient creates a new ArkServiceTrustedOnboardingParams object
// with the ability to set a custom HTTPClient for a request.
func NewArkServiceTrustedOnboardingParamsWithHTTPClient(client *http.Client) *ArkServiceTrustedOnboardingParams {
return &ArkServiceTrustedOnboardingParams{
HTTPClient: client,
}
}
/*
ArkServiceTrustedOnboardingParams contains all the parameters to send to the API endpoint
for the ark service trusted onboarding operation.
Typically these are written to a http.Request.
*/
type ArkServiceTrustedOnboardingParams struct {
// Body.
Body *models.V1TrustedOnboardingRequest
timeout time.Duration
Context context.Context
HTTPClient *http.Client
}
// WithDefaults hydrates default values in the ark service trusted onboarding params (not the query body).
//
// All values with no default are reset to their zero value.
func (o *ArkServiceTrustedOnboardingParams) WithDefaults() *ArkServiceTrustedOnboardingParams {
o.SetDefaults()
return o
}
// SetDefaults hydrates default values in the ark service trusted onboarding params (not the query body).
//
// All values with no default are reset to their zero value.
func (o *ArkServiceTrustedOnboardingParams) SetDefaults() {
// no default values defined for this parameter
}
// WithTimeout adds the timeout to the ark service trusted onboarding params
func (o *ArkServiceTrustedOnboardingParams) WithTimeout(timeout time.Duration) *ArkServiceTrustedOnboardingParams {
o.SetTimeout(timeout)
return o
}
// SetTimeout adds the timeout to the ark service trusted onboarding params
func (o *ArkServiceTrustedOnboardingParams) SetTimeout(timeout time.Duration) {
o.timeout = timeout
}
// WithContext adds the context to the ark service trusted onboarding params
func (o *ArkServiceTrustedOnboardingParams) WithContext(ctx context.Context) *ArkServiceTrustedOnboardingParams {
o.SetContext(ctx)
return o
}
// SetContext adds the context to the ark service trusted onboarding params
func (o *ArkServiceTrustedOnboardingParams) SetContext(ctx context.Context) {
o.Context = ctx
}
// WithHTTPClient adds the HTTPClient to the ark service trusted onboarding params
func (o *ArkServiceTrustedOnboardingParams) WithHTTPClient(client *http.Client) *ArkServiceTrustedOnboardingParams {
o.SetHTTPClient(client)
return o
}
// SetHTTPClient adds the HTTPClient to the ark service trusted onboarding params
func (o *ArkServiceTrustedOnboardingParams) SetHTTPClient(client *http.Client) {
o.HTTPClient = client
}
// WithBody adds the body to the ark service trusted onboarding params
func (o *ArkServiceTrustedOnboardingParams) WithBody(body *models.V1TrustedOnboardingRequest) *ArkServiceTrustedOnboardingParams {
o.SetBody(body)
return o
}
// SetBody adds the body to the ark service trusted onboarding params
func (o *ArkServiceTrustedOnboardingParams) SetBody(body *models.V1TrustedOnboardingRequest) {
o.Body = body
}
// WriteToRequest writes these params to a swagger request
func (o *ArkServiceTrustedOnboardingParams) 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
}

View File

@@ -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-sdk/client/rest/service/models"
)
// ArkServiceTrustedOnboardingReader is a Reader for the ArkServiceTrustedOnboarding structure.
type ArkServiceTrustedOnboardingReader struct {
formats strfmt.Registry
}
// ReadResponse reads a server response into the received o.
func (o *ArkServiceTrustedOnboardingReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) {
switch response.Code() {
case 200:
result := NewArkServiceTrustedOnboardingOK()
if err := result.readResponse(response, consumer, o.formats); err != nil {
return nil, err
}
return result, nil
default:
result := NewArkServiceTrustedOnboardingDefault(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
}
}
// NewArkServiceTrustedOnboardingOK creates a ArkServiceTrustedOnboardingOK with default headers values
func NewArkServiceTrustedOnboardingOK() *ArkServiceTrustedOnboardingOK {
return &ArkServiceTrustedOnboardingOK{}
}
/*
ArkServiceTrustedOnboardingOK describes a response with status code 200, with default header values.
A successful response.
*/
type ArkServiceTrustedOnboardingOK struct {
Payload *models.V1TrustedOnboardingResponse
}
// IsSuccess returns true when this ark service trusted onboarding o k response has a 2xx status code
func (o *ArkServiceTrustedOnboardingOK) IsSuccess() bool {
return true
}
// IsRedirect returns true when this ark service trusted onboarding o k response has a 3xx status code
func (o *ArkServiceTrustedOnboardingOK) IsRedirect() bool {
return false
}
// IsClientError returns true when this ark service trusted onboarding o k response has a 4xx status code
func (o *ArkServiceTrustedOnboardingOK) IsClientError() bool {
return false
}
// IsServerError returns true when this ark service trusted onboarding o k response has a 5xx status code
func (o *ArkServiceTrustedOnboardingOK) IsServerError() bool {
return false
}
// IsCode returns true when this ark service trusted onboarding o k response a status code equal to that given
func (o *ArkServiceTrustedOnboardingOK) IsCode(code int) bool {
return code == 200
}
// Code gets the status code for the ark service trusted onboarding o k response
func (o *ArkServiceTrustedOnboardingOK) Code() int {
return 200
}
func (o *ArkServiceTrustedOnboardingOK) Error() string {
payload, _ := json.Marshal(o.Payload)
return fmt.Sprintf("[POST /v1/onboard/address][%d] arkServiceTrustedOnboardingOK %s", 200, payload)
}
func (o *ArkServiceTrustedOnboardingOK) String() string {
payload, _ := json.Marshal(o.Payload)
return fmt.Sprintf("[POST /v1/onboard/address][%d] arkServiceTrustedOnboardingOK %s", 200, payload)
}
func (o *ArkServiceTrustedOnboardingOK) GetPayload() *models.V1TrustedOnboardingResponse {
return o.Payload
}
func (o *ArkServiceTrustedOnboardingOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
o.Payload = new(models.V1TrustedOnboardingResponse)
// response payload
if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF {
return err
}
return nil
}
// NewArkServiceTrustedOnboardingDefault creates a ArkServiceTrustedOnboardingDefault with default headers values
func NewArkServiceTrustedOnboardingDefault(code int) *ArkServiceTrustedOnboardingDefault {
return &ArkServiceTrustedOnboardingDefault{
_statusCode: code,
}
}
/*
ArkServiceTrustedOnboardingDefault describes a response with status code -1, with default header values.
An unexpected error response.
*/
type ArkServiceTrustedOnboardingDefault struct {
_statusCode int
Payload *models.RPCStatus
}
// IsSuccess returns true when this ark service trusted onboarding default response has a 2xx status code
func (o *ArkServiceTrustedOnboardingDefault) IsSuccess() bool {
return o._statusCode/100 == 2
}
// IsRedirect returns true when this ark service trusted onboarding default response has a 3xx status code
func (o *ArkServiceTrustedOnboardingDefault) IsRedirect() bool {
return o._statusCode/100 == 3
}
// IsClientError returns true when this ark service trusted onboarding default response has a 4xx status code
func (o *ArkServiceTrustedOnboardingDefault) IsClientError() bool {
return o._statusCode/100 == 4
}
// IsServerError returns true when this ark service trusted onboarding default response has a 5xx status code
func (o *ArkServiceTrustedOnboardingDefault) IsServerError() bool {
return o._statusCode/100 == 5
}
// IsCode returns true when this ark service trusted onboarding default response a status code equal to that given
func (o *ArkServiceTrustedOnboardingDefault) IsCode(code int) bool {
return o._statusCode == code
}
// Code gets the status code for the ark service trusted onboarding default response
func (o *ArkServiceTrustedOnboardingDefault) Code() int {
return o._statusCode
}
func (o *ArkServiceTrustedOnboardingDefault) Error() string {
payload, _ := json.Marshal(o.Payload)
return fmt.Sprintf("[POST /v1/onboard/address][%d] ArkService_TrustedOnboarding default %s", o._statusCode, payload)
}
func (o *ArkServiceTrustedOnboardingDefault) String() string {
payload, _ := json.Marshal(o.Payload)
return fmt.Sprintf("[POST /v1/onboard/address][%d] ArkService_TrustedOnboarding default %s", o._statusCode, payload)
}
func (o *ArkServiceTrustedOnboardingDefault) GetPayload() *models.RPCStatus {
return o.Payload
}
func (o *ArkServiceTrustedOnboardingDefault) 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
}

View File

@@ -0,0 +1,112 @@
// Code generated by go-swagger; DO NOT EDIT.
package arkservice
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"github.com/go-openapi/runtime"
httptransport "github.com/go-openapi/runtime/client"
"github.com/go-openapi/strfmt"
"github.com/ark-network/ark-sdk/client/rest/service/arkservice/ark_service"
)
// Default ark v1 service proto HTTP client.
var Default = NewHTTPClient(nil)
const (
// DefaultHost is the default Host
// found in Meta (info) section of spec file
DefaultHost string = "localhost"
// DefaultBasePath is the default BasePath
// found in Meta (info) section of spec file
DefaultBasePath string = "/"
)
// DefaultSchemes are the default schemes found in Meta (info) section of spec file
var DefaultSchemes = []string{"http"}
// NewHTTPClient creates a new ark v1 service proto HTTP client.
func NewHTTPClient(formats strfmt.Registry) *ArkV1ServiceProto {
return NewHTTPClientWithConfig(formats, nil)
}
// NewHTTPClientWithConfig creates a new ark v1 service proto HTTP client,
// using a customizable transport config.
func NewHTTPClientWithConfig(formats strfmt.Registry, cfg *TransportConfig) *ArkV1ServiceProto {
// ensure nullable parameters have default
if cfg == nil {
cfg = DefaultTransportConfig()
}
// create transport and client
transport := httptransport.New(cfg.Host, cfg.BasePath, cfg.Schemes)
return New(transport, formats)
}
// New creates a new ark v1 service proto client
func New(transport runtime.ClientTransport, formats strfmt.Registry) *ArkV1ServiceProto {
// ensure nullable parameters have default
if formats == nil {
formats = strfmt.Default
}
cli := new(ArkV1ServiceProto)
cli.Transport = transport
cli.ArkService = ark_service.New(transport, formats)
return cli
}
// DefaultTransportConfig creates a TransportConfig with the
// default settings taken from the meta section of the spec file.
func DefaultTransportConfig() *TransportConfig {
return &TransportConfig{
Host: DefaultHost,
BasePath: DefaultBasePath,
Schemes: DefaultSchemes,
}
}
// TransportConfig contains the transport related info,
// found in the meta section of the spec file.
type TransportConfig struct {
Host string
BasePath string
Schemes []string
}
// WithHost overrides the default host,
// provided by the meta section of the spec file.
func (cfg *TransportConfig) WithHost(host string) *TransportConfig {
cfg.Host = host
return cfg
}
// WithBasePath overrides the default basePath,
// provided by the meta section of the spec file.
func (cfg *TransportConfig) WithBasePath(basePath string) *TransportConfig {
cfg.BasePath = basePath
return cfg
}
// WithSchemes overrides the default schemes,
// provided by the meta section of the spec file.
func (cfg *TransportConfig) WithSchemes(schemes []string) *TransportConfig {
cfg.Schemes = schemes
return cfg
}
// ArkV1ServiceProto is a client for ark v1 service proto
type ArkV1ServiceProto struct {
ArkService ark_service.ClientService
Transport runtime.ClientTransport
}
// SetTransport changes the transport on the client and all its subresources
func (c *ArkV1ServiceProto) SetTransport(transport runtime.ClientTransport) {
c.Transport = transport
c.ArkService.SetTransport(transport)
}

View File

@@ -0,0 +1,127 @@
// 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"
"encoding/json"
"github.com/go-openapi/strfmt"
"github.com/go-openapi/swag"
)
// ProtobufAny protobuf any
//
// swagger:model protobufAny
type ProtobufAny struct {
// at type
AtType string `json:"@type,omitempty"`
// protobuf any
ProtobufAny map[string]interface{} `json:"-"`
}
// UnmarshalJSON unmarshals this object with additional properties from JSON
func (m *ProtobufAny) UnmarshalJSON(data []byte) error {
// stage 1, bind the properties
var stage1 struct {
// at type
AtType string `json:"@type,omitempty"`
}
if err := json.Unmarshal(data, &stage1); err != nil {
return err
}
var rcv ProtobufAny
rcv.AtType = stage1.AtType
*m = rcv
// stage 2, remove properties and add to map
stage2 := make(map[string]json.RawMessage)
if err := json.Unmarshal(data, &stage2); err != nil {
return err
}
delete(stage2, "@type")
// stage 3, add additional properties values
if len(stage2) > 0 {
result := make(map[string]interface{})
for k, v := range stage2 {
var toadd interface{}
if err := json.Unmarshal(v, &toadd); err != nil {
return err
}
result[k] = toadd
}
m.ProtobufAny = result
}
return nil
}
// MarshalJSON marshals this object with additional properties into a JSON object
func (m ProtobufAny) MarshalJSON() ([]byte, error) {
var stage1 struct {
// at type
AtType string `json:"@type,omitempty"`
}
stage1.AtType = m.AtType
// make JSON object for known properties
props, err := json.Marshal(stage1)
if err != nil {
return nil, err
}
if len(m.ProtobufAny) == 0 { // no additional properties
return props, nil
}
// make JSON object for the additional properties
additional, err := json.Marshal(m.ProtobufAny)
if err != nil {
return nil, err
}
if len(props) < 3 { // "{}": only additional properties
return additional, nil
}
// concatenate the 2 objects
return swag.ConcatJSON(props, additional), nil
}
// Validate validates this protobuf any
func (m *ProtobufAny) Validate(formats strfmt.Registry) error {
return nil
}
// ContextValidate validates this protobuf any based on context it is used
func (m *ProtobufAny) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
return nil
}
// MarshalBinary interface implementation
func (m *ProtobufAny) MarshalBinary() ([]byte, error) {
if m == nil {
return nil, nil
}
return swag.WriteJSON(m)
}
// UnmarshalBinary interface implementation
func (m *ProtobufAny) UnmarshalBinary(b []byte) error {
var res ProtobufAny
if err := swag.ReadJSON(b, &res); err != nil {
return err
}
*m = res
return nil
}

View File

@@ -0,0 +1,127 @@
// 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"
)
// RPCStatus rpc status
//
// swagger:model rpcStatus
type RPCStatus struct {
// code
Code int32 `json:"code,omitempty"`
// details
Details []*ProtobufAny `json:"details"`
// message
Message string `json:"message,omitempty"`
}
// Validate validates this rpc status
func (m *RPCStatus) Validate(formats strfmt.Registry) error {
var res []error
if err := m.validateDetails(formats); err != nil {
res = append(res, err)
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}
func (m *RPCStatus) validateDetails(formats strfmt.Registry) error {
if swag.IsZero(m.Details) { // not required
return nil
}
for i := 0; i < len(m.Details); i++ {
if swag.IsZero(m.Details[i]) { // not required
continue
}
if m.Details[i] != nil {
if err := m.Details[i].Validate(formats); err != nil {
if ve, ok := err.(*errors.Validation); ok {
return ve.ValidateName("details" + "." + strconv.Itoa(i))
} else if ce, ok := err.(*errors.CompositeError); ok {
return ce.ValidateName("details" + "." + strconv.Itoa(i))
}
return err
}
}
}
return nil
}
// ContextValidate validate this rpc status based on the context it is used
func (m *RPCStatus) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
var res []error
if err := m.contextValidateDetails(ctx, formats); err != nil {
res = append(res, err)
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}
func (m *RPCStatus) contextValidateDetails(ctx context.Context, formats strfmt.Registry) error {
for i := 0; i < len(m.Details); i++ {
if m.Details[i] != nil {
if swag.IsZero(m.Details[i]) { // not required
return nil
}
if err := m.Details[i].ContextValidate(ctx, formats); err != nil {
if ve, ok := err.(*errors.Validation); ok {
return ve.ValidateName("details" + "." + strconv.Itoa(i))
} else if ce, ok := err.(*errors.CompositeError); ok {
return ce.ValidateName("details" + "." + strconv.Itoa(i))
}
return err
}
}
}
return nil
}
// MarshalBinary interface implementation
func (m *RPCStatus) MarshalBinary() ([]byte, error) {
if m == nil {
return nil, nil
}
return swag.WriteJSON(m)
}
// UnmarshalBinary interface implementation
func (m *RPCStatus) UnmarshalBinary(b []byte) error {
var res RPCStatus
if err := swag.ReadJSON(b, &res); err != nil {
return err
}
*m = res
return nil
}

View File

@@ -0,0 +1,124 @@
// 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
}

View File

@@ -0,0 +1,11 @@
// 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{}

View File

@@ -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"
)
// V1FinalizePaymentRequest v1 finalize payment request
//
// swagger:model v1FinalizePaymentRequest
type V1FinalizePaymentRequest struct {
// Forfeit txs signed by the user.
SignedForfeitTxs []string `json:"signedForfeitTxs"`
}
// 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
}

View File

@@ -0,0 +1,11 @@
// 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{}

View File

@@ -0,0 +1,211 @@
// 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"
)
// V1GetEventStreamResponse v1 get event stream response
//
// swagger:model v1GetEventStreamResponse
type V1GetEventStreamResponse struct {
// round failed
RoundFailed *V1RoundFailed `json:"roundFailed,omitempty"`
// TODO: BTC add "signTree" event
RoundFinalization *V1RoundFinalizationEvent `json:"roundFinalization,omitempty"`
// round finalized
RoundFinalized *V1RoundFinalizedEvent `json:"roundFinalized,omitempty"`
}
// Validate validates this v1 get event stream response
func (m *V1GetEventStreamResponse) Validate(formats strfmt.Registry) error {
var res []error
if err := m.validateRoundFailed(formats); err != nil {
res = append(res, err)
}
if err := m.validateRoundFinalization(formats); err != nil {
res = append(res, err)
}
if err := m.validateRoundFinalized(formats); err != nil {
res = append(res, err)
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}
func (m *V1GetEventStreamResponse) validateRoundFailed(formats strfmt.Registry) error {
if swag.IsZero(m.RoundFailed) { // not required
return nil
}
if m.RoundFailed != nil {
if err := m.RoundFailed.Validate(formats); err != nil {
if ve, ok := err.(*errors.Validation); ok {
return ve.ValidateName("roundFailed")
} else if ce, ok := err.(*errors.CompositeError); ok {
return ce.ValidateName("roundFailed")
}
return err
}
}
return nil
}
func (m *V1GetEventStreamResponse) validateRoundFinalization(formats strfmt.Registry) error {
if swag.IsZero(m.RoundFinalization) { // not required
return nil
}
if m.RoundFinalization != nil {
if err := m.RoundFinalization.Validate(formats); err != nil {
if ve, ok := err.(*errors.Validation); ok {
return ve.ValidateName("roundFinalization")
} else if ce, ok := err.(*errors.CompositeError); ok {
return ce.ValidateName("roundFinalization")
}
return err
}
}
return nil
}
func (m *V1GetEventStreamResponse) validateRoundFinalized(formats strfmt.Registry) error {
if swag.IsZero(m.RoundFinalized) { // not required
return nil
}
if m.RoundFinalized != nil {
if err := m.RoundFinalized.Validate(formats); err != nil {
if ve, ok := err.(*errors.Validation); ok {
return ve.ValidateName("roundFinalized")
} else if ce, ok := err.(*errors.CompositeError); ok {
return ce.ValidateName("roundFinalized")
}
return err
}
}
return nil
}
// ContextValidate validate this v1 get event stream response based on the context it is used
func (m *V1GetEventStreamResponse) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
var res []error
if err := m.contextValidateRoundFailed(ctx, formats); err != nil {
res = append(res, err)
}
if err := m.contextValidateRoundFinalization(ctx, formats); err != nil {
res = append(res, err)
}
if err := m.contextValidateRoundFinalized(ctx, formats); err != nil {
res = append(res, err)
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}
func (m *V1GetEventStreamResponse) contextValidateRoundFailed(ctx context.Context, formats strfmt.Registry) error {
if m.RoundFailed != nil {
if swag.IsZero(m.RoundFailed) { // not required
return nil
}
if err := m.RoundFailed.ContextValidate(ctx, formats); err != nil {
if ve, ok := err.(*errors.Validation); ok {
return ve.ValidateName("roundFailed")
} else if ce, ok := err.(*errors.CompositeError); ok {
return ce.ValidateName("roundFailed")
}
return err
}
}
return nil
}
func (m *V1GetEventStreamResponse) contextValidateRoundFinalization(ctx context.Context, formats strfmt.Registry) error {
if m.RoundFinalization != nil {
if swag.IsZero(m.RoundFinalization) { // not required
return nil
}
if err := m.RoundFinalization.ContextValidate(ctx, formats); err != nil {
if ve, ok := err.(*errors.Validation); ok {
return ve.ValidateName("roundFinalization")
} else if ce, ok := err.(*errors.CompositeError); ok {
return ce.ValidateName("roundFinalization")
}
return err
}
}
return nil
}
func (m *V1GetEventStreamResponse) contextValidateRoundFinalized(ctx context.Context, formats strfmt.Registry) error {
if m.RoundFinalized != nil {
if swag.IsZero(m.RoundFinalized) { // not required
return nil
}
if err := m.RoundFinalized.ContextValidate(ctx, formats); err != nil {
if ve, ok := err.(*errors.Validation); ok {
return ve.ValidateName("roundFinalized")
} else if ce, ok := err.(*errors.CompositeError); ok {
return ce.ValidateName("roundFinalized")
}
return err
}
}
return nil
}
// MarshalBinary interface implementation
func (m *V1GetEventStreamResponse) MarshalBinary() ([]byte, error) {
if m == nil {
return nil, nil
}
return swag.WriteJSON(m)
}
// UnmarshalBinary interface implementation
func (m *V1GetEventStreamResponse) UnmarshalBinary(b []byte) error {
var res V1GetEventStreamResponse
if err := swag.ReadJSON(b, &res); err != nil {
return err
}
*m = res
return nil
}

View File

@@ -0,0 +1,65 @@
// 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"
)
// V1GetInfoResponse v1 get info response
//
// swagger:model v1GetInfoResponse
type V1GetInfoResponse struct {
// min relay fee
MinRelayFee string `json:"minRelayFee,omitempty"`
// network
Network string `json:"network,omitempty"`
// pubkey
Pubkey string `json:"pubkey,omitempty"`
// round interval
RoundInterval string `json:"roundInterval,omitempty"`
// round lifetime
RoundLifetime string `json:"roundLifetime,omitempty"`
// unilateral exit delay
UnilateralExitDelay string `json:"unilateralExitDelay,omitempty"`
}
// Validate validates this v1 get info response
func (m *V1GetInfoResponse) Validate(formats strfmt.Registry) error {
return nil
}
// ContextValidate validates this v1 get info response based on context it is used
func (m *V1GetInfoResponse) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
return nil
}
// MarshalBinary interface implementation
func (m *V1GetInfoResponse) MarshalBinary() ([]byte, error) {
if m == nil {
return nil, nil
}
return swag.WriteJSON(m)
}
// UnmarshalBinary interface implementation
func (m *V1GetInfoResponse) UnmarshalBinary(b []byte) error {
var res V1GetInfoResponse
if err := swag.ReadJSON(b, &res); err != nil {
return err
}
*m = res
return nil
}

View File

@@ -0,0 +1,109 @@
// 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"
)
// V1GetRoundByIDResponse v1 get round by Id response
//
// swagger:model v1GetRoundByIdResponse
type V1GetRoundByIDResponse struct {
// round
Round *V1Round `json:"round,omitempty"`
}
// Validate validates this v1 get round by Id response
func (m *V1GetRoundByIDResponse) Validate(formats strfmt.Registry) error {
var res []error
if err := m.validateRound(formats); err != nil {
res = append(res, err)
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}
func (m *V1GetRoundByIDResponse) 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 round by Id response based on the context it is used
func (m *V1GetRoundByIDResponse) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
var res []error
if err := m.contextValidateRound(ctx, formats); err != nil {
res = append(res, err)
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}
func (m *V1GetRoundByIDResponse) 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 *V1GetRoundByIDResponse) MarshalBinary() ([]byte, error) {
if m == nil {
return nil, nil
}
return swag.WriteJSON(m)
}
// UnmarshalBinary interface implementation
func (m *V1GetRoundByIDResponse) UnmarshalBinary(b []byte) error {
var res V1GetRoundByIDResponse
if err := swag.ReadJSON(b, &res); err != nil {
return err
}
*m = res
return nil
}

View File

@@ -0,0 +1,109 @@
// 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"
)
// V1GetRoundResponse v1 get round response
//
// swagger:model v1GetRoundResponse
type V1GetRoundResponse struct {
// round
Round *V1Round `json:"round,omitempty"`
}
// Validate validates this v1 get round response
func (m *V1GetRoundResponse) Validate(formats strfmt.Registry) error {
var res []error
if err := m.validateRound(formats); err != nil {
res = append(res, err)
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}
func (m *V1GetRoundResponse) 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 round response based on the context it is used
func (m *V1GetRoundResponse) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
var res []error
if err := m.contextValidateRound(ctx, formats); err != nil {
res = append(res, err)
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}
func (m *V1GetRoundResponse) 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 *V1GetRoundResponse) MarshalBinary() ([]byte, error) {
if m == nil {
return nil, nil
}
return swag.WriteJSON(m)
}
// UnmarshalBinary interface implementation
func (m *V1GetRoundResponse) UnmarshalBinary(b []byte) error {
var res V1GetRoundResponse
if err := swag.ReadJSON(b, &res); err != nil {
return err
}
*m = res
return nil
}

View File

@@ -0,0 +1,53 @@
// 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"
)
// V1Input v1 input
//
// swagger:model v1Input
type V1Input struct {
// txid
Txid string `json:"txid,omitempty"`
// vout
Vout int64 `json:"vout,omitempty"`
}
// Validate validates this v1 input
func (m *V1Input) Validate(formats strfmt.Registry) error {
return nil
}
// ContextValidate validates this v1 input based on context it is used
func (m *V1Input) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
return nil
}
// MarshalBinary interface implementation
func (m *V1Input) MarshalBinary() ([]byte, error) {
if m == nil {
return nil, nil
}
return swag.WriteJSON(m)
}
// UnmarshalBinary interface implementation
func (m *V1Input) UnmarshalBinary(b []byte) error {
var res V1Input
if err := swag.ReadJSON(b, &res); err != nil {
return err
}
*m = res
return nil
}

View File

@@ -0,0 +1,183 @@
// 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"
)
// V1ListVtxosResponse v1 list vtxos response
//
// swagger:model v1ListVtxosResponse
type V1ListVtxosResponse struct {
// spendable vtxos
SpendableVtxos []*V1Vtxo `json:"spendableVtxos"`
// spent vtxos
SpentVtxos []*V1Vtxo `json:"spentVtxos"`
}
// Validate validates this v1 list vtxos response
func (m *V1ListVtxosResponse) 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 *V1ListVtxosResponse) 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 *V1ListVtxosResponse) 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 list vtxos response based on the context it is used
func (m *V1ListVtxosResponse) 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 *V1ListVtxosResponse) 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 *V1ListVtxosResponse) 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 *V1ListVtxosResponse) MarshalBinary() ([]byte, error) {
if m == nil {
return nil, nil
}
return swag.WriteJSON(m)
}
// UnmarshalBinary interface implementation
func (m *V1ListVtxosResponse) UnmarshalBinary(b []byte) error {
var res V1ListVtxosResponse
if err := swag.ReadJSON(b, &res); err != nil {
return err
}
*m = res
return nil
}

View File

@@ -0,0 +1,56 @@
// 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"
)
// V1Node v1 node
//
// swagger:model v1Node
type V1Node struct {
// parent txid
ParentTxid string `json:"parentTxid,omitempty"`
// tx
Tx string `json:"tx,omitempty"`
// txid
Txid string `json:"txid,omitempty"`
}
// Validate validates this v1 node
func (m *V1Node) Validate(formats strfmt.Registry) error {
return nil
}
// ContextValidate validates this v1 node based on context it is used
func (m *V1Node) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
return nil
}
// MarshalBinary interface implementation
func (m *V1Node) MarshalBinary() ([]byte, error) {
if m == nil {
return nil, nil
}
return swag.WriteJSON(m)
}
// UnmarshalBinary interface implementation
func (m *V1Node) UnmarshalBinary(b []byte) error {
var res V1Node
if err := swag.ReadJSON(b, &res); err != nil {
return err
}
*m = res
return nil
}

View File

@@ -0,0 +1,115 @@
// 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"
)
// V1OnboardRequest v1 onboard request
//
// swagger:model v1OnboardRequest
type V1OnboardRequest struct {
// boarding tx
BoardingTx string `json:"boardingTx,omitempty"`
// congestion tree
CongestionTree *V1Tree `json:"congestionTree,omitempty"`
// user pubkey
UserPubkey string `json:"userPubkey,omitempty"`
}
// Validate validates this v1 onboard request
func (m *V1OnboardRequest) Validate(formats strfmt.Registry) error {
var res []error
if err := m.validateCongestionTree(formats); err != nil {
res = append(res, err)
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}
func (m *V1OnboardRequest) validateCongestionTree(formats strfmt.Registry) error {
if swag.IsZero(m.CongestionTree) { // not required
return nil
}
if m.CongestionTree != nil {
if err := m.CongestionTree.Validate(formats); err != nil {
if ve, ok := err.(*errors.Validation); ok {
return ve.ValidateName("congestionTree")
} else if ce, ok := err.(*errors.CompositeError); ok {
return ce.ValidateName("congestionTree")
}
return err
}
}
return nil
}
// ContextValidate validate this v1 onboard request based on the context it is used
func (m *V1OnboardRequest) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
var res []error
if err := m.contextValidateCongestionTree(ctx, formats); err != nil {
res = append(res, err)
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}
func (m *V1OnboardRequest) contextValidateCongestionTree(ctx context.Context, formats strfmt.Registry) error {
if m.CongestionTree != nil {
if swag.IsZero(m.CongestionTree) { // not required
return nil
}
if err := m.CongestionTree.ContextValidate(ctx, formats); err != nil {
if ve, ok := err.(*errors.Validation); ok {
return ve.ValidateName("congestionTree")
} else if ce, ok := err.(*errors.CompositeError); ok {
return ce.ValidateName("congestionTree")
}
return err
}
}
return nil
}
// MarshalBinary interface implementation
func (m *V1OnboardRequest) MarshalBinary() ([]byte, error) {
if m == nil {
return nil, nil
}
return swag.WriteJSON(m)
}
// UnmarshalBinary interface implementation
func (m *V1OnboardRequest) UnmarshalBinary(b []byte) error {
var res V1OnboardRequest
if err := swag.ReadJSON(b, &res); err != nil {
return err
}
*m = res
return nil
}

View File

@@ -0,0 +1,11 @@
// 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
// V1OnboardResponse v1 onboard response
//
// swagger:model v1OnboardResponse
type V1OnboardResponse interface{}

View File

@@ -0,0 +1,53 @@
// 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"
)
// V1Output v1 output
//
// swagger:model v1Output
type V1Output struct {
// Either the offchain or onchain address.
Address string `json:"address,omitempty"`
// Amount to send in satoshis.
Amount string `json:"amount,omitempty"`
}
// Validate validates this v1 output
func (m *V1Output) Validate(formats strfmt.Registry) error {
return nil
}
// ContextValidate validates this v1 output based on context it is used
func (m *V1Output) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
return nil
}
// MarshalBinary interface implementation
func (m *V1Output) MarshalBinary() ([]byte, error) {
if m == nil {
return nil, nil
}
return swag.WriteJSON(m)
}
// UnmarshalBinary interface implementation
func (m *V1Output) UnmarshalBinary(b []byte) error {
var res V1Output
if err := swag.ReadJSON(b, &res); err != nil {
return err
}
*m = res
return nil
}

View File

@@ -0,0 +1,112 @@
// 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"
)
// V1PingResponse v1 ping response
//
// swagger:model v1PingResponse
type V1PingResponse struct {
// event
Event *V1RoundFinalizationEvent `json:"event,omitempty"`
// forfeit txs
ForfeitTxs []string `json:"forfeitTxs"`
}
// Validate validates this v1 ping response
func (m *V1PingResponse) Validate(formats strfmt.Registry) error {
var res []error
if err := m.validateEvent(formats); err != nil {
res = append(res, err)
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}
func (m *V1PingResponse) validateEvent(formats strfmt.Registry) error {
if swag.IsZero(m.Event) { // not required
return nil
}
if m.Event != nil {
if err := m.Event.Validate(formats); err != nil {
if ve, ok := err.(*errors.Validation); ok {
return ve.ValidateName("event")
} else if ce, ok := err.(*errors.CompositeError); ok {
return ce.ValidateName("event")
}
return err
}
}
return nil
}
// ContextValidate validate this v1 ping response based on the context it is used
func (m *V1PingResponse) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
var res []error
if err := m.contextValidateEvent(ctx, formats); err != nil {
res = append(res, err)
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}
func (m *V1PingResponse) contextValidateEvent(ctx context.Context, formats strfmt.Registry) error {
if m.Event != nil {
if swag.IsZero(m.Event) { // not required
return nil
}
if err := m.Event.ContextValidate(ctx, formats); err != nil {
if ve, ok := err.(*errors.Validation); ok {
return ve.ValidateName("event")
} else if ce, ok := err.(*errors.CompositeError); ok {
return ce.ValidateName("event")
}
return err
}
}
return nil
}
// MarshalBinary interface implementation
func (m *V1PingResponse) MarshalBinary() ([]byte, error) {
if m == nil {
return nil, nil
}
return swag.WriteJSON(m)
}
// UnmarshalBinary interface implementation
func (m *V1PingResponse) UnmarshalBinary(b []byte) error {
var res V1PingResponse
if err := swag.ReadJSON(b, &res); err != nil {
return err
}
*m = res
return nil
}

View File

@@ -0,0 +1,121 @@
// 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 {
// 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
}

View File

@@ -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"
)
// 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
}

View File

@@ -0,0 +1,178 @@
// 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"
)
// V1Round v1 round
//
// swagger:model v1Round
type V1Round struct {
// congestion tree
CongestionTree *V1Tree `json:"congestionTree,omitempty"`
// connectors
Connectors []string `json:"connectors"`
// end
End string `json:"end,omitempty"`
// forfeit txs
ForfeitTxs []string `json:"forfeitTxs"`
// id
ID string `json:"id,omitempty"`
// pool tx
PoolTx string `json:"poolTx,omitempty"`
// stage
Stage *V1RoundStage `json:"stage,omitempty"`
// start
Start string `json:"start,omitempty"`
}
// Validate validates this v1 round
func (m *V1Round) Validate(formats strfmt.Registry) error {
var res []error
if err := m.validateCongestionTree(formats); err != nil {
res = append(res, err)
}
if err := m.validateStage(formats); err != nil {
res = append(res, err)
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}
func (m *V1Round) validateCongestionTree(formats strfmt.Registry) error {
if swag.IsZero(m.CongestionTree) { // not required
return nil
}
if m.CongestionTree != nil {
if err := m.CongestionTree.Validate(formats); err != nil {
if ve, ok := err.(*errors.Validation); ok {
return ve.ValidateName("congestionTree")
} else if ce, ok := err.(*errors.CompositeError); ok {
return ce.ValidateName("congestionTree")
}
return err
}
}
return nil
}
func (m *V1Round) validateStage(formats strfmt.Registry) error {
if swag.IsZero(m.Stage) { // not required
return nil
}
if m.Stage != nil {
if err := m.Stage.Validate(formats); err != nil {
if ve, ok := err.(*errors.Validation); ok {
return ve.ValidateName("stage")
} else if ce, ok := err.(*errors.CompositeError); ok {
return ce.ValidateName("stage")
}
return err
}
}
return nil
}
// ContextValidate validate this v1 round based on the context it is used
func (m *V1Round) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
var res []error
if err := m.contextValidateCongestionTree(ctx, formats); err != nil {
res = append(res, err)
}
if err := m.contextValidateStage(ctx, formats); err != nil {
res = append(res, err)
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}
func (m *V1Round) contextValidateCongestionTree(ctx context.Context, formats strfmt.Registry) error {
if m.CongestionTree != nil {
if swag.IsZero(m.CongestionTree) { // not required
return nil
}
if err := m.CongestionTree.ContextValidate(ctx, formats); err != nil {
if ve, ok := err.(*errors.Validation); ok {
return ve.ValidateName("congestionTree")
} else if ce, ok := err.(*errors.CompositeError); ok {
return ce.ValidateName("congestionTree")
}
return err
}
}
return nil
}
func (m *V1Round) contextValidateStage(ctx context.Context, formats strfmt.Registry) error {
if m.Stage != nil {
if swag.IsZero(m.Stage) { // not required
return nil
}
if err := m.Stage.ContextValidate(ctx, formats); err != nil {
if ve, ok := err.(*errors.Validation); ok {
return ve.ValidateName("stage")
} else if ce, ok := err.(*errors.CompositeError); ok {
return ce.ValidateName("stage")
}
return err
}
}
return nil
}
// MarshalBinary interface implementation
func (m *V1Round) MarshalBinary() ([]byte, error) {
if m == nil {
return nil, nil
}
return swag.WriteJSON(m)
}
// UnmarshalBinary interface implementation
func (m *V1Round) UnmarshalBinary(b []byte) error {
var res V1Round
if err := swag.ReadJSON(b, &res); err != nil {
return err
}
*m = res
return nil
}

View File

@@ -0,0 +1,53 @@
// 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"
)
// V1RoundFailed v1 round failed
//
// swagger:model v1RoundFailed
type V1RoundFailed struct {
// id
ID string `json:"id,omitempty"`
// reason
Reason string `json:"reason,omitempty"`
}
// Validate validates this v1 round failed
func (m *V1RoundFailed) Validate(formats strfmt.Registry) error {
return nil
}
// ContextValidate validates this v1 round failed based on context it is used
func (m *V1RoundFailed) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
return nil
}
// MarshalBinary interface implementation
func (m *V1RoundFailed) MarshalBinary() ([]byte, error) {
if m == nil {
return nil, nil
}
return swag.WriteJSON(m)
}
// UnmarshalBinary interface implementation
func (m *V1RoundFailed) UnmarshalBinary(b []byte) error {
var res V1RoundFailed
if err := swag.ReadJSON(b, &res); err != nil {
return err
}
*m = res
return nil
}

View File

@@ -0,0 +1,121 @@
// 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"
)
// V1RoundFinalizationEvent v1 round finalization event
//
// swagger:model v1RoundFinalizationEvent
type V1RoundFinalizationEvent struct {
// congestion tree
CongestionTree *V1Tree `json:"congestionTree,omitempty"`
// connectors
Connectors []string `json:"connectors"`
// forfeit txs
ForfeitTxs []string `json:"forfeitTxs"`
// id
ID string `json:"id,omitempty"`
// pool tx
PoolTx string `json:"poolTx,omitempty"`
}
// Validate validates this v1 round finalization event
func (m *V1RoundFinalizationEvent) Validate(formats strfmt.Registry) error {
var res []error
if err := m.validateCongestionTree(formats); err != nil {
res = append(res, err)
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}
func (m *V1RoundFinalizationEvent) validateCongestionTree(formats strfmt.Registry) error {
if swag.IsZero(m.CongestionTree) { // not required
return nil
}
if m.CongestionTree != nil {
if err := m.CongestionTree.Validate(formats); err != nil {
if ve, ok := err.(*errors.Validation); ok {
return ve.ValidateName("congestionTree")
} else if ce, ok := err.(*errors.CompositeError); ok {
return ce.ValidateName("congestionTree")
}
return err
}
}
return nil
}
// ContextValidate validate this v1 round finalization event based on the context it is used
func (m *V1RoundFinalizationEvent) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
var res []error
if err := m.contextValidateCongestionTree(ctx, formats); err != nil {
res = append(res, err)
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}
func (m *V1RoundFinalizationEvent) contextValidateCongestionTree(ctx context.Context, formats strfmt.Registry) error {
if m.CongestionTree != nil {
if swag.IsZero(m.CongestionTree) { // not required
return nil
}
if err := m.CongestionTree.ContextValidate(ctx, formats); err != nil {
if ve, ok := err.(*errors.Validation); ok {
return ve.ValidateName("congestionTree")
} else if ce, ok := err.(*errors.CompositeError); ok {
return ce.ValidateName("congestionTree")
}
return err
}
}
return nil
}
// MarshalBinary interface implementation
func (m *V1RoundFinalizationEvent) MarshalBinary() ([]byte, error) {
if m == nil {
return nil, nil
}
return swag.WriteJSON(m)
}
// UnmarshalBinary interface implementation
func (m *V1RoundFinalizationEvent) UnmarshalBinary(b []byte) error {
var res V1RoundFinalizationEvent
if err := swag.ReadJSON(b, &res); err != nil {
return err
}
*m = res
return nil
}

View File

@@ -0,0 +1,53 @@
// 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"
)
// V1RoundFinalizedEvent v1 round finalized event
//
// swagger:model v1RoundFinalizedEvent
type V1RoundFinalizedEvent struct {
// id
ID string `json:"id,omitempty"`
// pool txid
PoolTxid string `json:"poolTxid,omitempty"`
}
// Validate validates this v1 round finalized event
func (m *V1RoundFinalizedEvent) Validate(formats strfmt.Registry) error {
return nil
}
// ContextValidate validates this v1 round finalized event based on context it is used
func (m *V1RoundFinalizedEvent) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
return nil
}
// MarshalBinary interface implementation
func (m *V1RoundFinalizedEvent) MarshalBinary() ([]byte, error) {
if m == nil {
return nil, nil
}
return swag.WriteJSON(m)
}
// UnmarshalBinary interface implementation
func (m *V1RoundFinalizedEvent) UnmarshalBinary(b []byte) error {
var res V1RoundFinalizedEvent
if err := swag.ReadJSON(b, &res); err != nil {
return err
}
*m = res
return nil
}

View File

@@ -0,0 +1,87 @@
// 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"
"encoding/json"
"github.com/go-openapi/errors"
"github.com/go-openapi/strfmt"
"github.com/go-openapi/validate"
)
// V1RoundStage v1 round stage
//
// swagger:model v1RoundStage
type V1RoundStage string
func NewV1RoundStage(value V1RoundStage) *V1RoundStage {
return &value
}
// Pointer returns a pointer to a freshly-allocated V1RoundStage.
func (m V1RoundStage) Pointer() *V1RoundStage {
return &m
}
const (
// V1RoundStageROUNDSTAGEUNSPECIFIED captures enum value "ROUND_STAGE_UNSPECIFIED"
V1RoundStageROUNDSTAGEUNSPECIFIED V1RoundStage = "ROUND_STAGE_UNSPECIFIED"
// V1RoundStageROUNDSTAGEREGISTRATION captures enum value "ROUND_STAGE_REGISTRATION"
V1RoundStageROUNDSTAGEREGISTRATION V1RoundStage = "ROUND_STAGE_REGISTRATION"
// V1RoundStageROUNDSTAGEFINALIZATION captures enum value "ROUND_STAGE_FINALIZATION"
V1RoundStageROUNDSTAGEFINALIZATION V1RoundStage = "ROUND_STAGE_FINALIZATION"
// V1RoundStageROUNDSTAGEFINALIZED captures enum value "ROUND_STAGE_FINALIZED"
V1RoundStageROUNDSTAGEFINALIZED V1RoundStage = "ROUND_STAGE_FINALIZED"
// V1RoundStageROUNDSTAGEFAILED captures enum value "ROUND_STAGE_FAILED"
V1RoundStageROUNDSTAGEFAILED V1RoundStage = "ROUND_STAGE_FAILED"
)
// for schema
var v1RoundStageEnum []interface{}
func init() {
var res []V1RoundStage
if err := json.Unmarshal([]byte(`["ROUND_STAGE_UNSPECIFIED","ROUND_STAGE_REGISTRATION","ROUND_STAGE_FINALIZATION","ROUND_STAGE_FINALIZED","ROUND_STAGE_FAILED"]`), &res); err != nil {
panic(err)
}
for _, v := range res {
v1RoundStageEnum = append(v1RoundStageEnum, v)
}
}
func (m V1RoundStage) validateV1RoundStageEnum(path, location string, value V1RoundStage) error {
if err := validate.EnumCase(path, location, value, v1RoundStageEnum, true); err != nil {
return err
}
return nil
}
// Validate validates this v1 round stage
func (m V1RoundStage) Validate(formats strfmt.Registry) error {
var res []error
// value enum
if err := m.validateV1RoundStageEnum("", "body", m); err != nil {
return err
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}
// ContextValidate validates this v1 round stage based on context it is used
func (m V1RoundStage) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
return nil
}

View File

@@ -0,0 +1,121 @@
// 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"
)
// V1Tree v1 tree
//
// swagger:model v1Tree
type V1Tree struct {
// levels
Levels []*V1TreeLevel `json:"levels"`
}
// Validate validates this v1 tree
func (m *V1Tree) Validate(formats strfmt.Registry) error {
var res []error
if err := m.validateLevels(formats); err != nil {
res = append(res, err)
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}
func (m *V1Tree) validateLevels(formats strfmt.Registry) error {
if swag.IsZero(m.Levels) { // not required
return nil
}
for i := 0; i < len(m.Levels); i++ {
if swag.IsZero(m.Levels[i]) { // not required
continue
}
if m.Levels[i] != nil {
if err := m.Levels[i].Validate(formats); err != nil {
if ve, ok := err.(*errors.Validation); ok {
return ve.ValidateName("levels" + "." + strconv.Itoa(i))
} else if ce, ok := err.(*errors.CompositeError); ok {
return ce.ValidateName("levels" + "." + strconv.Itoa(i))
}
return err
}
}
}
return nil
}
// ContextValidate validate this v1 tree based on the context it is used
func (m *V1Tree) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
var res []error
if err := m.contextValidateLevels(ctx, formats); err != nil {
res = append(res, err)
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}
func (m *V1Tree) contextValidateLevels(ctx context.Context, formats strfmt.Registry) error {
for i := 0; i < len(m.Levels); i++ {
if m.Levels[i] != nil {
if swag.IsZero(m.Levels[i]) { // not required
return nil
}
if err := m.Levels[i].ContextValidate(ctx, formats); err != nil {
if ve, ok := err.(*errors.Validation); ok {
return ve.ValidateName("levels" + "." + strconv.Itoa(i))
} else if ce, ok := err.(*errors.CompositeError); ok {
return ce.ValidateName("levels" + "." + strconv.Itoa(i))
}
return err
}
}
}
return nil
}
// MarshalBinary interface implementation
func (m *V1Tree) MarshalBinary() ([]byte, error) {
if m == nil {
return nil, nil
}
return swag.WriteJSON(m)
}
// UnmarshalBinary interface implementation
func (m *V1Tree) UnmarshalBinary(b []byte) error {
var res V1Tree
if err := swag.ReadJSON(b, &res); err != nil {
return err
}
*m = res
return nil
}

View File

@@ -0,0 +1,121 @@
// 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"
)
// V1TreeLevel v1 tree level
//
// swagger:model v1TreeLevel
type V1TreeLevel struct {
// nodes
Nodes []*V1Node `json:"nodes"`
}
// Validate validates this v1 tree level
func (m *V1TreeLevel) Validate(formats strfmt.Registry) error {
var res []error
if err := m.validateNodes(formats); err != nil {
res = append(res, err)
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}
func (m *V1TreeLevel) validateNodes(formats strfmt.Registry) error {
if swag.IsZero(m.Nodes) { // not required
return nil
}
for i := 0; i < len(m.Nodes); i++ {
if swag.IsZero(m.Nodes[i]) { // not required
continue
}
if m.Nodes[i] != nil {
if err := m.Nodes[i].Validate(formats); err != nil {
if ve, ok := err.(*errors.Validation); ok {
return ve.ValidateName("nodes" + "." + strconv.Itoa(i))
} else if ce, ok := err.(*errors.CompositeError); ok {
return ce.ValidateName("nodes" + "." + strconv.Itoa(i))
}
return err
}
}
}
return nil
}
// ContextValidate validate this v1 tree level based on the context it is used
func (m *V1TreeLevel) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
var res []error
if err := m.contextValidateNodes(ctx, formats); err != nil {
res = append(res, err)
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}
func (m *V1TreeLevel) contextValidateNodes(ctx context.Context, formats strfmt.Registry) error {
for i := 0; i < len(m.Nodes); i++ {
if m.Nodes[i] != nil {
if swag.IsZero(m.Nodes[i]) { // not required
return nil
}
if err := m.Nodes[i].ContextValidate(ctx, formats); err != nil {
if ve, ok := err.(*errors.Validation); ok {
return ve.ValidateName("nodes" + "." + strconv.Itoa(i))
} else if ce, ok := err.(*errors.CompositeError); ok {
return ce.ValidateName("nodes" + "." + strconv.Itoa(i))
}
return err
}
}
}
return nil
}
// MarshalBinary interface implementation
func (m *V1TreeLevel) MarshalBinary() ([]byte, error) {
if m == nil {
return nil, nil
}
return swag.WriteJSON(m)
}
// UnmarshalBinary interface implementation
func (m *V1TreeLevel) UnmarshalBinary(b []byte) error {
var res V1TreeLevel
if err := swag.ReadJSON(b, &res); err != nil {
return err
}
*m = res
return nil
}

View File

@@ -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"
)
// V1TrustedOnboardingRequest v1 trusted onboarding request
//
// swagger:model v1TrustedOnboardingRequest
type V1TrustedOnboardingRequest struct {
// user pubkey
UserPubkey string `json:"userPubkey,omitempty"`
}
// Validate validates this v1 trusted onboarding request
func (m *V1TrustedOnboardingRequest) Validate(formats strfmt.Registry) error {
return nil
}
// ContextValidate validates this v1 trusted onboarding request based on context it is used
func (m *V1TrustedOnboardingRequest) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
return nil
}
// MarshalBinary interface implementation
func (m *V1TrustedOnboardingRequest) MarshalBinary() ([]byte, error) {
if m == nil {
return nil, nil
}
return swag.WriteJSON(m)
}
// UnmarshalBinary interface implementation
func (m *V1TrustedOnboardingRequest) UnmarshalBinary(b []byte) error {
var res V1TrustedOnboardingRequest
if err := swag.ReadJSON(b, &res); err != nil {
return err
}
*m = res
return nil
}

View File

@@ -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"
)
// V1TrustedOnboardingResponse v1 trusted onboarding response
//
// swagger:model v1TrustedOnboardingResponse
type V1TrustedOnboardingResponse struct {
// address
Address string `json:"address,omitempty"`
}
// Validate validates this v1 trusted onboarding response
func (m *V1TrustedOnboardingResponse) Validate(formats strfmt.Registry) error {
return nil
}
// ContextValidate validates this v1 trusted onboarding response based on context it is used
func (m *V1TrustedOnboardingResponse) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
return nil
}
// MarshalBinary interface implementation
func (m *V1TrustedOnboardingResponse) MarshalBinary() ([]byte, error) {
if m == nil {
return nil, nil
}
return swag.WriteJSON(m)
}
// UnmarshalBinary interface implementation
func (m *V1TrustedOnboardingResponse) UnmarshalBinary(b []byte) error {
var res V1TrustedOnboardingResponse
if err := swag.ReadJSON(b, &res); err != nil {
return err
}
*m = res
return nil
}

View File

@@ -0,0 +1,175 @@
// 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"
)
// V1Vtxo v1 vtxo
//
// swagger:model v1Vtxo
type V1Vtxo struct {
// expire at
ExpireAt string `json:"expireAt,omitempty"`
// outpoint
Outpoint *V1Input `json:"outpoint,omitempty"`
// pool txid
PoolTxid string `json:"poolTxid,omitempty"`
// receiver
Receiver *V1Output `json:"receiver,omitempty"`
// spent
Spent bool `json:"spent,omitempty"`
// spent by
SpentBy string `json:"spentBy,omitempty"`
// swept
Swept bool `json:"swept,omitempty"`
}
// Validate validates this v1 vtxo
func (m *V1Vtxo) Validate(formats strfmt.Registry) error {
var res []error
if err := m.validateOutpoint(formats); err != nil {
res = append(res, err)
}
if err := m.validateReceiver(formats); err != nil {
res = append(res, err)
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}
func (m *V1Vtxo) validateOutpoint(formats strfmt.Registry) error {
if swag.IsZero(m.Outpoint) { // not required
return nil
}
if m.Outpoint != nil {
if err := m.Outpoint.Validate(formats); err != nil {
if ve, ok := err.(*errors.Validation); ok {
return ve.ValidateName("outpoint")
} else if ce, ok := err.(*errors.CompositeError); ok {
return ce.ValidateName("outpoint")
}
return err
}
}
return nil
}
func (m *V1Vtxo) validateReceiver(formats strfmt.Registry) error {
if swag.IsZero(m.Receiver) { // not required
return nil
}
if m.Receiver != nil {
if err := m.Receiver.Validate(formats); err != nil {
if ve, ok := err.(*errors.Validation); ok {
return ve.ValidateName("receiver")
} else if ce, ok := err.(*errors.CompositeError); ok {
return ce.ValidateName("receiver")
}
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
if err := m.contextValidateOutpoint(ctx, formats); err != nil {
res = append(res, err)
}
if err := m.contextValidateReceiver(ctx, formats); err != nil {
res = append(res, err)
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}
func (m *V1Vtxo) contextValidateOutpoint(ctx context.Context, formats strfmt.Registry) error {
if m.Outpoint != nil {
if swag.IsZero(m.Outpoint) { // not required
return nil
}
if err := m.Outpoint.ContextValidate(ctx, formats); err != nil {
if ve, ok := err.(*errors.Validation); ok {
return ve.ValidateName("outpoint")
} else if ce, ok := err.(*errors.CompositeError); ok {
return ce.ValidateName("outpoint")
}
return err
}
}
return nil
}
func (m *V1Vtxo) contextValidateReceiver(ctx context.Context, formats strfmt.Registry) error {
if m.Receiver != nil {
if swag.IsZero(m.Receiver) { // not required
return nil
}
if err := m.Receiver.ContextValidate(ctx, formats); err != nil {
if ve, ok := err.(*errors.Validation); ok {
return ve.ValidateName("receiver")
} else if ce, ok := err.(*errors.CompositeError); ok {
return ce.ValidateName("receiver")
}
return err
}
}
return nil
}
// MarshalBinary interface implementation
func (m *V1Vtxo) MarshalBinary() ([]byte, error) {
if m == nil {
return nil, nil
}
return swag.WriteJSON(m)
}
// UnmarshalBinary interface implementation
func (m *V1Vtxo) UnmarshalBinary(b []byte) error {
var res V1Vtxo
if err := swag.ReadJSON(b, &res); err != nil {
return err
}
*m = res
return nil
}