electrum

package module
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Jun 12, 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) GetTx added in v0.1.3

func (s *ElectrumServer) GetTx(txid string, verbose bool) (*Tx, 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 ScriptPubKey added in v0.1.3

type ScriptPubKey struct {
	Addresses []string `json:"addresses,omitempty"`
	Address   string   `json:"address,omitempty`
	Desc      string   `json:"desc,omitempty"`
	Asm       string   `json:"asm"`
	Hex       string   `json:"hex"`
	ReqSigs   int      `json:"reqSigs,omitempty"`
	Type      string   `json:"type"`
}

type ScriptSig added in v0.1.3

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

type Tx added in v0.1.3

type Tx struct {
	BlockHash     string `json:"blockhash,omitempty"`
	BlockTime     int    `json:"blocktime,omitempty"`
	Confirmations int    `json:"confirmations,omitempty"`
	Hash          string `json:"hash"`
	Hex           string `json:"hex,omitempty"`
	Locktime      int    `json:"locktime"`
	Size          int    `json:"size"`
	Time          int    `json:"time,omitempty"`
	Txid          string `json:"txid"`
	Version       int    `json:"version"`
	Vin           []Vin  `json:"vin"`
	Vout          []Vout `json:"vout"`
	Vsize         int    `json:"vsize,omitempty"`
	Weight        int    `json:"weight,omitempty"`
}

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.

type Vin added in v0.1.3

type Vin struct {
	Txid        string    `json:"txid"`
	Vout        int       `json:"vout"`
	ScriptSig   ScriptSig `json:"scriptSig"`
	Sequence    uint32    `json:"sequence"`
	Txinwitness []string  `json:"txinwitness"`
}

type Vout added in v0.1.3

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

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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