Documentation ¶
Index ¶
- Variables
- func NodeIdent(addr, port string) string
- type Balance
- type Block
- type BlockchainHeader
- type ErrorResponse
- type Feature
- type GetTransaction
- type Header
- type Node
- func (n *Node) BlockchainAddressGetHistory(address string) ([]*Transaction, error)
- func (n *Node) BlockchainBlockHeaders(height uint32, count uint) (Block, error)
- func (n *Node) BlockchainHeadersSubscribe() (*Header, error)
- func (n *Node) BlockchainTransactionGet(txid string) (string, error)
- func (n *Node) Disconnect() error
- func (n *Node) ServerFeatures() (*Feature, error)
- func (n *Node) ServerPeersSubscribe() ([]Peer, error)
- func (n *Node) ServerVersion(ver string) error
- type Peer
- type RequestMessage
- type ResponseMessage
- type ScriptPubKeyResult
- type ScriptSig
- type TCPTransport
- type Transaction
- type Transport
- type Vin
- type Vout
Constants ¶
This section is empty.
Variables ¶
var ( ErrNotImplemented = errors.New("not implemented") ErrNodeConnected = errors.New("node already connected") ErrNodeShutdown = errors.New("node has shutdown") ErrIdMismatch = errors.New("response id mismatch") ErrUnknown = errors.New("unknown error") ErrNetwork = errors.New("network error") ErrAPI = errors.New("received API error") )
var DebugMode bool
Functions ¶
Types ¶
type BlockchainHeader ¶
type BlockchainHeader struct { Nonce uint32 `json:"nonce"` PrevBlockHash string `json:"prev_block_hash"` Timestamp int64 `json:"timestamp"` MerkleRoot string `json:"merkle_root"` BlockHeight int32 `json:"block_height"` UtxoRoot string `json:"utxo_root"` Version int32 `json:"version"` Bits int64 `json:"bits"` }
type ErrorResponse ¶
type GetTransaction ¶
type GetTransaction struct { Hex string `json:"hex"` Txid string `json:"txid"` Version int32 `json:"version"` Locktime uint32 `json:"locktime"` Vin []Vin `json:"vin"` Vout []Vout `json:"vout"` BlockHash string `json:"blockhash"` Confirmations int32 `json:"confirmations"` Time int64 `json:"time"` Blocktime int64 `json:"blocktime"` }
type Node ¶
type Node struct { // Ident is a an identifier of the form 127.0.0.1|s1234 or ::1|t5432. Ident string Network Network // contains filtered or unexported fields }
func (*Node) BlockchainAddressGetHistory ¶
func (n *Node) BlockchainAddressGetHistory(address string) ([]*Transaction, error)
BlockchainAddressGetHistory returns the history of an address.
version 1.1 and version 1.2 only https://electrumx.readthedocs.io/en/latest/protocol-methods.html#blockchain-scripthash-get_history
func (*Node) BlockchainBlockHeaders ¶
BlockchainBlockHeaders returns a block header (160 hex).
func (*Node) BlockchainHeadersSubscribe ¶
Subscribe to receive block headers when a new block is found.
Note: there's no way to unsubscribe, and the rest of this code doesn't know how to deal with notifications. It is advisable to only call this method once and disconnect/reconnect after getting the block height.
https://electrumx.readthedocs.io/en/latest/protocol-methods.html#blockchain-headers-subscribe
func (*Node) BlockchainTransactionGet ¶
BlockchainTransactionGet returns a raw transaction.
https://electrumx.readthedocs.io/en/latest/protocol-methods.html#blockchain-transaction-get
func (*Node) Disconnect ¶
func (*Node) ServerFeatures ¶
ServerFeatures returns the server features dictionary. method: "server.features"
version 1.1 https://electrumx.readthedocs.io/en/latest/protocol-methods.html#server-features
func (*Node) ServerPeersSubscribe ¶
ServerPeersSubscribe requests peers from a server.
https://electrumx.readthedocs.io/en/latest/protocol-methods.html#server-peers-subscribe
func (*Node) ServerVersion ¶
ServerVersion allows negotiating a min protocol version. This is required, as various methods appeared (or were removed) in various versions.
version 1.1 https://electrumx.readthedocs.io/en/latest/protocol-methods.html#server-version
type RequestMessage ¶
type ResponseMessage ¶
type ResponseMessage struct { Id uint64 `json:"id"` JsonRpc string `json:"jsonrpc"` Result interface{} `json:"result"` Error *ErrorResponse `json:"error"` }
type ScriptPubKeyResult ¶
type ScriptPubKeyResult struct { Asm string `json:"asm"` Hex string `json:"hex,omitempty"` ReqSigs int32 `json:"reqSigs,omitempty"` Type string `json:"type"` Addresses []string `json:"addresses,omitempty"` }
ScriptPubKeyResult models the scriptPubKey data of a tx script. It is defined separately since it is used by multiple commands.
type ScriptSig ¶
ScriptSig models a signature script. It is defined separately since it only applies to non-coinbase. Therefore the field in the Vin structure needs to be a pointer.
type TCPTransport ¶
type TCPTransport struct {
// contains filtered or unexported fields
}
func (*TCPTransport) SendMessage ¶
func (t *TCPTransport) SendMessage(request RequestMessage) (*ResponseMessage, error)
func (*TCPTransport) Shutdown ¶
func (t *TCPTransport) Shutdown() error
type Transaction ¶
type Transport ¶
type Transport interface { SendMessage(RequestMessage) (*ResponseMessage, error) Shutdown() error }
func NewSSLTransport ¶
func NewTCPTransport ¶
type Vin ¶
type Vin struct { Coinbase string `json:"coinbase"` Txid string `json:"txid"` Vout uint32 `json:"vout"` ScriptSig *ScriptSig `json:"scriptSig"` Sequence uint32 `json:"sequence"` }
Vin models parts of the tx data.
func (*Vin) IsCoinBase ¶
IsCoinBase returns a bool to show if a Vin is a Coinbase one or not.
type Vout ¶
type Vout struct { Value float64 `json:"value"` N uint32 `json:"n"` ScriptPubKey ScriptPubKeyResult `json:"scriptPubKey"` }
Vout models parts of the tx data.