electrum

package
v0.0.0-...-65385de Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2018 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package electrum is a electrum bitcoin client.

Index

Constants

View Source
const (
	ClientVersion   = "0.0.1"
	ProtocolVersion = "1.0"
)

Variables

View Source
var (
	ErrNotImplemented = errors.New("not implemented")
	ErrNodeConnected  = errors.New("node already connected")
)

Functions

This section is empty.

Types

type Balance

type Balance struct {
	Confirmed   btcutil.Amount `json:"confirmed"`
	Unconfirmed btcutil.Amount `json:"unconfirmed"`
}

type BlockchainHeader

type BlockchainHeader struct {
	Nonce         uint64 `json:"nonce"`
	PrevBlockHash string `json:"prev_block_hash"`
	Timestamp     uint64 `json:"timestamp"`
	MerkleRoot    string `json:"merkle_root"`
	BlockHeight   uint64 `json:"block_height"`
	UtxoRoot      string `json:"utxo_root"`
	Version       int    `json:"version"`
	Bits          uint64 `json:"bits"`
}

type Node

type Node struct {
	Address string
	// contains filtered or unexported fields
}

func NewNode

func NewNode() *Node

NewNode creates a new node.

func (*Node) BlockchainAddressGetBalance

func (n *Node) BlockchainAddressGetBalance(address string) (*Balance, error)

BlockchainAddressGetBalance returns the balance of an address. TODO (d4l3k) investigate `error from server: "'Node' object has no attribute '__getitem__'"` http://docs.electrum.org/en/latest/protocol.html#blockchain-address-get-balance

func (*Node) BlockchainAddressGetHistory

func (n *Node) BlockchainAddressGetHistory(address string) ([]*Transaction, error)

BlockchainAddressGetHistory returns the history of an address. http://docs.electrum.org/en/latest/protocol.html#blockchain-address-get-history

func (*Node) BlockchainAddressGetMempool

func (n *Node) BlockchainAddressGetMempool() error

TODO(d4l3k) implement http://docs.electrum.org/en/latest/protocol.html#blockchain-address-get-mempool

func (*Node) BlockchainAddressGetProof

func (n *Node) BlockchainAddressGetProof() error

TODO(d4l3k) implement http://docs.electrum.org/en/latest/protocol.html#blockchain-address-get-proof

func (*Node) BlockchainAddressListUnspent

func (n *Node) BlockchainAddressListUnspent(address string) ([]*Transaction, error)

BlockchainAddressListUnspent lists the unspent transactions for the given address. http://docs.electrum.org/en/latest/protocol.html#blockchain-address-listunspent

func (*Node) BlockchainAddressSubscribe

func (n *Node) BlockchainAddressSubscribe(address string) (<-chan string, error)

BlockchainAddressSubscribe subscribes to transactions on an address and returns the hash of the transaction history. http://docs.electrum.org/en/latest/protocol.html#blockchain-address-subscribe

func (*Node) BlockchainBlockGetChunk

func (n *Node) BlockchainBlockGetChunk() error

TODO(d4l3k) implement http://docs.electrum.org/en/latest/protocol.html#blockchain-block-get-chunk

func (*Node) BlockchainBlockGetHeader

func (n *Node) BlockchainBlockGetHeader() error

TODO(d4l3k) implement http://docs.electrum.org/en/latest/protocol.html#blockchain-block-get-header

func (*Node) BlockchainEstimateFee

func (n *Node) BlockchainEstimateFee(block int) (float64, error)

http://docs.electrum.org/en/latest/protocol.html#blockchain-estimatefee BlockchainEstimateFee estimates the transaction fee per kilobyte that needs to be paid for a transaction to be included within a certain number of blocks.

func (*Node) BlockchainHeadersSubscribe

func (n *Node) BlockchainHeadersSubscribe() (<-chan *BlockchainHeader, error)

BlockchainHeadersSubscribe request client notifications about new blocks in form of parsed blockheaders and returns the current block header. http://docs.electrum.org/en/latest/protocol.html#blockchain-headers-subscribe

func (*Node) BlockchainNumBlocksSubscribe

func (n *Node) BlockchainNumBlocksSubscribe() (int, error)

BlockchainNumBlocksSubscribe returns the current number of blocks. http://docs.electrum.org/en/latest/protocol.html#blockchain-numblocks-subscribe

func (*Node) BlockchainTransactionBroadcast

func (n *Node) BlockchainTransactionBroadcast(tx []byte) (interface{}, error)

BlockchainTransactionBroadcast sends a raw transaction. TODO(d4l3k) implement http://docs.electrum.org/en/latest/protocol.html#blockchain-transaction-broadcast

func (*Node) BlockchainTransactionGet

func (n *Node) BlockchainTransactionGet(txid string) (string, error)

BlockchainTransactionGet returns the raw transaction (hex-encoded) for the given txid. If transaction doesn't exist, an error is returned. http://docs.electrum.org/en/latest/protocol.html#blockchain-transaction-get

func (*Node) BlockchainTransactionGetMerkle

func (n *Node) BlockchainTransactionGetMerkle() error

TODO(d4l3k) implement http://docs.electrum.org/en/latest/protocol.html#blockchain-transaction-get-merkle

func (*Node) BlockchainUtxoGetAddress

func (n *Node) BlockchainUtxoGetAddress() error

TODO(d4l3k) implement http://docs.electrum.org/en/latest/protocol.html#blockchain-utxo-get-address

func (*Node) ConnectSSL

func (n *Node) ConnectSSL(addr string, config *tls.Config) error

ConnectSLL creates a new SLL connection to the specified address.

func (*Node) ConnectTCP

func (n *Node) ConnectTCP(addr string) error

ConnectTCP creates a new TCP connection to the specified address.

func (*Node) ServerBanner

func (n *Node) ServerBanner() (string, error)

ServerBanner returns the server's banner. http://docs.electrum.org/en/latest/protocol.html#server-banner

func (*Node) ServerDonationAddress

func (n *Node) ServerDonationAddress() (string, error)

ServerDonationAddress returns the donation address of the server. http://docs.electrum.org/en/latest/protocol.html#server-donation-address

func (*Node) ServerPeersSubscribe

func (n *Node) ServerPeersSubscribe() ([][]interface{}, error)

ServerPeersSubscribe requests peers from a server. http://docs.electrum.org/en/latest/protocol.html#server-peers-subscribe

func (*Node) ServerVersion

func (n *Node) ServerVersion() (string, error)

ServerVersion returns the server's version. http://docs.electrum.org/en/latest/protocol.html#server-version

type TCPTransport

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

func NewSSLTransport

func NewSSLTransport(addr string, config *tls.Config) (*TCPTransport, error)

func NewTCPTransport

func NewTCPTransport(addr string) (*TCPTransport, error)

func (*TCPTransport) Errors

func (t *TCPTransport) Errors() <-chan error

func (*TCPTransport) Responses

func (t *TCPTransport) Responses() <-chan []byte

func (*TCPTransport) SendMessage

func (t *TCPTransport) SendMessage(body []byte) error

type Transaction

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

type Transport

type Transport interface {
	SendMessage([]byte) error
	Responses() <-chan []byte
	Errors() <-chan error
}

Jump to

Keyboard shortcuts

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