Documentation ¶
Index ¶
- type Client
- func (c *Client) Close()
- func (c *Client) EstimateFee(ctx context.Context, number int) (float64, error)
- func (c *Client) GetMerkle(ctx context.Context, txHashHex string, height int) (*GetMerkleResult, error)
- func (c *Client) Headers(ctx context.Context, startHeight int, count int) (*HeadersResult, error)
- func (c *Client) HeadersSubscribe(ctx context.Context, result func(header *types.Header, err error))
- func (c *Client) RelayFee(ctx context.Context) (float64, error)
- func (c *Client) ScriptHashGetHistory(ctx context.Context, scriptHashHex string) (types.TxHistory, error)
- func (c *Client) ScriptHashSubscribe(ctx context.Context, scriptHashHex string, ...)
- func (c *Client) ServerVersion() ServerVersion
- func (c *Client) SetOnError(f func(error))
- func (c *Client) TransactionBroadcast(ctx context.Context, rawTxHex string) (string, error)
- func (c *Client) TransactionGet(ctx context.Context, txHash string) ([]byte, error)
- func (c *Client) VaultTransactionSubscribe(ctx context.Context, ...)
- func (c *Client) VaultTransactionsGetFrom(ctx context.Context, txHash string, length int) ([]map[string]interface{}, error)
- type GetMerkleResult
- type HeadersResult
- type Method
- type Options
- type ServerVersion
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is a high level API access to an Electrum protocol compatible server. See https://electrumx-spesmilo.readthedocs.io/en/latest/protocol-methods.html selecting the `supportedProtocolVersion` currently in use.
func Connect ¶
Connect connets to an Electrum server and negotiates the protocol in a blocking fashion immediately. If the connection could not be established or the server didn't respond with a valid server version response, an error is returned.
func (*Client) Close ¶
func (c *Client) Close()
Close closes the connection and shuts down all pending requests. All pending requests will be resolved with an error.
func (*Client) EstimateFee ¶
EstimateFee estimates the fee rate needed to be confirmed within the given number of blocks using the blockchain.estimatefee RPC method. The value returned is the fee rate in BTC/kB. If the fee rate could not be estimated, an error is returned.
func (*Client) GetMerkle ¶
func (c *Client) GetMerkle(ctx context.Context, txHashHex string, height int) (*GetMerkleResult, error)
GetMerkle does the blockchain.transaction.get_merkle RPC call.
func (*Client) Headers ¶
Headers does the blockchain.block.headers RPC call. It returns a slice of 80-byte headers, and the maximum number of headers the server will return in a single request.
func (*Client) HeadersSubscribe ¶
func (c *Client) HeadersSubscribe(ctx context.Context, result func(header *types.Header, err error))
HeadersSubscribe does the blockchain.headers.subscribe RPC call. The callback is called once with the latest header and subsequently on each new header.
This function is non-blocking, the result is delivered asynchronously to the callback. The callback is called with an error if: - writing to the socket fails - there was a timeout in invoking the RPC call - the server responds with invalid data to the RPC call - the server sends invalid data in the `blockchain.headers.subscribe` notification.
func (*Client) RelayFee ¶
RelayFee does the blockchain.relayfee RPC call. The value returned is the fee rate in BTC/kB.
func (*Client) ScriptHashGetHistory ¶
func (c *Client) ScriptHashGetHistory(ctx context.Context, scriptHashHex string) (types.TxHistory, error)
ScriptHashGetHistory does the blockchain.scripthash.get_history RPC call.
func (*Client) ScriptHashSubscribe ¶
func (*Client) ServerVersion ¶
func (c *Client) ServerVersion() ServerVersion
ServerVersion returns the version as reported by the server.
func (*Client) SetOnError ¶
SetOnError defines a callback that is called when there is a JSON RPC error. See `jsonrpc.SetOnError`.
func (*Client) TransactionBroadcast ¶
TransactionBroadcast does the blockchain.transaction.broadcast RPC call.
func (*Client) TransactionGet ¶
TransactionGet downloads a transaction using the blockchain.transaction.get RPC method. The response is the raw transaction.
func (*Client) VaultTransactionSubscribe ¶
type GetMerkleResult ¶
type GetMerkleResult struct { Merkle []string `json:"merkle"` Pos int `json:"pos"` BlockHeight int `json:"block_height"` }
GetMerkleResult is returned by `GetMerkle()`.
type HeadersResult ¶
type HeadersResult struct { // Headers is a slice of 80-byte headers. Headers [][]byte // Max is the maximum number of headers the server will return in a single request. Max int }
HeadersResult is returned by `Headers()`.
type Options ¶
type Options struct { // SoftwareVersion reports to an electrum protocol compatible server // its name and a version so that server owners can identify what kind of // clients are connected. SoftwareVersion string // MethodTimeout is the duration after method calls time out. If 0, no timeout is applied. MethodTimeout time.Duration // PingInterval is the time between periodic ping requests to the Electrum server. 1m is the // default if not specified. If negative, pinging is disabled. This should be longer than // `MethodTimeout`. PingInterval time.Duration // Dial connects to the server and returns a connection object. Dial func() (net.Conn, error) }
Options to initialize the Electrum client.
type ServerVersion ¶
type ServerVersion struct {
// contains filtered or unexported fields
}
ServerVersion is returned by the `server.version` RPC call.
func (ServerVersion) String ¶
func (v ServerVersion) String() string