client

package
v0.0.0-...-f587991 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2024 License: MIT Imports: 8 Imported by: 9

README

Package client

The client is the interface between an electrum wallet and the node(s) it connects to.

Documentation

Index

Constants

View Source
const (
	DbTypeBolt   = "bbolt"
	DbTypeSqlite = "sqlite"
)
View Source
const (
	GoeleVersionMajor = "0"
	GoeleVersionMinor = "1"
	GoeleVersionPatch = "0"
	GoeleVersion      = GoeleVersionMajor +
		"." +
		GoeleVersionMinor +
		"." +
		GoeleVersionPatch
)
View Source
const (
	// Electrum Wallet
	GAP_LIMIT = 10
)

Variables

This section is empty.

Functions

func GetConfigPath

func GetConfigPath() (string, error)

Types

type ClientConfig

type ClientConfig struct {
	// Coin ticker to id the coin
	Coin string

	// bip44 mainnet
	CoinType wallet.CoinType

	// Net type - mainnet, testnet or regtest
	NetType string

	// Network parameters - make more general if it cannot adapt to other coins.
	Params *chaincfg.Params

	// Location of the data directory
	DataDir string

	// We use this electrumX server to bootstrap others so it should
	// be set.
	TrustedPeer *electrumx.NodeServerAddr

	// A localhost socks5 proxy port can be set here and will be used as to proxy
	// ElectrumX server onion connections.
	//
	// If not "" setting this enables goele to connect to a limited number of
	// onion servers. Default is "".
	//
	// You should have already set up a localhost socks5 proxy and tor service.
	//
	// Note: This is tested on Linux and is still considered *Experimental*
	ProxyPort string

	// Store the seed in encrypted storage - default false
	StoreEncSeed bool

	// Database implementation type (bbolt or sqlite)
	DbType string

	// An implementation of the Datastore interface
	DB wallet.Datastore

	// The default fee-per-byte for each level
	LowFee    int64
	MediumFee int64
	HighFee   int64

	// The highest allowable fee-per-byte
	MaxFee int64

	// External API to query to look up fees. If this field is nil then the
	// default fees will be used. If the API is unreachable then the default
	// fees will likewise be used. If the API returns a fee greater than MaxFee
	// then the MaxFee will be used instead.
	FeeAPI url.URL

	// If not testing do not overwrite existing wallet files
	Testing bool

	// Test RPC server
	RPCTestPort int
}

func NewDefaultConfig

func NewDefaultConfig() *ClientConfig

func (*ClientConfig) MakeElectrumXConfig

func (cc *ClientConfig) MakeElectrumXConfig() *electrumx.ElectrumXConfig

func (*ClientConfig) MakeWalletConfig

func (cc *ClientConfig) MakeWalletConfig() *wallet.WalletConfig

type ElectrumClient

type ElectrumClient interface {
	Start(ctx context.Context) error
	Stop()
	//
	GetConfig() *ClientConfig
	GetWallet() wallet.ElectrumWallet
	GetX() electrumx.ElectrumX
	//
	RegisterTipChangeNotify() (<-chan int64, error)
	UnregisterTipChangeNotify()
	//
	CreateWallet(pw string) error
	LoadWallet(pw string) error
	RecreateWallet(ctx context.Context, pw, mnenomic string) error
	//
	SyncWallet(ctx context.Context) error
	RescanWallet(ctx context.Context) error
	ImportAndSweep(ctx context.Context, keyPairs []string) error
	//
	// Subset of electrum-like methods
	Tip() int64
	Synced() bool
	GetBlockHeader(height int64) (*electrumx.ClientBlockHeader, error)
	GetBlockHeaders(startHeight, count int64) ([]*electrumx.ClientBlockHeader, error)
	Spend(pw string, amount int64, toAddress string, feeLevel wallet.FeeLevel) (int, string, string, error)
	GetPrivKeyForAddress(pw, addr string) (string, error)
	ListUnspent() ([]wallet.Utxo, error)
	ListConfirmedUnspent() ([]wallet.Utxo, error)
	ListFrozenUnspent() ([]wallet.Utxo, error)
	FreezeUTXO(txid string, out uint32) error
	UnfreezeUTXO(txid string, out uint32) error
	UnusedAddress(ctx context.Context) (string, error)
	ChangeAddress(ctx context.Context) (string, error)
	ValidateAddress(addr string) (bool, bool, error)
	SignTx(pw string, txBytes []byte) ([]byte, error)
	GetWalletTx(txid string) (int, bool, []byte, error)
	GetWalletSpents() ([]wallet.Stxo, error)
	Balance() (int64, int64, int64, error)

	// adapt and pass thru to electrumx
	Broadcast(ctx context.Context, rawTx []byte) (string, error)
	FeeRate(ctx context.Context, confTarget int64) (int64, error)

	//pass thru directly to electrumx
	GetTransaction(ctx context.Context, txid string) (*electrumx.GetTransactionResult, error)
	GetRawTransaction(ctx context.Context, txid string) ([]byte, error)
	GetAddressHistory(ctx context.Context, addr string) (electrumx.HistoryResult, error)
	GetAddressUnspent(ctx context.Context, addr string) (electrumx.ListUnspentResult, error)
}

type NodeType

type NodeType int
const (
	// ElectrumX Server(s)
	SingleNode NodeType = iota
	MultiNode  NodeType = 1
)

Directories

Path Synopsis
btc
rpc_test Module
rpc_test Module

Jump to

Keyboard shortcuts

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