electrum

package
v0.0.0-...-7dbe333 Latest Latest
Warning

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

Go to latest
Published: Feb 18, 2024 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotImplemented = errors.New("not implemented")
	ErrNodeConnected  = errors.New("node already connected")
	ErrNodeShutdown   = errors.New("node has shutdown")
	ErrTimeout        = errors.New("request timeout")
)
View Source
var DebugMode bool

Functions

This section is empty.

Types

type APIErr

type APIErr struct {
	Code    int    `json:"code"`
	Message string `json:"message"`
}

func (*APIErr) Error

func (e *APIErr) Error() string

type Balance

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

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 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 {
	Error chan error
	// 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)

BlockchainGetBalance returns the balance of an address. Available(version < 1.3)

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. Available(version < 1.3)

http://docs.electrum.org/en/latest/protocol.html#blockchain-address-get-history

func (*Node) BlockchainAddressGetMempool

func (n *Node) BlockchainAddressGetMempool() error

TODO implement

Available(version < 1.3)

http://docs.electrum.org/en/latest/protocol.html#blockchain-address-get-mempool

func (*Node) BlockchainAddressListUnspent

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

BlockchainAddressListUnspent lists the unspent transactions for the given address. Available(version < 1.3)

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. Available(version < 1.3)

http://docs.electrum.org/en/latest/protocol.html#blockchain-address-subscribe

func (*Node) BlockchainBlockGetChunk

func (n *Node) BlockchainBlockGetChunk(index int32) (string, error)

TODO implement BlockchainBlockGetChunk returns a chunk of block headers as a hexadecimal string. method: "blockchain.block.get_chunk"

document not updated

func (*Node) BlockchainBlockGetHeader

func (n *Node) BlockchainBlockGetHeader(height int32) error

TODO implement BlockchainBlockGetHeader returns the deserialized header at a given height. method "blockchain.block.get_header"

document not updated

func (*Node) BlockchainEstimateFee

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

BlockchainEstimateFee returns the estimated transaction fee per kilobyte for a transaction to be confirmed within a certain number of blocks.

https://electrumx.readthedocs.io/en/latest/protocol-methods.html#blockchain-estimatefee

func (*Node) BlockchainHeadersSubscribe

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

BlockchainHeadersSubscribe subscribes to get raw headers of new blocks.

https://electrumx.readthedocs.io/en/latest/protocol-methods.html#blockchain-headers-subscribe

func (*Node) BlockchainRelayfee

func (n *Node) BlockchainRelayfee() error

TODO implement BlockchainRelayfee returns the minimum fee a low-priority tx must pay in order to be accepted to the daemon's memory pool. method: "blockchain.relayfee"

https://electrumx.readthedocs.io/en/latest/protocol-methods.html#blockchain-relayfee

func (*Node) BlockchainScripthashGetBalance

func (n *Node) BlockchainScripthashGetBalance(scriptHash string) (*Balance, error)

BlockchainScripthashGetBalance returns the confirmed and unconfirmed balance of a scripthash. method: "blockchain.scripthash.get_balance"

https://electrumx.readthedocs.io/en/latest/protocol-methods.html#blockchain-scripthash-get-balance

func (*Node) BlockchainScripthashGetHistory

func (n *Node) BlockchainScripthashGetHistory(scriptHash string) ([]*Transaction, error)

BlockchainScripthashGetHistory returns the confirmed and unconfirmed history of a scripthash. method: "blockchain.scripthash.get_history"

https://electrumx.readthedocs.io/en/latest/protocol-methods.html#blockchain-scripthash-get-history

func (*Node) BlockchainScripthashGetMempool

func (n *Node) BlockchainScripthashGetMempool(scriptHash string) error

TODO implement BlockchainScripthashGetMempool returns the mempool transactions touching a scripthash. method: "blockchain.scripthash.get_mempool"

https://electrumx.readthedocs.io/en/latest/protocol-methods.html#blockchain-scripthash-get-mempool

func (*Node) BlockchainScripthashListUnspent

func (n *Node) BlockchainScripthashListUnspent(scriptHash string) ([]*Transaction, error)

TODO implement BlockchainScripthashListUnspent returns the list of UTXOs of a scripthash. method: "blockchain.scripthash.listunspent"

https://electrumx.readthedocs.io/en/latest/protocol-methods.html#blockchain-scripthash-listunspent

func (*Node) BlockchainScripthashSubscribe

func (n *Node) BlockchainScripthashSubscribe(scriptHash string) (<-chan string, error)

BlockchainScripthashSubscribe subscribes to a script hash. method: "blockchain.scripthash.subscribe"

https://electrumx.readthedocs.io/en/latest/protocol-methods.html#blockchain-scripthash-subscribe

func (*Node) BlockchainTransactionBroadcast

func (n *Node) BlockchainTransactionBroadcast(tx string) (interface{}, error)

TODO implement Broadcast a transaction to the network.

https://electrumx.readthedocs.io/en/latest/protocol-methods.html#blockchain-transaction-broadcast

func (*Node) BlockchainTransactionGet

func (n *Node) BlockchainTransactionGet(txid string, verbose bool) (*GetTransaction, error)

BlockchainTransactionGet returns a raw transaction.

https://electrumx.readthedocs.io/en/latest/protocol-methods.html#blockchain-transaction-get

func (*Node) BlockchainTransactionGetMerkle

func (n *Node) BlockchainTransactionGetMerkle() error

TODO implement Return the merkle branch to a confirmed transaction given its hash and height.

https://electrumx.readthedocs.io/en/latest/protocol-methods.html#blockchain-transaction-get-merkle

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) Disconnect

func (n *Node) Disconnect()

func (*Node) Ping

func (n *Node) Ping() error

func (*Node) ServerAddPeer

func (n *Node) ServerAddPeer() error

TODO implement ServerAddPeer add a peer (but only if the peer resolves to the source). method: "server.add_peer"

https://electrumx.readthedocs.io/en/latest/protocol-methods.html#server-add-peer

func (*Node) ServerBanner

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

ServerBanner returns the server banner text.

https://electrumx.readthedocs.io/en/latest/protocol-methods.html#server-banner

func (*Node) ServerDonationAddress

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

ServerDonationAddress returns the donation address of the server.

https://electrumx.readthedocs.io/en/latest/protocol-methods.html#server-donation-address

func (*Node) ServerFeatures

func (n *Node) ServerFeatures() error

TODO implement ServerFeatures returns the server features dictionary. method: "server.features"

https://electrumx.readthedocs.io/en/latest/protocol-methods.html#server-features

func (*Node) ServerPeersSubscribe

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

ServerPeersSubscribe requests peers from a server.

https://electrumx.readthedocs.io/en/latest/protocol-methods.html#server-peers-subscribe

func (*Node) ServerVersion

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

TODO return concrete struct instead of unnamed string slice ServerVersion returns the server's version.

http://docs.electrum.org/en/latest/protocol.html#server-version

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

type ScriptSig struct {
	Asm string `json:"asm"`
	Hex string `json:"hex"`
}

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 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 int32  `json:"height"`
	Value  int64  `json:"value"`
	Pos    uint32 `json:"tx_pos"`
}

type Transport

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

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

func (v *Vin) IsCoinBase() bool

IsCoinBase returns a bool to show if a Vin is a Coinbase one or not.

func (*Vin) MarshalJSON

func (v *Vin) MarshalJSON() ([]byte, error)

MarshalJSON provides a custom Marshal method for Vin.

type Vout

type Vout struct {
	Value        float64            `json:"value"`
	N            uint32             `json:"n"`
	ScriptPubKey ScriptPubKeyResult `json:"scriptPubKey"`
}

Vout models parts of the tx data.

Jump to

Keyboard shortcuts

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