dash

package
v1.0.8 Latest Latest
Warning

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

Go to latest
Published: Jan 31, 2019 License: Apache-2.0 Imports: 6 Imported by: 4 modules, 4 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DuffsToDash added in v1.0.3

func DuffsToDash(duffs float64) float64

DuffsToDash is used to convert units of duffs to dash

Types

type BlockByHashResponse

type BlockByHashResponse struct {
	Error             string      `json:"error,omitempty"`
	Hash              string      `json:"hash"`
	Size              int         `json:"size"`
	Height            int         `json:"height"`
	Version           int         `json:"version"`
	MerkleRoot        string      `json:"merkleroot"`
	Tx                []string    `json:"tx"`
	Time              int         `json:"time"`
	Bits              string      `json:"bits"`
	ChainWork         string      `json:"chainwork"`
	Confirmations     int         `json:"confirmations"`
	PreviousBlockHash string      `json:"previousblockhash"`
	NextBlockHash     string      `json:"nextblockhash"`
	Reward            string      `json:"reward"`
	IsMainChain       bool        `json:"isMainChain"`
	PoolInfo          interface{} `json:"poolInfo"`
}

BlockByHashResponse is information fro a particular block

type BlockchainDataSyncStatusResponse

type BlockchainDataSyncStatusResponse struct {
	Error            string `json:"error,omitempty"`
	Status           string `json:"status"`
	BlockchainHeight int    `json:"blockChainHeight"`
	SyncPercentage   int    `json:"syncPercentage"`
	Height           int    `json:"height"`
	Type             string `json:"type"`
}

BlockchainDataSyncStatusResponse is a response from the blockchain data sync call

type Client

type Client struct {
	URL     string `json:"url"`
	Payload string `json:"payload"`
	Token   string `json:"token"`
	HC      *http.Client
}

Client is how we interact with the chain rider api

func NewClient

func NewClient(opts *ConfigOpts) *Client

NewClient is used to initialize our ChainRider client

func (*Client) BalanceForAddress

func (c *Client) BalanceForAddress(address string) (int, error)

BalanceForAddress returns the balance for an address in duffs

func (*Client) CreatePaymentForward

func (c *Client) CreatePaymentForward(opts *PaymentForwardOpts) (*CreatePaymentForwardResponse, error)

CreatePaymentForward is used to create a payment forward

func (*Client) DeletePaymentForwardByID

func (c *Client) DeletePaymentForwardByID(id string) error

DeletePaymentForwardByID is used to delete a particular payment forward rule

func (*Client) GeneratePayload

func (c *Client) GeneratePayload()

GeneratePayload is used to generate our payload

func (*Client) GetBlockByHash

func (c *Client) GetBlockByHash(blockHash string) (*BlockByHashResponse, error)

func (*Client) GetBlockchainSyncStatus

func (c *Client) GetBlockchainSyncStatus() (*BlockchainDataSyncStatusResponse, error)

func (*Client) GetInformation

func (c *Client) GetInformation() (*InformationResponse, error)

GetInformation is used to retrieve general blockchain information

func (*Client) GetLastBlockHash

func (c *Client) GetLastBlockHash() (*LastBlockHashResponse, error)

func (*Client) GetPaymentForwardByID

func (c *Client) GetPaymentForwardByID(id string) (*GetPaymentForwardByIDResponse, error)

GetPaymentForwardByID is used to lookup a particular payment forward

func (*Client) GetRateLimit

func (c *Client) GetRateLimit() (*RateLimitResponse, error)

GetRateLimit is used to get our rate limit information for the current token

func (*Client) TransactionByHash

func (c *Client) TransactionByHash(txHash string) (*TransactionByHashResponse, error)

TransactionByHash is used to get transaction information for a particular hash

func (*Client) TransactionsForAddress

func (c *Client) TransactionsForAddress(address string) (*TransactionsForAddressResponse, error)

TransactionsForAddress is used to get a list of several transactions for a particular address

type ConfigOpts

type ConfigOpts struct {
	APIVersion      string `json:"api_version"`
	DigitalCurrency string `json:"digital_currency"`
	Blockchain      string `json:"blockchain"`
	Token           string `json:"token"`
}

ConfigOpts are the configuration options for our session with teh api

type CreatePaymentForwardResponse

type CreatePaymentForwardResponse struct {
	Error                string  `json:"error,omitempty"`
	PaymentForwardID     string  `json:"paymentforward_id"`
	PaymentAddress       string  `json:"payment_address"`
	DestinationAddress   string  `json:"destination_address"`
	CommissionFeePercent float64 `json:"commission_fee_percent"`
	MiningFeeDuffs       int     `json:"mining_fee_duffs"`
}

CreatePaymentForwardResponse is a resposne from the create payment forward call

type GetPaymentForwardByIDResponse

type GetPaymentForwardByIDResponse struct {
	Error                string              `json:"error,omitempty"`
	PaymentForwardID     string              `json:"paymentforward_id"`
	PaymentAddress       string              `json:"payment_address"`
	DestinationAddress   string              `json:"destination_address"`
	CommissionAddress    string              `json:"commission_address"`
	CommissionFeePercent float64             `json:"commission_fee_percent"`
	CreatedDate          string              `json:"created_date"`
	CallbackURL          string              `json:"callback_url"`
	MiningFeeDuffs       int                 `json:"mining_fee_duffs"`
	ProcessedTxs         []ProcessedTxObject `json:"processed_txs"`
}

GetPaymentForwardByIDResponse is a response a from get payment forward by id

type InformationResponse

type InformationResponse struct {
	Error string `json:"error,omitempty"`
	Info  struct {
		Version         int     `json:"version"`
		InsightVerison  string  `json:"insightversion"`
		ProtocolVersion int     `json:"protocolversion"`
		Blocks          int     `json:"blocks"`
		TimeOffset      int     `json:"timeoffset"`
		Connections     int     `json:"connections"`
		Proxy           string  `json:"proxy"`
		Difficulty      float64 `json:"difficulty"`
		Testnet         bool    `json:"testnet"`
		RelayFee        float64 `json:"relayfee"`
		Errors          string  `json:"errors"`
		Network         string  `json:"network"`
	} `json:"info"`
}

InformationResponse is the resposne from the information request

type LastBlockHashResponse

type LastBlockHashResponse struct {
	Error         string `json:"error,omitempty"`
	SyncTipHash   string `json:"syncTipHash"`
	LastBlockHash string `json:"lastblockhash"`
}

LastBlockHashResponse is a resposne from the last block hash call

type PaymentForwardOpts

type PaymentForwardOpts struct {
	// DestinationAddress is the address to which dash will be forwarded to
	DestinationAddress string `json:"destination_address"`
	CallbackURL        string `json:"callback_url,omitempty"`
}

PaymentForwardOpts is used to configure payment forward creation

type ProcessedTxObject

type ProcessedTxObject struct {
	Error                string `json:"error,omitempty"`
	InputTransactionHash string `json:"input_transaction_hash"`
	ReceivedAmountDuffs  int    `json:"received_amount_duffs"`
	TransactionHash      string `json:"transaction_hash"`
	// time at which the payment was forwarded
	ProcessedDate string `json:"processed_date"`
}

ProcessedTxObject is a transaction that has been processed for a payment forward

type RateLimitResponse

type RateLimitResponse struct {
	Error   string `json:"error,omitempty"`
	Message struct {
		Hour struct {
			Usage    int `json:"usage"`
			Limit    int `json:"limit"`
			TimeLeft int `json:"time_left"`
		} `json:"hour"`
		Day struct {
			Usage    int `json:"usage"`
			Limit    int `json:"limit"`
			TimeLeft int `json:"time_left"`
		} `json:"day"`
		Forward struct {
			Usage    int `json:"usage"`
			Limit    int `json:"limit"`
			TimeLeft int `json:"time_left"`
		} `json:"forward"`
	} `json:"message"`
}

RateLimitResponse is the response given by the rate limit request

type TransactionByHashResponse

type TransactionByHashResponse struct {
	Error    string `json:"error,omitempty"`
	TxID     string `json:"txid"`
	Version  int    `json:"version"`
	Locktime int    `json:"locktime"`
	Vin      []struct {
		TxID      string `json:"txid"`
		Vout      int    `json:"vout"`
		N         int    `json:"n"`
		ScriptSig struct {
			Hex string `json:"hex"`
			Asm string `json:"asm"`
		} `json:"scriptsig"`
		Addr            string  `json:"addr"`
		ValueSat        int     `json:"valueSat"`
		Value           float64 `json:"value"`
		DoubleSpentTxID string  `json:"doubleSpentTxID,omitempty"`
	} `json:"vin"`
	Vout []struct {
		Value        string `json:"value"` // this might need to be a string
		N            int    `json:"n"`
		ScriptPubKey struct {
			Hex       string   `json:"hex"`
			Asm       string   `json:"asm"`
			Addresses []string `json:"addresses"`
			Type      string   `json:"type"`
		} `json:"scriptPubKey"`
		SpentTxID   string `json:"spentTxId"`
		SpentIndex  int    `json:"spentIndex"`
		SpentHeight int    `json:"spentHeight"`
	} `json:"vout"`
	BlockHash     string  `json:"blockhash"`
	BlockHeight   int     `json:"blockheight"`
	Confirmations int     `json:"confirmations"`
	Time          int     `json:"time"`      // looks like its unix timestamp
	BlockTime     int     `json:"blocktime"` // looks like its unix timestamps
	ValueOut      float64 `json:"valueOut"`
	Size          int     `json:"size"`
	ValueIn       float64 `json:"valueIn"`
	Fees          float64 `json:"fees"`
	TxLock        bool    `json:"txlock"`
}

TransactionByHashResponse is a response for a given transaction hash request

type TransactionsForAddressResponse

type TransactionsForAddressResponse struct {
	Error        string                      `json:"error,omitempty"`
	PagesTotal   int                         `json:"pagesTotal"`
	Transactions []TransactionByHashResponse `json:"txs"`
}

TransactionsForAddressResponse is a collection of multiple transactions

Jump to

Keyboard shortcuts

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