Documentation
¶
Overview ¶
Package mattercloud is the unofficial golang implementation for the MatterCloud API
Index ¶
- type APIInternalError
- type AddressList
- type AddressService
- type Balance
- type BroadcastResponse
- type BroadcastResult
- type Client
- func (c *Client) AddressBalance(ctx context.Context, address string) (balance *Balance, err error)
- func (c *Client) AddressBalanceBatch(ctx context.Context, addresses []string) (balances []*Balance, err error)
- func (c *Client) AddressHistory(ctx context.Context, address string) (history *History, err error)
- func (c *Client) AddressHistoryBatch(ctx context.Context, addresses []string) (history *History, err error)
- func (c *Client) AddressUtxos(ctx context.Context, address string) (utxos []*UnspentTransaction, err error)
- func (c *Client) AddressUtxosBatch(ctx context.Context, addresses []string) (utxos []*UnspentTransaction, err error)
- func (c *Client) Broadcast(ctx context.Context, rawTx string) (response *BroadcastResponse, err error)
- func (c *Client) Network() NetworkType
- func (c *Client) Request(ctx context.Context, endpoint, method string, payload []byte) (response string, err error)
- func (c *Client) Transaction(ctx context.Context, tx string) (transaction *Transaction, err error)
- func (c *Client) TransactionBatch(ctx context.Context, txIDs []string) (transactions []*Transaction, err error)
- type ClientInterface
- type HTTPInterface
- type History
- type HistoryItem
- type LastRequest
- type NetworkType
- type Options
- type Parameters
- type ScriptPubKeyType
- type ScriptSigType
- type Transaction
- type TransactionList
- type TransactionService
- type UnspentTransaction
- type VinType
- type VoutType
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type APIInternalError ¶
type APIInternalError struct { Code int `json:"code,omitempty"` ErrorMessage string `json:"message,omitempty"` Error string `json:"error,omitempty"` Errors []string `json:"errors,omitempty"` Success bool `json:"success,omitempty"` }
APIInternalError is for internal server errors (most requests)
type AddressList ¶
type AddressList struct {
Addrs string `json:"addrs"`
}
AddressList is the list of addresses for batch
type AddressService ¶ added in v0.5.1
type AddressService interface { AddressBalance(ctx context.Context, address string) (balance *Balance, err error) AddressBalanceBatch(ctx context.Context, addresses []string) (balances []*Balance, err error) AddressHistory(ctx context.Context, address string) (history *History, err error) AddressHistoryBatch(ctx context.Context, addresses []string) (history *History, err error) AddressUtxos(ctx context.Context, address string) (utxos []*UnspentTransaction, err error) AddressUtxosBatch(ctx context.Context, addresses []string) (utxos []*UnspentTransaction, err error) }
AddressService is the MatterCloud address related requests
type Balance ¶
type Balance struct { Address string `json:"address"` Confirmed int64 `json:"confirmed"` Unconfirmed int64 `json:"unconfirmed"` }
Balance is the response from the get balance request
type BroadcastResponse ¶
type BroadcastResponse struct { Success bool `json:"success"` Result *BroadcastResult `json:"result"` }
BroadcastResponse is the response for the broadcast
type BroadcastResult ¶ added in v0.5.3
type BroadcastResult struct {
TxID string `json:"txid"`
}
BroadcastResult is the internal response payload
type Client ¶
type Client struct { LastRequest *LastRequest // is the raw information from the last request Parameters *Parameters // contains application specific values // contains filtered or unexported fields }
Client is the parent struct that wraps the heimdall client
func (*Client) AddressBalance ¶
AddressBalance this endpoint retrieves balance for a specific address.
For more information: https://developers.mattercloud.io/#get-balance
func (*Client) AddressBalanceBatch ¶
func (c *Client) AddressBalanceBatch(ctx context.Context, addresses []string) (balances []*Balance, err error)
AddressBalanceBatch this endpoint retrieves balances for multiple addresses at same time
For more information: https://developers.mattercloud.io/#get-balance-batch
func (*Client) AddressHistory ¶
AddressHistory this endpoint retrieves history for a specific address
For more information: https://developers.mattercloud.io/#get-history
func (*Client) AddressHistoryBatch ¶
func (c *Client) AddressHistoryBatch(ctx context.Context, addresses []string) (history *History, err error)
AddressHistoryBatch this endpoint retrieves history for multiple addresses
For more information: https://developers.mattercloud.io/#get-history-batch
func (*Client) AddressUtxos ¶
func (c *Client) AddressUtxos(ctx context.Context, address string) (utxos []*UnspentTransaction, err error)
AddressUtxos this endpoint retrieves utxos for a specific address
For more information: https://developers.mattercloud.io/#get-utxos
func (*Client) AddressUtxosBatch ¶
func (c *Client) AddressUtxosBatch(ctx context.Context, addresses []string) (utxos []*UnspentTransaction, err error)
AddressUtxosBatch this endpoint retrieves utxos for multiple addresses
For more information: https://developers.mattercloud.io/#get-utxos-batch
func (*Client) Broadcast ¶
func (c *Client) Broadcast(ctx context.Context, rawTx string) (response *BroadcastResponse, err error)
Broadcast this endpoint broadcasts a raw transaction to the network
For more information: https://developers.mattercloud.io/#broadcast-transaction
func (*Client) Network ¶ added in v0.5.0
func (c *Client) Network() NetworkType
Network will return the current network
func (*Client) Request ¶
func (c *Client) Request(ctx context.Context, endpoint, method string, payload []byte) (response string, err error)
Request is a generic request wrapper that can be used without constraints
func (*Client) Transaction ¶
Transaction this endpoint retrieves specific transaction
For more information: https://developers.mattercloud.io/#get-transaction
func (*Client) TransactionBatch ¶
func (c *Client) TransactionBatch(ctx context.Context, txIDs []string) (transactions []*Transaction, err error)
TransactionBatch this endpoint retrieves details for multiple transactions at same time
For more information: https://developers.mattercloud.io/#get-transaction-batch
type ClientInterface ¶ added in v0.5.0
type ClientInterface interface { AddressService TransactionService Network() NetworkType Request(ctx context.Context, endpoint, method string, payload []byte) (response string, err error) }
ClientInterface is the MatterCloud client interface
func NewClient ¶
func NewClient(apiKey string, network NetworkType, clientOptions *Options, customHTTPClient HTTPInterface) (c ClientInterface, err error)
NewClient creates a new client to submit requests Parameters values are set to the defaults defined by the API documentation.
For more information: https://developers.mattercloud.io/
Example ¶
ExampleNewClient example using NewClient()
client, _ := NewClient(testAPIKey, NetworkMain, nil, nil) fmt.Println(client.Network())
Output: main
type HTTPInterface ¶ added in v0.4.0
HTTPInterface is used for the http client (mocking heimdall)
type History ¶
type History struct { From int `json:"from"` Results []*HistoryItem `json:"results"` To int `json:"to"` }
History is the response from address history
type HistoryItem ¶
HistoryItem is the individual history item
type LastRequest ¶
type LastRequest struct { Method string `json:"method"` // method is the HTTP method used PostData string `json:"post_data"` // postData is the post data submitted if POST/PUT request StatusCode int `json:"status_code"` // statusCode is the last code from the request URL string `json:"url"` // url is the url used for the request }
LastRequest is used to track what was submitted via the Request()
type NetworkType ¶
type NetworkType string
NetworkType is used internally to represent the possible values for network in queries to be submitted: {"main", "test", "stn"}
const ( // NetworkMain is for main-net NetworkMain NetworkType = "main" // NetworkTest is for test-net NetworkTest NetworkType = "test" // NetworkStn is for the stn-net NetworkStn NetworkType = "stn" )
type Options ¶
type Options struct { BackOffExponentFactor float64 `json:"back_off_exponent_factor"` BackOffInitialTimeout time.Duration `json:"back_off_initial_timeout"` BackOffMaximumJitterInterval time.Duration `json:"back_off_maximum_jitter_interval"` BackOffMaxTimeout time.Duration `json:"back_off_max_timeout"` DialerKeepAlive time.Duration `json:"dialer_keep_alive"` DialerTimeout time.Duration `json:"dialer_timeout"` RequestRetryCount int `json:"request_retry_count"` RequestTimeout time.Duration `json:"request_timeout"` TransportExpectContinueTimeout time.Duration `json:"transport_expect_continue_timeout"` TransportIdleTimeout time.Duration `json:"transport_idle_timeout"` TransportMaxIdleConnections int `json:"transport_max_idle_connections"` TransportTLSHandshakeTimeout time.Duration `json:"transport_tls_handshake_timeout"` UserAgent string `json:"user_agent"` }
Options holds all the configuration for connection, dialer and transport
func ClientDefaultOptions ¶
func ClientDefaultOptions() (clientOptions *Options)
ClientDefaultOptions will return an "Options" struct with the default settings Useful for starting with the default and then modifying as needed
type Parameters ¶
type Parameters struct { Network NetworkType // is the BitcoinSV network to use UserAgent string // (optional for changing user agents) // contains filtered or unexported fields }
Parameters are application specific values for requests
type ScriptPubKeyType ¶
type ScriptPubKeyType struct { Addresses []string `json:"addresses"` Asm string `json:"asm"` Hex string `json:"hex"` RequiredSignatures int `json:"reqSigs"` Type string `json:"type"` }
ScriptPubKeyType is the script pubKey data
type ScriptSigType ¶
ScriptSigType is the script signature data
type Transaction ¶
type Transaction struct { APIInternalError BlockHash string `json:"blockhash"` BlockHeight int64 `json:"blockheight"` BlockTime int64 `json:"blocktime"` Confirmations int64 `json:"confirmations"` Fees float64 `json:"fees"` Hash string `json:"hash"` LockTime int64 `json:"locktime"` RawTx string `json:"rawtx"` Size int64 `json:"size"` Time int64 `json:"time"` TxID string `json:"txid"` ValueIn float64 `json:"valueIn"` ValueOut float64 `json:"valueOut"` Version int `json:"version"` Vin []VinType `json:"vin"` Vout []VoutType `json:"vout"` }
Transaction is returned to the GetTransactionsResponse
type TransactionList ¶
type TransactionList struct {
TxIDs string `json:"txids"`
}
TransactionList is the list of tx ids for batch
type TransactionService ¶ added in v0.5.1
type TransactionService interface { Broadcast(ctx context.Context, rawTx string) (response *BroadcastResponse, err error) Transaction(ctx context.Context, tx string) (transaction *Transaction, err error) TransactionBatch(ctx context.Context, txIDs []string) (transactions []*Transaction, err error) }
TransactionService is the MatterCloud transaction related requests
type UnspentTransaction ¶
type UnspentTransaction struct { Address string `json:"address"` Amount float64 `json:"amount"` Confirmations int64 `json:"confirmations"` Height int64 `json:"height"` OutputIndex int64 `json:"outputIndex"` Satoshis int64 `json:"satoshis"` Script string `json:"script"` ScriptPubKey string `json:"scriptPubKey"` TxID string `json:"txid"` Value int64 `json:"value"` Vout int `json:"vout"` }
UnspentTransaction is a standard UTXO response
type VinType ¶
type VinType struct { Address string `json:"address"` AddressAddr string `json:"addr"` N int `json:"n"` ScriptSig ScriptSigType `json:"scriptSig"` Sequence int64 `json:"sequence"` TxID string `json:"txid"` Value float64 `json:"value"` ValueSatoshis int64 `json:"valueSat"` Vout int `json:"vout"` }
VinType is the vin data
type VoutType ¶
type VoutType struct { N int `json:"n"` ScriptPubKey ScriptPubKeyType `json:"scriptPubKey"` SpentHeight int64 `json:"spentHeight"` SpentIndex int64 `json:"spentIndex"` SpentTxID string `json:"spentTxId"` Value float64 `json:"value"` ValueSatoshis int64 `json:"valueSat"` }
VoutType is the vout data