fatd: github.com/Factom-Asset-Tokens/fatd/srv Index | Files

package srv

import "github.com/Factom-Asset-Tokens/fatd/srv"

Package srv provides the JSON RPC 2.0 API server and RPC functions. It calls out to the fatd/db package to obtain data about the current state saved to the DB.


Package Files

client.go doc.go errors.go methods.go params.go srv.go


const (
    FatdDefault = "http://localhost:8078"

Defaults for the factomd and factom-walletd endpoints.


var (
    ErrorTokenNotFound = jrpc.NewError(-32800, "Token Not Found",
        "token may be invalid, or not yet issued or tracked")
    ErrorTransactionNotFound = jrpc.NewError(-32803, "Transaction Not Found",
        "no matching tx-id was found")
    ErrorInvalidTransaction = jrpc.NewError(-32804, "Invalid Transaction", nil)
    ErrorTokenSyncing       = jrpc.NewError(-32805, "Token Syncing",
        "token is in the process of syncing")
    ErrorNoEC = jrpc.NewError(-32806, "No Entry Credits",
        "not configured with entry credits")
    ErrorPendingDisabled = jrpc.NewError(-32807, "Pending Transactions Disabled",
        "fatd is not tracking pending transactions")
var (
    APIVersion              = "1"
    FatdVersionHeaderKey    = http.CanonicalHeaderKey("Fatd-Version")
    FatdAPIVersionHeaderKey = http.CanonicalHeaderKey("Fatd-Api-Version")

func Start Uses

func Start(stop <-chan struct{}) (done <-chan struct{})

Start the server in its own goroutine. If stop is closed, the server is closed and any goroutines will exit. The done channel is closed when the server exits for any reason. If the done channel is closed before the stop channel is closed, an error occurred. Errors are logged.

type Client Uses

type Client struct {
    FatdServer string

Client makes RPC requests to fatd's APIs. Client embeds a jsonrpc2.Client, and thus also the http.Client. Use jsonrpc2.Client's BasicAuth settings to set up BasicAuth and http.Client's transport settings to configure TLS.

func NewClient Uses

func NewClient() *Client

NewClient returns a pointer to a Client initialized with the default localhost endpoints for factomd and factom-walletd, and 15 second timeouts for each of the http.Clients.

func (*Client) Request Uses

func (c *Client) Request(method string, params, result interface{}) error

Request makes a request to fatd's v1 API.

type Params Uses

type Params interface {
    IsValid() error
    ValidChainID() *factom.Bytes32
    HasIncludePending() bool

type ParamsGetAllNFTokens Uses

type ParamsGetAllNFTokens struct {

func (*ParamsGetAllNFTokens) IsValid Uses

func (p *ParamsGetAllNFTokens) IsValid() error

type ParamsGetBalance Uses

type ParamsGetBalance struct {
    Address *factom.FAAddress `json:"address,omitempty"`

func (ParamsGetBalance) IsValid Uses

func (p ParamsGetBalance) IsValid() error

type ParamsGetBalances Uses

type ParamsGetBalances struct {
    Address        *factom.FAAddress `json:"address,omitempty"`
    IncludePending bool              `json:"includepending,omitempty"`

func (ParamsGetBalances) HasIncludePending Uses

func (p ParamsGetBalances) HasIncludePending() bool

func (ParamsGetBalances) IsValid Uses

func (p ParamsGetBalances) IsValid() error

func (ParamsGetBalances) ValidChainID Uses

func (p ParamsGetBalances) ValidChainID() *factom.Bytes32

type ParamsGetNFBalance Uses

type ParamsGetNFBalance struct {
    Address *factom.FAAddress `json:"address,omitempty"`

func (*ParamsGetNFBalance) IsValid Uses

func (p *ParamsGetNFBalance) IsValid() error

type ParamsGetNFToken Uses

type ParamsGetNFToken struct {
    NFTokenID *fat1.NFTokenID `json:"nftokenid"`

func (ParamsGetNFToken) IsValid Uses

func (p ParamsGetNFToken) IsValid() error

type ParamsGetTransaction Uses

type ParamsGetTransaction struct {
    Hash *factom.Bytes32 `json:"entryhash"`

ParamsGetTransaction is used to query for a single particular transaction with the given Entry Hash.

func (ParamsGetTransaction) IsValid Uses

func (p ParamsGetTransaction) IsValid() error

type ParamsGetTransactions Uses

type ParamsGetTransactions struct {
    // Transaction filters
    NFTokenID *fat1.NFTokenID    `json:"nftokenid,omitempty"`
    Addresses []factom.FAAddress `json:"addresses,omitempty"`
    StartHash *factom.Bytes32    `json:"entryhash,omitempty"`
    ToFrom    string             `json:"tofrom,omitempty"`

func (*ParamsGetTransactions) IsValid Uses

func (p *ParamsGetTransactions) IsValid() error

type ParamsPagination Uses

type ParamsPagination struct {
    Page  *uint64 `json:"page,omitempty"`
    Limit uint64  `json:"limit,omitempty"`
    Order string  `json:"order,omitempty"`

func (*ParamsPagination) IsValid Uses

func (p *ParamsPagination) IsValid() error

type ParamsSendTransaction Uses

type ParamsSendTransaction struct {
    ExtIDs  []factom.Bytes `json:"extids,omitempty"`
    Content factom.Bytes   `json:"content,omitempty"`
    Raw     factom.Bytes   `json:"raw,omitempty"`
    DryRun  bool           `json:"dryrun,omitempty"`
    // contains filtered or unexported fields

func (ParamsSendTransaction) Entry Uses

func (p ParamsSendTransaction) Entry() factom.Entry

func (*ParamsSendTransaction) IsValid Uses

func (p *ParamsSendTransaction) IsValid() error

type ParamsToken Uses

type ParamsToken struct {
    ChainID       *factom.Bytes32 `json:"chainid,omitempty"`
    TokenID       string          `json:"tokenid,omitempty"`
    IssuerChainID *factom.Bytes32 `json:"issuerid,omitempty"`

    IncludePending bool `json:"includepending,omitempty"`

ParamsToken scopes a request down to a single FAT token using either the ChainID or both the TokenID and the IssuerChainID.

func (ParamsToken) HasIncludePending Uses

func (p ParamsToken) HasIncludePending() bool

func (ParamsToken) IsValid Uses

func (p ParamsToken) IsValid() error

func (ParamsToken) ValidChainID Uses

func (p ParamsToken) ValidChainID() *factom.Bytes32

type ResultGetBalances Uses

type ResultGetBalances map[factom.Bytes32]uint64

func (ResultGetBalances) MarshalJSON Uses

func (r ResultGetBalances) MarshalJSON() ([]byte, error)

func (*ResultGetBalances) UnmarshalJSON Uses

func (r *ResultGetBalances) UnmarshalJSON(data []byte) error

type ResultGetDaemonProperties Uses

type ResultGetDaemonProperties struct {
    FatdVersion string           `json:"fatdversion"`
    APIVersion  string           `json:"apiversion"`
    NetworkID   factom.NetworkID `json:"factomnetworkid"`

type ResultGetIssuance Uses

type ResultGetIssuance struct {
    Hash      *factom.Bytes32 `json:"entryhash"`
    Timestamp int64           `json:"timestamp"`
    Issuance  fat.Issuance    `json:"issuance"`

type ResultGetNFToken Uses

type ResultGetNFToken struct {
    NFTokenID  fat1.NFTokenID    `json:"id"`
    Owner      *factom.FAAddress `json:"owner,omitempty"`
    Burned     bool              `json:"burned,omitempty"`
    Metadata   json.RawMessage   `json:"metadata,omitempty"`
    CreationTx *factom.Bytes32   `json:"creationtx"`

type ResultGetStats Uses

type ResultGetStats struct {
    Issuance                 *fat.Issuance
    IssuanceHash             *factom.Bytes32
    CirculatingSupply        uint64 `json:"circulating"`
    Burned                   uint64 `json:"burned"`
    Transactions             int64  `json:"transactions"`
    IssuanceTimestamp        int64  `json:"issuancets"`
    LastTransactionTimestamp int64  `json:"lasttxts,omitempty"`
    NonZeroBalances          int64  `json:"nonzerobalances, omitempty"`

type ResultGetSyncStatus Uses

type ResultGetSyncStatus struct {
    Sync    uint32 `json:"syncheight"`
    Current uint32 `json:"factomheight"`

type ResultGetTransaction Uses

type ResultGetTransaction struct {
    Hash      *factom.Bytes32 `json:"entryhash"`
    Timestamp int64           `json:"timestamp"`
    Tx        interface{}     `json:"data"`
    Pending   bool            `json:"pending,omitempty"`

Package srv imports 17 packages (graph) and is imported by 2 packages. Updated 2019-09-11. Refresh now. Tools for package owners.