electrumx

package module
v0.0.0-...-1bad15e Latest Latest
Warning

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

Go to latest
Published: Sep 28, 2023 License: MIT Imports: 11 Imported by: 6

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")
)
View Source
var DebugMode bool

Functions

This section is empty.

Types

type Balance

type Balance struct {
	// Satoshis
	Confirmed int64 `json:"confirmed"`

	// Satoshis
	Unconfirmed int64 `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 {
	// contains filtered or unexported fields
}

func NewNode

func NewNode() *Node

NewNode creates a new node.

func (*Node) BlockchainAddressGetBalance

func (n *Node) BlockchainAddressGetBalance(ctx context.Context, 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(ctx context.Context, 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(ctx context.Context, 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(ctx context.Context, 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(ctx context.Context, 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(ctx context.Context) (<-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(ctx context.Context, 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(ctx context.Context, 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(ctx context.Context, 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(ctx context.Context, 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(ctx context.Context, 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) Connect

func (n *Node) Connect(ctx context.Context, addr string, config *tls.Config) error

Connect creates a new TCP connection to the specified address. If the TLS config is not nil, TLS is applied to the connection.

func (*Node) Disconnect

func (n *Node) Disconnect()

Disconnect shuts down the node. It is safe to call multiple times. Subsequent calls to the first one are no-ops. TODO: implement support for draining requests and waiting until everything is finished.

func (*Node) Errors

func (n *Node) Errors() <-chan error

Errors returns any errors the node ran into while listening to messages.

func (*Node) Ping

func (n *Node) Ping(ctx context.Context) 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(ctx context.Context) (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(ctx context.Context) (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(ctx context.Context) ([][]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(ctx context.Context) ([]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 Transaction

type Transaction struct {
	Hash   string `json:"tx_hash"`
	Height int32  `json:"height"`
	Value  int64  `json:"value"`
	Pos    uint32 `json:"tx_pos"`
}

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