Documentation ¶
Overview ¶
Package client implements an Electrum JSON RPC client. See https://github.com/kyuupichan/electrumx/blob/159db3f8e70b2b2cbb8e8cd01d1e9df3fe83828f/docs/PROTOCOL.rst
Index ¶
- type Balance
- type ElectrumClient
- func (client *ElectrumClient) Close()
- func (client *ElectrumClient) ConnectionStatus() blockchain.Status
- func (client *ElectrumClient) EstimateFee(number int, success func(*btcutil.Amount) error, cleanup func(error))
- func (client *ElectrumClient) GetMerkle(txHash chainhash.Hash, height int, ...)
- func (client *ElectrumClient) Headers(startHeight int, count int, ...)
- func (client *ElectrumClient) HeadersSubscribe(setupAndTeardown func() func(error), success func(*blockchain.Header) error)
- func (client *ElectrumClient) RegisterOnConnectionStatusChangedEvent(onConnectionStatusChanged func(blockchain.Status))
- func (client *ElectrumClient) RelayFee(success func(btcutil.Amount) error, cleanup func(error))
- func (client *ElectrumClient) ScriptHashGetBalance(scriptHashHex string, success func(*Balance) error, cleanup func(error))
- func (client *ElectrumClient) ScriptHashGetHistory(scriptHashHex blockchain.ScriptHashHex, ...)
- func (client *ElectrumClient) ScriptHashListUnspent(scriptHashHex string) ([]*UTXO, error)
- func (client *ElectrumClient) ScriptHashSubscribe(setupAndTeardown func() func(error), scriptHashHex blockchain.ScriptHashHex, ...)
- func (client *ElectrumClient) ServerFeatures() (*ServerFeatures, error)
- func (client *ElectrumClient) ServerVersion() (*ServerVersion, error)
- func (client *ElectrumClient) TransactionBroadcast(transaction *wire.MsgTx) error
- func (client *ElectrumClient) TransactionGet(txHash chainhash.Hash, success func(*wire.MsgTx) error, cleanup func(error))
- type Header
- type ServerFeatures
- type ServerVersion
- type TXHash
- type UTXO
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
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) 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) error, 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 ¶
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 ¶
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 ¶
TXHash wraps chainhash.Hash for json deserialization.
func (*TXHash) MarshalJSON ¶
MarshalJSON implements the json.Marshaler interface.
func (*TXHash) UnmarshalJSON ¶
UnmarshalJSON implements the json.Unmarshaler interface.