client

package
v4.13.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Sep 25, 2019 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Overview

Package client implements an Electrum JSON RPC client. See https://github.com/kyuupichan/electrumx/blob/159db3f8e70b2b2cbb8e8cd01d1e9df3fe83828f/docs/PROTOCOL.rst

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Balance

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

Balance is returned by ScriptHashGetBalance().

type ElectrumClient

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

ElectrumClient is a high level API access to an ElectrumX server. See https://github.com/kyuupichan/electrumx/blob/159db3f8e70b2b2cbb8e8cd01d1e9df3fe83828f/docs/PROTOCOL.rst.

func NewElectrumClient

func NewElectrumClient(rpcClient rpc.Client, log *logrus.Entry) *ElectrumClient

NewElectrumClient creates a new Electrum client.

func (*ElectrumClient) Close

func (client *ElectrumClient) Close()

Close closes the connection.

func (*ElectrumClient) ConnectionStatus

func (client *ElectrumClient) ConnectionStatus() blockchain.Status

ConnectionStatus returns the current connection status of the backend.

func (*ElectrumClient) EstimateFee

func (client *ElectrumClient) EstimateFee(
	number int,
	success func(*btcutil.Amount) error,
	cleanup func(error),
)

EstimateFee estimates the fee rate (unit/kB) needed to be confirmed within the given number of blocks. If the fee rate could not be estimated by the blockchain node, `nil` is passed to the success callback. https://github.com/kyuupichan/electrumx/blob/159db3f8e70b2b2cbb8e8cd01d1e9df3fe83828f/docs/PROTOCOL.rst#blockchainestimatefee

func (*ElectrumClient) GetMerkle

func (client *ElectrumClient) GetMerkle(
	txHash chainhash.Hash, height int,
	success func(merkle []blockchain.TXHash, pos int) error,
	cleanup func(error),
)

GetMerkle does the blockchain.transaction.get_merkle() RPC call. See https://github.com/kyuupichan/electrumx/blob/1.3/docs/protocol-methods.rst#blockchaintransactionget_merkle

func (*ElectrumClient) Headers

func (client *ElectrumClient) Headers(
	startHeight int, count int,
	success func(headers []*wire.BlockHeader, max int) error,
	cleanup func(error),
)

Headers does the blockchain.block.headers() RPC call. See https://github.com/kyuupichan/electrumx/blob/1.3/docs/protocol-methods.rst#blockchainblockheaders

func (*ElectrumClient) HeadersSubscribe

func (client *ElectrumClient) HeadersSubscribe(
	setupAndTeardown func() func(error),
	success func(*blockchain.Header) error,
)

HeadersSubscribe does the blockchain.headers.subscribe() RPC call. https://github.com/kyuupichan/electrumx/blob/159db3f8e70b2b2cbb8e8cd01d1e9df3fe83828f/docs/PROTOCOL.rst#blockchainheaderssubscribe

func (*ElectrumClient) RegisterOnConnectionStatusChangedEvent

func (client *ElectrumClient) RegisterOnConnectionStatusChangedEvent(onConnectionStatusChanged func(blockchain.Status))

RegisterOnConnectionStatusChangedEvent registers an event that forwards the connection status from the underlying client to the given callback.

func (*ElectrumClient) RelayFee

func (client *ElectrumClient) RelayFee(
	success func(btcutil.Amount),
	cleanup func(error),
)

RelayFee does the blockchain.relayfee() RPC call. https://github.com/kyuupichan/electrumx/blob/159db3f8e70b2b2cbb8e8cd01d1e9df3fe83828f/docs/PROTOCOL.rst#blockchainrelayfee

func (*ElectrumClient) ScriptHashGetBalance

func (client *ElectrumClient) ScriptHashGetBalance(
	scriptHashHex string,
	success func(*Balance) error,
	cleanup func(error))

ScriptHashGetBalance does the blockchain.scripthash.get_balance() RPC call. https://github.com/kyuupichan/electrumx/blob/159db3f8e70b2b2cbb8e8cd01d1e9df3fe83828f/docs/PROTOCOL.rst#blockchainscripthashget_balance

func (*ElectrumClient) ScriptHashGetHistory

func (client *ElectrumClient) ScriptHashGetHistory(
	scriptHashHex blockchain.ScriptHashHex,
	success func(blockchain.TxHistory) error,
	cleanup func(error),
)

ScriptHashGetHistory does the blockchain.scripthash.get_history() RPC call. https://github.com/kyuupichan/electrumx/blob/159db3f8e70b2b2cbb8e8cd01d1e9df3fe83828f/docs/PROTOCOL.rst#blockchainscripthashget_history

func (*ElectrumClient) ScriptHashListUnspent

func (client *ElectrumClient) ScriptHashListUnspent(scriptHashHex string) ([]*UTXO, error)

ScriptHashListUnspent does the blockchain.address.listunspent() RPC call. https://github.com/kyuupichan/electrumx/blob/159db3f8e70b2b2cbb8e8cd01d1e9df3fe83828f/docs/PROTOCOL.rst#blockchainscripthashlistunspent

func (*ElectrumClient) ScriptHashSubscribe

func (client *ElectrumClient) ScriptHashSubscribe(
	setupAndTeardown func() func(error),
	scriptHashHex blockchain.ScriptHashHex,
	success func(string) error,
)

ScriptHashSubscribe does the blockchain.scripthash.subscribe() RPC call. https://github.com/kyuupichan/electrumx/blob/159db3f8e70b2b2cbb8e8cd01d1e9df3fe83828f/docs/PROTOCOL.rst#blockchainscripthashsubscribe

func (*ElectrumClient) ServerFeatures

func (client *ElectrumClient) ServerFeatures() (*ServerFeatures, error)

ServerFeatures does the server.features() RPC call. https://github.com/kyuupichan/electrumx/blob/159db3f8e70b2b2cbb8e8cd01d1e9df3fe83828f/docs/PROTOCOL.rst#serverfeatures

func (*ElectrumClient) ServerVersion

func (client *ElectrumClient) ServerVersion() (*ServerVersion, error)

ServerVersion does the server.version() RPC call. https://github.com/kyuupichan/electrumx/blob/159db3f8e70b2b2cbb8e8cd01d1e9df3fe83828f/docs/PROTOCOL.rst#serverversion

func (*ElectrumClient) TransactionBroadcast

func (client *ElectrumClient) TransactionBroadcast(transaction *wire.MsgTx) error

TransactionBroadcast does the blockchain.transaction.broadcast() RPC call. https://github.com/kyuupichan/electrumx/blob/159db3f8e70b2b2cbb8e8cd01d1e9df3fe83828f/docs/PROTOCOL.rst#blockchaintransactionbroadcast

func (*ElectrumClient) TransactionGet

func (client *ElectrumClient) TransactionGet(
	txHash chainhash.Hash,
	success func(*wire.MsgTx) error,
	cleanup func(error),
)

TransactionGet downloads a transaction. See https://github.com/kyuupichan/electrumx/blob/159db3f8e70b2b2cbb8e8cd01d1e9df3fe83828f/docs/PROTOCOL.rst#blockchaintransactionget

type Header struct {
	BlockHeight int `json:"block_height"`
}

Header is returned by HeadersSubscribe().

type ServerFeatures

type ServerFeatures struct {
	GenesisHash string `json:"genesis_hash"`
}

ServerFeatures is returned by ServerFeatures().

type ServerVersion

type ServerVersion struct {
	Version         string
	ProtocolVersion string
}

ServerVersion is returned by ServerVersion().

func (*ServerVersion) String

func (version *ServerVersion) String() string

func (*ServerVersion) UnmarshalJSON

func (version *ServerVersion) UnmarshalJSON(b []byte) error

UnmarshalJSON implements the json.Unmarshaler interface.

type TXHash

type TXHash chainhash.Hash

TXHash wraps chainhash.Hash for json deserialization.

func (*TXHash) Hash

func (txHash *TXHash) Hash() chainhash.Hash

Hash returns the wrapped hash.

func (*TXHash) MarshalJSON

func (txHash *TXHash) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaler interface.

func (*TXHash) UnmarshalJSON

func (txHash *TXHash) UnmarshalJSON(jsonBytes []byte) error

UnmarshalJSON implements the json.Unmarshaler interface.

type UTXO

type UTXO struct {
	TXPos  int    `json:"tx_pos"`
	Value  int64  `json:"value"`
	TXHash string `json:"tx_hash"`
	Height int    `json:"height"`
}

UTXO is the data returned by the listunspent RPC call.

Jump to

Keyboard shortcuts

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