electrum

package module
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Jun 8, 2024 License: MIT Imports: 10 Imported by: 0

README

It's a library to work with Electrum Server(local or remote).

You can: GetBalance() GetTxHistory() Subscribe for Changes

Support only BItcoin and Litecoin Networks right now. Do not work with Taproot address formats.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DecodeBase58

func DecodeBase58(b string) []byte

Types

type Balance

type Balance struct {
	Confirmed   int64 `json:"confirmed"`
	Unconfirmed int64 `json:"unconfirmed"`
}

Balance represents the balance structure with confirmed and unconfirmed fields.

type ElectrumError

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

ElectrumError represents the structure of an error returned by the Electrum server.

type ElectrumRequest

type ElectrumRequest struct {
	ID      int           `json:"id"`
	Method  string        `json:"method"`
	Params  []interface{} `json:"params"`
	Jsonrpc string        `json:"jsonrpc"`
}

ElectrumRequest represents the structure of an Electrum request.

type ElectrumResponse

type ElectrumResponse struct {
	ID     int             `json:"id"`
	Result json.RawMessage `json:"result"`
	Error  *ElectrumError  `json:"error,omitempty"`
}

ElectrumResponse represents the structure of an Electrum response.

type ElectrumServer

type ElectrumServer struct {
	Conn    net.Conn
	Network string
}

func (*ElectrumServer) GetBalance

func (s *ElectrumServer) GetBalance(address string) (int64, int64, error)

func (*ElectrumServer) GetTxHistory

func (s *ElectrumServer) GetTxHistory(address string) ([]TxHistory, string, error)

func (*ElectrumServer) ListenForNotification

func (s *ElectrumServer) ListenForNotification()

func (*ElectrumServer) SendPing

func (s *ElectrumServer) SendPing() error

func (*ElectrumServer) Subscribe

func (s *ElectrumServer) Subscribe(address string) (string, string, error)

Then you Subscribe to scriptHash,server return Current STATUS.Then something change you will get new status and scriptHash.

type TxHistory

type TxHistory struct {
	TxHash string `json:"tx_hash"`
	Height int    `json:"height"`
}

TxHistory represents a transaction history entry with transaction hash and height.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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