client

package
v0.1.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 14, 2018 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var NoApiKeyError = errors.New("no api key provided")

Functions

func GuessTransactionType added in v0.1.2

func GuessTransactionType(t *TransactionTypeVersion) (proto.Transaction, error)

Guess transaction from type and version

func NewTimestampFromTime

func NewTimestampFromTime(t time.Time) uint64

func NewTimestampFromUnixNano

func NewTimestampFromUnixNano(nano int64) uint64

Types

type Addresses

type Addresses struct {
	// contains filtered or unexported fields
}

func NewAddresses

func NewAddresses(options Options) *Addresses

NewAddresses create new address block

func (*Addresses) Addresses

func (a *Addresses) Addresses(ctx context.Context) ([]proto.Address, *Response, error)

Get wallet accounts addresses

func (*Addresses) Balance

func (a *Addresses) Balance(ctx context.Context, address proto.Address) (*AddressesBalance, *Response, error)

Balance returns account's balance by its address

func (*Addresses) BalanceAfterConfirmations

func (a *Addresses) BalanceAfterConfirmations(
	ctx context.Context, address proto.Address, confirmations uint64) (*BalanceAfterConfirmations, *Response, error)

Balance of address after confirmations

func (*Addresses) BalanceDetails

func (a *Addresses) BalanceDetails(ctx context.Context, address proto.Address) (*AddressesBalanceDetails, *Response, error)

BalanceDetails returns account's detail balance by its address

func (*Addresses) EffectiveBalance

func (a *Addresses) EffectiveBalance(ctx context.Context, address proto.Address) (*AddressesEffectiveBalance, *Response, error)

Account's balance

func (*Addresses) PublicKey

func (a *Addresses) PublicKey(ctx context.Context, publicKey string) (*proto.Address, *Response, error)

Generate address from public key

func (*Addresses) ScriptInfo

func (a *Addresses) ScriptInfo(ctx context.Context, address proto.Address) (*AddressesScriptInfo, *Response, error)

ScriptInfo gets account's script information

func (*Addresses) SignText

func (a *Addresses) SignText(ctx context.Context, address proto.Address, message string) (*AddressesSignText, *Response, error)

Sign a message with a private key associated with address

func (*Addresses) Validate

func (a *Addresses) Validate(ctx context.Context, address proto.Address) (*AddressesValidate, *Response, error)

Check whether address is valid or not

func (*Addresses) VerifyText

func (a *Addresses) VerifyText(ctx context.Context, address proto.Address, body VerifyTextReq) (bool, *Response, error)

Check a signature of a message signed by an account

type AddressesBalance

type AddressesBalance struct {
	Address       proto.Address `json:"address"`
	Confirmations uint64        `json:"confirmations"`
	Balance       uint64        `json:"balance"`
}

type AddressesBalanceDetails

type AddressesBalanceDetails struct {
	Address    proto.Address `json:"address"`
	Regular    uint64        `json:"regular"`
	Generating uint64        `json:"generating"`
	Available  uint64        `json:"available"`
	Effective  uint64        `json:"effective"`
}

type AddressesEffectiveBalance

type AddressesEffectiveBalance struct {
	Address       proto.Address `json:"address"`
	Confirmations uint64        `json:"confirmations"`
	Balance       uint64        `json:"balance"`
}

type AddressesScriptInfo

type AddressesScriptInfo struct {
	Address    proto.Address `json:"address"`
	Complexity uint64        `json:"complexity"`
	ExtraFee   uint64        `json:"extra_fee"`
}

type AddressesSignText

type AddressesSignText struct {
	Message   string           `json:"message"`
	PublicKey crypto.PublicKey `json:"publicKey"`
	Signature crypto.Signature `json:"signature"`
}

type AddressesValidate

type AddressesValidate struct {
	Address proto.Address `json:"address"`
	Valid   bool          `json:"valid"`
}

type Alias

type Alias struct {
	// contains filtered or unexported fields
}

func NewAlias

func NewAlias(options Options) *Alias

func (*Alias) Broadcast

func (a *Alias) Broadcast(ctx context.Context, broadcastReq AliasBroadcastReq) (*CreateAliasV1, *Response, error)

func (*Alias) Create

func (a *Alias) Create(ctx context.Context, createReq AliasCreateReq) (*CreateAliasV1, *Response, error)

func (*Alias) Get

func (a *Alias) Get(ctx context.Context, alias string) (proto.Address, *Response, error)

func (*Alias) GetByAddress

func (a *Alias) GetByAddress(ctx context.Context, address proto.Address) ([]*proto.Alias, *Response, error)

type AliasBroadcastReq

type AliasBroadcastReq struct {
	SenderPublicKey crypto.PublicKey `json:"senderPublicKey"`
	Fee             uint64           `json:"fee"`
	Timestamp       uint64           `json:"timestamp"`
	Signature       crypto.Signature `json:"signature"`
	Alias           string           `json:"alias"`
}

type AliasCreateReq

type AliasCreateReq struct {
	Sender    proto.Address `json:"sender"`
	Alias     string        `json:"alias"`
	Fee       uint64        `json:"fee"`
	Timestamp uint64        `json:"timestamp,omitempty"`
}

type Assets added in v0.1.2

type Assets struct {
	// contains filtered or unexported fields
}

func NewAssets added in v0.1.2

func NewAssets(options Options) *Assets

NewAssets creates new Assets

func (*Assets) BalanceByAddress added in v0.1.2

func (a *Assets) BalanceByAddress(ctx context.Context, address proto.Address) (*AssetsBalances, *Response, error)

Provides detailed information about given asset

func (*Assets) BalanceByAddressAndAsset added in v0.1.2

func (a *Assets) BalanceByAddressAndAsset(ctx context.Context, address proto.Address, assetId crypto.Digest) (*AssetsBalanceAndAsset, *Response, error)

Account's balance by given asset

func (*Assets) Burn added in v0.1.2

func (a *Assets) Burn(ctx context.Context, burnReq AssetsBurnReq) (*proto.BurnV1, *Response, error)

Burn some of your assets

func (*Assets) Details added in v0.1.2

func (a *Assets) Details(ctx context.Context, assetId crypto.Digest) (*AssetsDetail, *Response, error)

Provides detailed information about given asset

func (*Assets) Distribution added in v0.1.2

func (a *Assets) Distribution(ctx context.Context, assetId crypto.Digest) (AssetsDistribution, *Response, error)

Asset balance distribution by account

func (*Assets) Issue added in v0.1.2

func (a *Assets) Issue(ctx context.Context, issueReq AssetsIssueReq) (*AssetsIssue, *Response, error)

Issue new Asset

func (*Assets) MassTransfer added in v0.1.2

func (a *Assets) MassTransfer(ctx context.Context, transfersReq AssetsMassTransfersReq) (*proto.MassTransferV1, *Response, error)

Mass transfer of assets

func (*Assets) Sponsor added in v0.1.2

func (a *Assets) Sponsor(ctx context.Context, sponsorReq AssetsSponsorReq) (*proto.SponsorshipV1, *Response, error)

Sponsor provided asset

func (*Assets) Transfer added in v0.1.2

func (a *Assets) Transfer(ctx context.Context, transferReq AssetsTransferReq) (*proto.TransferV2, *Response, error)

Transfer asset to new address

type AssetsBalance added in v0.1.2

type AssetsBalance struct {
	AssetId              crypto.Digest `json:"assetId"`
	Balance              uint64        `json:"balance"`
	Reissuable           bool          `json:"reissuable"`
	MinSponsoredAssetFee uint64        `json:"minSponsoredAssetFee"`
	SponsorBalance       uint64        `json:"sponsorBalance"`
	Quantity             uint64        `json:"quantity"`
	IssueTransaction     proto.IssueV1 `json:"issueTransaction"`
}

type AssetsBalanceAndAsset added in v0.1.2

type AssetsBalanceAndAsset struct {
	Address proto.Address `json:"address"`
	AssetId crypto.Digest `json:"assetId"`
	Balance uint64        `json:"balance"`
}

type AssetsBalances added in v0.1.2

type AssetsBalances struct {
	Address  proto.Address   `json:"address"`
	Balances []AssetsBalance `json:"balances"`
}

type AssetsBurnReq added in v0.1.2

type AssetsBurnReq struct {
	Sender    proto.Address `json:"sender"`
	AssetId   crypto.Digest `json:"assetId"`
	Quantity  uint64        `json:"quantity"`
	Fee       uint64        `json:"fee"`
	Timestamp uint64        `json:"timestamp"`
}

type AssetsDetail added in v0.1.2

type AssetsDetail struct {
	AssetId              crypto.Digest `json:"assetId"`
	IssueHeight          uint64        `json:"issueHeight"`
	IssueTimestamp       uint64        `json:"issueTimestamp"`
	Issuer               proto.Address `json:"issuer"`
	Name                 string        `json:"name"`
	Description          string        `json:"description"`
	Decimals             uint64        `json:"decimals"`
	Reissuable           bool          `json:"reissuable"`
	Quantity             uint64        `json:"quantity"`
	MinSponsoredAssetFee uint64        `json:"minSponsoredAssetFee"`
}

type AssetsDistribution added in v0.1.2

type AssetsDistribution map[string]uint64

type AssetsIssue added in v0.1.2

type AssetsIssue struct {
	Sender      proto.Address `json:"sender"`
	Name        string        `json:"name"`
	Description string        `json:"description"`
	Quantity    uint64        `json:"quantity"`
	Decimals    uint8         `json:"decimals"`
	Reissuable  bool          `json:"reissuable"`
	Fee         uint64        `json:"fee"`
	Timestamp   uint64        `json:"timestamp"`
}

type AssetsIssueReq added in v0.1.2

type AssetsIssueReq struct {
	Sender      proto.Address `json:"sender"`
	Name        string        `json:"name"`
	Description string        `json:"description"`
	Quantity    uint64        `json:"quantity"`
	Decimals    uint8         `json:"decimals"`
	Reissuable  bool          `json:"reissuable"`
	Fee         uint64        `json:"fee"`
	Timestamp   uint64        `json:"timestamp"`
}

type AssetsMassTransferReq added in v0.1.2

type AssetsMassTransferReq struct {
	Recipient proto.Address `json:"recipient"`
	Amount    uint64        `json:"amount"`
}

type AssetsMassTransfersReq added in v0.1.2

type AssetsMassTransfersReq struct {
	Version    uint8                   `json:"version"`
	AssetId    crypto.Digest           `json:"asset_id"`
	Sender     proto.Address           `json:"sender"`
	Transfers  []AssetsMassTransferReq `json:"transfers"`
	Fee        uint64                  `json:"fee"`
	Attachment proto.Attachment        `json:"attachment"`
	Timestamp  uint64                  `json:"timestamp"`
}

type AssetsSponsorReq added in v0.1.2

type AssetsSponsorReq struct {
	Sender               proto.Address `json:"sender"`
	AssetId              crypto.Digest `json:"assetId"`
	MinSponsoredAssetFee uint64        `json:"minSponsoredAssetFee"`
	Fee                  uint64        `json:"fee"`
	Version              uint8         `json:"version"`
}

type AssetsTransferReq added in v0.1.2

type AssetsTransferReq struct {
	Version    uint8            `json:"version"`
	AssetId    crypto.Digest    `json:"assetId"`
	Amount     uint64           `json:"amount"`
	FeeAssetId crypto.Digest    `json:"feeAssetId"`
	Fee        uint64           `json:"fee"`
	Sender     proto.Address    `json:"sender"`
	Attachment proto.Attachment `json:"attachment"`
	Recipient  proto.Address    `json:"recipient"`
	Timestamp  uint64           `json:"timestamp"`
}

type BalanceAfterConfirmations

type BalanceAfterConfirmations struct {
	Address       proto.Address `json:"address"`
	Confirmations uint64        `json:"confirmations"`
	Balance       uint64        `json:"balance"`
}

type Block

type Block struct {
	Version          uint64       `json:"version"`
	Timestamp        uint64       `json:"timestamp"`
	Reference        string       `json:"reference"`
	NxtConsensus     NxtConsensus `json:"nxt-consensus"`
	Features         []uint64     `json:"features"`
	Generator        string       `json:"generator"`
	Signature        string       `json:"signature"`
	Blocksize        uint64       `json:"blocksize"`
	TransactionCount uint64       `json:"transactionCount"`
	Fee              uint64       `json:"fee"`
	Height           uint64       `json:"height"`
}

type Blocks

type Blocks struct {
	// contains filtered or unexported fields
}

func NewBlocks

func NewBlocks(options Options) *Blocks

func (*Blocks) HeadersAt

func (a *Blocks) HeadersAt(ctx context.Context, height uint64) (*Headers, *Response, error)

func (*Blocks) HeadersLast

func (a *Blocks) HeadersLast(ctx context.Context) (*Headers, *Response, error)

func (*Blocks) HeadersSeq

func (a *Blocks) HeadersSeq(ctx context.Context, from uint64, to uint64) ([]*Headers, *Response, error)

func (*Blocks) Height

func (a *Blocks) Height(ctx context.Context) (*BlocksHeight, *Response, error)

func (*Blocks) HeightBySignature

func (a *Blocks) HeightBySignature(ctx context.Context, signature string) (*BlocksHeight, *Response, error)

type BlocksHeight

type BlocksHeight struct {
	Height uint64 `json:"height"`
}

type Client

type Client struct {
	Addresses    *Addresses
	Blocks       *Blocks
	Wallet       *Wallet
	Alias        *Alias
	Peers        *Peers
	Consensus    *Consensus
	Transactions *Transactions
	Assets       *Assets
	Utils        *Utils
	// contains filtered or unexported fields
}

func NewClient

func NewClient(options ...Options) (*Client, error)

Creates new client instance If no options provided will use default

func (*Client) Do

func (a *Client) Do(ctx context.Context, req *http.Request, v interface{}) (*Response, error)

func (Client) GetOptions

func (a Client) GetOptions() Options

type Consensus

type Consensus struct {
	// contains filtered or unexported fields
}

func NewConsensus

func NewConsensus(options Options) *Consensus

creates new consensus api section

func (*Consensus) Algo

func (a *Consensus) Algo(ctx context.Context) (string, *Response, error)

Shows which consensus algo being using

func (*Consensus) BaseTarget

func (a *Consensus) BaseTarget(ctx context.Context) (*ConsensusBaseTarget, *Response, error)

Base target of a last block

func (*Consensus) BaseTargetByBlock

func (a *Consensus) BaseTargetByBlock(ctx context.Context, blockID string) (uint64, *Response, error)

Base target of a block with specified id

func (Consensus) GeneratingBalance

func (a Consensus) GeneratingBalance(ctx context.Context, address proto.Address) (*ConsensusGeneratingBalance, *Response, error)

Account's generating balance(the same as balance atm)

func (*Consensus) GenerationSignature

func (a *Consensus) GenerationSignature(ctx context.Context) (string, *Response, error)

Generation signature of a last block

func (*Consensus) GenerationSignatureByBlock

func (a *Consensus) GenerationSignatureByBlock(ctx context.Context, blockID string) (string, *Response, error)

Generation signature of a block with specified id

type ConsensusBaseTarget

type ConsensusBaseTarget struct {
	BaseTarget uint64 `json:"baseTarget"`
	Score      string `json:"score"`
}

type ConsensusGeneratingBalance

type ConsensusGeneratingBalance struct {
	Address proto.Address `json:"address"`
	Balance uint64        `json:"balance"`
}

type CreateAliasV1

type CreateAliasV1 struct {
	Type      proto.TransactionType `json:"type"`
	Version   byte                  `json:"version,omitempty"`
	ID        *crypto.Digest        `json:"id,omitempty"`
	Signature *crypto.Signature     `json:"signature,omitempty"`
	SenderPK  crypto.PublicKey      `json:"senderPublicKey"`
	Alias     string                `json:"alias"`
	Fee       uint64                `json:"fee"`
	Timestamp uint64                `json:"timestamp,omitempty"`
}

type Doer

type Doer interface {
	Do(req *http.Request) (*http.Response, error)
}

type Headers

type Headers struct {
	Version          uint64           `json:"version"`
	Timestamp        uint64           `json:"timestamp"`
	Reference        crypto.Signature `json:"reference"`
	NxtConsensus     NxtConsensus     `json:"nxt-consensus"`
	Features         []uint64         `json:"features"`
	Generator        proto.Address    `json:"generator"`
	Signature        crypto.Signature `json:"signature"`
	Blocksize        uint64           `json:"blocksize"`
	TransactionCount uint64           `json:"transactionCount"`
	Height           uint64           `json:"height"`
}

type HttpClient

type HttpClient interface {
}

type NxtConsensus

type NxtConsensus struct {
	BaseTarget          uint64 `json:"base-target"`
	GenerationSignature string `json:"generation-signature"`
}

type Options

type Options struct {
	BaseUrl string
	Client  Doer
	ApiKey  string
}

type ParseError

type ParseError struct {
	Err error
}

func (ParseError) Error

func (a ParseError) Error() string

type PeerAllRow

type PeerAllRow struct {
	Address  proto.PeerInfo
	LastSeen uint64 `json:"lastSeen"`
}

type Peers

type Peers struct {
	// contains filtered or unexported fields
}

func NewPeers

func NewPeers(options Options) *Peers

func (*Peers) All

func (a *Peers) All(ctx context.Context) ([]*PeerAllRow, *Response, error)

func (*Peers) Blacklisted

func (a *Peers) Blacklisted(ctx context.Context) ([]*PeersBlacklistedRow, *Response, error)

func (*Peers) ClearBlacklist

func (a *Peers) ClearBlacklist(ctx context.Context) (string, *Response, error)

func (*Peers) Connect

func (a *Peers) Connect(ctx context.Context, host string, port uint16) (*PeersConnect, *Response, error)

func (*Peers) Connected

func (a *Peers) Connected(ctx context.Context) ([]*PeersConnectedRow, *Response, error)

func (*Peers) Suspended

func (a *Peers) Suspended(ctx context.Context) ([]*PeersSuspendedRow, *Response, error)

type PeersBlacklistedRow

type PeersBlacklistedRow struct {
	Hostname  proto.PeerInfo `json:"hostname"`
	Timestamp uint64         `json:"timestamp"`
	Reason    string         `json:"reason"`
}

type PeersConnect

type PeersConnect struct {
	Hostname string `json:"hostname"`
	Status   string `json:"status"`
}

type PeersConnectedRow

type PeersConnectedRow struct {
	Address            proto.PeerInfo `json:"address"`
	DeclaredAddress    proto.PeerInfo `json:"declaredAddress"`
	PeerName           string         `json:"peerName"`
	PeerNonce          uint64         `json:"peerNonce"`
	ApplicationName    string         `json:"applicationName"`
	ApplicationVersion string         `json:"applicationVersion"`
}

type PeersSuspendedRow

type PeersSuspendedRow struct {
	Hostname  proto.PeerInfo `json:"hostname"`
	Timestamp uint64         `json:"timestamp"`
}

type RequestError

type RequestError struct {
	Err  error
	Body string
}

func (*RequestError) Error

func (a *RequestError) Error() string

type Response

type Response struct {
	*http.Response
}

type TransactionTypeVersion added in v0.1.2

type TransactionTypeVersion struct {
	Type    proto.TransactionType `json:"type"`
	Version byte                  `json:"version,omitempty"`
}

type Transactions added in v0.1.2

type Transactions struct {
	// contains filtered or unexported fields
}

func NewTransactions added in v0.1.2

func NewTransactions(options Options) *Transactions

func (*Transactions) Address added in v0.1.2

func (a *Transactions) Address(ctx context.Context, address proto.Address, limit uint) ([]proto.Transaction, *Response, error)

Get list of transactions where specified address has been involved

func (*Transactions) Info added in v0.1.2

Get transaction info

func (*Transactions) Unconfirmed added in v0.1.2

func (a *Transactions) Unconfirmed(ctx context.Context) ([]proto.Transaction, *Response, error)

Get the number of unconfirmed transactions in the UTX pool

func (*Transactions) UnconfirmedInfo added in v0.1.2

func (a *Transactions) UnconfirmedInfo(ctx context.Context, id crypto.Digest) (proto.Transaction, *Response, error)

Get transaction that is in the UTX

func (*Transactions) UnconfirmedSize added in v0.1.2

func (a *Transactions) UnconfirmedSize(ctx context.Context) (uint64, *Response, error)

Get the number of unconfirmed transactions in the UTX pool

type Utils added in v0.1.2

type Utils struct {
	// contains filtered or unexported fields
}

func NewUtils added in v0.1.2

func NewUtils(options Options) *Utils

returns new utils

func (*Utils) HashFast added in v0.1.2

func (a *Utils) HashFast(ctx context.Context, message string) (*UtilsHashFast, *Response, error)

Return FastCryptographicHash of specified message

func (*Utils) HashSecure added in v0.1.2

func (a *Utils) HashSecure(ctx context.Context, message string) (*UtilsHashSecure, *Response, error)

Return SecureCryptographicHash of specified message

func (*Utils) ScriptCompile added in v0.1.2

func (a *Utils) ScriptCompile(ctx context.Context, code string) (*UtilsScriptCompile, *Response, error)

Compiles string code to base64 script representation

func (*Utils) ScriptEstimate added in v0.1.2

func (a *Utils) ScriptEstimate(ctx context.Context, base64code string) (*UtilsScriptEstimate, *Response, error)

Estimates compiled code in Base64 representation

func (*Utils) Seed added in v0.1.2

func (a *Utils) Seed(ctx context.Context) (string, *Response, error)

Generate random seed

func (*Utils) SeedByLength added in v0.1.2

func (a *Utils) SeedByLength(ctx context.Context, length uint16) (string, *Response, error)

Generate random seed of specified length

func (*Utils) Sign added in v0.1.2

func (a *Utils) Sign(ctx context.Context, secretKey crypto.SecretKey, message string) (*UtilsSign, *Response, error)

Return FastCryptographicHash of specified message

func (*Utils) Time added in v0.1.2

func (a *Utils) Time(ctx context.Context) (*UtilsTime, *Response, error)

Current Node time (UTC)

type UtilsHashFast added in v0.1.2

type UtilsHashFast struct {
	Message string `json:"message"`
	Hash    string `json:"hash"`
}

type UtilsHashSecure added in v0.1.2

type UtilsHashSecure struct {
	Message string `json:"message"`
	Hash    string `json:"hash"`
}

type UtilsScriptCompile added in v0.1.2

type UtilsScriptCompile struct {
	Script     string `json:"script"`
	Complexity uint64 `json:"complexity"`
	ExtraFee   uint64 `json:"extraFee"`
}

type UtilsScriptEstimate added in v0.1.2

type UtilsScriptEstimate struct {
	Script     string `json:"script"`
	ScriptText string `json:"scriptText"`
	Complexity uint64 `json:"complexity"`
	ExtraFee   uint64 `json:"extraFee"`
}

type UtilsSign added in v0.1.2

type UtilsSign struct {
	Message   string `json:"message"`
	Signature string `json:"signature"`
}

type UtilsTime added in v0.1.2

type UtilsTime struct {
	System uint64 `json:"system"`
	NTP    uint64 `json:"NTP"`
}

type VerifyText

type VerifyText struct {
	Valid bool
}

type VerifyTextReq

type VerifyTextReq struct {
	Message   string           `json:"message"`
	PublicKey crypto.PublicKey `json:"publickey"`
	Signature crypto.Signature `json:"signature"`
}

type Wallet

type Wallet struct {
	// contains filtered or unexported fields
}

func NewWallet

func NewWallet(options Options) *Wallet

func (*Wallet) Seed

func (a *Wallet) Seed(ctx context.Context) (string, *Response, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL