gostratum

package module
v0.0.0-...-248f6f3 Latest Latest
Warning

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

Go to latest
Published: Apr 9, 2015 License: MIT Imports: 7 Imported by: 0

README

gostratum

Stratum (Electrum) client implementation in Go. ###documentation API Reference
Bitcoin Address Watch example
###status Package is not tested yet, is not recommended to use it in production at this point ###installation go get https://github.com/devktor/gostratum ###concurency It is safe to use Client object in multiple goroutines. ###protocol compliance Implements protocol specifications according to https://docs.google.com/document/d/17zHy1SUlhgtCMbypO8cHgpWH73V5iUQKk_0rWvMqSNs/edit?hl=en_US

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WrapAddressHandler

func WrapAddressHandler(callback func(string, string, error), decoder *Decoder) func(*json.RawMessage)

func WrapBlockHeadersHandler

func WrapBlockHeadersHandler(callback func([]BlockHeader, error), decoder *Decoder) func(*json.RawMessage)

func WrapNumBlocksHandler

func WrapNumBlocksHandler(callback func(int, error), decoder *Decoder) func(*json.RawMessage)

func WrapPeersHandler

func WrapPeersHandler(callback func([]Peer, error), decoder *Decoder) func(*json.RawMessage)

Types

type Action

type Action struct {
	// contains filtered or unexported fields
}

func MakeAction

func MakeAction() *Action

func (*Action) Done

func (a *Action) Done(response *Response)

func (*Action) SetTimeout

func (a *Action) SetTimeout(timeout time.Duration, callback func())

func (*Action) Wait

func (a *Action) Wait() *Response

type AddressTransaction

type AddressTransaction struct {
	TxHash string `json:"tx_hash"`
	Height uint64 `json:"height"`
}

type Balance

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

type BlockHeader

type BlockHeader struct {
	Nonce     uint64 `json:"nonce"`
	PrevHash  string `json:"prev_block_hash"`
	Timestamp uint64 `json:"timestamp"`
	Merkle    string `json:"merkle_root"`
	Height    uint64 `json:"block_height"`
	UTXO      string `json:"utxo_root"`
	Version   uint64 `json:"version"`
	Bits      uint64 `json:"bits"`
}

type Client

type Client struct {
	// contains filtered or unexported fields
}

func Connect

func Connect(host string) (*Client, error)

func (*Client) AddressGetBalance

func (c *Client) AddressGetBalance(address string) (Balance, error)

func (*Client) AddressGetHistory

func (c *Client) AddressGetHistory(address string) ([]AddressTransaction, error)

func (*Client) AddressGetMemPool

func (c *Client) AddressGetMemPool(address string) error

func (*Client) AddressListUnspent

func (c *Client) AddressListUnspent(address string) ([]UnspentTransaction, error)

func (*Client) AddressSubscribe

func (c *Client) AddressSubscribe(address string, callback func(string, string, error)) error

func (*Client) BlockHeaderSubscribe

func (c *Client) BlockHeaderSubscribe(callback func([]BlockHeader, error)) error

func (*Client) BroadcastTransaction

func (c *Client) BroadcastTransaction(raw string) (string, error)

func (*Client) GetBlockChunk

func (c *Client) GetBlockChunk(chunk uint64) (string, error)

func (*Client) GetBlockHeader

func (c *Client) GetBlockHeader(height uint64) (BlockHeader, error)

func (*Client) Listen

func (c *Client) Listen()

func (*Client) NumBlocksSubscribe

func (c *Client) NumBlocksSubscribe(callback func(int, error)) error

func (*Client) PeersSubscribe

func (c *Client) PeersSubscribe(callback func([]Peer, error)) error

func (*Client) Request

func (c *Client) Request(method string, params ...string) *Response

func (*Client) Send

func (c *Client) Send(request *Request) *Response

func (*Client) ServerBanner

func (c *Client) ServerBanner() (string, error)

func (*Client) ServerDontationAddress

func (c *Client) ServerDontationAddress() (string, error)

func (*Client) ServerVersion

func (c *Client) ServerVersion() (string, error)

func (*Client) SetTimeout

func (c *Client) SetTimeout(timeout int64)

func (*Client) Subscribe

func (c *Client) Subscribe(method string, eventHandler func(*json.RawMessage), msgHandler func(*json.RawMessage), params ...string) error

type Decoder

type Decoder struct{}

func MakeDecoder

func MakeDecoder() *Decoder

func (*Decoder) Decode

func (d *Decoder) Decode(msg string, response *Response) error

func (*Decoder) DecodeAddressTransactions

func (d *Decoder) DecodeAddressTransactions(response *json.RawMessage) ([]AddressTransaction, error)

func (*Decoder) DecodeAddressTransactionsResult

func (d *Decoder) DecodeAddressTransactionsResult(response *Response) ([]AddressTransaction, error)

func (*Decoder) DecodeBalance

func (d *Decoder) DecodeBalance(response *Response) (Balance, error)

func (*Decoder) DecodeBlockHeader

func (d *Decoder) DecodeBlockHeader(response *Response) (BlockHeader, error)

func (*Decoder) DecodeBlockHeaders

func (d *Decoder) DecodeBlockHeaders(response *json.RawMessage) ([]BlockHeader, error)

func (*Decoder) DecodeData

func (d *Decoder) DecodeData(response *json.RawMessage, result interface{}) error

func (*Decoder) DecodeInt

func (d *Decoder) DecodeInt(response *json.RawMessage) (int, error)

func (*Decoder) DecodePeers

func (d *Decoder) DecodePeers(response *json.RawMessage) ([]Peer, error)

func (*Decoder) DecodeResult

func (d *Decoder) DecodeResult(response *Response, result interface{}) error

func (*Decoder) DecodeString

func (d *Decoder) DecodeString(response *json.RawMessage) (string, error)

func (*Decoder) DecodeStringResult

func (d *Decoder) DecodeStringResult(response *Response) (string, error)

func (*Decoder) DecodeUnspent

func (d *Decoder) DecodeUnspent(response *Response) ([]UnspentTransaction, error)

type Dispatcher

type Dispatcher struct {
	// contains filtered or unexported fields
}

func MakeDispatcher

func MakeDispatcher() *Dispatcher

func (*Dispatcher) Cancel

func (d *Dispatcher) Cancel(id uint64)

func (*Dispatcher) Error

func (d *Dispatcher) Error(err error)

func (*Dispatcher) Process

func (d *Dispatcher) Process(msg *Response)

func (*Dispatcher) RegisterNotifiactionHandler

func (d *Dispatcher) RegisterNotifiactionHandler(uri string, callback func(*json.RawMessage))

func (*Dispatcher) RegisterRequest

func (d *Dispatcher) RegisterRequest(request *Request) (*Action, error)

type Encoder

type Encoder struct{}

func MakeEncoder

func MakeEncoder() *Encoder

func (*Encoder) Encode

func (e *Encoder) Encode(request *Request) (string, error)

type Peer

type Peer struct {
	IP      string
	URL     string
	Version string
}

type Request

type Request struct {
	Method string   `json:"method"`
	Params []string `json:"params"`
	ID     uint64   `json:"id"`
}

type Response

type Response struct {
	ID     uint64           `json:"id"`
	Result *json.RawMessage `json:"result"`
	Error  error            `json:"error,string"`
	Method string           `json:"method"`
	Params *json.RawMessage `json:"params"`
}

type Transaction

type Transaction struct {
}

type UnspentTransaction

type UnspentTransaction struct {
	Hash   string `json:"tx_hash"`
	Pos    uint64 `json:"tx_pos"`
	Value  uint64 `json:"value"`
	Height uint64 `json:"height"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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