blockchain

package module
v0.0.0-...-09d9570 Latest Latest
Warning

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

Go to latest
Published: Mar 4, 2017 License: MIT Imports: 5 Imported by: 6 modules, 6 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

blockchain

Build Status

Go Client for the Blockchain Data API https://blockchain.info/api/blockchain_api

Documentation: https://godoc.org/github.com/alfg/blockchain

Installation

go get github.com/alfg/blockchain

Example

package main

import (
  "github.com/alfg/blockchain"
  "fmt"
)

func main() {

	c, e := blockchain.New()
	resp, e := c.GetAddress("162FjqU7RYdojnejCDe6zrPDUpaLcv9Hhq")
	if e != nil {
		fmt.Print(e)
	}

	fmt.Println(resp.Hash160)
	fmt.Println(resp.Address)
	fmt.Println(resp.NTx)
	fmt.Println(resp.TotalReceived)
	fmt.Println(resp.TotalSent)
	fmt.Println(resp.FinalBalance)

	for i := range resp.Txs {
		fmt.Println(resp.Txs[i].Result)

		for j := range resp.Txs[i].Inputs {
			fmt.Println(resp.Txs[i].Inputs[j].Sequence)
			fmt.Println(resp.Txs[i].Inputs[j].PrevOut.Spent)
		}
	}

}

License

MIT

Documentation

Index

Constants

View Source
const (
	API_ROOT = "https://blockchain.info"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Address

type Address struct {
	Hash160       string `json:"hash160"`
	Address       string `json:"address"`
	NTx           int    `json:"n_tx"`
	TotalReceived int    `json:"total_received"`
	TotalSent     int    `json:"total_sent"`
	FinalBalance  int    `json:"final_balance"`
	Txs           []*Tx  `json:"txs"`
}

type Block

type Block struct {
	Hash         string `json:"hash"`
	Ver          int    `json:"ver"`
	PrevBlock    string `json:"prev_block"`
	MrklRoot     string `json:"mrkl_root"`
	Time         int    `json:"time"`
	Bits         int    `json:"bits"`
	Nonce        int    `json:"nonce"`
	NTx          int    `json:"n_tx"`
	Size         int    `json:"size"`
	BlockIndex   int    `json:"block_index"`
	MainChain    bool   `json:"main_chain"`
	Height       int    `json:"height"`
	ReceivedTime int    `json:"received_time"`
	RelayedBy    string `json:"relayed_by"`
	Tx           []*Tx  `json:"tx"`
	TxIndexes    []int  `json:"txIndexes"`
}

type BlockHeight

type BlockHeight struct {
	Blocks []*Block `json:"blocks"`
}

type Chart

type Chart struct {
	Values []*Value `json:"values"`
}

type Client

type Client struct {
	*http.Client
}

func New

func New() (*Client, error)

func (*Client) GetAddress

func (c *Client) GetAddress(address string) (*Address, error)

func (*Client) GetAddresses

func (c *Client) GetAddresses(addresses []string) (*MultiAddr, error)

func (*Client) GetBlock

func (c *Client) GetBlock(block string) (*Block, error)

func (*Client) GetBlockHeight

func (c *Client) GetBlockHeight(blockHeight string) (*BlockHeight, error)

func (*Client) GetChart

func (c *Client) GetChart(chartType string) (*Chart, error)

func (*Client) GetLatestBlock

func (c *Client) GetLatestBlock() (*Block, error)

func (*Client) GetTransaction

func (c *Client) GetTransaction(transaction string) (*Transaction, error)

func (*Client) GetUnconfirmedTransactions

func (c *Client) GetUnconfirmedTransactions() (*Transactions, error)

type Inputs

type Inputs struct {
	Sequence int      `json:"sequence"`
	Script   string   `json:"script"`
	PrevOut  *PrevOut `json:"prev_out"`
}

type MultiAddr

type MultiAddr struct {
	Addresses []*Address `json:"addresses"`
	Txs       []*Tx      `json:"txs"`
}

type Out

type Out struct {
	Spent   bool   `json:"spent"`
	TxIndex int    `json:"tx_index"`
	Type    int    `json:"type"`
	Addr    string `json:"addr"`
	Value   int    `json:"value"`
	N       int    `json:"n"`
	Script  string `json:"script"`
}

type PrevOut

type PrevOut struct {
	Spent   bool   `json:"spent"`
	TxIndex int    `json:"tx_index"`
	Type    int    `json:"type"`
	Addr    string `json:"addr"`
	Value   int    `json:"value"`
	N       int    `json:"n"`
	Script  string `json:"script"`
}

type Transaction

type Transaction struct {
	Hash        string    `json:"hash"`
	Ver         int       `json:"ver"`
	VinSz       int       `json:"vin_sz"`
	VoutSz      int       `json:"vout_sz"`
	LockTime    int       `json:"lock_time"`
	Size        int       `json:"size"`
	RelayedBy   string    `json:"relayed_by"`
	BlockHeight int       `json:"block_height"`
	TxIndex     int       `json:"tx_index"`
	Inputs      []*Inputs `json:"inputs"`
	Out         []*Out    `json:"out"`
}

type Transactions

type Transactions struct {
	Transactions []*Transaction `json:"txs"`
}

type Tx

type Tx struct {
	Result      int       `json:"result"`
	Ver         int       `json:"ver"`
	Size        int       `json:"size"`
	Inputs      []*Inputs `json:"inputs"`
	Time        int       `json:"time"`
	BlockHeight int       `json:"block_height"`
	TxIndex     int       `json:"tx_index"`
	VinSz       int       `json:"vin_sz"`
	Hash        string    `json:"hash"`
	VoutSz      int       `json:"vout_sz"`
	RelayedBy   string    `json:"relayed_by"`
	Out         []*Out    `json:"out"`
}

type Value

type Value struct {
	X int `json:"x"`
	Y int `json:"y"`
}

Jump to

Keyboard shortcuts

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