mirror of
https://github.com/aljazceru/ark.git
synced 2025-12-17 04:04:21 +01:00
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:
committed by
GitHub
parent
e45bff3c70
commit
89df461623
28
.github/workflows/ark.unit.yaml
vendored
28
.github/workflows/ark.unit.yaml
vendored
@@ -12,8 +12,8 @@ on:
|
||||
- "server/**"
|
||||
|
||||
jobs:
|
||||
test:
|
||||
name: unit tests
|
||||
test-server:
|
||||
name: server unit tests
|
||||
runs-on: ubuntu-latest
|
||||
defaults:
|
||||
run:
|
||||
@@ -38,4 +38,26 @@ jobs:
|
||||
- run: go get -v -t -d ./...
|
||||
- name: unit testing
|
||||
run: make test
|
||||
|
||||
test-sdk:
|
||||
name: sdk unit tests
|
||||
runs-on: ubuntu-latest
|
||||
defaults:
|
||||
run:
|
||||
working-directory: ./pkg/client-sdk
|
||||
steps:
|
||||
- uses: actions/setup-go@v3
|
||||
with:
|
||||
go-version: ">1.17.2"
|
||||
- uses: actions/checkout@v3
|
||||
- name: check linting
|
||||
uses: golangci/golangci-lint-action@v3
|
||||
with:
|
||||
version: v1.54
|
||||
working-directory: ./pkg/client-sdk
|
||||
- name: check code integrity
|
||||
uses: securego/gosec@master
|
||||
with:
|
||||
args: '-severity high -quiet ./...'
|
||||
- run: go get -v -t -d ./...
|
||||
- name: unit testing
|
||||
run: make test
|
||||
@@ -2,11 +2,14 @@ package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
arkgrpcclient "github.com/ark-network/ark-sdk/grpc"
|
||||
arkv1 "github.com/ark-network/ark/api-spec/protobuf/gen/ark/v1"
|
||||
"github.com/urfave/cli/v2"
|
||||
"google.golang.org/grpc"
|
||||
"google.golang.org/grpc/credentials"
|
||||
"google.golang.org/grpc/credentials/insecure"
|
||||
)
|
||||
|
||||
type vtxo struct {
|
||||
@@ -86,6 +89,29 @@ func getClientFromState(ctx *cli.Context) (arkv1.ArkServiceClient, func(), error
|
||||
}
|
||||
|
||||
func getClient(addr string) (arkv1.ArkServiceClient, func(), error) {
|
||||
client, cleanFn, err := arkgrpcclient.New(addr)
|
||||
return client.Service(), cleanFn, err
|
||||
creds := insecure.NewCredentials()
|
||||
port := 80
|
||||
if strings.HasPrefix(addr, "https://") {
|
||||
addr = strings.TrimPrefix(addr, "https://")
|
||||
creds = credentials.NewTLS(nil)
|
||||
port = 443
|
||||
}
|
||||
if !strings.Contains(addr, ":") {
|
||||
addr = fmt.Sprintf("%s:%d", addr, port)
|
||||
}
|
||||
conn, err := grpc.Dial(addr, grpc.WithTransportCredentials(creds))
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
client := arkv1.NewArkServiceClient(conn)
|
||||
|
||||
closeFn := func() {
|
||||
err := conn.Close()
|
||||
if err != nil {
|
||||
fmt.Printf("error closing connection: %s\n", err)
|
||||
}
|
||||
}
|
||||
|
||||
return client, closeFn, nil
|
||||
}
|
||||
|
||||
@@ -326,7 +326,7 @@ func getTxBlocktime(ctx *cli.Context, txid string) (confirmed bool, blocktime in
|
||||
func getNetwork(ctx *cli.Context) (*common.Network, *network.Network) {
|
||||
state, err := getState(ctx)
|
||||
if err != nil {
|
||||
return &common.TestNet, &network.Testnet
|
||||
return &common.LiquidTestNet, &network.Testnet
|
||||
}
|
||||
|
||||
net, ok := state[NETWORK]
|
||||
@@ -337,11 +337,11 @@ func getNetwork(ctx *cli.Context) (*common.Network, *network.Network) {
|
||||
}
|
||||
|
||||
func networkFromString(net string) (*common.Network, *network.Network) {
|
||||
if net == "testnet" {
|
||||
return &common.TestNet, &network.Testnet
|
||||
if net == common.LiquidTestNet.Name {
|
||||
return &common.LiquidTestNet, &network.Testnet
|
||||
}
|
||||
if net == "regtest" {
|
||||
return &common.RegTest, &network.Regtest
|
||||
if net == common.LiquidRegTest.Name {
|
||||
return &common.LiquidRegTest, &network.Regtest
|
||||
}
|
||||
return &common.Liquid, &network.Liquid
|
||||
}
|
||||
|
||||
@@ -6,19 +6,16 @@ replace github.com/ark-network/ark/common => ../common
|
||||
|
||||
replace github.com/ark-network/ark => ../server
|
||||
|
||||
replace github.com/ark-network/ark-sdk => ../pkg/client-sdk
|
||||
|
||||
require (
|
||||
github.com/ark-network/ark v0.0.0-00010101000000-000000000000
|
||||
github.com/ark-network/ark-sdk v0.0.0-00010101000000-000000000000
|
||||
github.com/ark-network/ark/common v0.0.0
|
||||
github.com/btcsuite/btcd v0.24.2
|
||||
github.com/btcsuite/btcd/btcec/v2 v2.3.4
|
||||
github.com/btcsuite/btcd/chaincfg/chainhash v1.1.0
|
||||
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.3.0
|
||||
github.com/urfave/cli/v2 v2.27.2
|
||||
golang.org/x/crypto v0.23.0
|
||||
golang.org/x/term v0.20.0
|
||||
golang.org/x/crypto v0.25.0
|
||||
golang.org/x/term v0.22.0
|
||||
)
|
||||
|
||||
require (
|
||||
@@ -35,11 +32,11 @@ require (
|
||||
github.com/russross/blackfriday/v2 v2.1.0 // indirect
|
||||
github.com/vulpemventures/go-elements v0.5.3
|
||||
github.com/xrash/smetrics v0.0.0-20240312152122-5f08fbb34913 // indirect
|
||||
golang.org/x/net v0.25.0 // indirect
|
||||
golang.org/x/sys v0.20.0 // indirect
|
||||
golang.org/x/text v0.15.0 // indirect
|
||||
golang.org/x/net v0.27.0 // indirect
|
||||
golang.org/x/sys v0.22.0 // indirect
|
||||
golang.org/x/text v0.16.0 // indirect
|
||||
google.golang.org/genproto/googleapis/api v0.0.0-20240528184218-531527333157 // indirect
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20240528184218-531527333157 // indirect
|
||||
google.golang.org/grpc v1.65.0 // indirect
|
||||
google.golang.org/grpc v1.65.0
|
||||
google.golang.org/protobuf v1.34.1 // indirect
|
||||
)
|
||||
|
||||
@@ -97,15 +97,15 @@ github.com/xrash/smetrics v0.0.0-20240312152122-5f08fbb34913/go.mod h1:4aEEwZQut
|
||||
golang.org/x/crypto v0.0.0-20170930174604-9419663f5a44/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
|
||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
||||
golang.org/x/crypto v0.23.0 h1:dIJU/v2J8Mdglj/8rJ6UUOM3Zc9zLZxVZwwxMooUSAI=
|
||||
golang.org/x/crypto v0.23.0/go.mod h1:CKFgDieR+mRhux2Lsu27y0fO304Db0wZe70UKqHu0v8=
|
||||
golang.org/x/crypto v0.25.0 h1:ypSNr+bnYL2YhwoMt2zPxHFmbAN1KZs/njMG3hxUp30=
|
||||
golang.org/x/crypto v0.25.0/go.mod h1:T+wALwcMOSE0kXgUAnPAHqTLW+XHgcELELW8VaDgm/M=
|
||||
golang.org/x/net v0.0.0-20180719180050-a680a1efc54d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||
golang.org/x/net v0.0.0-20200520004742-59133d7f0dd7/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
|
||||
golang.org/x/net v0.0.0-20200813134508-3edf25e44fcc/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA=
|
||||
golang.org/x/net v0.25.0 h1:d/OCCoBEUq33pjydKrGQhw7IlUPI2Oylr+8qLx49kac=
|
||||
golang.org/x/net v0.25.0/go.mod h1:JkAGAh7GEvH74S6FOH42FLoXpXbE/aqXSrIQjXgsiwM=
|
||||
golang.org/x/net v0.27.0 h1:5K3Njcw06/l2y9vpGCSdcxWOYHOUk3dVNGDXN+FvAys=
|
||||
golang.org/x/net v0.27.0/go.mod h1:dDi0PyhWNoiUOrAS8uXv/vnScO4wnHQO4mj9fn/RytE=
|
||||
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
@@ -116,15 +116,15 @@ golang.org/x/sys v0.0.0-20191120155948-bd437916bb0e/go.mod h1:h1NjWce9XRLGQEsW7w
|
||||
golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200519105757-fe76b779f299/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200814200057-3d37ad5750ed/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.20.0 h1:Od9JTbYCk261bKm4M/mw7AklTlFYIa0bIp9BgSm1S8Y=
|
||||
golang.org/x/sys v0.20.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||
golang.org/x/term v0.20.0 h1:VnkxpohqXaOBYJtBmEppKUG6mXpi+4O6purfc2+sMhw=
|
||||
golang.org/x/term v0.20.0/go.mod h1:8UkIAJTvZgivsXaD6/pH6U9ecQzZ45awqEOzuCvwpFY=
|
||||
golang.org/x/sys v0.22.0 h1:RI27ohtqKCnwULzJLqkv897zojh5/DwS/ENaMzUOaWI=
|
||||
golang.org/x/sys v0.22.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||
golang.org/x/term v0.22.0 h1:BbsgPEJULsl2fV/AT3v15Mjva5yXKQDyKf+TbDz7QJk=
|
||||
golang.org/x/term v0.22.0/go.mod h1:F3qCibpT5AMpCRfhfT53vVJwhLtIVHhB9XDjfFvnMI4=
|
||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
|
||||
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||
golang.org/x/text v0.15.0 h1:h1V/4gjBv8v9cjcR6+AR5+/cIYK5N/WAgiv4xlsEtAk=
|
||||
golang.org/x/text v0.15.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
|
||||
golang.org/x/text v0.16.0 h1:a94ExnEXNtEwYLGJSIUxnWoxoRz/ZcCsV63ROupILh4=
|
||||
golang.org/x/text v0.16.0/go.mod h1:GhwF1Be+LQoKShO3cGOHzqOgRrGaYc9AvblQOmPVHnI=
|
||||
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
|
||||
@@ -9,6 +9,7 @@ import (
|
||||
"strings"
|
||||
|
||||
arkv1 "github.com/ark-network/ark/api-spec/protobuf/gen/ark/v1"
|
||||
"github.com/ark-network/ark/common"
|
||||
"github.com/btcsuite/btcd/btcec/v2"
|
||||
"github.com/decred/dcrd/dcrec/secp256k1/v4"
|
||||
"github.com/urfave/cli/v2"
|
||||
@@ -54,7 +55,8 @@ func initAction(ctx *cli.Context) error {
|
||||
if len(url) <= 0 {
|
||||
return fmt.Errorf("invalid ark url")
|
||||
}
|
||||
if net != "liquid" && net != "testnet" && net != "regtest" {
|
||||
if net != common.Liquid.Name && net != common.LiquidTestNet.Name &&
|
||||
net != common.LiquidRegTest.Name {
|
||||
return fmt.Errorf("invalid network")
|
||||
}
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ func EncodeAddress(
|
||||
err = fmt.Errorf("missing asp public key")
|
||||
return
|
||||
}
|
||||
if hrp != Liquid.Addr && hrp != TestNet.Addr {
|
||||
if hrp != Liquid.Addr && hrp != LiquidTestNet.Addr {
|
||||
err = fmt.Errorf("invalid prefix")
|
||||
return
|
||||
}
|
||||
@@ -40,7 +40,7 @@ func DecodeAddress(
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
if prefix != Liquid.Addr && prefix != TestNet.Addr {
|
||||
if prefix != Liquid.Addr && prefix != LiquidTestNet.Addr && prefix != LiquidRegTest.Addr {
|
||||
err = fmt.Errorf("invalid prefix")
|
||||
return
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package common
|
||||
|
||||
import "strings"
|
||||
|
||||
type Network struct {
|
||||
Name string
|
||||
Addr string
|
||||
@@ -10,12 +12,31 @@ var Liquid = Network{
|
||||
Addr: "ark",
|
||||
}
|
||||
|
||||
var TestNet = Network{
|
||||
var LiquidTestNet = Network{
|
||||
Name: "liquidtestnet",
|
||||
Addr: "tark",
|
||||
}
|
||||
|
||||
var LiquidRegTest = Network{
|
||||
Name: "liquidregtest",
|
||||
Addr: LiquidTestNet.Addr,
|
||||
}
|
||||
|
||||
var Bitcoin = Network{
|
||||
Name: "bitcoin",
|
||||
Addr: "ark",
|
||||
}
|
||||
|
||||
var BitcoinTestNet = Network{
|
||||
Name: "testnet",
|
||||
Addr: "tark",
|
||||
}
|
||||
|
||||
var RegTest = Network{
|
||||
var BitcoinRegTest = Network{
|
||||
Name: "regtest",
|
||||
Addr: TestNet.Addr,
|
||||
Addr: BitcoinTestNet.Addr,
|
||||
}
|
||||
|
||||
func IsLiquid(network Network) bool {
|
||||
return strings.Contains(network.Name, "liquid")
|
||||
}
|
||||
|
||||
@@ -9,6 +9,9 @@ import (
|
||||
"github.com/btcsuite/btcd/btcec/v2/schnorr"
|
||||
"github.com/btcsuite/btcd/txscript"
|
||||
"github.com/decred/dcrd/dcrec/secp256k1/v4"
|
||||
"github.com/vulpemventures/go-elements/address"
|
||||
"github.com/vulpemventures/go-elements/network"
|
||||
"github.com/vulpemventures/go-elements/payment"
|
||||
"github.com/vulpemventures/go-elements/taproot"
|
||||
)
|
||||
|
||||
@@ -60,7 +63,6 @@ func DecodeClosure(script []byte) (Closure, error) {
|
||||
}
|
||||
|
||||
return nil, fmt.Errorf("invalid closure script")
|
||||
|
||||
}
|
||||
|
||||
func (f *ForfeitClosure) Leaf() (*taproot.TapElementsLeaf, error) {
|
||||
@@ -281,6 +283,59 @@ func (c *UnrollClosure) Decode(script []byte) (valid bool, err error) {
|
||||
return true, nil
|
||||
}
|
||||
|
||||
func ComputeVtxoTaprootScript(
|
||||
userPubkey, aspPubkey *secp256k1.PublicKey, exitDelay uint, net network.Network,
|
||||
) (*secp256k1.PublicKey, *taproot.TapscriptElementsProof, []byte, string, error) {
|
||||
redeemClosure := &CSVSigClosure{
|
||||
Pubkey: userPubkey,
|
||||
Seconds: exitDelay,
|
||||
}
|
||||
|
||||
forfeitClosure := &ForfeitClosure{
|
||||
Pubkey: userPubkey,
|
||||
AspPubkey: aspPubkey,
|
||||
}
|
||||
|
||||
redeemLeaf, err := redeemClosure.Leaf()
|
||||
if err != nil {
|
||||
return nil, nil, nil, "", err
|
||||
}
|
||||
|
||||
forfeitLeaf, err := forfeitClosure.Leaf()
|
||||
if err != nil {
|
||||
return nil, nil, nil, "", err
|
||||
}
|
||||
|
||||
vtxoTaprootTree := taproot.AssembleTaprootScriptTree(
|
||||
*redeemLeaf, *forfeitLeaf,
|
||||
)
|
||||
root := vtxoTaprootTree.RootNode.TapHash()
|
||||
|
||||
unspendableKey := UnspendableKey()
|
||||
vtxoTaprootKey := taproot.ComputeTaprootOutputKey(unspendableKey, root[:])
|
||||
|
||||
redeemLeafHash := redeemLeaf.TapHash()
|
||||
proofIndex := vtxoTaprootTree.LeafProofIndex[redeemLeafHash]
|
||||
proof := vtxoTaprootTree.LeafMerkleProofs[proofIndex]
|
||||
|
||||
pay, err := payment.FromTweakedKey(vtxoTaprootKey, &net, nil)
|
||||
if err != nil {
|
||||
return nil, nil, nil, "", err
|
||||
}
|
||||
|
||||
addr, err := pay.TaprootAddress()
|
||||
if err != nil {
|
||||
return nil, nil, nil, "", err
|
||||
}
|
||||
|
||||
script, err := address.ToOutputScript(addr)
|
||||
if err != nil {
|
||||
return nil, nil, nil, "", err
|
||||
}
|
||||
|
||||
return vtxoTaprootKey, &proof, script, addr, nil
|
||||
}
|
||||
|
||||
func decodeIntrospectionScript(
|
||||
script []byte, expectedIndex byte, isVerify bool,
|
||||
) (bool, *secp256k1.PublicKey, uint64, error) {
|
||||
|
||||
@@ -27,7 +27,7 @@ services:
|
||||
environment:
|
||||
- ARK_WALLET_ADDR=oceand:18000
|
||||
- ARK_ROUND_INTERVAL=10
|
||||
- ARK_NETWORK=regtest
|
||||
- ARK_NETWORK=liquidregtest
|
||||
- ARK_LOG_LEVEL=5
|
||||
- ARK_ROUND_LIFETIME=512
|
||||
- ARK_DB_TYPE=sqlite
|
||||
|
||||
@@ -1,6 +1,21 @@
|
||||
genrest:
|
||||
swagger generate client -f ./../../server/api-spec/openapi/swagger/ark/v1/admin.swagger.json -t ./rest/admin --client-package=arkadminrestclient
|
||||
swagger generate client -f ./../../server/api-spec/openapi/swagger/ark/v1/service.swagger.json -t ./rest/service --client-package=arkservicerestclient
|
||||
.PHONY: genrest test vet lint
|
||||
|
||||
## genrest: compiles rest client from stub with https://github.com/go-swagger/go-swagger
|
||||
genrest:
|
||||
@echo "Generating rest client from stub..."
|
||||
@swagger generate client -f ../../server/api-spec/openapi/swagger/ark/v1/service.swagger.json -t ./client/rest/service --client-package=arkservice
|
||||
|
||||
## test: runs unit tests
|
||||
test:
|
||||
@echo "Running unit tests..."
|
||||
@go test -v -count=1 -race ./...
|
||||
|
||||
## vet: code analysis
|
||||
vet:
|
||||
go vet ./...
|
||||
@echo "Running code analysis..."
|
||||
@go vet ./...
|
||||
|
||||
## lint: lint codebase
|
||||
lint:
|
||||
@echo "Linting code..."
|
||||
@golangci-lint run --fix
|
||||
File diff suppressed because it is too large
Load Diff
60
pkg/client-sdk/client/client.go
Normal file
60
pkg/client-sdk/client/client.go
Normal 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()
|
||||
}
|
||||
277
pkg/client-sdk/client/grpc/client.go
Normal file
277
pkg/client-sdk/client/grpc/client.go
Normal 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
|
||||
}
|
||||
@@ -1,9 +1,10 @@
|
||||
package arksdk
|
||||
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"
|
||||
@@ -11,19 +12,19 @@ import (
|
||||
"github.com/vulpemventures/go-elements/taproot"
|
||||
)
|
||||
|
||||
type redeemBranch struct {
|
||||
vtxo *vtxo
|
||||
type RedeemBranch struct {
|
||||
vtxo *Vtxo
|
||||
branch []*psetv2.Pset
|
||||
internalKey *secp256k1.PublicKey
|
||||
sweepClosure *taproot.TapElementsLeaf
|
||||
lifetime time.Duration
|
||||
explorer Explorer
|
||||
explorer explorer.Explorer
|
||||
}
|
||||
|
||||
func newRedeemBranch(
|
||||
explorer Explorer,
|
||||
congestionTree tree.CongestionTree, vtxo vtxo,
|
||||
) (*redeemBranch, error) {
|
||||
func NewRedeemBranch(
|
||||
explorer explorer.Explorer,
|
||||
congestionTree tree.CongestionTree, vtxo *Vtxo,
|
||||
) (*RedeemBranch, error) {
|
||||
sweepClosure, seconds, err := findSweepClosure(congestionTree)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -34,7 +35,7 @@ func newRedeemBranch(
|
||||
return nil, err
|
||||
}
|
||||
|
||||
nodes, err := congestionTree.Branch(vtxo.txid)
|
||||
nodes, err := congestionTree.Branch(vtxo.Txid)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -54,8 +55,8 @@ func newRedeemBranch(
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &redeemBranch{
|
||||
vtxo: &vtxo,
|
||||
return &RedeemBranch{
|
||||
vtxo: vtxo,
|
||||
branch: branch,
|
||||
internalKey: internalKey,
|
||||
sweepClosure: sweepClosure,
|
||||
@@ -65,10 +66,10 @@ func newRedeemBranch(
|
||||
}
|
||||
|
||||
// RedeemPath returns the list of transactions to broadcast in order to access the vtxo output
|
||||
func (r *redeemBranch) redeemPath() ([]string, error) {
|
||||
func (r *RedeemBranch) RedeemPath() ([]string, error) {
|
||||
transactions := make([]string, 0, len(r.branch))
|
||||
|
||||
offchainPath, err := r.offchainPath()
|
||||
offchainPath, err := r.OffchainPath()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -115,10 +116,10 @@ func (r *redeemBranch) redeemPath() ([]string, error) {
|
||||
return transactions, nil
|
||||
}
|
||||
|
||||
func (r *redeemBranch) expireAt(explorer Explorer) (*time.Time, error) {
|
||||
func (r *RedeemBranch) ExpiresAt() (*time.Time, error) {
|
||||
lastKnownBlocktime := int64(0)
|
||||
|
||||
confirmed, blocktime, _ := explorer.GetTxBlockTime(r.vtxo.poolTxid)
|
||||
confirmed, blocktime, _ := r.explorer.GetTxBlockTime(r.vtxo.RoundTxid)
|
||||
|
||||
if confirmed {
|
||||
lastKnownBlocktime = blocktime
|
||||
@@ -131,7 +132,7 @@ func (r *redeemBranch) expireAt(explorer Explorer) (*time.Time, error) {
|
||||
utx, _ := pset.UnsignedTx()
|
||||
txid := utx.TxHash().String()
|
||||
|
||||
confirmed, blocktime, err := explorer.GetTxBlockTime(txid)
|
||||
confirmed, blocktime, err := r.explorer.GetTxBlockTime(txid)
|
||||
if err != nil {
|
||||
break
|
||||
}
|
||||
@@ -149,7 +150,7 @@ func (r *redeemBranch) expireAt(explorer Explorer) (*time.Time, error) {
|
||||
}
|
||||
|
||||
// offchainPath checks for transactions of the branch onchain and returns only the offchain part
|
||||
func (r *redeemBranch) offchainPath() ([]*psetv2.Pset, error) {
|
||||
func (r *RedeemBranch) OffchainPath() ([]*psetv2.Pset, error) {
|
||||
offchainPath := append([]*psetv2.Pset{}, r.branch...)
|
||||
|
||||
for i := len(r.branch) - 1; i >= 0; i-- {
|
||||
@@ -178,3 +179,39 @@ func (r *redeemBranch) offchainPath() ([]*psetv2.Pset, error) {
|
||||
|
||||
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
|
||||
}
|
||||
672
pkg/client-sdk/client/rest/client.go
Normal file
672
pkg/client-sdk/client/rest/client.go
Normal 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
|
||||
}
|
||||
@@ -13,57 +13,57 @@ import (
|
||||
"github.com/go-openapi/errors"
|
||||
"github.com/go-openapi/runtime"
|
||||
cr "github.com/go-openapi/runtime/client"
|
||||
"github.com/go-openapi/strfmt"
|
||||
|
||||
strfmt "github.com/go-openapi/strfmt"
|
||||
|
||||
models "github.com/ark-network/ark-sdk/rest/service/models"
|
||||
"github.com/ark-network/ark-sdk/client/rest/service/models"
|
||||
)
|
||||
|
||||
// NewArkServiceClaimPaymentParams creates a new ArkServiceClaimPaymentParams object
|
||||
// with the default values initialized.
|
||||
// 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 {
|
||||
var ()
|
||||
return &ArkServiceClaimPaymentParams{
|
||||
|
||||
timeout: cr.DefaultTimeout,
|
||||
}
|
||||
}
|
||||
|
||||
// NewArkServiceClaimPaymentParamsWithTimeout creates a new ArkServiceClaimPaymentParams object
|
||||
// with the default values initialized, and the ability to set a timeout on a request
|
||||
// with the ability to set a timeout on a request.
|
||||
func NewArkServiceClaimPaymentParamsWithTimeout(timeout time.Duration) *ArkServiceClaimPaymentParams {
|
||||
var ()
|
||||
return &ArkServiceClaimPaymentParams{
|
||||
|
||||
timeout: timeout,
|
||||
}
|
||||
}
|
||||
|
||||
// NewArkServiceClaimPaymentParamsWithContext creates a new ArkServiceClaimPaymentParams object
|
||||
// with the default values initialized, and the ability to set a context for a request
|
||||
// with the ability to set a context for a request.
|
||||
func NewArkServiceClaimPaymentParamsWithContext(ctx context.Context) *ArkServiceClaimPaymentParams {
|
||||
var ()
|
||||
return &ArkServiceClaimPaymentParams{
|
||||
|
||||
Context: ctx,
|
||||
}
|
||||
}
|
||||
|
||||
// NewArkServiceClaimPaymentParamsWithHTTPClient creates a new ArkServiceClaimPaymentParams object
|
||||
// with the default values initialized, and the ability to set a custom HTTPClient for a request
|
||||
// with the ability to set a custom HTTPClient for a request.
|
||||
func NewArkServiceClaimPaymentParamsWithHTTPClient(client *http.Client) *ArkServiceClaimPaymentParams {
|
||||
var ()
|
||||
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
|
||||
/*
|
||||
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.
|
||||
Body *models.V1ClaimPaymentRequest
|
||||
|
||||
timeout time.Duration
|
||||
@@ -71,6 +71,21 @@ type ArkServiceClaimPaymentParams struct {
|
||||
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)
|
||||
@@ -122,7 +137,6 @@ func (o *ArkServiceClaimPaymentParams) WriteToRequest(r runtime.ClientRequest, r
|
||||
return err
|
||||
}
|
||||
var res []error
|
||||
|
||||
if o.Body != nil {
|
||||
if err := r.SetBodyParam(o.Body); err != nil {
|
||||
return err
|
||||
@@ -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
|
||||
}
|
||||
@@ -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
|
||||
}
|
||||
@@ -13,57 +13,57 @@ import (
|
||||
"github.com/go-openapi/errors"
|
||||
"github.com/go-openapi/runtime"
|
||||
cr "github.com/go-openapi/runtime/client"
|
||||
"github.com/go-openapi/strfmt"
|
||||
|
||||
strfmt "github.com/go-openapi/strfmt"
|
||||
|
||||
models "github.com/ark-network/ark-sdk/rest/service/models"
|
||||
"github.com/ark-network/ark-sdk/client/rest/service/models"
|
||||
)
|
||||
|
||||
// NewArkServiceFinalizePaymentParams creates a new ArkServiceFinalizePaymentParams object
|
||||
// with the default values initialized.
|
||||
// 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 {
|
||||
var ()
|
||||
return &ArkServiceFinalizePaymentParams{
|
||||
|
||||
timeout: cr.DefaultTimeout,
|
||||
}
|
||||
}
|
||||
|
||||
// NewArkServiceFinalizePaymentParamsWithTimeout creates a new ArkServiceFinalizePaymentParams object
|
||||
// with the default values initialized, and the ability to set a timeout on a request
|
||||
// with the ability to set a timeout on a request.
|
||||
func NewArkServiceFinalizePaymentParamsWithTimeout(timeout time.Duration) *ArkServiceFinalizePaymentParams {
|
||||
var ()
|
||||
return &ArkServiceFinalizePaymentParams{
|
||||
|
||||
timeout: timeout,
|
||||
}
|
||||
}
|
||||
|
||||
// NewArkServiceFinalizePaymentParamsWithContext creates a new ArkServiceFinalizePaymentParams object
|
||||
// with the default values initialized, and the ability to set a context for a request
|
||||
// with the ability to set a context for a request.
|
||||
func NewArkServiceFinalizePaymentParamsWithContext(ctx context.Context) *ArkServiceFinalizePaymentParams {
|
||||
var ()
|
||||
return &ArkServiceFinalizePaymentParams{
|
||||
|
||||
Context: ctx,
|
||||
}
|
||||
}
|
||||
|
||||
// NewArkServiceFinalizePaymentParamsWithHTTPClient creates a new ArkServiceFinalizePaymentParams object
|
||||
// with the default values initialized, and the ability to set a custom HTTPClient for a request
|
||||
// with the ability to set a custom HTTPClient for a request.
|
||||
func NewArkServiceFinalizePaymentParamsWithHTTPClient(client *http.Client) *ArkServiceFinalizePaymentParams {
|
||||
var ()
|
||||
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
|
||||
/*
|
||||
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.
|
||||
Body *models.V1FinalizePaymentRequest
|
||||
|
||||
timeout time.Duration
|
||||
@@ -71,6 +71,21 @@ type ArkServiceFinalizePaymentParams struct {
|
||||
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)
|
||||
@@ -122,7 +137,6 @@ func (o *ArkServiceFinalizePaymentParams) WriteToRequest(r runtime.ClientRequest
|
||||
return err
|
||||
}
|
||||
var res []error
|
||||
|
||||
if o.Body != nil {
|
||||
if err := r.SetBodyParam(o.Body); err != nil {
|
||||
return err
|
||||
@@ -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
|
||||
}
|
||||
@@ -13,51 +13,51 @@ import (
|
||||
"github.com/go-openapi/errors"
|
||||
"github.com/go-openapi/runtime"
|
||||
cr "github.com/go-openapi/runtime/client"
|
||||
|
||||
strfmt "github.com/go-openapi/strfmt"
|
||||
"github.com/go-openapi/strfmt"
|
||||
)
|
||||
|
||||
// NewArkServiceGetEventStreamParams creates a new ArkServiceGetEventStreamParams object
|
||||
// with the default values initialized.
|
||||
// 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 default values initialized, and the ability to set a timeout on a request
|
||||
// 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 default values initialized, and the ability to set a context for a request
|
||||
// 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 default values initialized, and the ability to set a custom HTTPClient for a request
|
||||
// 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
|
||||
/*
|
||||
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
|
||||
@@ -65,6 +65,21 @@ type ArkServiceGetEventStreamParams struct {
|
||||
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)
|
||||
@@ -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
|
||||
}
|
||||
@@ -13,51 +13,51 @@ import (
|
||||
"github.com/go-openapi/errors"
|
||||
"github.com/go-openapi/runtime"
|
||||
cr "github.com/go-openapi/runtime/client"
|
||||
|
||||
strfmt "github.com/go-openapi/strfmt"
|
||||
"github.com/go-openapi/strfmt"
|
||||
)
|
||||
|
||||
// NewArkServiceGetInfoParams creates a new ArkServiceGetInfoParams object
|
||||
// with the default values initialized.
|
||||
// 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 default values initialized, and the ability to set a timeout on a request
|
||||
// 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 default values initialized, and the ability to set a context for a request
|
||||
// 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 default values initialized, and the ability to set a custom HTTPClient for a request
|
||||
// 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
|
||||
/*
|
||||
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
|
||||
@@ -65,6 +65,21 @@ type ArkServiceGetInfoParams struct {
|
||||
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)
|
||||
@@ -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
|
||||
}
|
||||
@@ -13,55 +13,55 @@ import (
|
||||
"github.com/go-openapi/errors"
|
||||
"github.com/go-openapi/runtime"
|
||||
cr "github.com/go-openapi/runtime/client"
|
||||
|
||||
strfmt "github.com/go-openapi/strfmt"
|
||||
"github.com/go-openapi/strfmt"
|
||||
)
|
||||
|
||||
// NewArkServiceGetRoundByIDParams creates a new ArkServiceGetRoundByIDParams object
|
||||
// with the default values initialized.
|
||||
// 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 {
|
||||
var ()
|
||||
return &ArkServiceGetRoundByIDParams{
|
||||
|
||||
timeout: cr.DefaultTimeout,
|
||||
}
|
||||
}
|
||||
|
||||
// NewArkServiceGetRoundByIDParamsWithTimeout creates a new ArkServiceGetRoundByIDParams object
|
||||
// with the default values initialized, and the ability to set a timeout on a request
|
||||
// with the ability to set a timeout on a request.
|
||||
func NewArkServiceGetRoundByIDParamsWithTimeout(timeout time.Duration) *ArkServiceGetRoundByIDParams {
|
||||
var ()
|
||||
return &ArkServiceGetRoundByIDParams{
|
||||
|
||||
timeout: timeout,
|
||||
}
|
||||
}
|
||||
|
||||
// NewArkServiceGetRoundByIDParamsWithContext creates a new ArkServiceGetRoundByIDParams object
|
||||
// with the default values initialized, and the ability to set a context for a request
|
||||
// with the ability to set a context for a request.
|
||||
func NewArkServiceGetRoundByIDParamsWithContext(ctx context.Context) *ArkServiceGetRoundByIDParams {
|
||||
var ()
|
||||
return &ArkServiceGetRoundByIDParams{
|
||||
|
||||
Context: ctx,
|
||||
}
|
||||
}
|
||||
|
||||
// NewArkServiceGetRoundByIDParamsWithHTTPClient creates a new ArkServiceGetRoundByIDParams object
|
||||
// with the default values initialized, and the ability to set a custom HTTPClient for a request
|
||||
// with the ability to set a custom HTTPClient for a request.
|
||||
func NewArkServiceGetRoundByIDParamsWithHTTPClient(client *http.Client) *ArkServiceGetRoundByIDParams {
|
||||
var ()
|
||||
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
|
||||
/*
|
||||
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.
|
||||
ID string
|
||||
|
||||
timeout time.Duration
|
||||
@@ -69,6 +69,21 @@ type ArkServiceGetRoundByIDParams struct {
|
||||
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)
|
||||
@@ -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
|
||||
}
|
||||
@@ -13,55 +13,55 @@ import (
|
||||
"github.com/go-openapi/errors"
|
||||
"github.com/go-openapi/runtime"
|
||||
cr "github.com/go-openapi/runtime/client"
|
||||
|
||||
strfmt "github.com/go-openapi/strfmt"
|
||||
"github.com/go-openapi/strfmt"
|
||||
)
|
||||
|
||||
// NewArkServiceGetRoundParams creates a new ArkServiceGetRoundParams object
|
||||
// with the default values initialized.
|
||||
// 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 {
|
||||
var ()
|
||||
return &ArkServiceGetRoundParams{
|
||||
|
||||
timeout: cr.DefaultTimeout,
|
||||
}
|
||||
}
|
||||
|
||||
// NewArkServiceGetRoundParamsWithTimeout creates a new ArkServiceGetRoundParams object
|
||||
// with the default values initialized, and the ability to set a timeout on a request
|
||||
// with the ability to set a timeout on a request.
|
||||
func NewArkServiceGetRoundParamsWithTimeout(timeout time.Duration) *ArkServiceGetRoundParams {
|
||||
var ()
|
||||
return &ArkServiceGetRoundParams{
|
||||
|
||||
timeout: timeout,
|
||||
}
|
||||
}
|
||||
|
||||
// NewArkServiceGetRoundParamsWithContext creates a new ArkServiceGetRoundParams object
|
||||
// with the default values initialized, and the ability to set a context for a request
|
||||
// with the ability to set a context for a request.
|
||||
func NewArkServiceGetRoundParamsWithContext(ctx context.Context) *ArkServiceGetRoundParams {
|
||||
var ()
|
||||
return &ArkServiceGetRoundParams{
|
||||
|
||||
Context: ctx,
|
||||
}
|
||||
}
|
||||
|
||||
// NewArkServiceGetRoundParamsWithHTTPClient creates a new ArkServiceGetRoundParams object
|
||||
// with the default values initialized, and the ability to set a custom HTTPClient for a request
|
||||
// with the ability to set a custom HTTPClient for a request.
|
||||
func NewArkServiceGetRoundParamsWithHTTPClient(client *http.Client) *ArkServiceGetRoundParams {
|
||||
var ()
|
||||
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
|
||||
/*
|
||||
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.
|
||||
Txid string
|
||||
|
||||
timeout time.Duration
|
||||
@@ -69,6 +69,21 @@ type ArkServiceGetRoundParams struct {
|
||||
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)
|
||||
@@ -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
|
||||
}
|
||||
@@ -13,55 +13,55 @@ import (
|
||||
"github.com/go-openapi/errors"
|
||||
"github.com/go-openapi/runtime"
|
||||
cr "github.com/go-openapi/runtime/client"
|
||||
|
||||
strfmt "github.com/go-openapi/strfmt"
|
||||
"github.com/go-openapi/strfmt"
|
||||
)
|
||||
|
||||
// NewArkServiceListVtxosParams creates a new ArkServiceListVtxosParams object
|
||||
// with the default values initialized.
|
||||
// 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 {
|
||||
var ()
|
||||
return &ArkServiceListVtxosParams{
|
||||
|
||||
timeout: cr.DefaultTimeout,
|
||||
}
|
||||
}
|
||||
|
||||
// NewArkServiceListVtxosParamsWithTimeout creates a new ArkServiceListVtxosParams object
|
||||
// with the default values initialized, and the ability to set a timeout on a request
|
||||
// with the ability to set a timeout on a request.
|
||||
func NewArkServiceListVtxosParamsWithTimeout(timeout time.Duration) *ArkServiceListVtxosParams {
|
||||
var ()
|
||||
return &ArkServiceListVtxosParams{
|
||||
|
||||
timeout: timeout,
|
||||
}
|
||||
}
|
||||
|
||||
// NewArkServiceListVtxosParamsWithContext creates a new ArkServiceListVtxosParams object
|
||||
// with the default values initialized, and the ability to set a context for a request
|
||||
// with the ability to set a context for a request.
|
||||
func NewArkServiceListVtxosParamsWithContext(ctx context.Context) *ArkServiceListVtxosParams {
|
||||
var ()
|
||||
return &ArkServiceListVtxosParams{
|
||||
|
||||
Context: ctx,
|
||||
}
|
||||
}
|
||||
|
||||
// NewArkServiceListVtxosParamsWithHTTPClient creates a new ArkServiceListVtxosParams object
|
||||
// with the default values initialized, and the ability to set a custom HTTPClient for a request
|
||||
// with the ability to set a custom HTTPClient for a request.
|
||||
func NewArkServiceListVtxosParamsWithHTTPClient(client *http.Client) *ArkServiceListVtxosParams {
|
||||
var ()
|
||||
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
|
||||
/*
|
||||
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.
|
||||
Address string
|
||||
|
||||
timeout time.Duration
|
||||
@@ -69,6 +69,21 @@ type ArkServiceListVtxosParams struct {
|
||||
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)
|
||||
@@ -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
|
||||
}
|
||||
@@ -13,57 +13,57 @@ import (
|
||||
"github.com/go-openapi/errors"
|
||||
"github.com/go-openapi/runtime"
|
||||
cr "github.com/go-openapi/runtime/client"
|
||||
"github.com/go-openapi/strfmt"
|
||||
|
||||
strfmt "github.com/go-openapi/strfmt"
|
||||
|
||||
models "github.com/ark-network/ark-sdk/rest/service/models"
|
||||
"github.com/ark-network/ark-sdk/client/rest/service/models"
|
||||
)
|
||||
|
||||
// NewArkServiceOnboardParams creates a new ArkServiceOnboardParams object
|
||||
// with the default values initialized.
|
||||
// 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 {
|
||||
var ()
|
||||
return &ArkServiceOnboardParams{
|
||||
|
||||
timeout: cr.DefaultTimeout,
|
||||
}
|
||||
}
|
||||
|
||||
// NewArkServiceOnboardParamsWithTimeout creates a new ArkServiceOnboardParams object
|
||||
// with the default values initialized, and the ability to set a timeout on a request
|
||||
// with the ability to set a timeout on a request.
|
||||
func NewArkServiceOnboardParamsWithTimeout(timeout time.Duration) *ArkServiceOnboardParams {
|
||||
var ()
|
||||
return &ArkServiceOnboardParams{
|
||||
|
||||
timeout: timeout,
|
||||
}
|
||||
}
|
||||
|
||||
// NewArkServiceOnboardParamsWithContext creates a new ArkServiceOnboardParams object
|
||||
// with the default values initialized, and the ability to set a context for a request
|
||||
// with the ability to set a context for a request.
|
||||
func NewArkServiceOnboardParamsWithContext(ctx context.Context) *ArkServiceOnboardParams {
|
||||
var ()
|
||||
return &ArkServiceOnboardParams{
|
||||
|
||||
Context: ctx,
|
||||
}
|
||||
}
|
||||
|
||||
// NewArkServiceOnboardParamsWithHTTPClient creates a new ArkServiceOnboardParams object
|
||||
// with the default values initialized, and the ability to set a custom HTTPClient for a request
|
||||
// with the ability to set a custom HTTPClient for a request.
|
||||
func NewArkServiceOnboardParamsWithHTTPClient(client *http.Client) *ArkServiceOnboardParams {
|
||||
var ()
|
||||
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
|
||||
/*
|
||||
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.
|
||||
Body *models.V1OnboardRequest
|
||||
|
||||
timeout time.Duration
|
||||
@@ -71,6 +71,21 @@ type ArkServiceOnboardParams struct {
|
||||
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)
|
||||
@@ -122,7 +137,6 @@ func (o *ArkServiceOnboardParams) WriteToRequest(r runtime.ClientRequest, reg st
|
||||
return err
|
||||
}
|
||||
var res []error
|
||||
|
||||
if o.Body != nil {
|
||||
if err := r.SetBodyParam(o.Body); err != nil {
|
||||
return err
|
||||
@@ -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
|
||||
}
|
||||
@@ -13,55 +13,55 @@ import (
|
||||
"github.com/go-openapi/errors"
|
||||
"github.com/go-openapi/runtime"
|
||||
cr "github.com/go-openapi/runtime/client"
|
||||
|
||||
strfmt "github.com/go-openapi/strfmt"
|
||||
"github.com/go-openapi/strfmt"
|
||||
)
|
||||
|
||||
// NewArkServicePingParams creates a new ArkServicePingParams object
|
||||
// with the default values initialized.
|
||||
// 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 {
|
||||
var ()
|
||||
return &ArkServicePingParams{
|
||||
|
||||
timeout: cr.DefaultTimeout,
|
||||
}
|
||||
}
|
||||
|
||||
// NewArkServicePingParamsWithTimeout creates a new ArkServicePingParams object
|
||||
// with the default values initialized, and the ability to set a timeout on a request
|
||||
// with the ability to set a timeout on a request.
|
||||
func NewArkServicePingParamsWithTimeout(timeout time.Duration) *ArkServicePingParams {
|
||||
var ()
|
||||
return &ArkServicePingParams{
|
||||
|
||||
timeout: timeout,
|
||||
}
|
||||
}
|
||||
|
||||
// NewArkServicePingParamsWithContext creates a new ArkServicePingParams object
|
||||
// with the default values initialized, and the ability to set a context for a request
|
||||
// with the ability to set a context for a request.
|
||||
func NewArkServicePingParamsWithContext(ctx context.Context) *ArkServicePingParams {
|
||||
var ()
|
||||
return &ArkServicePingParams{
|
||||
|
||||
Context: ctx,
|
||||
}
|
||||
}
|
||||
|
||||
// NewArkServicePingParamsWithHTTPClient creates a new ArkServicePingParams object
|
||||
// with the default values initialized, and the ability to set a custom HTTPClient for a request
|
||||
// with the ability to set a custom HTTPClient for a request.
|
||||
func NewArkServicePingParamsWithHTTPClient(client *http.Client) *ArkServicePingParams {
|
||||
var ()
|
||||
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
|
||||
/*
|
||||
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.
|
||||
PaymentID string
|
||||
|
||||
timeout time.Duration
|
||||
@@ -69,6 +69,21 @@ type ArkServicePingParams struct {
|
||||
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)
|
||||
@@ -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
|
||||
}
|
||||
@@ -13,57 +13,57 @@ import (
|
||||
"github.com/go-openapi/errors"
|
||||
"github.com/go-openapi/runtime"
|
||||
cr "github.com/go-openapi/runtime/client"
|
||||
"github.com/go-openapi/strfmt"
|
||||
|
||||
strfmt "github.com/go-openapi/strfmt"
|
||||
|
||||
models "github.com/ark-network/ark-sdk/rest/service/models"
|
||||
"github.com/ark-network/ark-sdk/client/rest/service/models"
|
||||
)
|
||||
|
||||
// NewArkServiceRegisterPaymentParams creates a new ArkServiceRegisterPaymentParams object
|
||||
// with the default values initialized.
|
||||
// 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 {
|
||||
var ()
|
||||
return &ArkServiceRegisterPaymentParams{
|
||||
|
||||
timeout: cr.DefaultTimeout,
|
||||
}
|
||||
}
|
||||
|
||||
// NewArkServiceRegisterPaymentParamsWithTimeout creates a new ArkServiceRegisterPaymentParams object
|
||||
// with the default values initialized, and the ability to set a timeout on a request
|
||||
// with the ability to set a timeout on a request.
|
||||
func NewArkServiceRegisterPaymentParamsWithTimeout(timeout time.Duration) *ArkServiceRegisterPaymentParams {
|
||||
var ()
|
||||
return &ArkServiceRegisterPaymentParams{
|
||||
|
||||
timeout: timeout,
|
||||
}
|
||||
}
|
||||
|
||||
// NewArkServiceRegisterPaymentParamsWithContext creates a new ArkServiceRegisterPaymentParams object
|
||||
// with the default values initialized, and the ability to set a context for a request
|
||||
// with the ability to set a context for a request.
|
||||
func NewArkServiceRegisterPaymentParamsWithContext(ctx context.Context) *ArkServiceRegisterPaymentParams {
|
||||
var ()
|
||||
return &ArkServiceRegisterPaymentParams{
|
||||
|
||||
Context: ctx,
|
||||
}
|
||||
}
|
||||
|
||||
// NewArkServiceRegisterPaymentParamsWithHTTPClient creates a new ArkServiceRegisterPaymentParams object
|
||||
// with the default values initialized, and the ability to set a custom HTTPClient for a request
|
||||
// with the ability to set a custom HTTPClient for a request.
|
||||
func NewArkServiceRegisterPaymentParamsWithHTTPClient(client *http.Client) *ArkServiceRegisterPaymentParams {
|
||||
var ()
|
||||
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
|
||||
/*
|
||||
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.
|
||||
Body *models.V1RegisterPaymentRequest
|
||||
|
||||
timeout time.Duration
|
||||
@@ -71,6 +71,21 @@ type ArkServiceRegisterPaymentParams struct {
|
||||
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)
|
||||
@@ -122,7 +137,6 @@ func (o *ArkServiceRegisterPaymentParams) WriteToRequest(r runtime.ClientRequest
|
||||
return err
|
||||
}
|
||||
var res []error
|
||||
|
||||
if o.Body != nil {
|
||||
if err := r.SetBodyParam(o.Body); err != nil {
|
||||
return err
|
||||
@@ -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
|
||||
}
|
||||
@@ -13,57 +13,57 @@ import (
|
||||
"github.com/go-openapi/errors"
|
||||
"github.com/go-openapi/runtime"
|
||||
cr "github.com/go-openapi/runtime/client"
|
||||
"github.com/go-openapi/strfmt"
|
||||
|
||||
strfmt "github.com/go-openapi/strfmt"
|
||||
|
||||
models "github.com/ark-network/ark-sdk/rest/service/models"
|
||||
"github.com/ark-network/ark-sdk/client/rest/service/models"
|
||||
)
|
||||
|
||||
// NewArkServiceTrustedOnboardingParams creates a new ArkServiceTrustedOnboardingParams object
|
||||
// with the default values initialized.
|
||||
// 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 {
|
||||
var ()
|
||||
return &ArkServiceTrustedOnboardingParams{
|
||||
|
||||
timeout: cr.DefaultTimeout,
|
||||
}
|
||||
}
|
||||
|
||||
// NewArkServiceTrustedOnboardingParamsWithTimeout creates a new ArkServiceTrustedOnboardingParams object
|
||||
// with the default values initialized, and the ability to set a timeout on a request
|
||||
// with the ability to set a timeout on a request.
|
||||
func NewArkServiceTrustedOnboardingParamsWithTimeout(timeout time.Duration) *ArkServiceTrustedOnboardingParams {
|
||||
var ()
|
||||
return &ArkServiceTrustedOnboardingParams{
|
||||
|
||||
timeout: timeout,
|
||||
}
|
||||
}
|
||||
|
||||
// NewArkServiceTrustedOnboardingParamsWithContext creates a new ArkServiceTrustedOnboardingParams object
|
||||
// with the default values initialized, and the ability to set a context for a request
|
||||
// with the ability to set a context for a request.
|
||||
func NewArkServiceTrustedOnboardingParamsWithContext(ctx context.Context) *ArkServiceTrustedOnboardingParams {
|
||||
var ()
|
||||
return &ArkServiceTrustedOnboardingParams{
|
||||
|
||||
Context: ctx,
|
||||
}
|
||||
}
|
||||
|
||||
// NewArkServiceTrustedOnboardingParamsWithHTTPClient creates a new ArkServiceTrustedOnboardingParams object
|
||||
// with the default values initialized, and the ability to set a custom HTTPClient for a request
|
||||
// with the ability to set a custom HTTPClient for a request.
|
||||
func NewArkServiceTrustedOnboardingParamsWithHTTPClient(client *http.Client) *ArkServiceTrustedOnboardingParams {
|
||||
var ()
|
||||
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
|
||||
/*
|
||||
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.
|
||||
Body *models.V1TrustedOnboardingRequest
|
||||
|
||||
timeout time.Duration
|
||||
@@ -71,6 +71,21 @@ type ArkServiceTrustedOnboardingParams struct {
|
||||
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)
|
||||
@@ -122,7 +137,6 @@ func (o *ArkServiceTrustedOnboardingParams) WriteToRequest(r runtime.ClientReque
|
||||
return err
|
||||
}
|
||||
var res []error
|
||||
|
||||
if o.Body != nil {
|
||||
if err := r.SetBodyParam(o.Body); err != nil {
|
||||
return err
|
||||
@@ -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
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
package arkservicerestclient
|
||||
package arkservice
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the swagger generate command
|
||||
@@ -8,10 +8,9 @@ package arkservicerestclient
|
||||
import (
|
||||
"github.com/go-openapi/runtime"
|
||||
httptransport "github.com/go-openapi/runtime/client"
|
||||
"github.com/go-openapi/strfmt"
|
||||
|
||||
strfmt "github.com/go-openapi/strfmt"
|
||||
|
||||
"github.com/ark-network/ark-sdk/rest/service/arkservicerestclient/ark_service"
|
||||
"github.com/ark-network/ark-sdk/client/rest/service/arkservice/ark_service"
|
||||
)
|
||||
|
||||
// Default ark v1 service proto HTTP client.
|
||||
@@ -56,9 +55,7 @@ func New(transport runtime.ClientTransport, formats strfmt.Registry) *ArkV1Servi
|
||||
|
||||
cli := new(ArkV1ServiceProto)
|
||||
cli.Transport = transport
|
||||
|
||||
cli.ArkService = ark_service.New(transport, formats)
|
||||
|
||||
return cli
|
||||
}
|
||||
|
||||
@@ -103,7 +100,7 @@ func (cfg *TransportConfig) WithSchemes(schemes []string) *TransportConfig {
|
||||
|
||||
// ArkV1ServiceProto is a client for ark v1 service proto
|
||||
type ArkV1ServiceProto struct {
|
||||
ArkService *ark_service.Client
|
||||
ArkService ark_service.ClientService
|
||||
|
||||
Transport runtime.ClientTransport
|
||||
}
|
||||
@@ -111,7 +108,5 @@ type ArkV1ServiceProto struct {
|
||||
// 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)
|
||||
|
||||
}
|
||||
127
pkg/client-sdk/client/rest/service/models/protobuf_any.go
Normal file
127
pkg/client-sdk/client/rest/service/models/protobuf_any.go
Normal 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
|
||||
}
|
||||
@@ -6,15 +6,16 @@ package models
|
||||
// Editing this file might prove futile when you re-run the swagger generate command
|
||||
|
||||
import (
|
||||
"context"
|
||||
"strconv"
|
||||
|
||||
strfmt "github.com/go-openapi/strfmt"
|
||||
|
||||
"github.com/go-openapi/errors"
|
||||
"github.com/go-openapi/strfmt"
|
||||
"github.com/go-openapi/swag"
|
||||
)
|
||||
|
||||
// RPCStatus rpc status
|
||||
//
|
||||
// swagger:model rpcStatus
|
||||
type RPCStatus struct {
|
||||
|
||||
@@ -43,7 +44,6 @@ func (m *RPCStatus) Validate(formats strfmt.Registry) error {
|
||||
}
|
||||
|
||||
func (m *RPCStatus) validateDetails(formats strfmt.Registry) error {
|
||||
|
||||
if swag.IsZero(m.Details) { // not required
|
||||
return nil
|
||||
}
|
||||
@@ -57,6 +57,47 @@ func (m *RPCStatus) validateDetails(formats strfmt.Registry) error {
|
||||
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
|
||||
}
|
||||
@@ -6,15 +6,16 @@ package models
|
||||
// Editing this file might prove futile when you re-run the swagger generate command
|
||||
|
||||
import (
|
||||
"context"
|
||||
"strconv"
|
||||
|
||||
strfmt "github.com/go-openapi/strfmt"
|
||||
|
||||
"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 {
|
||||
|
||||
@@ -40,7 +41,6 @@ func (m *V1ClaimPaymentRequest) Validate(formats strfmt.Registry) error {
|
||||
}
|
||||
|
||||
func (m *V1ClaimPaymentRequest) validateOutputs(formats strfmt.Registry) error {
|
||||
|
||||
if swag.IsZero(m.Outputs) { // not required
|
||||
return nil
|
||||
}
|
||||
@@ -54,6 +54,47 @@ func (m *V1ClaimPaymentRequest) validateOutputs(formats strfmt.Registry) error {
|
||||
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
|
||||
}
|
||||
@@ -6,5 +6,6 @@ package models
|
||||
// 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{}
|
||||
@@ -6,12 +6,14 @@ package models
|
||||
// Editing this file might prove futile when you re-run the swagger generate command
|
||||
|
||||
import (
|
||||
strfmt "github.com/go-openapi/strfmt"
|
||||
"context"
|
||||
|
||||
"github.com/go-openapi/strfmt"
|
||||
"github.com/go-openapi/swag"
|
||||
)
|
||||
|
||||
// V1FinalizePaymentRequest v1 finalize payment request
|
||||
//
|
||||
// swagger:model v1FinalizePaymentRequest
|
||||
type V1FinalizePaymentRequest struct {
|
||||
|
||||
@@ -24,6 +26,11 @@ 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 {
|
||||
@@ -6,5 +6,6 @@ package models
|
||||
// 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{}
|
||||
@@ -6,13 +6,15 @@ package models
|
||||
// Editing this file might prove futile when you re-run the swagger generate command
|
||||
|
||||
import (
|
||||
strfmt "github.com/go-openapi/strfmt"
|
||||
"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 {
|
||||
|
||||
@@ -49,7 +51,6 @@ func (m *V1GetEventStreamResponse) Validate(formats strfmt.Registry) error {
|
||||
}
|
||||
|
||||
func (m *V1GetEventStreamResponse) validateRoundFailed(formats strfmt.Registry) error {
|
||||
|
||||
if swag.IsZero(m.RoundFailed) { // not required
|
||||
return nil
|
||||
}
|
||||
@@ -58,6 +59,8 @@ func (m *V1GetEventStreamResponse) validateRoundFailed(formats strfmt.Registry)
|
||||
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
|
||||
}
|
||||
@@ -67,7 +70,6 @@ func (m *V1GetEventStreamResponse) validateRoundFailed(formats strfmt.Registry)
|
||||
}
|
||||
|
||||
func (m *V1GetEventStreamResponse) validateRoundFinalization(formats strfmt.Registry) error {
|
||||
|
||||
if swag.IsZero(m.RoundFinalization) { // not required
|
||||
return nil
|
||||
}
|
||||
@@ -76,6 +78,8 @@ func (m *V1GetEventStreamResponse) validateRoundFinalization(formats strfmt.Regi
|
||||
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
|
||||
}
|
||||
@@ -85,7 +89,6 @@ func (m *V1GetEventStreamResponse) validateRoundFinalization(formats strfmt.Regi
|
||||
}
|
||||
|
||||
func (m *V1GetEventStreamResponse) validateRoundFinalized(formats strfmt.Registry) error {
|
||||
|
||||
if swag.IsZero(m.RoundFinalized) { // not required
|
||||
return nil
|
||||
}
|
||||
@@ -94,6 +97,93 @@ func (m *V1GetEventStreamResponse) validateRoundFinalized(formats strfmt.Registr
|
||||
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
|
||||
}
|
||||
@@ -6,12 +6,14 @@ package models
|
||||
// Editing this file might prove futile when you re-run the swagger generate command
|
||||
|
||||
import (
|
||||
strfmt "github.com/go-openapi/strfmt"
|
||||
"context"
|
||||
|
||||
"github.com/go-openapi/strfmt"
|
||||
"github.com/go-openapi/swag"
|
||||
)
|
||||
|
||||
// V1GetInfoResponse v1 get info response
|
||||
//
|
||||
// swagger:model v1GetInfoResponse
|
||||
type V1GetInfoResponse struct {
|
||||
|
||||
@@ -39,6 +41,11 @@ 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 {
|
||||
@@ -6,13 +6,15 @@ package models
|
||||
// Editing this file might prove futile when you re-run the swagger generate command
|
||||
|
||||
import (
|
||||
strfmt "github.com/go-openapi/strfmt"
|
||||
"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 {
|
||||
|
||||
@@ -35,7 +37,6 @@ func (m *V1GetRoundByIDResponse) Validate(formats strfmt.Registry) error {
|
||||
}
|
||||
|
||||
func (m *V1GetRoundByIDResponse) validateRound(formats strfmt.Registry) error {
|
||||
|
||||
if swag.IsZero(m.Round) { // not required
|
||||
return nil
|
||||
}
|
||||
@@ -44,6 +45,43 @@ func (m *V1GetRoundByIDResponse) validateRound(formats strfmt.Registry) error {
|
||||
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
|
||||
}
|
||||
@@ -6,13 +6,15 @@ package models
|
||||
// Editing this file might prove futile when you re-run the swagger generate command
|
||||
|
||||
import (
|
||||
strfmt "github.com/go-openapi/strfmt"
|
||||
"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 {
|
||||
|
||||
@@ -35,7 +37,6 @@ func (m *V1GetRoundResponse) Validate(formats strfmt.Registry) error {
|
||||
}
|
||||
|
||||
func (m *V1GetRoundResponse) validateRound(formats strfmt.Registry) error {
|
||||
|
||||
if swag.IsZero(m.Round) { // not required
|
||||
return nil
|
||||
}
|
||||
@@ -44,6 +45,43 @@ func (m *V1GetRoundResponse) validateRound(formats strfmt.Registry) error {
|
||||
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
|
||||
}
|
||||
@@ -6,12 +6,14 @@ package models
|
||||
// Editing this file might prove futile when you re-run the swagger generate command
|
||||
|
||||
import (
|
||||
strfmt "github.com/go-openapi/strfmt"
|
||||
"context"
|
||||
|
||||
"github.com/go-openapi/strfmt"
|
||||
"github.com/go-openapi/swag"
|
||||
)
|
||||
|
||||
// V1Input v1 input
|
||||
//
|
||||
// swagger:model v1Input
|
||||
type V1Input struct {
|
||||
|
||||
@@ -27,6 +29,11 @@ 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 {
|
||||
@@ -6,15 +6,16 @@ package models
|
||||
// Editing this file might prove futile when you re-run the swagger generate command
|
||||
|
||||
import (
|
||||
"context"
|
||||
"strconv"
|
||||
|
||||
strfmt "github.com/go-openapi/strfmt"
|
||||
|
||||
"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 {
|
||||
|
||||
@@ -44,7 +45,6 @@ func (m *V1ListVtxosResponse) Validate(formats strfmt.Registry) error {
|
||||
}
|
||||
|
||||
func (m *V1ListVtxosResponse) validateSpendableVtxos(formats strfmt.Registry) error {
|
||||
|
||||
if swag.IsZero(m.SpendableVtxos) { // not required
|
||||
return nil
|
||||
}
|
||||
@@ -58,6 +58,8 @@ func (m *V1ListVtxosResponse) validateSpendableVtxos(formats strfmt.Registry) er
|
||||
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
|
||||
}
|
||||
@@ -69,7 +71,6 @@ func (m *V1ListVtxosResponse) validateSpendableVtxos(formats strfmt.Registry) er
|
||||
}
|
||||
|
||||
func (m *V1ListVtxosResponse) validateSpentVtxos(formats strfmt.Registry) error {
|
||||
|
||||
if swag.IsZero(m.SpentVtxos) { // not required
|
||||
return nil
|
||||
}
|
||||
@@ -83,6 +84,76 @@ func (m *V1ListVtxosResponse) validateSpentVtxos(formats strfmt.Registry) error
|
||||
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
|
||||
}
|
||||
@@ -6,12 +6,14 @@ package models
|
||||
// Editing this file might prove futile when you re-run the swagger generate command
|
||||
|
||||
import (
|
||||
strfmt "github.com/go-openapi/strfmt"
|
||||
"context"
|
||||
|
||||
"github.com/go-openapi/strfmt"
|
||||
"github.com/go-openapi/swag"
|
||||
)
|
||||
|
||||
// V1Node v1 node
|
||||
//
|
||||
// swagger:model v1Node
|
||||
type V1Node struct {
|
||||
|
||||
@@ -30,6 +32,11 @@ 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 {
|
||||
@@ -6,13 +6,15 @@ package models
|
||||
// Editing this file might prove futile when you re-run the swagger generate command
|
||||
|
||||
import (
|
||||
strfmt "github.com/go-openapi/strfmt"
|
||||
"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 {
|
||||
|
||||
@@ -41,7 +43,6 @@ func (m *V1OnboardRequest) Validate(formats strfmt.Registry) error {
|
||||
}
|
||||
|
||||
func (m *V1OnboardRequest) validateCongestionTree(formats strfmt.Registry) error {
|
||||
|
||||
if swag.IsZero(m.CongestionTree) { // not required
|
||||
return nil
|
||||
}
|
||||
@@ -50,6 +51,43 @@ func (m *V1OnboardRequest) validateCongestionTree(formats strfmt.Registry) error
|
||||
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
|
||||
}
|
||||
@@ -6,5 +6,6 @@ package models
|
||||
// Editing this file might prove futile when you re-run the swagger generate command
|
||||
|
||||
// V1OnboardResponse v1 onboard response
|
||||
//
|
||||
// swagger:model v1OnboardResponse
|
||||
type V1OnboardResponse interface{}
|
||||
@@ -6,12 +6,14 @@ package models
|
||||
// Editing this file might prove futile when you re-run the swagger generate command
|
||||
|
||||
import (
|
||||
strfmt "github.com/go-openapi/strfmt"
|
||||
"context"
|
||||
|
||||
"github.com/go-openapi/strfmt"
|
||||
"github.com/go-openapi/swag"
|
||||
)
|
||||
|
||||
// V1Output v1 output
|
||||
//
|
||||
// swagger:model v1Output
|
||||
type V1Output struct {
|
||||
|
||||
@@ -27,6 +29,11 @@ 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 {
|
||||
@@ -6,13 +6,15 @@ package models
|
||||
// Editing this file might prove futile when you re-run the swagger generate command
|
||||
|
||||
import (
|
||||
strfmt "github.com/go-openapi/strfmt"
|
||||
"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 {
|
||||
|
||||
@@ -38,7 +40,6 @@ func (m *V1PingResponse) Validate(formats strfmt.Registry) error {
|
||||
}
|
||||
|
||||
func (m *V1PingResponse) validateEvent(formats strfmt.Registry) error {
|
||||
|
||||
if swag.IsZero(m.Event) { // not required
|
||||
return nil
|
||||
}
|
||||
@@ -47,6 +48,43 @@ func (m *V1PingResponse) validateEvent(formats strfmt.Registry) error {
|
||||
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
|
||||
}
|
||||
@@ -6,15 +6,16 @@ package models
|
||||
// Editing this file might prove futile when you re-run the swagger generate command
|
||||
|
||||
import (
|
||||
"context"
|
||||
"strconv"
|
||||
|
||||
strfmt "github.com/go-openapi/strfmt"
|
||||
|
||||
"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 {
|
||||
|
||||
@@ -37,7 +38,6 @@ func (m *V1RegisterPaymentRequest) Validate(formats strfmt.Registry) error {
|
||||
}
|
||||
|
||||
func (m *V1RegisterPaymentRequest) validateInputs(formats strfmt.Registry) error {
|
||||
|
||||
if swag.IsZero(m.Inputs) { // not required
|
||||
return nil
|
||||
}
|
||||
@@ -51,6 +51,47 @@ func (m *V1RegisterPaymentRequest) validateInputs(formats strfmt.Registry) error
|
||||
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
|
||||
}
|
||||
@@ -6,12 +6,14 @@ package models
|
||||
// Editing this file might prove futile when you re-run the swagger generate command
|
||||
|
||||
import (
|
||||
strfmt "github.com/go-openapi/strfmt"
|
||||
"context"
|
||||
|
||||
"github.com/go-openapi/strfmt"
|
||||
"github.com/go-openapi/swag"
|
||||
)
|
||||
|
||||
// V1RegisterPaymentResponse v1 register payment response
|
||||
//
|
||||
// swagger:model v1RegisterPaymentResponse
|
||||
type V1RegisterPaymentResponse struct {
|
||||
|
||||
@@ -24,6 +26,11 @@ 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 {
|
||||
@@ -6,13 +6,15 @@ package models
|
||||
// Editing this file might prove futile when you re-run the swagger generate command
|
||||
|
||||
import (
|
||||
strfmt "github.com/go-openapi/strfmt"
|
||||
"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 {
|
||||
|
||||
@@ -35,7 +37,7 @@ type V1Round struct {
|
||||
PoolTx string `json:"poolTx,omitempty"`
|
||||
|
||||
// stage
|
||||
Stage V1RoundStage `json:"stage,omitempty"`
|
||||
Stage *V1RoundStage `json:"stage,omitempty"`
|
||||
|
||||
// start
|
||||
Start string `json:"start,omitempty"`
|
||||
@@ -60,7 +62,6 @@ func (m *V1Round) Validate(formats strfmt.Registry) error {
|
||||
}
|
||||
|
||||
func (m *V1Round) validateCongestionTree(formats strfmt.Registry) error {
|
||||
|
||||
if swag.IsZero(m.CongestionTree) { // not required
|
||||
return nil
|
||||
}
|
||||
@@ -69,6 +70,8 @@ func (m *V1Round) validateCongestionTree(formats strfmt.Registry) error {
|
||||
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
|
||||
}
|
||||
@@ -78,16 +81,79 @@ func (m *V1Round) validateCongestionTree(formats strfmt.Registry) error {
|
||||
}
|
||||
|
||||
func (m *V1Round) validateStage(formats strfmt.Registry) error {
|
||||
|
||||
if swag.IsZero(m.Stage) { // not required
|
||||
return nil
|
||||
}
|
||||
|
||||
if err := m.Stage.Validate(formats); err != nil {
|
||||
if ve, ok := err.(*errors.Validation); ok {
|
||||
return ve.ValidateName("stage")
|
||||
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 err
|
||||
}
|
||||
|
||||
return nil
|
||||
@@ -6,12 +6,14 @@ package models
|
||||
// Editing this file might prove futile when you re-run the swagger generate command
|
||||
|
||||
import (
|
||||
strfmt "github.com/go-openapi/strfmt"
|
||||
"context"
|
||||
|
||||
"github.com/go-openapi/strfmt"
|
||||
"github.com/go-openapi/swag"
|
||||
)
|
||||
|
||||
// V1RoundFailed v1 round failed
|
||||
//
|
||||
// swagger:model v1RoundFailed
|
||||
type V1RoundFailed struct {
|
||||
|
||||
@@ -27,6 +29,11 @@ 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 {
|
||||
@@ -6,13 +6,15 @@ package models
|
||||
// Editing this file might prove futile when you re-run the swagger generate command
|
||||
|
||||
import (
|
||||
strfmt "github.com/go-openapi/strfmt"
|
||||
"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 {
|
||||
|
||||
@@ -47,7 +49,6 @@ func (m *V1RoundFinalizationEvent) Validate(formats strfmt.Registry) error {
|
||||
}
|
||||
|
||||
func (m *V1RoundFinalizationEvent) validateCongestionTree(formats strfmt.Registry) error {
|
||||
|
||||
if swag.IsZero(m.CongestionTree) { // not required
|
||||
return nil
|
||||
}
|
||||
@@ -56,6 +57,43 @@ func (m *V1RoundFinalizationEvent) validateCongestionTree(formats strfmt.Registr
|
||||
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
|
||||
}
|
||||
@@ -6,12 +6,14 @@ package models
|
||||
// Editing this file might prove futile when you re-run the swagger generate command
|
||||
|
||||
import (
|
||||
strfmt "github.com/go-openapi/strfmt"
|
||||
"context"
|
||||
|
||||
"github.com/go-openapi/strfmt"
|
||||
"github.com/go-openapi/swag"
|
||||
)
|
||||
|
||||
// V1RoundFinalizedEvent v1 round finalized event
|
||||
//
|
||||
// swagger:model v1RoundFinalizedEvent
|
||||
type V1RoundFinalizedEvent struct {
|
||||
|
||||
@@ -27,6 +29,11 @@ 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 {
|
||||
@@ -6,18 +6,28 @@ package models
|
||||
// Editing this file might prove futile when you re-run the swagger generate command
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
|
||||
strfmt "github.com/go-openapi/strfmt"
|
||||
|
||||
"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"
|
||||
@@ -50,7 +60,7 @@ func init() {
|
||||
}
|
||||
|
||||
func (m V1RoundStage) validateV1RoundStageEnum(path, location string, value V1RoundStage) error {
|
||||
if err := validate.Enum(path, location, value, v1RoundStageEnum); err != nil {
|
||||
if err := validate.EnumCase(path, location, value, v1RoundStageEnum, true); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
@@ -70,3 +80,8 @@ func (m V1RoundStage) Validate(formats strfmt.Registry) error {
|
||||
}
|
||||
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
|
||||
}
|
||||
@@ -6,15 +6,16 @@ package models
|
||||
// Editing this file might prove futile when you re-run the swagger generate command
|
||||
|
||||
import (
|
||||
"context"
|
||||
"strconv"
|
||||
|
||||
strfmt "github.com/go-openapi/strfmt"
|
||||
|
||||
"github.com/go-openapi/errors"
|
||||
"github.com/go-openapi/strfmt"
|
||||
"github.com/go-openapi/swag"
|
||||
)
|
||||
|
||||
// V1Tree v1 tree
|
||||
//
|
||||
// swagger:model v1Tree
|
||||
type V1Tree struct {
|
||||
|
||||
@@ -37,7 +38,6 @@ func (m *V1Tree) Validate(formats strfmt.Registry) error {
|
||||
}
|
||||
|
||||
func (m *V1Tree) validateLevels(formats strfmt.Registry) error {
|
||||
|
||||
if swag.IsZero(m.Levels) { // not required
|
||||
return nil
|
||||
}
|
||||
@@ -51,6 +51,47 @@ func (m *V1Tree) validateLevels(formats strfmt.Registry) error {
|
||||
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
|
||||
}
|
||||
@@ -6,15 +6,16 @@ package models
|
||||
// Editing this file might prove futile when you re-run the swagger generate command
|
||||
|
||||
import (
|
||||
"context"
|
||||
"strconv"
|
||||
|
||||
strfmt "github.com/go-openapi/strfmt"
|
||||
|
||||
"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 {
|
||||
|
||||
@@ -37,7 +38,6 @@ func (m *V1TreeLevel) Validate(formats strfmt.Registry) error {
|
||||
}
|
||||
|
||||
func (m *V1TreeLevel) validateNodes(formats strfmt.Registry) error {
|
||||
|
||||
if swag.IsZero(m.Nodes) { // not required
|
||||
return nil
|
||||
}
|
||||
@@ -51,6 +51,47 @@ func (m *V1TreeLevel) validateNodes(formats strfmt.Registry) error {
|
||||
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
|
||||
}
|
||||
@@ -6,12 +6,14 @@ package models
|
||||
// Editing this file might prove futile when you re-run the swagger generate command
|
||||
|
||||
import (
|
||||
strfmt "github.com/go-openapi/strfmt"
|
||||
"context"
|
||||
|
||||
"github.com/go-openapi/strfmt"
|
||||
"github.com/go-openapi/swag"
|
||||
)
|
||||
|
||||
// V1TrustedOnboardingRequest v1 trusted onboarding request
|
||||
//
|
||||
// swagger:model v1TrustedOnboardingRequest
|
||||
type V1TrustedOnboardingRequest struct {
|
||||
|
||||
@@ -24,6 +26,11 @@ 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 {
|
||||
@@ -6,12 +6,14 @@ package models
|
||||
// Editing this file might prove futile when you re-run the swagger generate command
|
||||
|
||||
import (
|
||||
strfmt "github.com/go-openapi/strfmt"
|
||||
"context"
|
||||
|
||||
"github.com/go-openapi/strfmt"
|
||||
"github.com/go-openapi/swag"
|
||||
)
|
||||
|
||||
// V1TrustedOnboardingResponse v1 trusted onboarding response
|
||||
//
|
||||
// swagger:model v1TrustedOnboardingResponse
|
||||
type V1TrustedOnboardingResponse struct {
|
||||
|
||||
@@ -24,6 +26,11 @@ 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 {
|
||||
@@ -6,13 +6,15 @@ package models
|
||||
// Editing this file might prove futile when you re-run the swagger generate command
|
||||
|
||||
import (
|
||||
strfmt "github.com/go-openapi/strfmt"
|
||||
"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 {
|
||||
|
||||
@@ -57,7 +59,6 @@ func (m *V1Vtxo) Validate(formats strfmt.Registry) error {
|
||||
}
|
||||
|
||||
func (m *V1Vtxo) validateOutpoint(formats strfmt.Registry) error {
|
||||
|
||||
if swag.IsZero(m.Outpoint) { // not required
|
||||
return nil
|
||||
}
|
||||
@@ -66,6 +67,8 @@ func (m *V1Vtxo) validateOutpoint(formats strfmt.Registry) error {
|
||||
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
|
||||
}
|
||||
@@ -75,7 +78,6 @@ func (m *V1Vtxo) validateOutpoint(formats strfmt.Registry) error {
|
||||
}
|
||||
|
||||
func (m *V1Vtxo) validateReceiver(formats strfmt.Registry) error {
|
||||
|
||||
if swag.IsZero(m.Receiver) { // not required
|
||||
return nil
|
||||
}
|
||||
@@ -84,6 +86,68 @@ func (m *V1Vtxo) validateReceiver(formats strfmt.Registry) error {
|
||||
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
|
||||
}
|
||||
@@ -1,296 +0,0 @@
|
||||
package arksdk
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io"
|
||||
"net/http"
|
||||
"sort"
|
||||
|
||||
arkv1 "github.com/ark-network/ark/api-spec/protobuf/gen/ark/v1"
|
||||
"github.com/ark-network/ark/common"
|
||||
"github.com/ark-network/ark/common/tree"
|
||||
"github.com/decred/dcrd/dcrec/secp256k1/v4"
|
||||
"github.com/vulpemventures/go-elements/address"
|
||||
"github.com/vulpemventures/go-elements/network"
|
||||
"github.com/vulpemventures/go-elements/payment"
|
||||
"github.com/vulpemventures/go-elements/psetv2"
|
||||
"github.com/vulpemventures/go-elements/taproot"
|
||||
)
|
||||
|
||||
func getAddress(
|
||||
walletPubKey []byte,
|
||||
aspPubKey []byte,
|
||||
unilateralExitDelay int64,
|
||||
net string,
|
||||
) (offchainAddr, onchainAddr, redemptionAddr string, err error) {
|
||||
userPubkey, err := secp256k1.ParsePubKey(walletPubKey)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
aspPubkey, err := secp256k1.ParsePubKey(aspPubKey)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
arkNet, liquidNet := networkFromString(net)
|
||||
|
||||
arkAddr, err := common.EncodeAddress(arkNet.Addr, userPubkey, aspPubkey)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
p2wpkh := payment.FromPublicKey(userPubkey, liquidNet, nil)
|
||||
liquidAddr, err := p2wpkh.WitnessPubKeyHash()
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
vtxoTapKey, _, err := computeVtxoTaprootScript(
|
||||
userPubkey, aspPubkey, uint(unilateralExitDelay),
|
||||
)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
_, n := networkFromString(net)
|
||||
|
||||
pay, err := payment.FromTweakedKey(vtxoTapKey, n, nil)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
redemptionAddr, err = pay.TaprootAddress()
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
offchainAddr = arkAddr
|
||||
onchainAddr = liquidAddr
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
func computeVtxoTaprootScript(
|
||||
userPubkey, aspPubkey *secp256k1.PublicKey, exitDelay uint,
|
||||
) (*secp256k1.PublicKey, *taproot.TapscriptElementsProof, error) {
|
||||
redeemClosure := &tree.CSVSigClosure{
|
||||
Pubkey: userPubkey,
|
||||
Seconds: exitDelay,
|
||||
}
|
||||
|
||||
forfeitClosure := &tree.ForfeitClosure{
|
||||
Pubkey: userPubkey,
|
||||
AspPubkey: aspPubkey,
|
||||
}
|
||||
|
||||
redeemLeaf, err := redeemClosure.Leaf()
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
forfeitLeaf, err := forfeitClosure.Leaf()
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
vtxoTaprootTree := taproot.AssembleTaprootScriptTree(
|
||||
*redeemLeaf, *forfeitLeaf,
|
||||
)
|
||||
root := vtxoTaprootTree.RootNode.TapHash()
|
||||
|
||||
unspendableKey := tree.UnspendableKey()
|
||||
vtxoTaprootKey := taproot.ComputeTaprootOutputKey(unspendableKey, root[:])
|
||||
|
||||
redeemLeafHash := redeemLeaf.TapHash()
|
||||
proofIndex := vtxoTaprootTree.LeafProofIndex[redeemLeafHash]
|
||||
proof := vtxoTaprootTree.LeafMerkleProofs[proofIndex]
|
||||
|
||||
return vtxoTaprootKey, &proof, nil
|
||||
}
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
func networkFromString(net string) (*common.Network, *network.Network) {
|
||||
if net == "testnet" {
|
||||
return &common.TestNet, &network.Testnet
|
||||
}
|
||||
if net == "regtest" {
|
||||
return &common.RegTest, &network.Regtest
|
||||
}
|
||||
return &common.Liquid, &network.Liquid
|
||||
}
|
||||
|
||||
func testEsploraEndpoint(net *network.Network, url string) error {
|
||||
resp, err := http.Get(fmt.Sprintf("%s/asset/%s", url, net.AssetID))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
body, err := io.ReadAll(resp.Body)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if resp.StatusCode != http.StatusOK {
|
||||
return fmt.Errorf(string(body))
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func castCongestionTree(congestionTree tree.CongestionTree) *arkv1.Tree {
|
||||
levels := make([]*arkv1.TreeLevel, 0, len(congestionTree))
|
||||
for _, level := range congestionTree {
|
||||
levelProto := &arkv1.TreeLevel{
|
||||
Nodes: make([]*arkv1.Node, 0, len(level)),
|
||||
}
|
||||
|
||||
for _, node := range level {
|
||||
levelProto.Nodes = append(levelProto.Nodes, &arkv1.Node{
|
||||
Txid: node.Txid,
|
||||
Tx: node.Tx,
|
||||
ParentTxid: node.ParentTxid,
|
||||
})
|
||||
}
|
||||
|
||||
levels = append(levels, levelProto)
|
||||
}
|
||||
return &arkv1.Tree{
|
||||
Levels: levels,
|
||||
}
|
||||
}
|
||||
|
||||
func coinSelect(vtxos []vtxo, amount uint64, sortByExpirationTime bool) ([]vtxo, uint64, error) {
|
||||
selected := make([]vtxo, 0)
|
||||
notSelected := make([]vtxo, 0)
|
||||
selectedAmount := uint64(0)
|
||||
|
||||
if sortByExpirationTime {
|
||||
// sort vtxos by expiration (older first)
|
||||
sort.SliceStable(vtxos, func(i, j int) bool {
|
||||
if vtxos[i].expireAt == nil || vtxos[j].expireAt == nil {
|
||||
return false
|
||||
}
|
||||
|
||||
return vtxos[i].expireAt.Before(*vtxos[j].expireAt)
|
||||
})
|
||||
}
|
||||
|
||||
for _, vtxo := range vtxos {
|
||||
if selectedAmount >= amount {
|
||||
notSelected = append(notSelected, vtxo)
|
||||
break
|
||||
}
|
||||
|
||||
selected = append(selected, vtxo)
|
||||
selectedAmount += vtxo.amount
|
||||
}
|
||||
|
||||
if selectedAmount < amount {
|
||||
return nil, 0, fmt.Errorf("not enough funds to cover amount%d", amount)
|
||||
}
|
||||
|
||||
change := selectedAmount - amount
|
||||
|
||||
if change < DUST {
|
||||
if len(notSelected) > 0 {
|
||||
selected = append(selected, notSelected[0])
|
||||
change += notSelected[0].amount
|
||||
}
|
||||
}
|
||||
|
||||
return selected, change, 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
|
||||
}
|
||||
|
||||
func decodeReceiverAddress(addr string) (
|
||||
bool, []byte, *secp256k1.PublicKey, error,
|
||||
) {
|
||||
outputScript, err := address.ToOutputScript(addr)
|
||||
if err != nil {
|
||||
_, userPubkey, _, err := common.DecodeAddress(addr)
|
||||
if err != nil {
|
||||
return false, nil, nil, err
|
||||
}
|
||||
return false, nil, userPubkey, nil
|
||||
}
|
||||
|
||||
return true, outputScript, nil, nil
|
||||
}
|
||||
|
||||
func isOnchainOnly(receivers []*arkv1.Output) bool {
|
||||
for _, receiver := range receivers {
|
||||
isOnChain, _, _, err := decodeReceiverAddress(receiver.Address)
|
||||
if err != nil {
|
||||
continue
|
||||
}
|
||||
|
||||
if !isOnChain {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
@@ -5,6 +5,8 @@ import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
"github.com/ark-network/ark-sdk/client"
|
||||
"github.com/ark-network/ark-sdk/internal/utils"
|
||||
arkv1 "github.com/ark-network/ark/api-spec/protobuf/gen/ark/v1"
|
||||
"github.com/ark-network/ark/common"
|
||||
"github.com/ark-network/ark/common/tree"
|
||||
@@ -17,11 +19,9 @@ import (
|
||||
|
||||
func (a *arkClient) handleRoundStream(
|
||||
ctx context.Context,
|
||||
paymentID string,
|
||||
vtxosToSign []vtxo,
|
||||
receivers []*arkv1.Output,
|
||||
paymentID string, vtxosToSign []*client.Vtxo, receivers []*arkv1.Output,
|
||||
) (string, error) {
|
||||
eventStream, err := a.innerClient.getEventStream(ctx, paymentID, &arkv1.GetEventStreamRequest{})
|
||||
eventsCh, err := a.client.GetEventStream(ctx, paymentID, &arkv1.GetEventStreamRequest{})
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
@@ -40,7 +40,12 @@ func (a *arkClient) handleRoundStream(
|
||||
select {
|
||||
case <-ctx.Done():
|
||||
return "", ctx.Err()
|
||||
case event := <-eventStream.eventResp:
|
||||
case notify := <-eventsCh:
|
||||
if notify.Err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
event := notify.Event
|
||||
if e := event.GetRoundFailed(); e != nil {
|
||||
pingStop()
|
||||
return "", fmt.Errorf("round failed: %s", e.GetReason())
|
||||
@@ -51,7 +56,7 @@ func (a *arkClient) handleRoundStream(
|
||||
log.Info("a round finalization started")
|
||||
|
||||
signedForfeitTxs, err := a.handleRoundFinalization(
|
||||
e, vtxosToSign, receivers,
|
||||
ctx, e, vtxosToSign, receivers,
|
||||
)
|
||||
if err != nil {
|
||||
return "", err
|
||||
@@ -63,7 +68,7 @@ func (a *arkClient) handleRoundStream(
|
||||
}
|
||||
|
||||
log.Info("finalizing payment... ")
|
||||
_, err = a.innerClient.finalizePayment(ctx, &arkv1.FinalizePaymentRequest{
|
||||
_, err = a.client.FinalizePayment(ctx, &arkv1.FinalizePaymentRequest{
|
||||
SignedForfeitTxs: signedForfeitTxs,
|
||||
})
|
||||
if err != nil {
|
||||
@@ -77,15 +82,14 @@ func (a *arkClient) handleRoundStream(
|
||||
if event.GetRoundFinalized() != nil {
|
||||
return event.GetRoundFinalized().GetPoolTxid(), nil
|
||||
}
|
||||
case e := <-eventStream.err:
|
||||
return "", e
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (a *arkClient) handleRoundFinalization(
|
||||
ctx context.Context,
|
||||
finalization *arkv1.RoundFinalizationEvent,
|
||||
vtxosToSign []vtxo,
|
||||
vtxosToSign []*client.Vtxo,
|
||||
receivers []*arkv1.Output,
|
||||
) ([]string, error) {
|
||||
if err := a.validateCongestionTree(finalization, receivers); err != nil {
|
||||
@@ -93,7 +97,7 @@ func (a *arkClient) handleRoundFinalization(
|
||||
}
|
||||
|
||||
return a.loopAndSign(
|
||||
finalization.GetForfeitTxs(), vtxosToSign, finalization.GetConnectors(),
|
||||
ctx, finalization.GetForfeitTxs(), vtxosToSign, finalization.GetConnectors(),
|
||||
)
|
||||
}
|
||||
|
||||
@@ -107,21 +111,18 @@ func (a *arkClient) validateCongestionTree(
|
||||
return err
|
||||
}
|
||||
|
||||
congestionTree, err := toCongestionTree(finalization.GetCongestionTree())
|
||||
congestionTree, err := utils.ToCongestionTree(
|
||||
finalization.GetCongestionTree(),
|
||||
)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
connectors := finalization.GetConnectors()
|
||||
|
||||
aspPubkey, err := secp256k1.ParsePubKey(a.aspPubKey)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if !isOnchainOnly(receivers) {
|
||||
if !utils.IsOnchainOnly(receivers) {
|
||||
if err := tree.ValidateCongestionTree(
|
||||
congestionTree, poolTx, aspPubkey, int64(a.roundLifeTime),
|
||||
congestionTree, poolTx, a.StoreData.AspPubkey, a.RoundLifetime,
|
||||
); err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -131,7 +132,9 @@ func (a *arkClient) validateCongestionTree(
|
||||
return err
|
||||
}
|
||||
|
||||
if err := a.validateReceivers(ptx, receivers, &congestionTree, aspPubkey); err != nil {
|
||||
if err := a.validateReceivers(
|
||||
ptx, receivers, &congestionTree, a.StoreData.AspPubkey,
|
||||
); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -147,7 +150,9 @@ func (a *arkClient) validateReceivers(
|
||||
aspPubkey *secp256k1.PublicKey,
|
||||
) error {
|
||||
for _, receiver := range receivers {
|
||||
isOnChain, onchainScript, userPubkey, err := decodeReceiverAddress(receiver.Address)
|
||||
isOnChain, onchainScript, userPubkey, err := utils.DecodeReceiverAddress(
|
||||
receiver.Address,
|
||||
)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -157,7 +162,9 @@ func (a *arkClient) validateReceivers(
|
||||
return err
|
||||
}
|
||||
} else {
|
||||
if err := a.validateOffChainReceiver(congestionTree, receiver, userPubkey, aspPubkey); err != nil {
|
||||
if err := a.validateOffChainReceiver(
|
||||
congestionTree, receiver, userPubkey, aspPubkey,
|
||||
); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
@@ -195,8 +202,9 @@ func (a *arkClient) validateOffChainReceiver(
|
||||
userPubkey, aspPubkey *secp256k1.PublicKey,
|
||||
) error {
|
||||
found := false
|
||||
outputTapKey, _, err := computeVtxoTaprootScript(
|
||||
userPubkey, aspPubkey, uint(a.unilateralExitDelay),
|
||||
net := a.explorer.GetNetwork()
|
||||
outputTapKey, _, _, _, err := tree.ComputeVtxoTaprootScript(
|
||||
userPubkey, aspPubkey, uint(a.UnilateralExitDelay), net,
|
||||
)
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -233,7 +241,8 @@ func (a *arkClient) validateOffChainReceiver(
|
||||
}
|
||||
|
||||
func (a *arkClient) loopAndSign(
|
||||
forfeitTxs []string, vtxosToSign []vtxo, connectors []string,
|
||||
ctx context.Context,
|
||||
forfeitTxs []string, vtxosToSign []*client.Vtxo, connectors []string,
|
||||
) ([]string, error) {
|
||||
signedForfeits := make([]string, 0)
|
||||
|
||||
@@ -254,8 +263,8 @@ func (a *arkClient) loopAndSign(
|
||||
for _, input := range pset.Inputs {
|
||||
inputTxid := chainhash.Hash(input.PreviousTxid).String()
|
||||
for _, coin := range vtxosToSign {
|
||||
if inputTxid == coin.txid {
|
||||
signedPset, err := a.signForfeitTx(forfeitTx, pset, connectorsTxids)
|
||||
if inputTxid == coin.Txid {
|
||||
signedPset, err := a.signForfeitTx(ctx, forfeitTx, pset, connectorsTxids)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -269,7 +278,7 @@ func (a *arkClient) loopAndSign(
|
||||
}
|
||||
|
||||
func (a *arkClient) signForfeitTx(
|
||||
txStr string, tx *psetv2.Pset, connectorsTxids []string,
|
||||
ctx context.Context, txStr string, tx *psetv2.Pset, connectorsTxids []string,
|
||||
) (string, error) {
|
||||
connectorTxid := chainhash.Hash(tx.Inputs[0].PreviousTxid).String()
|
||||
connectorFound := false
|
||||
@@ -283,5 +292,5 @@ func (a *arkClient) signForfeitTx(
|
||||
return "", fmt.Errorf("connector txid %s not found in the connectors list", connectorTxid)
|
||||
}
|
||||
|
||||
return a.wallet.SignTransaction(a.explorerSvc, txStr)
|
||||
return a.wallet.SignTransaction(ctx, a.explorer, txStr)
|
||||
}
|
||||
|
||||
@@ -14,42 +14,28 @@ import (
|
||||
log "github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
func main() {
|
||||
var (
|
||||
//grpcAspUrl = "localhost:8080"
|
||||
restAspUrl = "http://localhost:8080"
|
||||
//grpcProtocol = arksdk.Grpc
|
||||
restProtocol = arksdk.Rest
|
||||
ctx = context.Background()
|
||||
var (
|
||||
aspUrl = "localhost:8080"
|
||||
clientType = arksdk.GrpcClient
|
||||
password = "password"
|
||||
walletType = arksdk.SingleKeyWallet
|
||||
)
|
||||
|
||||
aspUrl = restAspUrl
|
||||
protocol = restProtocol
|
||||
)
|
||||
func main() {
|
||||
ctx := context.Background()
|
||||
|
||||
log.Info("alice is setting up her ark wallet...")
|
||||
aliceConfigStore, err := inmemorystore.New(aspUrl, protocol)
|
||||
|
||||
aliceArkClient, err := setupArkClient()
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
aliceWalletStore := inmemorystore.NewWalletStore()
|
||||
aliceWallet, err := arksdk.NewSingleKeyWallet(ctx, aliceWalletStore)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
aliceArkClient, err := arksdk.New(
|
||||
ctx,
|
||||
aliceWallet,
|
||||
aliceConfigStore,
|
||||
)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
if err := aliceArkClient.Connect(ctx); err != nil {
|
||||
if err := aliceArkClient.Unlock(ctx, password); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
//nolint:all
|
||||
defer aliceArkClient.Lock(ctx, password)
|
||||
|
||||
log.Info("alice is acquiring onchain funds...")
|
||||
_, aliceOnchainAddr, err := aliceArkClient.Receive(ctx)
|
||||
@@ -61,9 +47,7 @@ func main() {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
if err := generateBlock(); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
time.Sleep(5 * time.Second)
|
||||
|
||||
onboardAmount := uint64(20000)
|
||||
log.Infof("alice is onboarding with %d sats offchain...", onboardAmount)
|
||||
@@ -88,33 +72,18 @@ func main() {
|
||||
log.Infof("alice onchain balance: %d", aliceBalance.OnchainBalance.SpendableAmount)
|
||||
log.Infof("alice offchain balance: %d", aliceBalance.OffchainBalance.Total)
|
||||
|
||||
bobConfigStore, err := inmemorystore.New(aspUrl, protocol)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
fmt.Println("")
|
||||
log.Info("bob is setting up his ark wallet...")
|
||||
bobWalletStore := inmemorystore.NewWalletStore()
|
||||
if _, err := bobWalletStore.CreatePrivateKey(); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
bobWallet, err := arksdk.NewSingleKeyWallet(ctx, bobWalletStore)
|
||||
bobArkClient, err := setupArkClient()
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
bobArkClient, err := arksdk.New(
|
||||
ctx, bobWallet, bobConfigStore,
|
||||
)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
if err := bobArkClient.Connect(ctx); err != nil {
|
||||
if err := bobArkClient.Unlock(ctx, password); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
//nolint:all
|
||||
defer bobArkClient.Lock(ctx, password)
|
||||
|
||||
bobOffchainAddr, _, err := bobArkClient.Receive(ctx)
|
||||
if err != nil {
|
||||
@@ -130,17 +99,17 @@ func main() {
|
||||
log.Infof("bob offchain balance: %d", bobBalance.OffchainBalance.Total)
|
||||
|
||||
amount := uint64(1000)
|
||||
receivers := []arksdk.Receiver{
|
||||
{
|
||||
To: bobOffchainAddr,
|
||||
Amount: amount,
|
||||
},
|
||||
}
|
||||
|
||||
fmt.Println("")
|
||||
log.Infof("alice is sending %d sats to bob offchain...", amount)
|
||||
txid, err = aliceArkClient.SendOffChain(
|
||||
ctx,
|
||||
false,
|
||||
[]arksdk.Receiver{
|
||||
{
|
||||
To: bobOffchainAddr,
|
||||
Amount: amount,
|
||||
},
|
||||
})
|
||||
|
||||
txid, err = aliceArkClient.SendOffChain(ctx, false, receivers)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
@@ -171,6 +140,28 @@ func main() {
|
||||
log.Infof("bob offchain balance: %d", bobBalance.OffchainBalance.Total)
|
||||
}
|
||||
|
||||
func setupArkClient() (arksdk.ArkClient, error) {
|
||||
storeSvc, err := inmemorystore.NewConfigStore()
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to setup store: %s", err)
|
||||
}
|
||||
client, err := arksdk.New(storeSvc)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to setup ark client: %s", err)
|
||||
}
|
||||
|
||||
if err := client.Init(context.Background(), arksdk.InitArgs{
|
||||
WalletType: walletType,
|
||||
ClientType: clientType,
|
||||
AspUrl: aspUrl,
|
||||
Password: password,
|
||||
}); err != nil {
|
||||
return nil, fmt.Errorf("failed to initialize wallet: %s", err)
|
||||
}
|
||||
|
||||
return client, nil
|
||||
}
|
||||
|
||||
func runCommand(name string, arg ...string) (string, error) {
|
||||
errb := new(strings.Builder)
|
||||
cmd := newCommand(name, arg...)
|
||||
|
||||
@@ -48,11 +48,11 @@ require (
|
||||
go.opentelemetry.io/otel v1.24.0 // indirect
|
||||
go.opentelemetry.io/otel/metric v1.24.0 // indirect
|
||||
go.opentelemetry.io/otel/trace v1.24.0 // indirect
|
||||
golang.org/x/crypto v0.23.0 // indirect
|
||||
golang.org/x/net v0.25.0 // indirect
|
||||
golang.org/x/crypto v0.25.0 // indirect
|
||||
golang.org/x/net v0.27.0 // indirect
|
||||
golang.org/x/sync v0.7.0 // indirect
|
||||
golang.org/x/sys v0.20.0 // indirect
|
||||
golang.org/x/text v0.15.0 // indirect
|
||||
golang.org/x/sys v0.22.0 // indirect
|
||||
golang.org/x/text v0.16.0 // indirect
|
||||
google.golang.org/genproto/googleapis/api v0.0.0-20240528184218-531527333157 // indirect
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20240528184218-531527333157 // indirect
|
||||
google.golang.org/grpc v1.65.0 // indirect
|
||||
|
||||
@@ -147,15 +147,15 @@ go.opentelemetry.io/otel/trace v1.24.0/go.mod h1:HPc3Xr/cOApsBI154IU0OI0HJexz+aw
|
||||
golang.org/x/crypto v0.0.0-20170930174604-9419663f5a44/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
|
||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
||||
golang.org/x/crypto v0.23.0 h1:dIJU/v2J8Mdglj/8rJ6UUOM3Zc9zLZxVZwwxMooUSAI=
|
||||
golang.org/x/crypto v0.23.0/go.mod h1:CKFgDieR+mRhux2Lsu27y0fO304Db0wZe70UKqHu0v8=
|
||||
golang.org/x/crypto v0.25.0 h1:ypSNr+bnYL2YhwoMt2zPxHFmbAN1KZs/njMG3hxUp30=
|
||||
golang.org/x/crypto v0.25.0/go.mod h1:T+wALwcMOSE0kXgUAnPAHqTLW+XHgcELELW8VaDgm/M=
|
||||
golang.org/x/net v0.0.0-20180719180050-a680a1efc54d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||
golang.org/x/net v0.0.0-20200520004742-59133d7f0dd7/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
|
||||
golang.org/x/net v0.0.0-20200813134508-3edf25e44fcc/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA=
|
||||
golang.org/x/net v0.25.0 h1:d/OCCoBEUq33pjydKrGQhw7IlUPI2Oylr+8qLx49kac=
|
||||
golang.org/x/net v0.25.0/go.mod h1:JkAGAh7GEvH74S6FOH42FLoXpXbE/aqXSrIQjXgsiwM=
|
||||
golang.org/x/net v0.27.0 h1:5K3Njcw06/l2y9vpGCSdcxWOYHOUk3dVNGDXN+FvAys=
|
||||
golang.org/x/net v0.27.0/go.mod h1:dDi0PyhWNoiUOrAS8uXv/vnScO4wnHQO4mj9fn/RytE=
|
||||
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.7.0 h1:YsImfSBoP9QPYL0xyKJPq0gcaJdG3rInoqxTWbfQu9M=
|
||||
golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
|
||||
@@ -169,13 +169,13 @@ golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7w
|
||||
golang.org/x/sys v0.0.0-20200519105757-fe76b779f299/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200814200057-3d37ad5750ed/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.20.0 h1:Od9JTbYCk261bKm4M/mw7AklTlFYIa0bIp9BgSm1S8Y=
|
||||
golang.org/x/sys v0.20.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||
golang.org/x/sys v0.22.0 h1:RI27ohtqKCnwULzJLqkv897zojh5/DwS/ENaMzUOaWI=
|
||||
golang.org/x/sys v0.22.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
|
||||
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||
golang.org/x/text v0.15.0 h1:h1V/4gjBv8v9cjcR6+AR5+/cIYK5N/WAgiv4xlsEtAk=
|
||||
golang.org/x/text v0.15.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
|
||||
golang.org/x/text v0.16.0 h1:a94ExnEXNtEwYLGJSIUxnWoxoRz/ZcCsV63ROupILh4=
|
||||
golang.org/x/text v0.16.0/go.mod h1:GhwF1Be+LQoKShO3cGOHzqOgRrGaYc9AvblQOmPVHnI=
|
||||
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
|
||||
@@ -16,13 +16,26 @@
|
||||
logArea.scrollTop = logArea.scrollHeight;
|
||||
}
|
||||
|
||||
async function conn() {
|
||||
async function initWallet() {
|
||||
try {
|
||||
await connect();
|
||||
logMessage("Connected to ASP");
|
||||
const walletType = "singlekey"
|
||||
const clientType = "rest"
|
||||
const privateKey = document.getElementById("prvkey").value;
|
||||
const password = document.getElementById("i_password").value;
|
||||
if (!password) {
|
||||
logMessage("Init error: password is required");
|
||||
return;
|
||||
}
|
||||
const aspUrl = document.getElementById("aspUrl").value;
|
||||
if (!aspUrl) {
|
||||
logMessage("Init error: asp url is required");
|
||||
return;
|
||||
}
|
||||
await init(walletType, clientType, aspUrl, privateKey, password);
|
||||
logMessage("wallet initialized and connected to ASP");
|
||||
await config();
|
||||
} catch (err) {
|
||||
logMessage("Connect error: " + err.message);
|
||||
logMessage("Init error: " + err.message);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -45,13 +58,18 @@
|
||||
|
||||
|
||||
async function send() {
|
||||
const password = document.getElementById("s_password").value;
|
||||
if (!password) {
|
||||
logMessage("Send error: password is required");
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
const address = document.getElementById("sendAddress").value;
|
||||
if (!address) {
|
||||
logMessage("Send error: Address is required");
|
||||
return;
|
||||
}
|
||||
|
||||
const amountStr = document.getElementById("amountToSend").value;
|
||||
if (!amountStr) {
|
||||
logMessage("Send error: Amount is required");
|
||||
@@ -59,10 +77,13 @@
|
||||
}
|
||||
const amount = parseInt(amountStr, 10);
|
||||
|
||||
await unlock(password);
|
||||
const txID = await sendOffChain(false, [{ To: address, Amount: amount }]);
|
||||
logMessage("Sent money with tx ID: " + txID);
|
||||
} catch (err) {
|
||||
logMessage("Send error: " + err.message);
|
||||
} finally {
|
||||
await lock(password);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -72,32 +93,48 @@
|
||||
logMessage("ASP URL: " + aspUrl);
|
||||
|
||||
const aspPubKeyHex = await getAspPubKeyHex();
|
||||
logMessage("ASP PubKey Hex: " + aspPubKeyHex);
|
||||
logMessage("ASP PubKey: " + aspPubKeyHex);
|
||||
|
||||
const transportProtocol = await getTransportProtocol();
|
||||
logMessage("Transport Protocol: " + transportProtocol);
|
||||
const walletType = await getWalletType();
|
||||
logMessage("Wallet Type: " + walletType);
|
||||
|
||||
const explorerUrl = await getExplorerUrl();
|
||||
logMessage("Explorer URL: " + explorerUrl);
|
||||
const clientType = await getClientType();
|
||||
logMessage("Client Type: " + clientType);
|
||||
|
||||
const network = await getNetwork();
|
||||
logMessage("Network: " + network);
|
||||
const roundLifetime = await getRoundLifetime();
|
||||
logMessage("Round Lifetime: " + roundLifetime);
|
||||
|
||||
const unilateralExitDelay = await getUnilateralExitDelay();
|
||||
logMessage("Unilateral Exit Delay: " + unilateralExitDelay);
|
||||
|
||||
const minRelayFee = await getMinRelayFee();
|
||||
logMessage("Min Relay Fee: " + minRelayFee);
|
||||
} catch (err) {
|
||||
logMessage("Config error: " + err.message);
|
||||
}
|
||||
}
|
||||
|
||||
async function board() {
|
||||
logMessage("Board button clicked");
|
||||
const amountStr = document.getElementById("amount").value;
|
||||
const amount = parseInt(amountStr, 10);
|
||||
logMessage("Amount provided: " + amount);
|
||||
const password = document.getElementById("o_password").value;
|
||||
if (!password) {
|
||||
logMessage("Onboard error: password is required");
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
console.log("unlocking...");
|
||||
await unlock(password);
|
||||
console.log(amount, password);
|
||||
const txID = await onboard(amount);
|
||||
logMessage("Onboarded with amount: " + amount + " and txID: " + txID + ", if in regtest mine a block");
|
||||
} catch (err) {
|
||||
logMessage("Board error: " + err.message);
|
||||
logMessage("Onboard error: " + err.message);
|
||||
} finally {
|
||||
await lock(password);
|
||||
}
|
||||
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
@@ -106,7 +143,10 @@
|
||||
<div>
|
||||
<h2>Wallet</h2>
|
||||
<div>
|
||||
<button onclick="conn()">Connect</button>
|
||||
<button onclick="initWallet()">Init</button>
|
||||
<input type="text" id="aspUrl" placeholder="http://localhost:8080">
|
||||
<input type="password" id="i_password" placeholder="password">
|
||||
<input type="text" id="prvkey" placeholder="Optional: privkey (hex)">
|
||||
</div>
|
||||
<div>
|
||||
<button onclick="receiveAddresses()">Receive</button>
|
||||
@@ -117,11 +157,13 @@
|
||||
<div>
|
||||
<button onclick="board()">Onboard</button>
|
||||
<input type="text" id="amount" placeholder="Amount">
|
||||
<input type="password" id="o_password" placeholder="password">
|
||||
</div>
|
||||
<div>
|
||||
<button onclick="send()">Send</button>
|
||||
<input type="text" id="sendAddress" placeholder="Offchain Address">
|
||||
<input type="text" id="amountToSend" placeholder="Amount">
|
||||
<input type="password" id="s_password" placeholder="password">
|
||||
</div>
|
||||
<div>
|
||||
<button onclick="config()">Config</button>
|
||||
|
||||
@@ -5,15 +5,30 @@ package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
inmemorystore "github.com/ark-network/ark-sdk/store/inmemory"
|
||||
arksdkwasm "github.com/ark-network/ark-sdk/wasm"
|
||||
)
|
||||
|
||||
func main() {
|
||||
var (
|
||||
aspUrl = "http://localhost:8080"
|
||||
ctx = context.Background()
|
||||
ctx = context.Background()
|
||||
)
|
||||
|
||||
arksdkwasm.New(ctx, aspUrl)
|
||||
store, _ := arksdkwasm.NewLocalStorageStore()
|
||||
if store != nil {
|
||||
if err := arksdkwasm.New(ctx, store); err != nil {
|
||||
fmt.Println(err)
|
||||
}
|
||||
} else {
|
||||
storeSvc, err := inmemorystore.NewConfigStore()
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
return
|
||||
}
|
||||
if err := arksdkwasm.New(ctx, storeSvc); err != nil {
|
||||
fmt.Println(err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
34
pkg/client-sdk/explorer/explorer.go
Normal file
34
pkg/client-sdk/explorer/explorer.go
Normal file
@@ -0,0 +1,34 @@
|
||||
package explorer
|
||||
|
||||
import "github.com/vulpemventures/go-elements/network"
|
||||
|
||||
const (
|
||||
BitcoinExplorer = "bitcoin"
|
||||
LiquidExplorer = "liquid"
|
||||
)
|
||||
|
||||
type Utxo struct {
|
||||
Txid string `json:"txid"`
|
||||
Vout uint32 `json:"vout"`
|
||||
Amount uint64 `json:"value"`
|
||||
Asset string `json:"asset"`
|
||||
Status struct {
|
||||
Confirmed bool `json:"confirmed"`
|
||||
Blocktime int64 `json:"block_time"`
|
||||
} `json:"status"`
|
||||
}
|
||||
|
||||
type Explorer interface {
|
||||
GetTxHex(txid string) (string, error)
|
||||
Broadcast(txHex string) (string, error)
|
||||
GetUtxos(addr string) ([]Utxo, error)
|
||||
GetBalance(addr string) (uint64, error)
|
||||
GetRedeemedVtxosBalance(
|
||||
addr string, unilateralExitDelay int64,
|
||||
) (uint64, map[int64]uint64, error)
|
||||
GetTxBlockTime(
|
||||
txid string,
|
||||
) (confirmed bool, blocktime int64, err error)
|
||||
GetNetwork() network.Network
|
||||
BaseUrl() string
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package arksdk
|
||||
package liquidexplorer
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
@@ -9,56 +9,36 @@ import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/ark-network/ark-sdk/explorer"
|
||||
"github.com/ark-network/ark/common"
|
||||
"github.com/vulpemventures/go-elements/network"
|
||||
"github.com/vulpemventures/go-elements/psetv2"
|
||||
"github.com/vulpemventures/go-elements/transaction"
|
||||
)
|
||||
|
||||
type utxo struct {
|
||||
Txid string `json:"txid"`
|
||||
Vout uint32 `json:"vout"`
|
||||
Amount uint64 `json:"value"`
|
||||
Asset string `json:"asset"`
|
||||
Status struct {
|
||||
Confirmed bool `json:"confirmed"`
|
||||
Blocktime int64 `json:"block_time"`
|
||||
} `json:"status"`
|
||||
}
|
||||
|
||||
type Explorer interface {
|
||||
GetTxHex(txid string) (string, error)
|
||||
Broadcast(txHex string) (string, error)
|
||||
GetUtxos(addr string) ([]utxo, error)
|
||||
GetBalance(addr, asset string) (uint64, error)
|
||||
GetRedeemedVtxosBalance(
|
||||
addr string, unilateralExitDelay int64,
|
||||
) (uint64, map[int64]uint64, error)
|
||||
GetTxBlockTime(
|
||||
txid string,
|
||||
) (confirmed bool, blocktime int64, err error)
|
||||
GetNetwork() *network.Network
|
||||
}
|
||||
|
||||
type explorer struct {
|
||||
type liquidExplorer struct {
|
||||
cache map[string]string
|
||||
baseUrl string
|
||||
net string
|
||||
}
|
||||
|
||||
func NewExplorer(baseUrl string, net string) Explorer {
|
||||
return &explorer{
|
||||
func NewExplorer(baseUrl string, net string) explorer.Explorer {
|
||||
return &liquidExplorer{
|
||||
cache: make(map[string]string),
|
||||
baseUrl: baseUrl,
|
||||
net: net,
|
||||
}
|
||||
}
|
||||
|
||||
func (e *explorer) GetNetwork() *network.Network {
|
||||
_, liquidNet := networkFromString(e.net)
|
||||
return liquidNet
|
||||
func (e *liquidExplorer) BaseUrl() string {
|
||||
return e.baseUrl
|
||||
}
|
||||
|
||||
func (e *explorer) GetTxHex(txid string) (string, error) {
|
||||
func (e *liquidExplorer) GetNetwork() network.Network {
|
||||
return e.liquidNetwork()
|
||||
}
|
||||
|
||||
func (e *liquidExplorer) GetTxHex(txid string) (string, error) {
|
||||
if hex, ok := e.cache[txid]; ok {
|
||||
return hex, nil
|
||||
}
|
||||
@@ -73,7 +53,7 @@ func (e *explorer) GetTxHex(txid string) (string, error) {
|
||||
return txHex, nil
|
||||
}
|
||||
|
||||
func (e *explorer) Broadcast(txStr string) (string, error) {
|
||||
func (e *liquidExplorer) Broadcast(txStr string) (string, error) {
|
||||
tx, err := transaction.NewTxFromHex(txStr)
|
||||
if err != nil {
|
||||
pset, err := psetv2.NewPsetFromBase64(txStr)
|
||||
@@ -104,7 +84,7 @@ func (e *explorer) Broadcast(txStr string) (string, error) {
|
||||
return txid, nil
|
||||
}
|
||||
|
||||
func (e *explorer) GetUtxos(addr string) ([]utxo, error) {
|
||||
func (e *liquidExplorer) GetUtxos(addr string) ([]explorer.Utxo, error) {
|
||||
resp, err := http.Get(fmt.Sprintf("%s/address/%s/utxo", e.baseUrl, addr))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -118,7 +98,7 @@ func (e *explorer) GetUtxos(addr string) ([]utxo, error) {
|
||||
if resp.StatusCode != http.StatusOK {
|
||||
return nil, fmt.Errorf(string(body))
|
||||
}
|
||||
payload := []utxo{}
|
||||
payload := []explorer.Utxo{}
|
||||
if err := json.Unmarshal(body, &payload); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -126,11 +106,12 @@ func (e *explorer) GetUtxos(addr string) ([]utxo, error) {
|
||||
return payload, nil
|
||||
}
|
||||
|
||||
func (e *explorer) GetBalance(addr, asset string) (uint64, error) {
|
||||
func (e *liquidExplorer) GetBalance(addr string) (uint64, error) {
|
||||
payload, err := e.GetUtxos(addr)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
asset := e.liquidNetwork().AssetID
|
||||
|
||||
balance := uint64(0)
|
||||
for _, p := range payload {
|
||||
@@ -142,7 +123,7 @@ func (e *explorer) GetBalance(addr, asset string) (uint64, error) {
|
||||
return balance, nil
|
||||
}
|
||||
|
||||
func (e *explorer) GetRedeemedVtxosBalance(
|
||||
func (e *liquidExplorer) GetRedeemedVtxosBalance(
|
||||
addr string, unilateralExitDelay int64,
|
||||
) (spendableBalance uint64, lockedBalance map[int64]uint64, err error) {
|
||||
utxos, err := e.GetUtxos(addr)
|
||||
@@ -174,7 +155,7 @@ func (e *explorer) GetRedeemedVtxosBalance(
|
||||
return
|
||||
}
|
||||
|
||||
func (e *explorer) GetTxBlockTime(
|
||||
func (e *liquidExplorer) GetTxBlockTime(
|
||||
txid string,
|
||||
) (confirmed bool, blocktime int64, err error) {
|
||||
resp, err := http.Get(fmt.Sprintf("%s/tx/%s", e.baseUrl, txid))
|
||||
@@ -209,7 +190,7 @@ func (e *explorer) GetTxBlockTime(
|
||||
|
||||
}
|
||||
|
||||
func (e *explorer) getTxHex(txid string) (string, error) {
|
||||
func (e *liquidExplorer) getTxHex(txid string) (string, error) {
|
||||
resp, err := http.Get(fmt.Sprintf("%s/tx/%s/hex", e.baseUrl, txid))
|
||||
if err != nil {
|
||||
return "", err
|
||||
@@ -229,7 +210,7 @@ func (e *explorer) getTxHex(txid string) (string, error) {
|
||||
return hex, nil
|
||||
}
|
||||
|
||||
func (e *explorer) broadcast(txHex string) (string, error) {
|
||||
func (e *liquidExplorer) broadcast(txHex string) (string, error) {
|
||||
body := bytes.NewBuffer([]byte(txHex))
|
||||
|
||||
resp, err := http.Post(fmt.Sprintf("%s/tx", e.baseUrl), "text/plain", body)
|
||||
@@ -248,3 +229,13 @@ func (e *explorer) broadcast(txHex string) (string, error) {
|
||||
|
||||
return string(bodyResponse), nil
|
||||
}
|
||||
|
||||
func (e *liquidExplorer) liquidNetwork() network.Network {
|
||||
if e.net == common.LiquidTestNet.Name {
|
||||
return network.Testnet
|
||||
}
|
||||
if e.net == common.LiquidRegTest.Name {
|
||||
return network.Regtest
|
||||
}
|
||||
return network.Liquid
|
||||
}
|
||||
@@ -19,7 +19,9 @@ require (
|
||||
github.com/go-openapi/swag v0.23.0
|
||||
github.com/go-openapi/validate v0.24.0
|
||||
github.com/sirupsen/logrus v1.9.3
|
||||
github.com/stretchr/testify v1.9.0
|
||||
github.com/vulpemventures/go-elements v0.5.3
|
||||
golang.org/x/crypto v0.25.0
|
||||
google.golang.org/grpc v1.65.0
|
||||
)
|
||||
|
||||
@@ -28,6 +30,7 @@ require (
|
||||
github.com/btcsuite/btcd/btcutil v1.1.5 // indirect
|
||||
github.com/btcsuite/btcd/btcutil/psbt v1.1.9 // indirect
|
||||
github.com/btcsuite/btclog v0.0.0-20170628155309-84c8d2346e9f // indirect
|
||||
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
|
||||
github.com/decred/dcrd/crypto/blake256 v1.0.1 // indirect
|
||||
github.com/go-logr/logr v1.4.1 // indirect
|
||||
github.com/go-logr/stdr v1.2.2 // indirect
|
||||
@@ -43,16 +46,16 @@ require (
|
||||
github.com/mitchellh/mapstructure v1.5.0 // indirect
|
||||
github.com/oklog/ulid v1.3.1 // indirect
|
||||
github.com/opentracing/opentracing-go v1.2.0 // indirect
|
||||
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
|
||||
github.com/vulpemventures/fastsha256 v0.0.0-20160815193821-637e65642941 // indirect
|
||||
go.mongodb.org/mongo-driver v1.14.0 // indirect
|
||||
go.opentelemetry.io/otel v1.24.0 // indirect
|
||||
go.opentelemetry.io/otel/metric v1.24.0 // indirect
|
||||
go.opentelemetry.io/otel/trace v1.24.0 // indirect
|
||||
golang.org/x/crypto v0.23.0 // indirect
|
||||
golang.org/x/net v0.25.0 // indirect
|
||||
golang.org/x/net v0.27.0 // indirect
|
||||
golang.org/x/sync v0.7.0 // indirect
|
||||
golang.org/x/sys v0.20.0 // indirect
|
||||
golang.org/x/text v0.15.0 // indirect
|
||||
golang.org/x/sys v0.22.0 // indirect
|
||||
golang.org/x/text v0.16.0 // indirect
|
||||
google.golang.org/genproto/googleapis/api v0.0.0-20240528184218-531527333157 // indirect
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20240528184218-531527333157 // indirect
|
||||
google.golang.org/protobuf v1.34.1 // indirect
|
||||
|
||||
@@ -147,15 +147,15 @@ go.opentelemetry.io/otel/trace v1.24.0/go.mod h1:HPc3Xr/cOApsBI154IU0OI0HJexz+aw
|
||||
golang.org/x/crypto v0.0.0-20170930174604-9419663f5a44/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
|
||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
||||
golang.org/x/crypto v0.23.0 h1:dIJU/v2J8Mdglj/8rJ6UUOM3Zc9zLZxVZwwxMooUSAI=
|
||||
golang.org/x/crypto v0.23.0/go.mod h1:CKFgDieR+mRhux2Lsu27y0fO304Db0wZe70UKqHu0v8=
|
||||
golang.org/x/crypto v0.25.0 h1:ypSNr+bnYL2YhwoMt2zPxHFmbAN1KZs/njMG3hxUp30=
|
||||
golang.org/x/crypto v0.25.0/go.mod h1:T+wALwcMOSE0kXgUAnPAHqTLW+XHgcELELW8VaDgm/M=
|
||||
golang.org/x/net v0.0.0-20180719180050-a680a1efc54d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||
golang.org/x/net v0.0.0-20200520004742-59133d7f0dd7/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
|
||||
golang.org/x/net v0.0.0-20200813134508-3edf25e44fcc/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA=
|
||||
golang.org/x/net v0.25.0 h1:d/OCCoBEUq33pjydKrGQhw7IlUPI2Oylr+8qLx49kac=
|
||||
golang.org/x/net v0.25.0/go.mod h1:JkAGAh7GEvH74S6FOH42FLoXpXbE/aqXSrIQjXgsiwM=
|
||||
golang.org/x/net v0.27.0 h1:5K3Njcw06/l2y9vpGCSdcxWOYHOUk3dVNGDXN+FvAys=
|
||||
golang.org/x/net v0.27.0/go.mod h1:dDi0PyhWNoiUOrAS8uXv/vnScO4wnHQO4mj9fn/RytE=
|
||||
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.7.0 h1:YsImfSBoP9QPYL0xyKJPq0gcaJdG3rInoqxTWbfQu9M=
|
||||
golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
|
||||
@@ -169,13 +169,13 @@ golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7w
|
||||
golang.org/x/sys v0.0.0-20200519105757-fe76b779f299/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200814200057-3d37ad5750ed/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.20.0 h1:Od9JTbYCk261bKm4M/mw7AklTlFYIa0bIp9BgSm1S8Y=
|
||||
golang.org/x/sys v0.20.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||
golang.org/x/sys v0.22.0 h1:RI27ohtqKCnwULzJLqkv897zojh5/DwS/ENaMzUOaWI=
|
||||
golang.org/x/sys v0.22.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
|
||||
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||
golang.org/x/text v0.15.0 h1:h1V/4gjBv8v9cjcR6+AR5+/cIYK5N/WAgiv4xlsEtAk=
|
||||
golang.org/x/text v0.15.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
|
||||
golang.org/x/text v0.16.0 h1:a94ExnEXNtEwYLGJSIUxnWoxoRz/ZcCsV63ROupILh4=
|
||||
golang.org/x/text v0.16.0/go.mod h1:GhwF1Be+LQoKShO3cGOHzqOgRrGaYc9AvblQOmPVHnI=
|
||||
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
|
||||
@@ -1,63 +0,0 @@
|
||||
package arkgrpcclient
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
arkv1 "github.com/ark-network/ark/api-spec/protobuf/gen/ark/v1"
|
||||
"google.golang.org/grpc"
|
||||
"google.golang.org/grpc/credentials"
|
||||
"google.golang.org/grpc/credentials/insecure"
|
||||
)
|
||||
|
||||
var (
|
||||
errAspUrlEmpty = errors.New("asp url is empty")
|
||||
)
|
||||
|
||||
func New(aspUrl string) (ArkGrpcClient, func(), error) {
|
||||
if aspUrl == "" {
|
||||
return nil, nil, errAspUrlEmpty
|
||||
}
|
||||
|
||||
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, nil, err
|
||||
}
|
||||
|
||||
closeFn := func() {
|
||||
err := conn.Close()
|
||||
if err != nil {
|
||||
fmt.Printf("error closing connection: %s\n", err)
|
||||
}
|
||||
}
|
||||
|
||||
return &arkGrpcClient{conn: conn}, closeFn, nil
|
||||
}
|
||||
|
||||
type ArkGrpcClient interface {
|
||||
Admin() arkv1.AdminServiceClient
|
||||
Service() arkv1.ArkServiceClient
|
||||
}
|
||||
|
||||
type arkGrpcClient struct {
|
||||
conn *grpc.ClientConn
|
||||
}
|
||||
|
||||
func (a *arkGrpcClient) Admin() arkv1.AdminServiceClient {
|
||||
return arkv1.NewAdminServiceClient(a.conn)
|
||||
}
|
||||
|
||||
func (a *arkGrpcClient) Service() arkv1.ArkServiceClient {
|
||||
return arkv1.NewArkServiceClient(a.conn)
|
||||
}
|
||||
@@ -1,814 +0,0 @@
|
||||
package arksdk
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"net/url"
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
arkgrpcclient "github.com/ark-network/ark-sdk/grpc"
|
||||
"github.com/ark-network/ark-sdk/rest/service/arkservicerestclient"
|
||||
"github.com/ark-network/ark-sdk/rest/service/arkservicerestclient/ark_service"
|
||||
"github.com/ark-network/ark-sdk/rest/service/models"
|
||||
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 arkTransportClient interface {
|
||||
getInfo(ctx context.Context) (*arkv1.GetInfoResponse, error)
|
||||
listVtxos(ctx context.Context, addr string) (*arkv1.ListVtxosResponse, error)
|
||||
getSpendableVtxos(
|
||||
ctx context.Context, addr string, computeExpiryDetails bool,
|
||||
) ([]vtxo, error)
|
||||
getRound(ctx context.Context, txID string) (*arkv1.GetRoundResponse, error)
|
||||
getRoundByID(ctx context.Context, roundID string) (*arkv1.GetRoundByIdResponse, error)
|
||||
getRedeemBranches(
|
||||
ctx context.Context,
|
||||
explorer Explorer,
|
||||
vtxos []vtxo,
|
||||
) (map[string]*redeemBranch, error)
|
||||
getOffchainBalance(
|
||||
ctx context.Context, addr string, computeExpiration bool,
|
||||
) (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,
|
||||
) (*EventStream, error)
|
||||
ping(ctx context.Context, req *arkv1.PingRequest) (*arkv1.PingResponse, error)
|
||||
finalizePayment(
|
||||
ctx context.Context, req *arkv1.FinalizePaymentRequest,
|
||||
) (*arkv1.FinalizePaymentResponse, error)
|
||||
setExplorerSvc(explorerSvc Explorer)
|
||||
}
|
||||
|
||||
func newArkTransportClient(
|
||||
aspUrl string, protocol TransportProtocol, explorer Explorer,
|
||||
) (arkTransportClient, error) {
|
||||
switch protocol {
|
||||
case Grpc:
|
||||
grpcClient, closeFn, err := newGrpcClient(aspUrl)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &arkInnerClient{
|
||||
grpcClient: grpcClient,
|
||||
grpcCloseFn: closeFn,
|
||||
explorerSvc: explorer,
|
||||
eventStream: &EventStream{
|
||||
eventResp: make(chan *arkv1.GetEventStreamResponse),
|
||||
err: make(chan error),
|
||||
},
|
||||
}, nil
|
||||
case Rest:
|
||||
resClient, err := newRestClient(aspUrl)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &arkInnerClient{
|
||||
resClient: resClient,
|
||||
explorerSvc: explorer,
|
||||
eventStream: &EventStream{
|
||||
eventResp: make(chan *arkv1.GetEventStreamResponse),
|
||||
err: make(chan error),
|
||||
},
|
||||
}, nil
|
||||
default:
|
||||
return nil, errors.New("unknown protocol")
|
||||
}
|
||||
}
|
||||
|
||||
type arkInnerClient struct {
|
||||
grpcClient arkgrpcclient.ArkGrpcClient
|
||||
grpcCloseFn func()
|
||||
|
||||
resClient *arkservicerestclient.ArkV1ServiceProto
|
||||
|
||||
explorerSvc Explorer
|
||||
|
||||
eventStream *EventStream
|
||||
}
|
||||
|
||||
func (a *arkInnerClient) setExplorerSvc(explorerSvc Explorer) {
|
||||
a.explorerSvc = explorerSvc
|
||||
}
|
||||
|
||||
type EventStream struct {
|
||||
eventResp chan *arkv1.GetEventStreamResponse
|
||||
err chan error
|
||||
}
|
||||
|
||||
func (a *arkInnerClient) getEventStream(
|
||||
ctx context.Context, paymentID string, req *arkv1.GetEventStreamRequest,
|
||||
) (*EventStream, error) {
|
||||
switch {
|
||||
case a.grpcClient != nil:
|
||||
stream, err := a.grpcClient.Service().GetEventStream(ctx, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
go func() {
|
||||
defer close(a.eventStream.eventResp)
|
||||
defer close(a.eventStream.err)
|
||||
|
||||
for {
|
||||
resp, err := stream.Recv()
|
||||
if err != nil {
|
||||
a.eventStream.err <- err
|
||||
return
|
||||
}
|
||||
|
||||
a.eventStream.eventResp <- resp
|
||||
}
|
||||
}()
|
||||
case a.resClient != nil:
|
||||
go func(payID string) {
|
||||
defer close(a.eventStream.eventResp)
|
||||
defer close(a.eventStream.err)
|
||||
|
||||
timeout := time.After(30 * time.Second) // TODO make this configurable
|
||||
|
||||
mainloop:
|
||||
for {
|
||||
select {
|
||||
case <-timeout:
|
||||
a.eventStream.err <- errors.New("timeout reached")
|
||||
break mainloop
|
||||
default:
|
||||
resp, err := a.ping(ctx, &arkv1.PingRequest{
|
||||
PaymentId: payID,
|
||||
})
|
||||
if err != nil {
|
||||
a.eventStream.err <- err
|
||||
}
|
||||
|
||||
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.eventStream.eventResp <- &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.eventStream.err <- err
|
||||
}
|
||||
|
||||
if round.GetRound().GetStage() == arkv1.RoundStage_ROUND_STAGE_FINALIZED {
|
||||
ptx, _ := psetv2.NewPsetFromBase64(round.GetRound().GetPoolTx())
|
||||
utx, _ := ptx.UnsignedTx()
|
||||
a.eventStream.eventResp <- &arkv1.GetEventStreamResponse{
|
||||
Event: &arkv1.GetEventStreamResponse_RoundFinalized{
|
||||
RoundFinalized: &arkv1.RoundFinalizedEvent{
|
||||
PoolTxid: utx.TxHash().String(),
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
break mainloop
|
||||
}
|
||||
|
||||
if round.GetRound().GetStage() == arkv1.RoundStage_ROUND_STAGE_FAILED {
|
||||
a.eventStream.eventResp <- &arkv1.GetEventStreamResponse{
|
||||
Event: &arkv1.GetEventStreamResponse_RoundFailed{
|
||||
RoundFailed: &arkv1.RoundFailed{
|
||||
Id: round.GetRound().GetId(),
|
||||
Reason: "unknown reason", //TODO getRoundByID should return the reason
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
break mainloop
|
||||
}
|
||||
|
||||
time.Sleep(1 * time.Second)
|
||||
}
|
||||
}
|
||||
|
||||
time.Sleep(1 * time.Second)
|
||||
}
|
||||
}
|
||||
}(paymentID)
|
||||
}
|
||||
|
||||
return a.eventStream, nil
|
||||
}
|
||||
|
||||
func (a *arkInnerClient) getInfo(ctx context.Context) (*arkv1.GetInfoResponse, error) {
|
||||
switch {
|
||||
case a.grpcClient != nil:
|
||||
return a.grpcClient.Service().GetInfo(ctx, &arkv1.GetInfoRequest{})
|
||||
case a.resClient != nil:
|
||||
resp, err := a.resClient.ArkService.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
|
||||
}
|
||||
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func (a *arkInnerClient) listVtxos(
|
||||
ctx context.Context,
|
||||
addr string,
|
||||
) (*arkv1.ListVtxosResponse, error) {
|
||||
switch {
|
||||
case a.grpcClient != nil:
|
||||
return a.grpcClient.Service().ListVtxos(
|
||||
ctx, &arkv1.ListVtxosRequest{
|
||||
Address: addr,
|
||||
},
|
||||
)
|
||||
case a.resClient != nil:
|
||||
resp, err := a.resClient.ArkService.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
|
||||
}
|
||||
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func (a *arkInnerClient) getRound(
|
||||
ctx context.Context, txID string,
|
||||
) (*arkv1.GetRoundResponse, error) {
|
||||
switch {
|
||||
case a.grpcClient != nil:
|
||||
return a.grpcClient.Service().GetRound(
|
||||
ctx, &arkv1.GetRoundRequest{
|
||||
Txid: txID,
|
||||
},
|
||||
)
|
||||
case a.resClient != nil:
|
||||
resp, err := a.resClient.ArkService.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
|
||||
}
|
||||
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func (a *arkInnerClient) getSpendableVtxos(
|
||||
ctx context.Context, addr string, computeExpiryDetails bool,
|
||||
) ([]vtxo, error) {
|
||||
allVtxos, err := a.listVtxos(ctx, addr)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
vtxos := make([]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, vtxo{
|
||||
amount: v.Receiver.Amount,
|
||||
txid: v.Outpoint.Txid,
|
||||
vout: v.Outpoint.Vout,
|
||||
poolTxid: v.PoolTxid,
|
||||
expireAt: expireAt,
|
||||
})
|
||||
}
|
||||
|
||||
if !computeExpiryDetails {
|
||||
return vtxos, nil
|
||||
}
|
||||
|
||||
redeemBranches, err := a.getRedeemBranches(ctx, a.explorerSvc, vtxos)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
for vtxoTxid, branch := range redeemBranches {
|
||||
expiration, err := branch.expireAt(a.explorerSvc)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
for i, vtxo := range vtxos {
|
||||
if vtxo.txid == vtxoTxid {
|
||||
vtxos[i].expireAt = expiration
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return vtxos, nil
|
||||
}
|
||||
|
||||
type vtxo struct {
|
||||
amount uint64
|
||||
txid string
|
||||
vout uint32
|
||||
poolTxid string
|
||||
expireAt *time.Time
|
||||
}
|
||||
|
||||
func newGrpcClient(
|
||||
aspUrl string,
|
||||
) (arkgrpcclient.ArkGrpcClient, func(), error) {
|
||||
return arkgrpcclient.New(aspUrl)
|
||||
}
|
||||
|
||||
func newRestClient(
|
||||
serviceURL string,
|
||||
) (*arkservicerestclient.ArkV1ServiceProto, 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 = arkservicerestclient.DefaultBasePath
|
||||
}
|
||||
|
||||
cfg := &arkservicerestclient.TransportConfig{
|
||||
Host: host,
|
||||
BasePath: basePath,
|
||||
Schemes: schemes,
|
||||
}
|
||||
|
||||
transport := httptransport.New(cfg.Host, cfg.BasePath, cfg.Schemes)
|
||||
return arkservicerestclient.New(transport, strfmt.Default), nil
|
||||
}
|
||||
|
||||
func (a *arkInnerClient) getRedeemBranches(
|
||||
ctx context.Context,
|
||||
explorer Explorer,
|
||||
vtxos []vtxo,
|
||||
) (map[string]*redeemBranch, error) {
|
||||
congestionTrees := make(map[string]tree.CongestionTree, 0)
|
||||
redeemBranches := make(map[string]*redeemBranch, 0)
|
||||
|
||||
for _, vtxo := range vtxos {
|
||||
if _, ok := congestionTrees[vtxo.poolTxid]; !ok {
|
||||
round, err := a.getRound(ctx, vtxo.poolTxid)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
treeFromRound := round.GetRound().GetCongestionTree()
|
||||
congestionTree, err := toCongestionTree(treeFromRound)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
congestionTrees[vtxo.poolTxid] = congestionTree
|
||||
}
|
||||
|
||||
redeemBranch, err := newRedeemBranch(
|
||||
explorer, congestionTrees[vtxo.poolTxid], vtxo,
|
||||
)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
redeemBranches[vtxo.txid] = redeemBranch
|
||||
}
|
||||
|
||||
return redeemBranches, nil
|
||||
}
|
||||
|
||||
func (a *arkInnerClient) getOffchainBalance(
|
||||
ctx context.Context, addr string, computeExpiration bool,
|
||||
) (uint64, map[int64]uint64, error) {
|
||||
amountByExpiration := make(map[int64]uint64, 0)
|
||||
|
||||
vtxos, err := a.getSpendableVtxos(ctx, addr, computeExpiration)
|
||||
if err != nil {
|
||||
return 0, nil, err
|
||||
}
|
||||
var balance uint64
|
||||
for _, vtxo := range vtxos {
|
||||
balance += vtxo.amount
|
||||
|
||||
if vtxo.expireAt != nil {
|
||||
expiration := vtxo.expireAt.Unix()
|
||||
|
||||
if _, ok := amountByExpiration[expiration]; !ok {
|
||||
amountByExpiration[expiration] = 0
|
||||
}
|
||||
|
||||
amountByExpiration[expiration] += vtxo.amount
|
||||
}
|
||||
}
|
||||
|
||||
return balance, amountByExpiration, nil
|
||||
}
|
||||
|
||||
func (a *arkInnerClient) onboard(
|
||||
ctx context.Context, req *arkv1.OnboardRequest,
|
||||
) (*arkv1.OnboardResponse, error) {
|
||||
switch {
|
||||
case a.grpcClient != nil:
|
||||
return a.grpcClient.Service().Onboard(ctx, req)
|
||||
case a.resClient != nil:
|
||||
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.resClient.ArkService.ArkServiceOnboard(
|
||||
ark_service.NewArkServiceOnboardParams().WithBody(&body),
|
||||
)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &arkv1.OnboardResponse{}, nil
|
||||
}
|
||||
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func (a *arkInnerClient) registerPayment(
|
||||
ctx context.Context, req *arkv1.RegisterPaymentRequest,
|
||||
) (*arkv1.RegisterPaymentResponse, error) {
|
||||
switch {
|
||||
case a.grpcClient != nil:
|
||||
return a.grpcClient.Service().RegisterPayment(ctx, req)
|
||||
case a.resClient != nil:
|
||||
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.resClient.ArkService.ArkServiceRegisterPayment(
|
||||
ark_service.NewArkServiceRegisterPaymentParams().WithBody(&body),
|
||||
)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &arkv1.RegisterPaymentResponse{
|
||||
Id: resp.Payload.ID,
|
||||
}, nil
|
||||
}
|
||||
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func (a *arkInnerClient) claimPayment(
|
||||
ctx context.Context, req *arkv1.ClaimPaymentRequest,
|
||||
) (*arkv1.ClaimPaymentResponse, error) {
|
||||
switch {
|
||||
case a.grpcClient != nil:
|
||||
return a.grpcClient.Service().ClaimPayment(ctx, req)
|
||||
case a.resClient != nil:
|
||||
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.resClient.ArkService.ArkServiceClaimPayment(
|
||||
ark_service.NewArkServiceClaimPaymentParams().WithBody(&body),
|
||||
)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &arkv1.ClaimPaymentResponse{}, nil
|
||||
}
|
||||
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func (a *arkInnerClient) ping(
|
||||
ctx context.Context, req *arkv1.PingRequest,
|
||||
) (*arkv1.PingResponse, error) {
|
||||
switch {
|
||||
case a.grpcClient != nil:
|
||||
return a.grpcClient.Service().Ping(ctx, req)
|
||||
case a.resClient != nil:
|
||||
r := ark_service.NewArkServicePingParams()
|
||||
r.SetPaymentID(req.GetPaymentId())
|
||||
resp, err := a.resClient.ArkService.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
|
||||
}
|
||||
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func (a *arkInnerClient) finalizePayment(
|
||||
ctx context.Context, req *arkv1.FinalizePaymentRequest,
|
||||
) (*arkv1.FinalizePaymentResponse, error) {
|
||||
switch {
|
||||
case a.grpcClient != nil:
|
||||
return a.grpcClient.Service().FinalizePayment(ctx, req)
|
||||
case a.resClient != nil:
|
||||
body := models.V1FinalizePaymentRequest{
|
||||
SignedForfeitTxs: req.GetSignedForfeitTxs(),
|
||||
}
|
||||
_, err := a.resClient.ArkService.ArkServiceFinalizePayment(
|
||||
ark_service.NewArkServiceFinalizePaymentParams().WithBody(&body),
|
||||
)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &arkv1.FinalizePaymentResponse{}, nil
|
||||
}
|
||||
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func (a *arkInnerClient) getRoundByID(
|
||||
ctx context.Context, roundID string,
|
||||
) (*arkv1.GetRoundByIdResponse, error) {
|
||||
switch {
|
||||
case a.grpcClient != nil:
|
||||
return a.grpcClient.Service().GetRoundById(ctx, &arkv1.GetRoundByIdRequest{
|
||||
Id: roundID,
|
||||
})
|
||||
case a.resClient != nil:
|
||||
resp, err := a.resClient.ArkService.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
|
||||
}
|
||||
|
||||
return nil, 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
|
||||
}
|
||||
24
pkg/client-sdk/internal/utils/types.go
Normal file
24
pkg/client-sdk/internal/utils/types.go
Normal file
@@ -0,0 +1,24 @@
|
||||
package utils
|
||||
|
||||
import (
|
||||
"strings"
|
||||
|
||||
"github.com/ark-network/ark-sdk/client"
|
||||
)
|
||||
|
||||
type SupportedType[V any] map[string]V
|
||||
|
||||
func (t SupportedType[V]) String() string {
|
||||
types := make([]string, 0, len(t))
|
||||
for tt := range t {
|
||||
types = append(types, tt)
|
||||
}
|
||||
return strings.Join(types, " | ")
|
||||
}
|
||||
|
||||
func (t SupportedType[V]) Supports(typeStr string) bool {
|
||||
_, ok := t[typeStr]
|
||||
return ok
|
||||
}
|
||||
|
||||
type ClientFactory func(string) (client.ASPClient, error)
|
||||
226
pkg/client-sdk/internal/utils/utils.go
Normal file
226
pkg/client-sdk/internal/utils/utils.go
Normal file
@@ -0,0 +1,226 @@
|
||||
package utils
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"sort"
|
||||
"strings"
|
||||
|
||||
"github.com/ark-network/ark-sdk/client"
|
||||
"github.com/ark-network/ark-sdk/explorer"
|
||||
liquidexplorer "github.com/ark-network/ark-sdk/explorer/liquid"
|
||||
"github.com/ark-network/ark-sdk/store"
|
||||
"github.com/ark-network/ark-sdk/wallet"
|
||||
liquidwallet "github.com/ark-network/ark-sdk/wallet/singlekey/liquid"
|
||||
walletstore "github.com/ark-network/ark-sdk/wallet/singlekey/store"
|
||||
filestore "github.com/ark-network/ark-sdk/wallet/singlekey/store/file"
|
||||
inmemorystore "github.com/ark-network/ark-sdk/wallet/singlekey/store/inmemory"
|
||||
arkv1 "github.com/ark-network/ark/api-spec/protobuf/gen/ark/v1"
|
||||
"github.com/ark-network/ark/common"
|
||||
"github.com/ark-network/ark/common/tree"
|
||||
"github.com/decred/dcrd/dcrec/secp256k1/v4"
|
||||
"github.com/vulpemventures/go-elements/address"
|
||||
)
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
func CastCongestionTree(congestionTree tree.CongestionTree) *arkv1.Tree {
|
||||
levels := make([]*arkv1.TreeLevel, 0, len(congestionTree))
|
||||
for _, level := range congestionTree {
|
||||
levelProto := &arkv1.TreeLevel{
|
||||
Nodes: make([]*arkv1.Node, 0, len(level)),
|
||||
}
|
||||
|
||||
for _, node := range level {
|
||||
levelProto.Nodes = append(levelProto.Nodes, &arkv1.Node{
|
||||
Txid: node.Txid,
|
||||
Tx: node.Tx,
|
||||
ParentTxid: node.ParentTxid,
|
||||
})
|
||||
}
|
||||
|
||||
levels = append(levels, levelProto)
|
||||
}
|
||||
return &arkv1.Tree{
|
||||
Levels: levels,
|
||||
}
|
||||
}
|
||||
|
||||
func CoinSelect(
|
||||
vtxos []*client.Vtxo, amount, dust uint64, sortByExpirationTime bool,
|
||||
) ([]*client.Vtxo, uint64, error) {
|
||||
selected := make([]*client.Vtxo, 0)
|
||||
notSelected := make([]*client.Vtxo, 0)
|
||||
selectedAmount := uint64(0)
|
||||
|
||||
if sortByExpirationTime {
|
||||
// sort vtxos by expiration (older first)
|
||||
sort.SliceStable(vtxos, func(i, j int) bool {
|
||||
if vtxos[i].ExpiresAt == nil || vtxos[j].ExpiresAt == nil {
|
||||
return false
|
||||
}
|
||||
|
||||
return vtxos[i].ExpiresAt.Before(*vtxos[j].ExpiresAt)
|
||||
})
|
||||
}
|
||||
|
||||
for _, vtxo := range vtxos {
|
||||
if selectedAmount >= amount {
|
||||
notSelected = append(notSelected, vtxo)
|
||||
break
|
||||
}
|
||||
|
||||
selected = append(selected, vtxo)
|
||||
selectedAmount += vtxo.Amount
|
||||
}
|
||||
|
||||
if selectedAmount < amount {
|
||||
return nil, 0, fmt.Errorf("not enough funds to cover amount%d", amount)
|
||||
}
|
||||
|
||||
change := selectedAmount - amount
|
||||
|
||||
if change < dust {
|
||||
if len(notSelected) > 0 {
|
||||
selected = append(selected, notSelected[0])
|
||||
change += notSelected[0].Amount
|
||||
}
|
||||
}
|
||||
|
||||
return selected, change, nil
|
||||
}
|
||||
|
||||
func DecodeReceiverAddress(addr string) (
|
||||
bool, []byte, *secp256k1.PublicKey, error,
|
||||
) {
|
||||
outputScript, err := address.ToOutputScript(addr)
|
||||
if err != nil {
|
||||
_, userPubkey, _, err := common.DecodeAddress(addr)
|
||||
if err != nil {
|
||||
return false, nil, nil, err
|
||||
}
|
||||
return false, nil, userPubkey, nil
|
||||
}
|
||||
|
||||
return true, outputScript, nil, nil
|
||||
}
|
||||
|
||||
func IsOnchainOnly(receivers []*arkv1.Output) bool {
|
||||
for _, receiver := range receivers {
|
||||
isOnChain, _, _, err := DecodeReceiverAddress(receiver.Address)
|
||||
if err != nil {
|
||||
continue
|
||||
}
|
||||
|
||||
if !isOnChain {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
func GetClient(
|
||||
supportedClients SupportedType[ClientFactory], clientType, aspUrl string,
|
||||
) (client.ASPClient, error) {
|
||||
factory := supportedClients[clientType]
|
||||
return factory(aspUrl)
|
||||
}
|
||||
|
||||
func GetExplorer(
|
||||
supportedNetworks SupportedType[string], network string,
|
||||
) (explorer.Explorer, error) {
|
||||
url, ok := supportedNetworks[network]
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("invalid network")
|
||||
}
|
||||
if strings.Contains(network, "liquid") {
|
||||
return liquidexplorer.NewExplorer(url, network), nil
|
||||
}
|
||||
// TODO: support bitcoin explorer
|
||||
return nil, fmt.Errorf("network not supported yet")
|
||||
}
|
||||
|
||||
func GetWallet(
|
||||
storeSvc store.ConfigStore, data *store.StoreData, supportedWallets SupportedType[struct{}],
|
||||
) (wallet.WalletService, error) {
|
||||
switch data.WalletType {
|
||||
case wallet.SingleKeyWallet:
|
||||
return getSingleKeyWallet(storeSvc, data.Network.Name)
|
||||
default:
|
||||
return nil, fmt.Errorf(
|
||||
"unsuported wallet type '%s', please select one of: %s",
|
||||
data.WalletType, supportedWallets,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
func getSingleKeyWallet(
|
||||
configStore store.ConfigStore, network string,
|
||||
) (wallet.WalletService, error) {
|
||||
walletStore, err := getWalletStore(configStore.GetType(), configStore.GetDatadir())
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if strings.Contains(network, "liquid") {
|
||||
return liquidwallet.NewWalletService(configStore, walletStore)
|
||||
}
|
||||
// TODO: Support bitcoin wallet
|
||||
return nil, fmt.Errorf("network %s not supported yet", network)
|
||||
}
|
||||
|
||||
func getWalletStore(storeType, datadir string) (walletstore.WalletStore, error) {
|
||||
switch storeType {
|
||||
case store.InMemoryStore:
|
||||
return inmemorystore.NewWalletStore()
|
||||
case store.FileStore:
|
||||
return filestore.NewWalletStore(datadir)
|
||||
default:
|
||||
return nil, fmt.Errorf("unknown wallet store type")
|
||||
}
|
||||
}
|
||||
|
||||
func NetworkFromString(net string) common.Network {
|
||||
switch net {
|
||||
case common.Liquid.Name:
|
||||
return common.Liquid
|
||||
case common.LiquidTestNet.Name:
|
||||
return common.LiquidTestNet
|
||||
case common.LiquidRegTest.Name:
|
||||
return common.LiquidRegTest
|
||||
case common.BitcoinTestNet.Name:
|
||||
return common.BitcoinTestNet
|
||||
case common.BitcoinRegTest.Name:
|
||||
return common.BitcoinRegTest
|
||||
case common.Bitcoin.Name:
|
||||
fallthrough
|
||||
default:
|
||||
return common.Bitcoin
|
||||
}
|
||||
}
|
||||
@@ -1,142 +0,0 @@
|
||||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
package admin_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"
|
||||
|
||||
strfmt "github.com/go-openapi/strfmt"
|
||||
)
|
||||
|
||||
// New creates a new admin service API client.
|
||||
func New(transport runtime.ClientTransport, formats strfmt.Registry) *Client {
|
||||
return &Client{transport: transport, formats: formats}
|
||||
}
|
||||
|
||||
/*
|
||||
Client for admin service API
|
||||
*/
|
||||
type Client struct {
|
||||
transport runtime.ClientTransport
|
||||
formats strfmt.Registry
|
||||
}
|
||||
|
||||
/*
|
||||
AdminServiceGetBalance admin service get balance API
|
||||
*/
|
||||
func (a *Client) AdminServiceGetBalance(params *AdminServiceGetBalanceParams) (*AdminServiceGetBalanceOK, error) {
|
||||
// TODO: Validate the params before sending
|
||||
if params == nil {
|
||||
params = NewAdminServiceGetBalanceParams()
|
||||
}
|
||||
|
||||
result, err := a.transport.Submit(&runtime.ClientOperation{
|
||||
ID: "AdminService_GetBalance",
|
||||
Method: "GET",
|
||||
PathPattern: "/v1/admin/balance",
|
||||
ProducesMediaTypes: []string{"application/json"},
|
||||
ConsumesMediaTypes: []string{"application/json"},
|
||||
Schemes: []string{"http"},
|
||||
Params: params,
|
||||
Reader: &AdminServiceGetBalanceReader{formats: a.formats},
|
||||
Context: params.Context,
|
||||
Client: params.HTTPClient,
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return result.(*AdminServiceGetBalanceOK), nil
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
AdminServiceGetRoundDetails admin service get round details API
|
||||
*/
|
||||
func (a *Client) AdminServiceGetRoundDetails(params *AdminServiceGetRoundDetailsParams) (*AdminServiceGetRoundDetailsOK, error) {
|
||||
// TODO: Validate the params before sending
|
||||
if params == nil {
|
||||
params = NewAdminServiceGetRoundDetailsParams()
|
||||
}
|
||||
|
||||
result, err := a.transport.Submit(&runtime.ClientOperation{
|
||||
ID: "AdminService_GetRoundDetails",
|
||||
Method: "GET",
|
||||
PathPattern: "/v1/admin/round/{roundId}",
|
||||
ProducesMediaTypes: []string{"application/json"},
|
||||
ConsumesMediaTypes: []string{"application/json"},
|
||||
Schemes: []string{"http"},
|
||||
Params: params,
|
||||
Reader: &AdminServiceGetRoundDetailsReader{formats: a.formats},
|
||||
Context: params.Context,
|
||||
Client: params.HTTPClient,
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return result.(*AdminServiceGetRoundDetailsOK), nil
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
AdminServiceGetRounds admin service get rounds API
|
||||
*/
|
||||
func (a *Client) AdminServiceGetRounds(params *AdminServiceGetRoundsParams) (*AdminServiceGetRoundsOK, error) {
|
||||
// TODO: Validate the params before sending
|
||||
if params == nil {
|
||||
params = NewAdminServiceGetRoundsParams()
|
||||
}
|
||||
|
||||
result, err := a.transport.Submit(&runtime.ClientOperation{
|
||||
ID: "AdminService_GetRounds",
|
||||
Method: "POST",
|
||||
PathPattern: "/v1/admin/rounds",
|
||||
ProducesMediaTypes: []string{"application/json"},
|
||||
ConsumesMediaTypes: []string{"application/json"},
|
||||
Schemes: []string{"http"},
|
||||
Params: params,
|
||||
Reader: &AdminServiceGetRoundsReader{formats: a.formats},
|
||||
Context: params.Context,
|
||||
Client: params.HTTPClient,
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return result.(*AdminServiceGetRoundsOK), nil
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
AdminServiceGetScheduledSweep admin service get scheduled sweep API
|
||||
*/
|
||||
func (a *Client) AdminServiceGetScheduledSweep(params *AdminServiceGetScheduledSweepParams) (*AdminServiceGetScheduledSweepOK, error) {
|
||||
// TODO: Validate the params before sending
|
||||
if params == nil {
|
||||
params = NewAdminServiceGetScheduledSweepParams()
|
||||
}
|
||||
|
||||
result, err := a.transport.Submit(&runtime.ClientOperation{
|
||||
ID: "AdminService_GetScheduledSweep",
|
||||
Method: "GET",
|
||||
PathPattern: "/v1/admin/sweeps",
|
||||
ProducesMediaTypes: []string{"application/json"},
|
||||
ConsumesMediaTypes: []string{"application/json"},
|
||||
Schemes: []string{"http"},
|
||||
Params: params,
|
||||
Reader: &AdminServiceGetScheduledSweepReader{formats: a.formats},
|
||||
Context: params.Context,
|
||||
Client: params.HTTPClient,
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return result.(*AdminServiceGetScheduledSweepOK), nil
|
||||
|
||||
}
|
||||
|
||||
// SetTransport changes the transport on the client
|
||||
func (a *Client) SetTransport(transport runtime.ClientTransport) {
|
||||
a.transport = transport
|
||||
}
|
||||
@@ -1,113 +0,0 @@
|
||||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
package admin_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"
|
||||
|
||||
strfmt "github.com/go-openapi/strfmt"
|
||||
)
|
||||
|
||||
// NewAdminServiceGetBalanceParams creates a new AdminServiceGetBalanceParams object
|
||||
// with the default values initialized.
|
||||
func NewAdminServiceGetBalanceParams() *AdminServiceGetBalanceParams {
|
||||
|
||||
return &AdminServiceGetBalanceParams{
|
||||
|
||||
timeout: cr.DefaultTimeout,
|
||||
}
|
||||
}
|
||||
|
||||
// NewAdminServiceGetBalanceParamsWithTimeout creates a new AdminServiceGetBalanceParams object
|
||||
// with the default values initialized, and the ability to set a timeout on a request
|
||||
func NewAdminServiceGetBalanceParamsWithTimeout(timeout time.Duration) *AdminServiceGetBalanceParams {
|
||||
|
||||
return &AdminServiceGetBalanceParams{
|
||||
|
||||
timeout: timeout,
|
||||
}
|
||||
}
|
||||
|
||||
// NewAdminServiceGetBalanceParamsWithContext creates a new AdminServiceGetBalanceParams object
|
||||
// with the default values initialized, and the ability to set a context for a request
|
||||
func NewAdminServiceGetBalanceParamsWithContext(ctx context.Context) *AdminServiceGetBalanceParams {
|
||||
|
||||
return &AdminServiceGetBalanceParams{
|
||||
|
||||
Context: ctx,
|
||||
}
|
||||
}
|
||||
|
||||
// NewAdminServiceGetBalanceParamsWithHTTPClient creates a new AdminServiceGetBalanceParams object
|
||||
// with the default values initialized, and the ability to set a custom HTTPClient for a request
|
||||
func NewAdminServiceGetBalanceParamsWithHTTPClient(client *http.Client) *AdminServiceGetBalanceParams {
|
||||
|
||||
return &AdminServiceGetBalanceParams{
|
||||
HTTPClient: client,
|
||||
}
|
||||
}
|
||||
|
||||
/*AdminServiceGetBalanceParams contains all the parameters to send to the API endpoint
|
||||
for the admin service get balance operation typically these are written to a http.Request
|
||||
*/
|
||||
type AdminServiceGetBalanceParams struct {
|
||||
timeout time.Duration
|
||||
Context context.Context
|
||||
HTTPClient *http.Client
|
||||
}
|
||||
|
||||
// WithTimeout adds the timeout to the admin service get balance params
|
||||
func (o *AdminServiceGetBalanceParams) WithTimeout(timeout time.Duration) *AdminServiceGetBalanceParams {
|
||||
o.SetTimeout(timeout)
|
||||
return o
|
||||
}
|
||||
|
||||
// SetTimeout adds the timeout to the admin service get balance params
|
||||
func (o *AdminServiceGetBalanceParams) SetTimeout(timeout time.Duration) {
|
||||
o.timeout = timeout
|
||||
}
|
||||
|
||||
// WithContext adds the context to the admin service get balance params
|
||||
func (o *AdminServiceGetBalanceParams) WithContext(ctx context.Context) *AdminServiceGetBalanceParams {
|
||||
o.SetContext(ctx)
|
||||
return o
|
||||
}
|
||||
|
||||
// SetContext adds the context to the admin service get balance params
|
||||
func (o *AdminServiceGetBalanceParams) SetContext(ctx context.Context) {
|
||||
o.Context = ctx
|
||||
}
|
||||
|
||||
// WithHTTPClient adds the HTTPClient to the admin service get balance params
|
||||
func (o *AdminServiceGetBalanceParams) WithHTTPClient(client *http.Client) *AdminServiceGetBalanceParams {
|
||||
o.SetHTTPClient(client)
|
||||
return o
|
||||
}
|
||||
|
||||
// SetHTTPClient adds the HTTPClient to the admin service get balance params
|
||||
func (o *AdminServiceGetBalanceParams) SetHTTPClient(client *http.Client) {
|
||||
o.HTTPClient = client
|
||||
}
|
||||
|
||||
// WriteToRequest writes these params to a swagger request
|
||||
func (o *AdminServiceGetBalanceParams) 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
|
||||
}
|
||||
@@ -1,112 +0,0 @@
|
||||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
package admin_service
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the swagger generate command
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io"
|
||||
|
||||
"github.com/go-openapi/runtime"
|
||||
|
||||
strfmt "github.com/go-openapi/strfmt"
|
||||
|
||||
models "github.com/ark-network/ark-sdk/rest/admin/models"
|
||||
)
|
||||
|
||||
// AdminServiceGetBalanceReader is a Reader for the AdminServiceGetBalance structure.
|
||||
type AdminServiceGetBalanceReader struct {
|
||||
formats strfmt.Registry
|
||||
}
|
||||
|
||||
// ReadResponse reads a server response into the received o.
|
||||
func (o *AdminServiceGetBalanceReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) {
|
||||
switch response.Code() {
|
||||
|
||||
case 200:
|
||||
result := NewAdminServiceGetBalanceOK()
|
||||
if err := result.readResponse(response, consumer, o.formats); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return result, nil
|
||||
|
||||
default:
|
||||
result := NewAdminServiceGetBalanceDefault(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
|
||||
}
|
||||
}
|
||||
|
||||
// NewAdminServiceGetBalanceOK creates a AdminServiceGetBalanceOK with default headers values
|
||||
func NewAdminServiceGetBalanceOK() *AdminServiceGetBalanceOK {
|
||||
return &AdminServiceGetBalanceOK{}
|
||||
}
|
||||
|
||||
/*AdminServiceGetBalanceOK handles this case with default header values.
|
||||
|
||||
A successful response.
|
||||
*/
|
||||
type AdminServiceGetBalanceOK struct {
|
||||
Payload *models.V1GetBalanceResponse
|
||||
}
|
||||
|
||||
func (o *AdminServiceGetBalanceOK) Error() string {
|
||||
return fmt.Sprintf("[GET /v1/admin/balance][%d] adminServiceGetBalanceOK %+v", 200, o.Payload)
|
||||
}
|
||||
|
||||
func (o *AdminServiceGetBalanceOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
|
||||
|
||||
o.Payload = new(models.V1GetBalanceResponse)
|
||||
|
||||
// response payload
|
||||
if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// NewAdminServiceGetBalanceDefault creates a AdminServiceGetBalanceDefault with default headers values
|
||||
func NewAdminServiceGetBalanceDefault(code int) *AdminServiceGetBalanceDefault {
|
||||
return &AdminServiceGetBalanceDefault{
|
||||
_statusCode: code,
|
||||
}
|
||||
}
|
||||
|
||||
/*AdminServiceGetBalanceDefault handles this case with default header values.
|
||||
|
||||
An unexpected error response.
|
||||
*/
|
||||
type AdminServiceGetBalanceDefault struct {
|
||||
_statusCode int
|
||||
|
||||
Payload *models.RPCStatus
|
||||
}
|
||||
|
||||
// Code gets the status code for the admin service get balance default response
|
||||
func (o *AdminServiceGetBalanceDefault) Code() int {
|
||||
return o._statusCode
|
||||
}
|
||||
|
||||
func (o *AdminServiceGetBalanceDefault) Error() string {
|
||||
return fmt.Sprintf("[GET /v1/admin/balance][%d] AdminService_GetBalance default %+v", o._statusCode, o.Payload)
|
||||
}
|
||||
|
||||
func (o *AdminServiceGetBalanceDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
|
||||
|
||||
o.Payload = new(models.RPCStatus)
|
||||
|
||||
// response payload
|
||||
if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
@@ -1,133 +0,0 @@
|
||||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
package admin_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"
|
||||
|
||||
strfmt "github.com/go-openapi/strfmt"
|
||||
)
|
||||
|
||||
// NewAdminServiceGetRoundDetailsParams creates a new AdminServiceGetRoundDetailsParams object
|
||||
// with the default values initialized.
|
||||
func NewAdminServiceGetRoundDetailsParams() *AdminServiceGetRoundDetailsParams {
|
||||
var ()
|
||||
return &AdminServiceGetRoundDetailsParams{
|
||||
|
||||
timeout: cr.DefaultTimeout,
|
||||
}
|
||||
}
|
||||
|
||||
// NewAdminServiceGetRoundDetailsParamsWithTimeout creates a new AdminServiceGetRoundDetailsParams object
|
||||
// with the default values initialized, and the ability to set a timeout on a request
|
||||
func NewAdminServiceGetRoundDetailsParamsWithTimeout(timeout time.Duration) *AdminServiceGetRoundDetailsParams {
|
||||
var ()
|
||||
return &AdminServiceGetRoundDetailsParams{
|
||||
|
||||
timeout: timeout,
|
||||
}
|
||||
}
|
||||
|
||||
// NewAdminServiceGetRoundDetailsParamsWithContext creates a new AdminServiceGetRoundDetailsParams object
|
||||
// with the default values initialized, and the ability to set a context for a request
|
||||
func NewAdminServiceGetRoundDetailsParamsWithContext(ctx context.Context) *AdminServiceGetRoundDetailsParams {
|
||||
var ()
|
||||
return &AdminServiceGetRoundDetailsParams{
|
||||
|
||||
Context: ctx,
|
||||
}
|
||||
}
|
||||
|
||||
// NewAdminServiceGetRoundDetailsParamsWithHTTPClient creates a new AdminServiceGetRoundDetailsParams object
|
||||
// with the default values initialized, and the ability to set a custom HTTPClient for a request
|
||||
func NewAdminServiceGetRoundDetailsParamsWithHTTPClient(client *http.Client) *AdminServiceGetRoundDetailsParams {
|
||||
var ()
|
||||
return &AdminServiceGetRoundDetailsParams{
|
||||
HTTPClient: client,
|
||||
}
|
||||
}
|
||||
|
||||
/*AdminServiceGetRoundDetailsParams contains all the parameters to send to the API endpoint
|
||||
for the admin service get round details operation typically these are written to a http.Request
|
||||
*/
|
||||
type AdminServiceGetRoundDetailsParams struct {
|
||||
|
||||
/*RoundID*/
|
||||
RoundID string
|
||||
|
||||
timeout time.Duration
|
||||
Context context.Context
|
||||
HTTPClient *http.Client
|
||||
}
|
||||
|
||||
// WithTimeout adds the timeout to the admin service get round details params
|
||||
func (o *AdminServiceGetRoundDetailsParams) WithTimeout(timeout time.Duration) *AdminServiceGetRoundDetailsParams {
|
||||
o.SetTimeout(timeout)
|
||||
return o
|
||||
}
|
||||
|
||||
// SetTimeout adds the timeout to the admin service get round details params
|
||||
func (o *AdminServiceGetRoundDetailsParams) SetTimeout(timeout time.Duration) {
|
||||
o.timeout = timeout
|
||||
}
|
||||
|
||||
// WithContext adds the context to the admin service get round details params
|
||||
func (o *AdminServiceGetRoundDetailsParams) WithContext(ctx context.Context) *AdminServiceGetRoundDetailsParams {
|
||||
o.SetContext(ctx)
|
||||
return o
|
||||
}
|
||||
|
||||
// SetContext adds the context to the admin service get round details params
|
||||
func (o *AdminServiceGetRoundDetailsParams) SetContext(ctx context.Context) {
|
||||
o.Context = ctx
|
||||
}
|
||||
|
||||
// WithHTTPClient adds the HTTPClient to the admin service get round details params
|
||||
func (o *AdminServiceGetRoundDetailsParams) WithHTTPClient(client *http.Client) *AdminServiceGetRoundDetailsParams {
|
||||
o.SetHTTPClient(client)
|
||||
return o
|
||||
}
|
||||
|
||||
// SetHTTPClient adds the HTTPClient to the admin service get round details params
|
||||
func (o *AdminServiceGetRoundDetailsParams) SetHTTPClient(client *http.Client) {
|
||||
o.HTTPClient = client
|
||||
}
|
||||
|
||||
// WithRoundID adds the roundID to the admin service get round details params
|
||||
func (o *AdminServiceGetRoundDetailsParams) WithRoundID(roundID string) *AdminServiceGetRoundDetailsParams {
|
||||
o.SetRoundID(roundID)
|
||||
return o
|
||||
}
|
||||
|
||||
// SetRoundID adds the roundId to the admin service get round details params
|
||||
func (o *AdminServiceGetRoundDetailsParams) SetRoundID(roundID string) {
|
||||
o.RoundID = roundID
|
||||
}
|
||||
|
||||
// WriteToRequest writes these params to a swagger request
|
||||
func (o *AdminServiceGetRoundDetailsParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {
|
||||
|
||||
if err := r.SetTimeout(o.timeout); err != nil {
|
||||
return err
|
||||
}
|
||||
var res []error
|
||||
|
||||
// path param roundId
|
||||
if err := r.SetPathParam("roundId", o.RoundID); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if len(res) > 0 {
|
||||
return errors.CompositeValidationError(res...)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -1,112 +0,0 @@
|
||||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
package admin_service
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the swagger generate command
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io"
|
||||
|
||||
"github.com/go-openapi/runtime"
|
||||
|
||||
strfmt "github.com/go-openapi/strfmt"
|
||||
|
||||
models "github.com/ark-network/ark-sdk/rest/admin/models"
|
||||
)
|
||||
|
||||
// AdminServiceGetRoundDetailsReader is a Reader for the AdminServiceGetRoundDetails structure.
|
||||
type AdminServiceGetRoundDetailsReader struct {
|
||||
formats strfmt.Registry
|
||||
}
|
||||
|
||||
// ReadResponse reads a server response into the received o.
|
||||
func (o *AdminServiceGetRoundDetailsReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) {
|
||||
switch response.Code() {
|
||||
|
||||
case 200:
|
||||
result := NewAdminServiceGetRoundDetailsOK()
|
||||
if err := result.readResponse(response, consumer, o.formats); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return result, nil
|
||||
|
||||
default:
|
||||
result := NewAdminServiceGetRoundDetailsDefault(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
|
||||
}
|
||||
}
|
||||
|
||||
// NewAdminServiceGetRoundDetailsOK creates a AdminServiceGetRoundDetailsOK with default headers values
|
||||
func NewAdminServiceGetRoundDetailsOK() *AdminServiceGetRoundDetailsOK {
|
||||
return &AdminServiceGetRoundDetailsOK{}
|
||||
}
|
||||
|
||||
/*AdminServiceGetRoundDetailsOK handles this case with default header values.
|
||||
|
||||
A successful response.
|
||||
*/
|
||||
type AdminServiceGetRoundDetailsOK struct {
|
||||
Payload *models.V1GetRoundDetailsResponse
|
||||
}
|
||||
|
||||
func (o *AdminServiceGetRoundDetailsOK) Error() string {
|
||||
return fmt.Sprintf("[GET /v1/admin/round/{roundId}][%d] adminServiceGetRoundDetailsOK %+v", 200, o.Payload)
|
||||
}
|
||||
|
||||
func (o *AdminServiceGetRoundDetailsOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
|
||||
|
||||
o.Payload = new(models.V1GetRoundDetailsResponse)
|
||||
|
||||
// response payload
|
||||
if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// NewAdminServiceGetRoundDetailsDefault creates a AdminServiceGetRoundDetailsDefault with default headers values
|
||||
func NewAdminServiceGetRoundDetailsDefault(code int) *AdminServiceGetRoundDetailsDefault {
|
||||
return &AdminServiceGetRoundDetailsDefault{
|
||||
_statusCode: code,
|
||||
}
|
||||
}
|
||||
|
||||
/*AdminServiceGetRoundDetailsDefault handles this case with default header values.
|
||||
|
||||
An unexpected error response.
|
||||
*/
|
||||
type AdminServiceGetRoundDetailsDefault struct {
|
||||
_statusCode int
|
||||
|
||||
Payload *models.RPCStatus
|
||||
}
|
||||
|
||||
// Code gets the status code for the admin service get round details default response
|
||||
func (o *AdminServiceGetRoundDetailsDefault) Code() int {
|
||||
return o._statusCode
|
||||
}
|
||||
|
||||
func (o *AdminServiceGetRoundDetailsDefault) Error() string {
|
||||
return fmt.Sprintf("[GET /v1/admin/round/{roundId}][%d] AdminService_GetRoundDetails default %+v", o._statusCode, o.Payload)
|
||||
}
|
||||
|
||||
func (o *AdminServiceGetRoundDetailsDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
|
||||
|
||||
o.Payload = new(models.RPCStatus)
|
||||
|
||||
// response payload
|
||||
if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
@@ -1,136 +0,0 @@
|
||||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
package admin_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"
|
||||
|
||||
strfmt "github.com/go-openapi/strfmt"
|
||||
|
||||
models "github.com/ark-network/ark-sdk/rest/admin/models"
|
||||
)
|
||||
|
||||
// NewAdminServiceGetRoundsParams creates a new AdminServiceGetRoundsParams object
|
||||
// with the default values initialized.
|
||||
func NewAdminServiceGetRoundsParams() *AdminServiceGetRoundsParams {
|
||||
var ()
|
||||
return &AdminServiceGetRoundsParams{
|
||||
|
||||
timeout: cr.DefaultTimeout,
|
||||
}
|
||||
}
|
||||
|
||||
// NewAdminServiceGetRoundsParamsWithTimeout creates a new AdminServiceGetRoundsParams object
|
||||
// with the default values initialized, and the ability to set a timeout on a request
|
||||
func NewAdminServiceGetRoundsParamsWithTimeout(timeout time.Duration) *AdminServiceGetRoundsParams {
|
||||
var ()
|
||||
return &AdminServiceGetRoundsParams{
|
||||
|
||||
timeout: timeout,
|
||||
}
|
||||
}
|
||||
|
||||
// NewAdminServiceGetRoundsParamsWithContext creates a new AdminServiceGetRoundsParams object
|
||||
// with the default values initialized, and the ability to set a context for a request
|
||||
func NewAdminServiceGetRoundsParamsWithContext(ctx context.Context) *AdminServiceGetRoundsParams {
|
||||
var ()
|
||||
return &AdminServiceGetRoundsParams{
|
||||
|
||||
Context: ctx,
|
||||
}
|
||||
}
|
||||
|
||||
// NewAdminServiceGetRoundsParamsWithHTTPClient creates a new AdminServiceGetRoundsParams object
|
||||
// with the default values initialized, and the ability to set a custom HTTPClient for a request
|
||||
func NewAdminServiceGetRoundsParamsWithHTTPClient(client *http.Client) *AdminServiceGetRoundsParams {
|
||||
var ()
|
||||
return &AdminServiceGetRoundsParams{
|
||||
HTTPClient: client,
|
||||
}
|
||||
}
|
||||
|
||||
/*AdminServiceGetRoundsParams contains all the parameters to send to the API endpoint
|
||||
for the admin service get rounds operation typically these are written to a http.Request
|
||||
*/
|
||||
type AdminServiceGetRoundsParams struct {
|
||||
|
||||
/*Body*/
|
||||
Body *models.V1GetRoundsRequest
|
||||
|
||||
timeout time.Duration
|
||||
Context context.Context
|
||||
HTTPClient *http.Client
|
||||
}
|
||||
|
||||
// WithTimeout adds the timeout to the admin service get rounds params
|
||||
func (o *AdminServiceGetRoundsParams) WithTimeout(timeout time.Duration) *AdminServiceGetRoundsParams {
|
||||
o.SetTimeout(timeout)
|
||||
return o
|
||||
}
|
||||
|
||||
// SetTimeout adds the timeout to the admin service get rounds params
|
||||
func (o *AdminServiceGetRoundsParams) SetTimeout(timeout time.Duration) {
|
||||
o.timeout = timeout
|
||||
}
|
||||
|
||||
// WithContext adds the context to the admin service get rounds params
|
||||
func (o *AdminServiceGetRoundsParams) WithContext(ctx context.Context) *AdminServiceGetRoundsParams {
|
||||
o.SetContext(ctx)
|
||||
return o
|
||||
}
|
||||
|
||||
// SetContext adds the context to the admin service get rounds params
|
||||
func (o *AdminServiceGetRoundsParams) SetContext(ctx context.Context) {
|
||||
o.Context = ctx
|
||||
}
|
||||
|
||||
// WithHTTPClient adds the HTTPClient to the admin service get rounds params
|
||||
func (o *AdminServiceGetRoundsParams) WithHTTPClient(client *http.Client) *AdminServiceGetRoundsParams {
|
||||
o.SetHTTPClient(client)
|
||||
return o
|
||||
}
|
||||
|
||||
// SetHTTPClient adds the HTTPClient to the admin service get rounds params
|
||||
func (o *AdminServiceGetRoundsParams) SetHTTPClient(client *http.Client) {
|
||||
o.HTTPClient = client
|
||||
}
|
||||
|
||||
// WithBody adds the body to the admin service get rounds params
|
||||
func (o *AdminServiceGetRoundsParams) WithBody(body *models.V1GetRoundsRequest) *AdminServiceGetRoundsParams {
|
||||
o.SetBody(body)
|
||||
return o
|
||||
}
|
||||
|
||||
// SetBody adds the body to the admin service get rounds params
|
||||
func (o *AdminServiceGetRoundsParams) SetBody(body *models.V1GetRoundsRequest) {
|
||||
o.Body = body
|
||||
}
|
||||
|
||||
// WriteToRequest writes these params to a swagger request
|
||||
func (o *AdminServiceGetRoundsParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {
|
||||
|
||||
if err := r.SetTimeout(o.timeout); err != nil {
|
||||
return err
|
||||
}
|
||||
var res []error
|
||||
|
||||
if o.Body != nil {
|
||||
if err := r.SetBodyParam(o.Body); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
if len(res) > 0 {
|
||||
return errors.CompositeValidationError(res...)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -1,112 +0,0 @@
|
||||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
package admin_service
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the swagger generate command
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io"
|
||||
|
||||
"github.com/go-openapi/runtime"
|
||||
|
||||
strfmt "github.com/go-openapi/strfmt"
|
||||
|
||||
models "github.com/ark-network/ark-sdk/rest/admin/models"
|
||||
)
|
||||
|
||||
// AdminServiceGetRoundsReader is a Reader for the AdminServiceGetRounds structure.
|
||||
type AdminServiceGetRoundsReader struct {
|
||||
formats strfmt.Registry
|
||||
}
|
||||
|
||||
// ReadResponse reads a server response into the received o.
|
||||
func (o *AdminServiceGetRoundsReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) {
|
||||
switch response.Code() {
|
||||
|
||||
case 200:
|
||||
result := NewAdminServiceGetRoundsOK()
|
||||
if err := result.readResponse(response, consumer, o.formats); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return result, nil
|
||||
|
||||
default:
|
||||
result := NewAdminServiceGetRoundsDefault(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
|
||||
}
|
||||
}
|
||||
|
||||
// NewAdminServiceGetRoundsOK creates a AdminServiceGetRoundsOK with default headers values
|
||||
func NewAdminServiceGetRoundsOK() *AdminServiceGetRoundsOK {
|
||||
return &AdminServiceGetRoundsOK{}
|
||||
}
|
||||
|
||||
/*AdminServiceGetRoundsOK handles this case with default header values.
|
||||
|
||||
A successful response.
|
||||
*/
|
||||
type AdminServiceGetRoundsOK struct {
|
||||
Payload *models.V1GetRoundsResponse
|
||||
}
|
||||
|
||||
func (o *AdminServiceGetRoundsOK) Error() string {
|
||||
return fmt.Sprintf("[POST /v1/admin/rounds][%d] adminServiceGetRoundsOK %+v", 200, o.Payload)
|
||||
}
|
||||
|
||||
func (o *AdminServiceGetRoundsOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
|
||||
|
||||
o.Payload = new(models.V1GetRoundsResponse)
|
||||
|
||||
// response payload
|
||||
if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// NewAdminServiceGetRoundsDefault creates a AdminServiceGetRoundsDefault with default headers values
|
||||
func NewAdminServiceGetRoundsDefault(code int) *AdminServiceGetRoundsDefault {
|
||||
return &AdminServiceGetRoundsDefault{
|
||||
_statusCode: code,
|
||||
}
|
||||
}
|
||||
|
||||
/*AdminServiceGetRoundsDefault handles this case with default header values.
|
||||
|
||||
An unexpected error response.
|
||||
*/
|
||||
type AdminServiceGetRoundsDefault struct {
|
||||
_statusCode int
|
||||
|
||||
Payload *models.RPCStatus
|
||||
}
|
||||
|
||||
// Code gets the status code for the admin service get rounds default response
|
||||
func (o *AdminServiceGetRoundsDefault) Code() int {
|
||||
return o._statusCode
|
||||
}
|
||||
|
||||
func (o *AdminServiceGetRoundsDefault) Error() string {
|
||||
return fmt.Sprintf("[POST /v1/admin/rounds][%d] AdminService_GetRounds default %+v", o._statusCode, o.Payload)
|
||||
}
|
||||
|
||||
func (o *AdminServiceGetRoundsDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
|
||||
|
||||
o.Payload = new(models.RPCStatus)
|
||||
|
||||
// response payload
|
||||
if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
@@ -1,113 +0,0 @@
|
||||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
package admin_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"
|
||||
|
||||
strfmt "github.com/go-openapi/strfmt"
|
||||
)
|
||||
|
||||
// NewAdminServiceGetScheduledSweepParams creates a new AdminServiceGetScheduledSweepParams object
|
||||
// with the default values initialized.
|
||||
func NewAdminServiceGetScheduledSweepParams() *AdminServiceGetScheduledSweepParams {
|
||||
|
||||
return &AdminServiceGetScheduledSweepParams{
|
||||
|
||||
timeout: cr.DefaultTimeout,
|
||||
}
|
||||
}
|
||||
|
||||
// NewAdminServiceGetScheduledSweepParamsWithTimeout creates a new AdminServiceGetScheduledSweepParams object
|
||||
// with the default values initialized, and the ability to set a timeout on a request
|
||||
func NewAdminServiceGetScheduledSweepParamsWithTimeout(timeout time.Duration) *AdminServiceGetScheduledSweepParams {
|
||||
|
||||
return &AdminServiceGetScheduledSweepParams{
|
||||
|
||||
timeout: timeout,
|
||||
}
|
||||
}
|
||||
|
||||
// NewAdminServiceGetScheduledSweepParamsWithContext creates a new AdminServiceGetScheduledSweepParams object
|
||||
// with the default values initialized, and the ability to set a context for a request
|
||||
func NewAdminServiceGetScheduledSweepParamsWithContext(ctx context.Context) *AdminServiceGetScheduledSweepParams {
|
||||
|
||||
return &AdminServiceGetScheduledSweepParams{
|
||||
|
||||
Context: ctx,
|
||||
}
|
||||
}
|
||||
|
||||
// NewAdminServiceGetScheduledSweepParamsWithHTTPClient creates a new AdminServiceGetScheduledSweepParams object
|
||||
// with the default values initialized, and the ability to set a custom HTTPClient for a request
|
||||
func NewAdminServiceGetScheduledSweepParamsWithHTTPClient(client *http.Client) *AdminServiceGetScheduledSweepParams {
|
||||
|
||||
return &AdminServiceGetScheduledSweepParams{
|
||||
HTTPClient: client,
|
||||
}
|
||||
}
|
||||
|
||||
/*AdminServiceGetScheduledSweepParams contains all the parameters to send to the API endpoint
|
||||
for the admin service get scheduled sweep operation typically these are written to a http.Request
|
||||
*/
|
||||
type AdminServiceGetScheduledSweepParams struct {
|
||||
timeout time.Duration
|
||||
Context context.Context
|
||||
HTTPClient *http.Client
|
||||
}
|
||||
|
||||
// WithTimeout adds the timeout to the admin service get scheduled sweep params
|
||||
func (o *AdminServiceGetScheduledSweepParams) WithTimeout(timeout time.Duration) *AdminServiceGetScheduledSweepParams {
|
||||
o.SetTimeout(timeout)
|
||||
return o
|
||||
}
|
||||
|
||||
// SetTimeout adds the timeout to the admin service get scheduled sweep params
|
||||
func (o *AdminServiceGetScheduledSweepParams) SetTimeout(timeout time.Duration) {
|
||||
o.timeout = timeout
|
||||
}
|
||||
|
||||
// WithContext adds the context to the admin service get scheduled sweep params
|
||||
func (o *AdminServiceGetScheduledSweepParams) WithContext(ctx context.Context) *AdminServiceGetScheduledSweepParams {
|
||||
o.SetContext(ctx)
|
||||
return o
|
||||
}
|
||||
|
||||
// SetContext adds the context to the admin service get scheduled sweep params
|
||||
func (o *AdminServiceGetScheduledSweepParams) SetContext(ctx context.Context) {
|
||||
o.Context = ctx
|
||||
}
|
||||
|
||||
// WithHTTPClient adds the HTTPClient to the admin service get scheduled sweep params
|
||||
func (o *AdminServiceGetScheduledSweepParams) WithHTTPClient(client *http.Client) *AdminServiceGetScheduledSweepParams {
|
||||
o.SetHTTPClient(client)
|
||||
return o
|
||||
}
|
||||
|
||||
// SetHTTPClient adds the HTTPClient to the admin service get scheduled sweep params
|
||||
func (o *AdminServiceGetScheduledSweepParams) SetHTTPClient(client *http.Client) {
|
||||
o.HTTPClient = client
|
||||
}
|
||||
|
||||
// WriteToRequest writes these params to a swagger request
|
||||
func (o *AdminServiceGetScheduledSweepParams) 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
|
||||
}
|
||||
@@ -1,112 +0,0 @@
|
||||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
package admin_service
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the swagger generate command
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io"
|
||||
|
||||
"github.com/go-openapi/runtime"
|
||||
|
||||
strfmt "github.com/go-openapi/strfmt"
|
||||
|
||||
models "github.com/ark-network/ark-sdk/rest/admin/models"
|
||||
)
|
||||
|
||||
// AdminServiceGetScheduledSweepReader is a Reader for the AdminServiceGetScheduledSweep structure.
|
||||
type AdminServiceGetScheduledSweepReader struct {
|
||||
formats strfmt.Registry
|
||||
}
|
||||
|
||||
// ReadResponse reads a server response into the received o.
|
||||
func (o *AdminServiceGetScheduledSweepReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) {
|
||||
switch response.Code() {
|
||||
|
||||
case 200:
|
||||
result := NewAdminServiceGetScheduledSweepOK()
|
||||
if err := result.readResponse(response, consumer, o.formats); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return result, nil
|
||||
|
||||
default:
|
||||
result := NewAdminServiceGetScheduledSweepDefault(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
|
||||
}
|
||||
}
|
||||
|
||||
// NewAdminServiceGetScheduledSweepOK creates a AdminServiceGetScheduledSweepOK with default headers values
|
||||
func NewAdminServiceGetScheduledSweepOK() *AdminServiceGetScheduledSweepOK {
|
||||
return &AdminServiceGetScheduledSweepOK{}
|
||||
}
|
||||
|
||||
/*AdminServiceGetScheduledSweepOK handles this case with default header values.
|
||||
|
||||
A successful response.
|
||||
*/
|
||||
type AdminServiceGetScheduledSweepOK struct {
|
||||
Payload *models.V1GetScheduledSweepResponse
|
||||
}
|
||||
|
||||
func (o *AdminServiceGetScheduledSweepOK) Error() string {
|
||||
return fmt.Sprintf("[GET /v1/admin/sweeps][%d] adminServiceGetScheduledSweepOK %+v", 200, o.Payload)
|
||||
}
|
||||
|
||||
func (o *AdminServiceGetScheduledSweepOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
|
||||
|
||||
o.Payload = new(models.V1GetScheduledSweepResponse)
|
||||
|
||||
// response payload
|
||||
if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// NewAdminServiceGetScheduledSweepDefault creates a AdminServiceGetScheduledSweepDefault with default headers values
|
||||
func NewAdminServiceGetScheduledSweepDefault(code int) *AdminServiceGetScheduledSweepDefault {
|
||||
return &AdminServiceGetScheduledSweepDefault{
|
||||
_statusCode: code,
|
||||
}
|
||||
}
|
||||
|
||||
/*AdminServiceGetScheduledSweepDefault handles this case with default header values.
|
||||
|
||||
An unexpected error response.
|
||||
*/
|
||||
type AdminServiceGetScheduledSweepDefault struct {
|
||||
_statusCode int
|
||||
|
||||
Payload *models.RPCStatus
|
||||
}
|
||||
|
||||
// Code gets the status code for the admin service get scheduled sweep default response
|
||||
func (o *AdminServiceGetScheduledSweepDefault) Code() int {
|
||||
return o._statusCode
|
||||
}
|
||||
|
||||
func (o *AdminServiceGetScheduledSweepDefault) Error() string {
|
||||
return fmt.Sprintf("[GET /v1/admin/sweeps][%d] AdminService_GetScheduledSweep default %+v", o._statusCode, o.Payload)
|
||||
}
|
||||
|
||||
func (o *AdminServiceGetScheduledSweepDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
|
||||
|
||||
o.Payload = new(models.RPCStatus)
|
||||
|
||||
// response payload
|
||||
if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
@@ -1,117 +0,0 @@
|
||||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
package arkadminrestclient
|
||||
|
||||
// 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"
|
||||
|
||||
strfmt "github.com/go-openapi/strfmt"
|
||||
|
||||
"github.com/ark-network/ark-sdk/rest/admin/arkadminrestclient/admin_service"
|
||||
)
|
||||
|
||||
// Default ark v1 admin 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 admin proto HTTP client.
|
||||
func NewHTTPClient(formats strfmt.Registry) *ArkV1AdminProto {
|
||||
return NewHTTPClientWithConfig(formats, nil)
|
||||
}
|
||||
|
||||
// NewHTTPClientWithConfig creates a new ark v1 admin proto HTTP client,
|
||||
// using a customizable transport config.
|
||||
func NewHTTPClientWithConfig(formats strfmt.Registry, cfg *TransportConfig) *ArkV1AdminProto {
|
||||
// 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 admin proto client
|
||||
func New(transport runtime.ClientTransport, formats strfmt.Registry) *ArkV1AdminProto {
|
||||
// ensure nullable parameters have default
|
||||
if formats == nil {
|
||||
formats = strfmt.Default
|
||||
}
|
||||
|
||||
cli := new(ArkV1AdminProto)
|
||||
cli.Transport = transport
|
||||
|
||||
cli.AdminService = admin_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
|
||||
}
|
||||
|
||||
// ArkV1AdminProto is a client for ark v1 admin proto
|
||||
type ArkV1AdminProto struct {
|
||||
AdminService *admin_service.Client
|
||||
|
||||
Transport runtime.ClientTransport
|
||||
}
|
||||
|
||||
// SetTransport changes the transport on the client and all its subresources
|
||||
func (c *ArkV1AdminProto) SetTransport(transport runtime.ClientTransport) {
|
||||
c.Transport = transport
|
||||
|
||||
c.AdminService.SetTransport(transport)
|
||||
|
||||
}
|
||||
@@ -1,43 +0,0 @@
|
||||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
package models
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the swagger generate command
|
||||
|
||||
import (
|
||||
strfmt "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"`
|
||||
}
|
||||
|
||||
// Validate validates this protobuf any
|
||||
func (m *ProtobufAny) Validate(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
|
||||
}
|
||||
@@ -1,86 +0,0 @@
|
||||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
package models
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the swagger generate command
|
||||
|
||||
import (
|
||||
"strconv"
|
||||
|
||||
strfmt "github.com/go-openapi/strfmt"
|
||||
|
||||
"github.com/go-openapi/errors"
|
||||
"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))
|
||||
}
|
||||
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
|
||||
}
|
||||
@@ -1,46 +0,0 @@
|
||||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
package models
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the swagger generate command
|
||||
|
||||
import (
|
||||
strfmt "github.com/go-openapi/strfmt"
|
||||
|
||||
"github.com/go-openapi/swag"
|
||||
)
|
||||
|
||||
// V1Balance v1 balance
|
||||
// swagger:model v1Balance
|
||||
type V1Balance struct {
|
||||
|
||||
// available
|
||||
Available string `json:"available,omitempty"`
|
||||
|
||||
// locked
|
||||
Locked string `json:"locked,omitempty"`
|
||||
}
|
||||
|
||||
// Validate validates this v1 balance
|
||||
func (m *V1Balance) Validate(formats strfmt.Registry) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// MarshalBinary interface implementation
|
||||
func (m *V1Balance) MarshalBinary() ([]byte, error) {
|
||||
if m == nil {
|
||||
return nil, nil
|
||||
}
|
||||
return swag.WriteJSON(m)
|
||||
}
|
||||
|
||||
// UnmarshalBinary interface implementation
|
||||
func (m *V1Balance) UnmarshalBinary(b []byte) error {
|
||||
var res V1Balance
|
||||
if err := swag.ReadJSON(b, &res); err != nil {
|
||||
return err
|
||||
}
|
||||
*m = res
|
||||
return nil
|
||||
}
|
||||
@@ -1,96 +0,0 @@
|
||||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
package models
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the swagger generate command
|
||||
|
||||
import (
|
||||
strfmt "github.com/go-openapi/strfmt"
|
||||
|
||||
"github.com/go-openapi/errors"
|
||||
"github.com/go-openapi/swag"
|
||||
)
|
||||
|
||||
// V1GetBalanceResponse v1 get balance response
|
||||
// swagger:model v1GetBalanceResponse
|
||||
type V1GetBalanceResponse struct {
|
||||
|
||||
// connectors account
|
||||
ConnectorsAccount *V1Balance `json:"connectorsAccount,omitempty"`
|
||||
|
||||
// main account
|
||||
MainAccount *V1Balance `json:"mainAccount,omitempty"`
|
||||
}
|
||||
|
||||
// Validate validates this v1 get balance response
|
||||
func (m *V1GetBalanceResponse) Validate(formats strfmt.Registry) error {
|
||||
var res []error
|
||||
|
||||
if err := m.validateConnectorsAccount(formats); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
if err := m.validateMainAccount(formats); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
if len(res) > 0 {
|
||||
return errors.CompositeValidationError(res...)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *V1GetBalanceResponse) validateConnectorsAccount(formats strfmt.Registry) error {
|
||||
|
||||
if swag.IsZero(m.ConnectorsAccount) { // not required
|
||||
return nil
|
||||
}
|
||||
|
||||
if m.ConnectorsAccount != nil {
|
||||
if err := m.ConnectorsAccount.Validate(formats); err != nil {
|
||||
if ve, ok := err.(*errors.Validation); ok {
|
||||
return ve.ValidateName("connectorsAccount")
|
||||
}
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *V1GetBalanceResponse) validateMainAccount(formats strfmt.Registry) error {
|
||||
|
||||
if swag.IsZero(m.MainAccount) { // not required
|
||||
return nil
|
||||
}
|
||||
|
||||
if m.MainAccount != nil {
|
||||
if err := m.MainAccount.Validate(formats); err != nil {
|
||||
if ve, ok := err.(*errors.Validation); ok {
|
||||
return ve.ValidateName("mainAccount")
|
||||
}
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// MarshalBinary interface implementation
|
||||
func (m *V1GetBalanceResponse) MarshalBinary() ([]byte, error) {
|
||||
if m == nil {
|
||||
return nil, nil
|
||||
}
|
||||
return swag.WriteJSON(m)
|
||||
}
|
||||
|
||||
// UnmarshalBinary interface implementation
|
||||
func (m *V1GetBalanceResponse) UnmarshalBinary(b []byte) error {
|
||||
var res V1GetBalanceResponse
|
||||
if err := swag.ReadJSON(b, &res); err != nil {
|
||||
return err
|
||||
}
|
||||
*m = res
|
||||
return nil
|
||||
}
|
||||
@@ -1,67 +0,0 @@
|
||||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
package models
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the swagger generate command
|
||||
|
||||
import (
|
||||
strfmt "github.com/go-openapi/strfmt"
|
||||
|
||||
"github.com/go-openapi/swag"
|
||||
)
|
||||
|
||||
// V1GetRoundDetailsResponse v1 get round details response
|
||||
// swagger:model v1GetRoundDetailsResponse
|
||||
type V1GetRoundDetailsResponse struct {
|
||||
|
||||
// exit addresses
|
||||
ExitAddresses []string `json:"exitAddresses"`
|
||||
|
||||
// fees amount
|
||||
FeesAmount string `json:"feesAmount,omitempty"`
|
||||
|
||||
// forfeited amount
|
||||
ForfeitedAmount string `json:"forfeitedAmount,omitempty"`
|
||||
|
||||
// inputs vtxos
|
||||
InputsVtxos []string `json:"inputsVtxos"`
|
||||
|
||||
// outputs vtxos
|
||||
OutputsVtxos []string `json:"outputsVtxos"`
|
||||
|
||||
// round Id
|
||||
RoundID string `json:"roundId,omitempty"`
|
||||
|
||||
// total exit amount
|
||||
TotalExitAmount string `json:"totalExitAmount,omitempty"`
|
||||
|
||||
// total vtxos amount
|
||||
TotalVtxosAmount string `json:"totalVtxosAmount,omitempty"`
|
||||
|
||||
// txid
|
||||
Txid string `json:"txid,omitempty"`
|
||||
}
|
||||
|
||||
// Validate validates this v1 get round details response
|
||||
func (m *V1GetRoundDetailsResponse) Validate(formats strfmt.Registry) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// MarshalBinary interface implementation
|
||||
func (m *V1GetRoundDetailsResponse) MarshalBinary() ([]byte, error) {
|
||||
if m == nil {
|
||||
return nil, nil
|
||||
}
|
||||
return swag.WriteJSON(m)
|
||||
}
|
||||
|
||||
// UnmarshalBinary interface implementation
|
||||
func (m *V1GetRoundDetailsResponse) UnmarshalBinary(b []byte) error {
|
||||
var res V1GetRoundDetailsResponse
|
||||
if err := swag.ReadJSON(b, &res); err != nil {
|
||||
return err
|
||||
}
|
||||
*m = res
|
||||
return nil
|
||||
}
|
||||
@@ -1,46 +0,0 @@
|
||||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
package models
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the swagger generate command
|
||||
|
||||
import (
|
||||
strfmt "github.com/go-openapi/strfmt"
|
||||
|
||||
"github.com/go-openapi/swag"
|
||||
)
|
||||
|
||||
// V1GetRoundsRequest v1 get rounds request
|
||||
// swagger:model v1GetRoundsRequest
|
||||
type V1GetRoundsRequest struct {
|
||||
|
||||
// after
|
||||
After string `json:"after,omitempty"`
|
||||
|
||||
// before
|
||||
Before string `json:"before,omitempty"`
|
||||
}
|
||||
|
||||
// Validate validates this v1 get rounds request
|
||||
func (m *V1GetRoundsRequest) Validate(formats strfmt.Registry) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// MarshalBinary interface implementation
|
||||
func (m *V1GetRoundsRequest) MarshalBinary() ([]byte, error) {
|
||||
if m == nil {
|
||||
return nil, nil
|
||||
}
|
||||
return swag.WriteJSON(m)
|
||||
}
|
||||
|
||||
// UnmarshalBinary interface implementation
|
||||
func (m *V1GetRoundsRequest) UnmarshalBinary(b []byte) error {
|
||||
var res V1GetRoundsRequest
|
||||
if err := swag.ReadJSON(b, &res); err != nil {
|
||||
return err
|
||||
}
|
||||
*m = res
|
||||
return nil
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user