chainridergo

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2018 License: Apache-2.0 Imports: 6 Imported by: 0 modules, 0 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.

README

ChainRider-Go

Basic wrapper around the ChainRider API

Usage

The payload is how we authenticate with chainrider, and consists of the following: "{\n \"token\": \"%s\"\n}"

The url pattern for chain rider is as follows: https://api.chainrider.io/<API_VERSION>/<DIGITAL_CURRENCY>/<BLOCKCHAIN>

Examples:

  • https://api-dot-chainrider.io/v1/dash/main
  • https://api-dot-chainrider.io/v1/dash/testnet

Supported Calls

At the moment, only DASH is supported

DASH
  • POST /v1/ratelimit/
  • GET /status?q=getInfo
  • GET /tx/<tx_hash>
  • GET /txns (partial support)
  • GET /addr/<address>/balance
  • GET /block/<block_hash>
  • GET /status?q=getLastBlockHash
  • GET /sync

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BlockByHashResponse

type BlockByHashResponse struct {
	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"`
}

BlockByHash is information fro a particular block

type BlockchainDataSyncStatusResponse

type BlockchainDataSyncStatusResponse struct {
	Status           string `json:"status"`
	BlockchainHeight int    `json:"blockChainHeight"`
	SyncPercentage   int    `json:"syncPercentage"`
	Height           int    `json:"height"`
	Error            string `json:"error"`
	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, error)

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) 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) 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 InformationResponse

type InformationResponse struct {
	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 {
	SyncTipHash   string `json:"syncTipHash"`
	LastBlockHash string `json:"lastblockhash"`
}

LastBlockHashResponse is a resposne from the last block hash call

type RateLimitResponse

type RateLimitResponse struct {
	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 {
	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 {
	PagesTotal   int                         `json:"pagesTotal"`
	Transactions []TransactionByHashResponse `json:"txs"`
}

TransactionsForAddressResposne is a collection of multiple transactions

Jump to

Keyboard shortcuts

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