client

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

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

Go to latest
Published: Apr 24, 2024 License: MIT Imports: 11 Imported by: 3

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 {
	// The blockchain, Bitcoin, Dash, etc
	Chain wallet.CoinType

	// Network parameters. Set mainnet, testnet using this.
	Params *chaincfg.Params

	// Store the seed in encrypted storage
	StoreEncSeed bool

	// The user-agent that shall be visible to the network
	UserAgent string

	// Location of the data directory
	DataDir string

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

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

	// If you wish to connect to a single trusted electrumX peer server set this.
	// SingleNode servers will error if not provided
	TrustedPeer net.Addr

	// A Tor proxy can be set here causing the wallet will use Tor. TODO:
	Proxy proxy.Dialer

	// 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 in place. The API response must be formatted as
	// { "fastestFee": 40, "halfHourFee": 20, "hourFee": 10 }
	FeeAPI url.URL

	// Disable the exchange rate provider
	DisableExchangeRates bool

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

	// Test RPC server
	RPCTestPort int
}

func NewDefaultConfig

func NewDefaultConfig() *ClientConfig

func (*ClientConfig) MakeNodeConfig

func (cc *ClientConfig) MakeNodeConfig() *electrumx.NodeConfig

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
	GetNode() electrumx.ElectrumXNode
	//
	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
	//
	CloseWallet()
	//
	// Small subset of electrum-like methods
	Tip() (int64, bool)
	GetBlockHeader(height int64) *wire.BlockHeader
	GetBlockHeaders(startHeight, count int64) ([]*wire.BlockHeader, 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
	Broadcast(ctx context.Context, rawTx []byte) (string, error)
	FeeRate(ctx context.Context, confTarget int64) (int64, error)

	//pass thru
	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

Jump to

Keyboard shortcuts

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