clients

package
v0.0.0-...-80332c7 Latest Latest
Warning

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

Go to latest
Published: Jul 3, 2019 License: GPL-3.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Address

type Address struct {
	PublicKeyHash    string `json:"hash160"`
	Address          string `json:"address"`
	TransactionCount int64  `json:"n_tx"`
	Received         int64  `json:"total_received"`
	Sent             int64  `json:"total_sent"`
	Balance          int64  `json:"final_balance"`
}

type Block

type Block struct {
	BlockHash         string        `json:"hash"`
	Version           uint8         `json:"ver"`
	PreviousBlockHash string        `json:"prev_block"`
	MerkleRoot        string        `json:"mrkl_root"`
	Time              int64         `json:"time"`
	Bits              int64         `json:"bits"`
	Nonce             int64         `json:"nonce"`
	TransactionCount  int           `json:"n_tx"`
	Size              int64         `json:"size"`
	BlockIndex        uint64        `json:"block_index"`
	MainChain         bool          `json:"main_chain"`
	Height            int64         `json:"height"`
	ReceivedTime      int64         `json:"received_time"`
	RelayedBy         string        `json:"relayed_by"`
	Transactions      []Transaction `json:"tx"`
}

type Blocks

type Blocks struct {
	Blocks []Block `json:"block"`
}

type ClientCore

type ClientCore interface {
	// NetworkParams should return the network parameters of the underlying
	// Bitcoin blockchain.
	NetworkParams() *chaincfg.Params

	GetUTXOs(ctx context.Context, address string, limit, confitmations int64) ([]UTXO, error)

	GetUTXO(ctx context.Context, txHash string, vout uint32) (UTXO, error)

	Confirmations(ctx context.Context, txHash string) (int64, error)

	// ScriptFunded checks whether a script is funded.
	ScriptFunded(ctx context.Context, address string, value int64) (bool, int64, error)

	// ScriptRedeemed checks whether a script is redeemed.
	ScriptRedeemed(ctx context.Context, address string, value int64) (bool, int64, error)

	// ScriptSpent checks whether a script is spent.
	ScriptSpent(ctx context.Context, script, spender string) (bool, string, error)

	// PublishTransaction should publish a signed transaction to the Bitcoin
	// blockchain.
	PublishTransaction(ctx context.Context, signedTransaction *wire.MsgTx) error
}

func NewBitcoinFNClientCore

func NewBitcoinFNClientCore(host, user, password string) (ClientCore, error)

func NewBlockchainInfoClientCore

func NewBlockchainInfoClientCore(network string) (ClientCore, error)

func NewMercuryClientCore

func NewMercuryClientCore(network string) (ClientCore, error)

type Input

type Input struct {
	PrevOut PreviousOut `json:"prev_out"`
	Script  string      `json:"script"`
}

type LatestBlock

type LatestBlock struct {
	Hash       string `json:"hash"`
	Time       int64  `json:"time"`
	BlockIndex int64  `json:"block_index"`
	Height     int64  `json:"height"`
}

type ListReceivedByAddressObj

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

type ListReceivedByAddressResponse

type ListReceivedByAddressResponse []ListReceivedByAddressObj

type ListTransansactionsObj

type ListTransansactionsObj struct {
	Address  string  `json:"address"`
	Category string  `json:"category"`
	Amount   float64 `json:"amount"`
	TxID     string  `json:"txid"`
}

type ListTransansactionsResponse

type ListTransansactionsResponse []ListTransansactionsObj

type MercuryError

type MercuryError struct {
	Error string `json:"error"`
}

type MultiAddress

type MultiAddress struct {
	Addresses    []Address     `json:"addresses"`
	Transactions []Transaction `json:"txs"`
}

type Output

type Output struct {
	Value           uint64 `json:"value"`
	TransactionHash string `json:"hash"`
	Script          string `json:"script"`
}

type PreviousOut

type PreviousOut struct {
	TransactionHash  string `json:"hash"`
	Value            uint64 `json:"value"`
	TransactionIndex uint64 `json:"tx_index"`
	VoutNumber       uint8  `json:"n"`
	Address          string `json:"addr"`
}

type RPCCLient

type RPCCLient interface {
	ListTransansactions() (ListTransansactionsResponse, error)
	ListReceivedByAddress(address string) (ListReceivedByAddressResponse, error)
}

func NewRPCClient

func NewRPCClient(host, user, password string) RPCCLient

type Response

type Response struct {
	Result json.RawMessage `json:"result"`
}

type SingleAddress

type SingleAddress struct {
	Address      string        `json:"address"`
	Received     int64         `json:"total_received"`
	Sent         int64         `json:"total_sent"`
	Balance      int64         `json:"final_balance"`
	Transactions []Transaction `json:"txs"`
}

type Transaction

type Transaction struct {
	TransactionHash  string   `json:"hash"`
	Version          uint8    `json:"ver"`
	VinSize          uint32   `json:"vin_sz"`
	VoutSize         uint32   `json:"vout_sz"`
	Size             int64    `json:"size"`
	RelayedBy        string   `json:"relayed_by"`
	BlockHeight      int64    `json:"block_height"`
	TransactionIndex uint64   `json:"tx_index"`
	Inputs           []Input  `json:"inputs"`
	Outputs          []Output `json:"out"`
}

type UTXO

type UTXO struct {
	TxHash       string `json:"txHash"`
	Amount       int64  `json:"amount"`
	ScriptPubKey string `json:"scriptPubKey"`
	Vout         uint32 `json:"vout"`
}

type Unspent

type Unspent struct {
	Outputs []UnspentOutput `json:"unspent_outputs"`
}

type UnspentOutput

type UnspentOutput struct {
	TransactionAge          string `json:"tx_age"`
	TransactionHash         string `json:"tx_hash_big_endian"`
	TransactionIndex        uint32 `json:"tx_index"`
	TransactionOutputNumber uint32 `json:"tx_output_n"`
	ScriptPubKey            string `json:"script"`
	Amount                  int64  `json:"value"`
}

Jump to

Keyboard shortcuts

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