loader

package
v1.1.4 Latest Latest
Warning

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

Go to latest
Published: May 14, 2024 License: ISC Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

log is a logger that is initialized with no output filters. This means the package will not perform any logging by default until the caller requests it.

Functions

func UseLogger

func UseLogger(logger slog.Logger)

UseLogger uses a specified Logger to output package logging info. This should be used in preference to SetLogWriter if the caller is also using slog.

Types

type AssetLoader

type AssetLoader interface {
	GetDbDirPath() string
	SetDatabaseDriver(driver string)

	OpenExistingWallet(ctx context.Context, WalletID string, pubPassphrase []byte) (*LoadedWallets, error)
	CreateNewWallet(ctx context.Context, params *CreateWalletParams) (*LoadedWallets, error)
	CreateWatchingOnlyWallet(ctx context.Context, params *WatchOnlyWalletParams) (*LoadedWallets, error)

	GetLoadedWallet() (*LoadedWallets, bool)
	UnloadWallet() error
	WalletExists(WalletID string) (bool, error)
}

AssetLoader defines the interface exported by the loader implementation of each asset.

type CreateWalletParams

type CreateWalletParams struct {
	WalletID       string
	PubPassphrase  []byte
	PrivPassphrase []byte
	Seed           []byte
}

type LoadedWallets

type LoadedWallets struct {
	BTC *btcW.Wallet
	DCR *dcrW.Wallet
	LTC *ltcW.Wallet
}

LoadedWallets holds all the upstream wallets managed by the loader

type Loader

type Loader struct {
	// The full db path required to create the individual wallets follows the
	// format ~.cryptopower/[network_selected]/[asset_selected]/[wallet_ID].
	// DbDirPath by default is only expected to hold the path upto the
	// [network_selected] folder. The other details are added on demand.
	DbDirPath string
	// DbDriver defines the type of database driver in use by the individual
	// wallets.
	DbDriver string
}

func NewLoader

func NewLoader(dbDirPath string) *Loader

func (*Loader) CreateDirPath

func (l *Loader) CreateDirPath(WalletID, walletDbName string, assetType utils.AssetType) (dbPath string, err error)

CreateDirPath checks that fully qualified path to the wallet bucket exists. If it doesn't exist it's created. It also checks if the actual db file required exists, if it exists an error is returned otherwise it's created. Since the fully qualified path of the db is as follows: ~.cryptopower/[network_selected]/[asset_selected]/[wallet_ID]/[WalletDbName.db]. l.DbDirPath provides the path of the network_selected. assetType provides the asset_selected name, WalletID provides the wallet Id of the wallet needed. assetType and WalletID are provided for every new bucket instance needed.

func (*Loader) FileExists

func (l *Loader) FileExists(WalletID, walletDbName string, assetType utils.AssetType) (string, bool, error)

FileExists checks if db bucket path identified by the following parameters exists.

func (*Loader) SetDatabaseDriver

func (l *Loader) SetDatabaseDriver(driver string)

/SetDatabaseDriver specifies the database to be used by walletdb

type WatchOnlyWalletParams

type WatchOnlyWalletParams struct {
	WalletID       string
	ExtendedPubKey string
	PubPassphrase  []byte
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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