sebak: boscoin.io/sebak/lib/client Index | Files

package client

import "boscoin.io/sebak/lib/client"

Index

Package Files

client.go error.go response.go

Constants

const (
    UrlPrefixForAPIV1 = "/api/v1"

    UrlAccountTransactions   = "/accounts/{id}/transactions"
    UrlAccount               = "/accounts/{id}"
    UrlAccountOperations     = "/accounts/{id}/operations"
    UrlAccountFrozenAccounts = "/accounts/{id}/frozen-accounts"
    UrlFrozenAccounts        = "/frozen-accounts"
    UrlTransactions          = "/transactions"
    UrlTransactionByHash     = "/transactions/{id}"
    UrlTransactionStatus     = "/transactions/{id}/status"
    UrlTransactionOperations = "/transactions/{id}/operations"
    UrlSubscribe             = "/subscribe"
)

func NewDefaultListOptionsFromQuery Uses

func NewDefaultListOptionsFromQuery(v neturl.Values) (options *storage.DefaultListOptions, err error)

NewDefaultListOptionsFromQuery makes ListOptions from url.Query.

type Account Uses

type Account struct {
    Links struct {
        Self         Link `json:"self"`
        Transactions Link `json:"transactions"`
        Operations   Link `json:"operations"`
    }   `json:"_links"`

    Address    string `json:"address"`
    SequenceID uint64 `json:"sequence_id"`
    Balance    string `json:"balance"`
    Linked     string `json:"linked"`
}

type Client Uses

type Client struct {
    URL string

    HTTP *common.HTTP2Client
}

func MustNewClient Uses

func MustNewClient(url string) *Client

Calls `NewClient` and panic if an `error` is returned

func NewClient Uses

func NewClient(url string) (*Client, error)

Create a new Client object

Params:

url = The url of the node, e.g. "https://127.0.0.1:1234"

Returns:

error   = An error object, if the client could not be created.
          `nil` otherwise.
Client* = If `error == nil`, the constructed `Client`

func (*Client) Get Uses

func (c *Client) Get(path string, headers http.Header) (response *http.Response, err error)

func (*Client) LoadAFrozenAccounts Uses

func (c *Client) LoadAFrozenAccounts(id string, queries ...Q) (fPage FrozenAccountsPage, err error)

func (*Client) LoadAccount Uses

func (c *Client) LoadAccount(id string, queries ...Q) (account Account, err error)

func (*Client) LoadFrozenAccountsByLinked Uses

func (c *Client) LoadFrozenAccountsByLinked(id string, queries ...Q) (fPage FrozenAccountsPage, err error)

func (*Client) LoadOperationsByAccount Uses

func (c *Client) LoadOperationsByAccount(id string, queries ...Q) (oPage OperationsPage, err error)

func (*Client) LoadOperationsByTransaction Uses

func (c *Client) LoadOperationsByTransaction(id string, queries ...Q) (oPage OperationsPage, err error)

func (*Client) LoadTransaction Uses

func (c *Client) LoadTransaction(id string, queries ...Q) (transaction Transaction, err error)

func (*Client) LoadTransactionStatus Uses

func (c *Client) LoadTransactionStatus(id string, queries ...Q) (transactionHistory TransactionStatus, err error)

func (*Client) LoadTransactions Uses

func (c *Client) LoadTransactions(queries ...Q) (tPage TransactionsPage, err error)

func (*Client) LoadTransactionsByAccount Uses

func (c *Client) LoadTransactionsByAccount(id string, queries ...Q) (tPage TransactionsPage, err error)

func (*Client) Post Uses

func (c *Client) Post(path string, body []byte, headers http.Header) (response *http.Response, err error)

func (*Client) StreamAccount Uses

func (c *Client) StreamAccount(ctx context.Context, handler func(Account), ids ...string) error

Stream account updates from the node

Params:

ctx = Context to use. The streaming starts a goroutine and doesn't stop.
      A common pattern is to pass `context.WithCancel(context.Background())`.
      See go's `context` package for more details.
handler = The handler function that will be called every time an account is updated.

Returns: An `error` object, or `nil`

func (*Client) StreamTransactionStatus Uses

func (c *Client) StreamTransactionStatus(ctx context.Context, id string, handler func(TransactionStatus)) (err error)

func (*Client) StreamTransactions Uses

func (c *Client) StreamTransactions(ctx context.Context, handler func(Transaction), ids ...string) error

Stream transactions from the node

Params:

ctx = Context to use. The streaming starts a goroutine and doesn't stop.
      A common pattern is to pass `context.WithCancel(context.Background())`.
      See go's `context` package for more details.
handler = The handler function that will be called every time a transaction is received.
ids     = An (optional) list of transaction hashes to listen to.
          If `nil`, all transactions will be streamed to the handler.

Returns: An `error` object, or `nil`

func (*Client) StreamTransactionsByAccount Uses

func (c *Client) StreamTransactionsByAccount(ctx context.Context, id string, handler func(Transaction)) (err error)

func (*Client) SubmitTransaction Uses

func (c *Client) SubmitTransaction(tx []byte) (TransactionPostError, error)

Submit a transaction to the node (via POST `UrlTransactions`)

Params:

tx = JSON serialized Transaction that will be sent as body

Returns:

TransactionPostError = An object describing the node's answer if there's an error
error = An error object, or `nil`

func (*Client) SubmitTransactionAndWait Uses

func (c *Client) SubmitTransactionAndWait(hash string, tx []byte) (pTransaction TransactionPostError, err error)

Submit a transaction to the node (via POST `UrlTransactions`)

Params:

hash = the hash of the transaction
tx = JSON serialized Transaction that will be sent as body

Returns:

TransactionPostError = An object describing the node's answer if there's an error
error = An error object, or `nil`

func (*Client) ToResponse Uses

func (c *Client) ToResponse(resp *http.Response, response interface{}) (err error)

type CollectTxFee Uses

type CollectTxFee struct {
    Target    string `json:"target"`
    Amount    []byte `json:"amount"`
    Txs       uint64 `json:"txs"`
    Height    uint64 `json:"block-height"`
    BlockHash string `json:"block-hash"`
    TotalTxs  uint64 `json:"total-txs"`
    TotalOps  uint64 `json:"total-ops"`
}

type CongressVoting Uses

type CongressVoting struct {
    Contract string `json:"contract"`
    Voting   struct {
        Start uint64 `json:"start"`
        End   uint64 `json:"end"`
    }   `json:"voting"`
    FundingAddress string        `json:"funding_address"`
    Amount         common.Amount `json:"amount"`
}

type CongressVotingResult Uses

type CongressVotingResult struct {
    BallotStamps struct {
        Hash string   `json:"hash"`
        Urls []string `json:"urls"`
    }   `json:"ballot_stamps"`
    Voters struct {
        Hash string   `json:"hash"`
        Urls []string `json:"urls"`
    }   `json:"voters"`
    Membership struct {
        Hash string   `json:"hash"`
        Urls []string `json:"urls"`
    }   `json:"membership"`
    Result struct {
        Count uint64 `json:"count"`
        Yes   uint64 `json:"yes"`
        No    uint64 `json:"no"`
        ABS   uint64 `json:"abs"`
    }   `json:"result"`
    CongressVotingHash string `json:"congress_voting_hash"`
}

type CreateAccount Uses

type CreateAccount struct {
    Target string `json:"target"`
    Amount []byte `json:"amount"`
    Linked string `json:"linked,omitempty"`
}

type Error Uses

type Error struct {
    Problem Problem
}

func (Error) Error Uses

func (e Error) Error() string

type FrozenAccount Uses

type FrozenAccount struct {
    Links struct {
        Self Link `json:"self"`
    }   `json:"_links"`

    Address                    string                      `json:"address"`
    Linked                     string                      `json:"linked"`
    CreateBlockHeight          uint64                      `json:"create_block_height"`
    CreateOpHash               string                      `json:"create_op_hash"`
    SequenceID                 uint64                      `json:"sequence_id"`
    Amount                     common.Amount               `json:"amount"`
    State                      resource.FrozenAccountState `json:"state"`
    UnfreezingBlockHeight      uint64                      `json:"unfreezing_block_height"`
    UnfreezingOpHash           string                      `json:"unfreezing_op_hash"`
    UnfreezingRemainingBlockes uint64                      `json:"unfreezing_remaining_blockheight"`
    PaymentOpHash              string                      `json:"payment_op_hash"`
}

type FrozenAccountsPage Uses

type FrozenAccountsPage struct {
    Links struct {
        Self Link `json:"self"`
    }   `json:"_links"`
    Embedded struct {
        Records []FrozenAccount `json:"records"`
    }   `json:"_embedded"`
}

type Inflation Uses

type Inflation struct {
    Target         string `json:"target"`
    Amount         []byte `json:"amount"`
    InitialBalance []byte `json:"initial-balance"`
    Ratio          string `json:"ratio"`
    Height         uint64 `json:"block-height"`
    BlockHash      string `json:"block-hash"`
    TotalTxs       uint64 `json:"total-txs"`
    TotalOps       uint64 `json:"total-ops"`
}
type Link struct {
    Href      string `json:"href"`
    Templated bool   `json:"templated,omitempty"`
}

type Operation Uses

type Operation struct {
    Links struct {
        Self        Link `json:"self"`
        Transaction Link `json:"transaction"`
    }   `json:"_links"`
    Hash        string      `json:"hash"`
    Source      string      `json:"source"`
    Target      string      `json:"target"`
    Type        string      `json:"type"`
    TxHash      string      `json:"tx_hash"`
    BlockHeight uint64      `json:"block_height"`
    Index       uint64      `json:"index"`
    Body        interface{} `json:"body"`
}

type OperationsPage Uses

type OperationsPage struct {
    Links struct {
        Self Link `json:"self"`
        Next Link `json:"next"`
        Prev Link `json:"prev"`
    }   `json:"_links"`
    Embedded struct {
        Records []Operation `json:"records"`
    }   `json:"_embedded"`
}

type Payment Uses

type Payment struct {
    Target string `json:"target"`
    Amount []byte `json:"amount"`
}

type Problem Uses

type Problem struct {
    Type     string                     `json:"type"`
    Title    string                     `json:"title"`
    Status   int                        `json:"status"`
    Detail   string                     `json:"detail,omitempty"`
    Instance string                     `json:"instance,omitempty"`
    Extras   map[string]json.RawMessage `json:"extras,omitempty"`
}

type Q Uses

type Q struct {
    Key   QueryKey
    Value string
}

type Queries Uses

type Queries []Q

type QueryKey Uses

type QueryKey string
const (
    QueryLimit  QueryKey = "limit"
    QueryOrder  QueryKey = "reverse"
    QueryCursor QueryKey = "cursor"
    QueryType   QueryKey = "type"
)

func (QueryKey) String Uses

func (qk QueryKey) String() string

type Transaction Uses

type Transaction struct {
    Links struct {
        Self       Link `json:"self"`
        Account    Link `json:"account"`
        Operations Link `json:"operations"`
    }   `json:"_links"`
    Hash           string `json:"hash"`
    Source         string `json:"source"`
    Fee            string `json:"fee"`
    SequenceID     uint64 `json:"sequence_id"`
    Created        string `json:"created"`
    OperationCount uint64 `json:"operation_count"`
}

type TransactionPostError Uses

type TransactionPostError struct {
    Links struct {
        Self   Link `json:"self"`
        Status Link `json:"status"`
    }   `json:"_links"`
    Hash    string      `json:"hash"`
    Status  string      `json:"status"`
    Message interface{} `json:"message"`
}

type TransactionStatus Uses

type TransactionStatus struct {
    Links struct {
        Self        Link `json:"self"`
        Transaction Link `json:"transaction"`
    }   `json:"_links"`
    Hash   string `json:"hash"`
    Status string `json:"status"`
}

type TransactionsPage Uses

type TransactionsPage struct {
    Links struct {
        Self Link `json:"self"`
        Next Link `json:"next"`
        Prev Link `json:"prev"`
    }   `json:"_links"`
    Embedded struct {
        Records []Transaction `json:"records"`
    }   `json:"_embedded"`
}

Package client imports 12 packages (graph) and is imported by 3 packages. Updated 2019-03-27. Refresh now. Tools for package owners.