whatsonchain

package module
v0.6.1 Latest Latest
Warning

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

Go to latest
Published: Aug 26, 2020 License: MIT Imports: 12 Imported by: 8

README

go-whatsonchain

The unofficial golang implementation for the whatsonchain.com API

Release Build Status Report codecov Go Sponsor Donate


Table of Contents


Installation

go-whatsonchain requires a supported release of Go.

go get -u github.com/mrz1836/go-whatsonchain

Documentation

View the generated documentation

GoDoc

Features
  • Client is completely configurable
  • Customize the network per request (main, test or stn)
  • Using default heimdall http client with exponential backoff & more
  • Use your own custom HTTP client
  • Current coverage for the whatsonchain.com API
    • Health
      • Get API Status
    • Chain Info
      • Get Blockchain Info
      • Get Circulating Supply
    • Block
      • Get by Hash
      • Get by Height
      • Get Block Pages
      • Get Header by Hash
      • Get Headers
    • Transaction
      • Get by TX Hash
      • Broadcast Transaction
      • Bulk Broadcast
      • Bulk Transaction Details
      • Decode Transaction
      • Download Receipt
      • Get Raw Transaction Data
      • Get Raw Transaction Output
      • Get Merkle Proof
    • Mempool
      • Get Mempool Info
      • Get Mempool Transactions
    • Address
      • Get Address Info
      • Get Balance
      • Get History
      • Get Unspent Transactions
      • Get Unspent Transaction Details (Custom)
      • Download Statement
    • Script
      • Get Script History
      • Get Script Unspent Transactions
    • Exchange Rate
      • Get Exchange Rate
    • Search
      • Get Explorer Links
    • Merchant API
      • Fee Quotes
      • Submit Transaction
      • Transaction Status
Library Deployment

goreleaser for easy binary or library deployment to Github and can be installed via: brew install goreleaser.

The .goreleaser.yml file is used to configure goreleaser.

Use make release-snap to create a snapshot version of the release, and finally make release to ship to production.

Makefile Commands

View all makefile commands

make help

List of all current commands:

clean                  Remove previous builds and any test cache data
clean-mods             Remove all the Go mod cache
coverage               Shows the test coverage
godocs                 Sync the latest tag with GoDocs
help                   Show this help message
install                Install the application
install-go             Install the application (Using Native Go)
lint                   Run the Go lint application
release                Full production release (creates release in Github)
release                Runs common.release then runs godocs
release-snap           Test the full release (build binaries)
release-test           Full production test release (everything except deploy)
replace-version        Replaces the version in HTML/JS (pre-deploy)
tag                    Generate a new tag and push (tag version=0.0.0)
tag-remove             Remove a tag if found (tag-remove version=0.0.0)
tag-update             Update an existing tag to current commit (tag-update version=0.0.0)
test                   Runs vet, lint and ALL tests
test-short             Runs vet, lint and tests (excludes integration tests)
test-travis            Runs all tests via Travis (also exports coverage)
test-travis-short      Runs unit tests via Travis (also exports coverage)
uninstall              Uninstall the application (and remove files)
vet                    Run the Go vet application

Examples & Tests

All unit tests and examples run via Travis CI and uses Go version 1.15.x. View the deployment configuration file.

Run all tests (including integration tests)

make test

Run tests (excluding integration tests)

make test-short

Benchmarks

Run the Go benchmarks:

make bench

Code Standards

Read more about this Go project's code standards.


Usage

View the whatsonchain examples

Basic implementation:

package main

import (

    "fmt"
    
    "github.com/mrz1836/go-whatsonchain"
)

func main() {

    // Create a client
    client := whatsonchain.NewClient(whatsonchain.NetworkMain, nil, nil)

    // Get a balance for an address
    balance, _ := client.AddressBalance("16ZqP5Tb22KJuvSAbjNkoiZs13mmRmexZA")
    fmt.Println("confirmed balance", balance.Confirmed)
}

Maintainers

MrZ
MrZ

Contributing

View the contributing guidelines and please follow the code of conduct.

How can I help?

All kinds of contributions are welcome 🙌! The most basic way to show your support is to star 🌟 the project, or to raise issues 💬. You can also support this project by becoming a sponsor on GitHub 👏 or by making a bitcoin donation to ensure this journey continues indefinitely! 🚀

Credits

WhatsOnChain for their hard work on the Whatsonchain API

AustEcon's Python Version


License

License

Documentation

Overview

Package whatsonchain is the unofficial golang implementation for the whatsonchain.com API

Example:

``` // Create a client client := whatsonchain.NewClient(whatsonchain.NetworkMain, nil, nil)

// Get a balance for an address balance, _ := client.AddressBalance("16ZqP5Tb22KJuvSAbjNkoiZs13mmRmexZA") fmt.Println("confirmed balance", balance.Confirmed) ```

Index

Examples

Constants

View Source
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"

	// MaxTransactionsUTXO is the max allowed in the request
	MaxTransactionsUTXO int = 20

	// MaxBroadcastTransactions is the max transactions for Bulk Broadcast
	MaxBroadcastTransactions = 100

	// MaxSingleTransactionSize is the max single TX size for Bulk Broadcast
	MaxSingleTransactionSize = 102400

	// MaxCombinedTransactionSize is the max of all transactions combined
	MaxCombinedTransactionSize = 1e+7
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AddressBalance

type AddressBalance struct {
	Confirmed   int64 `json:"confirmed"`
	Unconfirmed int64 `json:"unconfirmed"`
}

AddressBalance is the address balance (unconfirmed and confirmed)

type AddressHistory

type AddressHistory []*HistoryRecord

AddressHistory is the history of transactions for an address

type AddressInfo

type AddressInfo struct {
	Address      string `json:"address"`
	IsMine       bool   `json:"ismine"`
	IsScript     bool   `json:"isscript"`
	IsValid      bool   `json:"isvalid"`
	IsWatchOnly  bool   `json:"iswatchonly"`
	ScriptPubKey string `json:"scriptPubKey"`
}

AddressInfo is the address info for a returned address request

type BlockInfo

type BlockInfo struct {
	Bits              string         `json:"bits"`
	ChainWork         string         `json:"chainwork"`
	CoinbaseTx        CoinbaseTxInfo `json:"coinbaseTx"`
	Confirmations     int64          `json:"confirmations"`
	Difficulty        float64        `json:"difficulty"`
	Hash              string         `json:"hash"`
	Height            int64          `json:"height"`
	MedianTime        int64          `json:"mediantime"`
	MerkleRoot        string         `json:"merkleroot"`
	Miner             string         `json:"Bmgpool"`
	NextBlockHash     string         `json:"nextblockhash"`
	Nonce             int64          `json:"nonce"`
	Pages             Page           `json:"pages"`
	PreviousBlockHash string         `json:"previousblockhash"`
	Size              int64          `json:"size"`
	Time              int64          `json:"time"`
	TotalFees         float64        `json:"totalFees"`
	Tx                []string       `json:"tx"`
	TxCount           int64          `json:"txcount"`
	Version           int64          `json:"version"`
	VersionHex        string         `json:"versionHex"`
}

BlockInfo is the response info about a returned block

type BlockPagesInfo

type BlockPagesInfo []string

BlockPagesInfo is the response from the page request

type BulkBroadcastResponse added in v0.0.5

type BulkBroadcastResponse struct {
	Feedback  bool   `json:"feedback"`
	StatusURL string `json:"statusUrl"`
}

BulkBroadcastResponse is the response from a bulk broadcast request

type ChainInfo

type ChainInfo struct {
	BestBlockHash        string  `json:"bestblockhash"`
	Blocks               int64   `json:"blocks"`
	Chain                string  `json:"chain"`
	ChainWork            string  `json:"chainwork"`
	Difficulty           float64 `json:"difficulty"`
	Headers              int64   `json:"headers"`
	MedianTime           int64   `json:"mediantime"`
	Pruned               bool    `json:"pruned"`
	VerificationProgress float64 `json:"verificationprogress"`
}

ChainInfo is the structure response from getting info about the chain

type CirculatingSupply added in v0.2.4

type CirculatingSupply float64

CirculatingSupply is the structure response

type Client

type Client struct {
	LastRequest *LastRequest // is the raw information from the last request
	Network     NetworkType  // is the BitcoinSV network to use
	UserAgent   string       // optional for changing user agents
	// contains filtered or unexported fields
}

Client is the parent struct that wraps the heimdall client

func NewClient

func NewClient(network NetworkType, clientOptions *Options, customHTTPClient *http.Client) *Client

NewClient creates a new client for WOC requests

Example

ExampleNewClient example using NewClient()

client := NewClient(NetworkTest, nil, nil)
fmt.Println(client.UserAgent)
Output:

go-whatsonchain: v0.6.1

func (*Client) AddressBalance

func (c *Client) AddressBalance(address string) (balance *AddressBalance, err error)

AddressBalance this endpoint retrieves confirmed and unconfirmed address balance.

For more information: https://developers.whatsonchain.com/#get-balance

func (*Client) AddressHistory

func (c *Client) AddressHistory(address string) (history AddressHistory, err error)

AddressHistory this endpoint retrieves confirmed and unconfirmed address transactions.

For more information: https://developers.whatsonchain.com/#get-history

func (*Client) AddressInfo

func (c *Client) AddressInfo(address string) (addressInfo *AddressInfo, err error)

AddressInfo this endpoint retrieves various address info.

For more information: https://developers.whatsonchain.com/#address

func (*Client) AddressUnspentTransactionDetails added in v0.2.3

func (c *Client) AddressUnspentTransactionDetails(address string, maxTransactions int) (history AddressHistory, err error)

AddressUnspentTransactionDetails this endpoint retrieves transaction details for a given address Use max transactions to filter if there are more UTXOs returned than needed by the user

For more information: (custom request for this go package)

func (*Client) AddressUnspentTransactions

func (c *Client) AddressUnspentTransactions(address string) (history AddressHistory, err error)

AddressUnspentTransactions this endpoint retrieves ordered list of UTXOs.

For more information: https://developers.whatsonchain.com/#get-unspent-transactions

func (*Client) BroadcastTx

func (c *Client) BroadcastTx(txHex string) (txID string, err error)

BroadcastTx will broadcast transaction using this endpoint. Get tx_id in response or error msg from node.

For more information: https://developers.whatsonchain.com/#broadcast-transaction

func (*Client) BulkBroadcastTx added in v0.0.5

func (c *Client) BulkBroadcastTx(rawTxs []string, feedback bool) (response *BulkBroadcastResponse, err error)

BulkBroadcastTx will broadcast many transactions at once You can bulk broadcast transactions using this endpoint.

Size per transaction should be less than 100KB
Overall payload per request should be less than 10MB
Max 100 transactions per request
Only available for mainnet

Tip: First transaction in the list should have an output to WOC tip address '16ZqP5Tb22KJuvSAbjNkoiZs13mmRmexZA'

Feedback: true/false: true if response from the node is required for each transaction, otherwise, set it to false. (For stress testing set it to false). When set to true a unique url is provided to check the progress of the submitted transactions, eg 'QUEUED' or 'PROCESSED', with response data from node. You can poll the provided unique url until all transactions are marked as 'PROCESSED'. Progress of the transactions are tracked on this unique url for up to 5 hours.

For more information: https://developers.whatsonchain.com/#bulk-broadcast

func (*Client) BulkTransactionDetails added in v0.4.0

func (c *Client) BulkTransactionDetails(hashes *TxHashes) (txList TxList, err error)

BulkTransactionDetails this fetches details for multiple transactions in single request Max 20 transactions per request

For more information: https://developers.whatsonchain.com/#bulk-transaction-details

func (*Client) DecodeTransaction added in v0.4.0

func (c *Client) DecodeTransaction(txHex string) (txInfo *TxInfo, err error)

DecodeTransaction this endpoint decodes raw transaction

For more information: https://developers.whatsonchain.com/#decode-transaction

func (*Client) DownloadReceipt added in v0.4.0

func (c *Client) DownloadReceipt(hash string) (string, error)

DownloadReceipt this endpoint downloads a transaction receipt (PDF) The contents will be returned in plain-text and need to be converted to a file.pdf

For more information: https://developers.whatsonchain.com/#download-receipt

func (*Client) DownloadStatement added in v0.4.0

func (c *Client) DownloadStatement(address string) (string, error)

DownloadStatement this endpoint downloads an address statement (PDF) The contents will be returned in plain-text and need to be converted to a file.pdf

For more information: https://developers.whatsonchain.com/#download-statement

func (*Client) GetBlockByHash

func (c *Client) GetBlockByHash(hash string) (blockInfo *BlockInfo, err error)

GetBlockByHash this endpoint retrieves block details with given hash.

For more information: https://developers.whatsonchain.com/#get-by-hash

func (*Client) GetBlockByHeight

func (c *Client) GetBlockByHeight(height int64) (blockInfo *BlockInfo, err error)

GetBlockByHeight this endpoint retrieves block details with given block height.

For more information: https://developers.whatsonchain.com/#get-by-height

func (*Client) GetBlockPages

func (c *Client) GetBlockPages(hash string, page int) (txList BlockPagesInfo, err error)

GetBlockPages If the block has more that 1000 transactions the page URIs will be provided in the pages element when getting a block by hash or height.

For more information: https://developers.whatsonchain.com/#get-block-pages

func (*Client) GetChainInfo

func (c *Client) GetChainInfo() (chainInfo *ChainInfo, err error)

GetChainInfo this endpoint retrieves various state info of the chain for the selected network.

For more information: https://developers.whatsonchain.com/#chain-info

func (*Client) GetCirculatingSupply added in v0.2.4

func (c *Client) GetCirculatingSupply() (supply float64, err error)

GetCirculatingSupply this endpoint retrieves the current circulating supply

For more information: (undocumented) //todo: add link once in documentation

func (*Client) GetExchangeRate added in v0.4.0

func (c *Client) GetExchangeRate() (rate *ExchangeRate, err error)

GetExchangeRate this endpoint provides exchange rate for BSV

For more information: https://developers.whatsonchain.com/#get-exchange-rate

func (c *Client) GetExplorerLinks(query string) (results SearchResults, err error)

GetExplorerLinks this endpoint identifies whether the posted query text is a block hash, txid or address and responds with WoC links. Ideal for extending customized search in apps.

For more information: https://developers.whatsonchain.com/#get-history

func (*Client) GetFeeQuotes added in v0.5.0

func (c *Client) GetFeeQuotes() (quotes *FeeQuotes, err error)

GetFeeQuotes this endpoint provides fee quotes from multiple transaction processors. Each quote also contains transaction processor specific txSubmissionUrl and txStatusUrl. These unique URLs can be used to submit transactions to the selected transaction processor and check the status of the submitted transaction. Any post request to txSubmissionUrl is forwarded to the selected transaction processor ‘AS IS’ and is ‘NOT’ broadcast from any WoC nodes.

For more information: https://developers.whatsonchain.com/#fee-quotes

func (*Client) GetHeaderByHash added in v0.6.1

func (c *Client) GetHeaderByHash(hash string) (headerInfo *BlockInfo, err error)

GetHeaderByHash this endpoint retrieves block header details with given hash.

For more information: https://developers.whatsonchain.com/#get-header-by-hash

func (*Client) GetHeaders added in v0.6.1

func (c *Client) GetHeaders() (blockHeaders []*BlockInfo, err error)

GetHeaders this endpoint retrieves last 10 block headers.

For more information: https://developers.whatsonchain.com/#get-headers

func (*Client) GetHealth

func (c *Client) GetHealth() (status string, err error)

GetHealth simple endpoint to show API server is up and running

For more information: https://developers.whatsonchain.com/#health

func (*Client) GetMempoolInfo added in v0.4.0

func (c *Client) GetMempoolInfo() (info *MempoolInfo, err error)

GetMempoolInfo this endpoint retrieves various info about the node's mempool for the selected network

For more information: https://developers.whatsonchain.com/#get-mempool-info

func (*Client) GetMempoolTransactions added in v0.4.0

func (c *Client) GetMempoolTransactions() (transactions []string, err error)

GetMempoolTransactions this endpoint endpoint retrieve list of transaction ids from the node's mempool for the selected network

For more information: https://developers.whatsonchain.com/#get-mempool-transactions

func (*Client) GetMerkleProof added in v0.0.4

func (c *Client) GetMerkleProof(hash string) (merkleResults MerkleResults, err error)

GetMerkleProof this endpoint returns merkle branch to a confirmed transaction

For more information: https://developers.whatsonchain.com/#get-merkle-proof

func (*Client) GetRawTransactionData added in v0.3.0

func (c *Client) GetRawTransactionData(hash string) (string, error)

GetRawTransactionData this endpoint returns raw hex for the transaction with given hash

For more information: https://developers.whatsonchain.com/#get-raw-transaction-data

func (*Client) GetRawTransactionOutputData added in v0.3.0

func (c *Client) GetRawTransactionOutputData(hash string, vOutIndex int) (string, error)

GetRawTransactionOutputData this endpoint returns raw hex for the transaction output with given hash and index

For more information: https://developers.whatsonchain.com/#get-raw-transaction-output-data

func (*Client) GetScriptHistory added in v0.4.0

func (c *Client) GetScriptHistory(scriptHash string) (history ScriptList, err error)

GetScriptHistory this endpoint retrieves confirmed and unconfirmed script transactions

For more information: https://developers.whatsonchain.com/#get-script-history

func (*Client) GetScriptUnspentTransactions added in v0.4.0

func (c *Client) GetScriptUnspentTransactions(scriptHash string) (scriptList ScriptList, err error)

GetScriptUnspentTransactions this endpoint retrieves ordered list of UTXOs

For more information: https://developers.whatsonchain.com/#get-script-unspent-transactions

func (*Client) GetTxByHash

func (c *Client) GetTxByHash(hash string) (txInfo *TxInfo, err error)

GetTxByHash this endpoint retrieves transaction details with given transaction hash

For more information: https://developers.whatsonchain.com/#get-by-tx-hash

func (*Client) SubmitTransaction added in v0.5.0

func (c *Client) SubmitTransaction(provider string, txHex string) (response *SubmissionResponse, err error)

SubmitTransaction this endpoint submits a transaction to a specific transaction processor using the txSubmissionUrl provided with each quote in the Fee quotes response.

For more information: https://developers.whatsonchain.com/#submit-transaction

func (*Client) TransactionStatus added in v0.5.0

func (c *Client) TransactionStatus(provider string, txID string) (status *StatusResponse, err error)

TransactionStatus gets a transaction's status from a specific transaction processor using the txStatusUrl provided with each quote in Fee quotes response.

For more information: https://developers.whatsonchain.com/#transaction-status

type CoinbaseTxInfo

type CoinbaseTxInfo struct {
	BlockHash     string     `json:"blockhash"`
	BlockTime     int64      `json:"blocktime"`
	Confirmations int64      `json:"confirmations"`
	Hash          string     `json:"hash"`
	Hex           string     `json:"hex"`
	LockTime      int64      `json:"locktime"`
	Size          int64      `json:"size"`
	Time          int64      `json:"time"`
	TxID          string     `json:"txid"`
	Version       int64      `json:"version"`
	Vin           []VinInfo  `json:"vin"`
	Vout          []VoutInfo `json:"vout"`
}

CoinbaseTxInfo is the coinbase tx info inside the BlockInfo

type ExchangeRate added in v0.4.0

type ExchangeRate struct {
	Currency string `json:"currency"`
	Rate     string `json:"rate"`
}

ExchangeRate is the response from getting the current exchange rate

type Fee added in v0.5.0

type Fee struct {
	Bytes    int `json:"bytes"`
	Satoshis int `json:"satoshis"`
}

Fee is the actual fee (satoshis per byte)

type FeeQuote added in v0.5.0

type FeeQuote struct {
	FeeType   string `json:"feeType"`
	MiningFee *Fee   `json:"miningFee"`
	RelayFee  *Fee   `json:"relayFee"`
}

FeeQuote is the structure response for a fee in a quote

type FeeQuotes added in v0.5.0

type FeeQuotes struct {
	Quotes []*QuoteProvider `json:"quotes"`
}

FeeQuotes is the structure response from getting quotes from Merchant API

type HistoryRecord

type HistoryRecord struct {
	Height int64   `json:"height"`
	Info   *TxInfo `json:"info,omitempty"` // Custom for our wrapper
	TxHash string  `json:"tx_hash"`
	TxPos  int64   `json:"tx_pos"`
	Value  int64   `json:"value"`
}

HistoryRecord is an internal record of AddressHistory

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 MempoolInfo added in v0.4.0

type MempoolInfo struct {
	Bytes         int64 `json:"bytes"`
	MaxMempool    int64 `json:"maxmempool"`
	MempoolMinFee int64 `json:"mempoolminfee"`
	Size          int64 `json:"size"`
	Usage         int64 `json:"usage"`
}

MempoolInfo is the response for the get mempool info request

type MerchantError added in v0.5.0

type MerchantError struct {
	Code   int    `json:"code"`
	Error  string `json:"error"`
	Status int    `json:"status"`
}

MerchantError is the error response from a bad tx submission

type MerchantResponse added in v0.5.0

type MerchantResponse struct {
	APIVersion                string `json:"apiVersion"`
	CurrentHighestBlockHash   string `json:"currentHighestBlockHash"`
	CurrentHighestBlockHeight int64  `json:"currentHighestBlockHeight"`
	MinerID                   string `json:"minerId"`
	ResultDescription         string `json:"resultDescription"`
	ReturnResult              string `json:"returnResult"`
	Timestamp                 string `json:"timestamp"`
	TxID                      string `json:"txid"`
	TxSecondMempoolExpiry     int    `json:"txSecondMempoolExpiry"`
}

MerchantResponse is the response from a tx submission

type MerchantStatus added in v0.5.0

type MerchantStatus struct {
	APIVersion            string `json:"apiVersion"`
	BlockHash             string `json:"blockHash"`
	BlockHeight           int64  `json:"blockHeight"`
	Confirmations         int64  `json:"confirmations"`
	MinerID               string `json:"minerId"`
	ResultDescription     string `json:"resultDescription"`
	ReturnResult          string `json:"returnResult"`
	Timestamp             string `json:"timestamp"`
	TxSecondMempoolExpiry int    `json:"txSecondMempoolExpiry"`
}

MerchantStatus is the response from a status request

type MerkleBranch added in v0.3.0

type MerkleBranch struct {
	Hash string `json:"hash"`
	Pos  string `json:"pos"`
}

MerkleBranch is a merkle branch

type MerkleInfo added in v0.0.4

type MerkleInfo struct {
	BlockHash  string          `json:"blockHash"`
	Branches   []*MerkleBranch `json:"branches"`
	Hash       string          `json:"hash"`
	MerkleRoot string          `json:"merkleRoot"`
}

MerkleInfo is the response for the get merkle request

type MerkleResults added in v0.3.0

type MerkleResults []*MerkleInfo

MerkleResults is the results from the proof 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"}

type Options added in v0.2.0

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 added in v0.2.0

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 Page

type Page struct {
	Size int64    `json:"size"`
	URI  []string `json:"uri"`
}

Page is used as a sub-type for BlockInfo

type Quote added in v0.5.0

type Quote struct {
	APIVersion                string      `json:"apiVersion"`
	CurrentHighestBlockHash   string      `json:"currentHighestBlockHash"`
	CurrentHighestBlockHeight int64       `json:"currentHighestBlockHeight"`
	ExpiryTime                string      `json:"expiryTime"`
	Fees                      []*FeeQuote `json:"fees"`
	MinerID                   string      `json:"minerId"`
	MinerReputation           interface{} `json:"minerReputation"`
	Timestamp                 string      `json:"timestamp"`
}

Quote is the structure response for a quote

type QuoteProvider added in v0.5.0

type QuoteProvider struct {
	Payload         string `json:"payload"`
	ProviderID      string `json:"providerId"`
	ProviderName    string `json:"providerName"`
	PublicKey       string `json:"publicKey"`
	Quote           *Quote `json:"quote"`
	Signature       string `json:"signature"`
	TxStatusURL     string `json:"txStatusUrl"`
	TxSubmissionURL string `json:"txSubmissionUrl"`
}

QuoteProvider is the structure response for a quote provider (which has quotes)

type ScriptList added in v0.4.0

type ScriptList []*ScriptRecord

ScriptList is the list of script history records

type ScriptPubKeyInfo

type ScriptPubKeyInfo struct {
	Addresses   []string `json:"addresses"`
	Asm         string   `json:"asm"`
	Hex         string   `json:"hex"`
	IsTruncated bool     `json:"isTruncated"`
	OpReturn    string   `json:"-"` // todo: support this (can be an object of key/vals based on the op return data)
	ReqSigs     int64    `json:"reqSigs"`
	Type        string   `json:"type"`
}

ScriptPubKeyInfo is the scriptPubKey info inside the VoutInfo

type ScriptRecord added in v0.4.0

type ScriptRecord struct {
	Height int64  `json:"height"`
	TxHash string `json:"tx_hash"`
	TxPos  int64  `json:"tx_pos"`
	Value  int64  `json:"value"`
}

ScriptRecord is the script history record

type ScriptSigInfo

type ScriptSigInfo struct {
	Asm string `json:"asm"`
	Hex string `json:"hex"`
}

ScriptSigInfo is the scriptSig info inside the VinInfo

type SearchResult added in v0.4.0

type SearchResult struct {
	Type string `json:"type"`
	URL  string `json:"url"`
}

SearchResult is the actual result for the search (included in SearchResults)

type SearchResults added in v0.4.0

type SearchResults struct {
	Results []*SearchResult `json:"results"`
}

SearchResults is the response from searching for explorer links

type StatusResponse added in v0.5.0

type StatusResponse struct {
	Payload      string          `json:"payload"`
	ProviderID   string          `json:"providerId"`
	ProviderName string          `json:"providerName"`
	PublicKey    string          `json:"publicKey"`
	Signature    string          `json:"signature"`
	Status       *MerchantStatus `json:"status"`
}

StatusResponse is the response from requesting a status update

type SubmissionResponse added in v0.5.0

type SubmissionResponse struct {
	Error        *MerchantError    `json:"error"`
	Payload      string            `json:"payload"`
	ProviderID   string            `json:"providerId"`
	ProviderName string            `json:"providerName"`
	PublicKey    string            `json:"publicKey"`
	Response     *MerchantResponse `json:"response"`
	Signature    string            `json:"signature"`
}

SubmissionResponse is the response from submitting a tx via Merchant API

type TxHashes added in v0.2.2

type TxHashes struct {
	TxIDs []string `json:"txids"`
}

TxHashes is the list of tx hashes for the post request

type TxInfo

type TxInfo struct {
	BlockHash     string     `json:"blockhash"`
	BlockTime     int64      `json:"blocktime"`
	Confirmations int64      `json:"confirmations"`
	Hash          string     `json:"hash"`
	Hex           string     `json:"hex"`
	LockTime      int64      `json:"locktime"`
	Size          int64      `json:"size"`
	Time          int64      `json:"time"`
	TxID          string     `json:"txid"`
	Version       int64      `json:"version"`
	Vin           []VinInfo  `json:"vin"`
	Vout          []VoutInfo `json:"vout"`
}

TxInfo is the response info about a returned tx

type TxList added in v0.2.2

type TxList []*TxInfo

TxList is the list of tx info structs returned from the /txs post response

type VinInfo

type VinInfo struct {
	Coinbase  string        `json:"coinbase"`
	ScriptSig ScriptSigInfo `json:"scriptSig"`
	Sequence  int64         `json:"sequence"`
	TxID      string        `json:"txid"`
	Vout      int64         `json:"vout"`
}

VinInfo is the vin info inside the CoinbaseTxInfo

type VoutInfo

type VoutInfo struct {
	N            int64            `json:"n"`
	ScriptPubKey ScriptPubKeyInfo `json:"scriptPubKey"`
	Value        float64          `json:"value"`
}

VoutInfo is the vout info inside the CoinbaseTxInfo

Directories

Path Synopsis
examples

Jump to

Keyboard shortcuts

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