fswallet

package
v1.2.1 Latest Latest
Warning

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

Go to latest
Published: Jun 29, 2026 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ConfigPath the path of the Keystore V3 wallet path
	ConfigPath = "path"
	// ConfigFilenamesWith0xPrefix whether or not to use the 0x prefix on filenames, when using passwordExt password
	ConfigFilenamesWith0xPrefix = "filenames.with0xPrefix"
	// ConfigFilenamesPrimaryExt extension to append to the "from" address string to find the file (see metadata section for file types). All filenames must be lower case on disk.
	ConfigFilenamesPrimaryExt = "filenames.primaryExt"
	// ConfigFilenamesPrimaryMatchRegex allows filenames where the address can be extracted with a regular expression. Takes precedence over primaryExt
	ConfigFilenamesPrimaryMatchRegex = "filenames.primaryMatchRegex"
	// ConfigFilenamesPasswordExt extension to append to the "from" address string to find the password file (if not using a metadata file to specify the password file)
	ConfigFilenamesPasswordExt = "filenames.passwordExt"
	// ConfigFilenamesPasswordPath directory path where the password files should be found - default is the same path as the primary file
	ConfigFilenamesPasswordPath = "filenames.passwordPath"
	// ConfigFilenamesPasswordTrimSpace whether to trim whitespace from passwords loaded from files (such as trailing newline characters)
	ConfigFilenamesPasswordTrimSpace = "filenames.passwordTrimSpace"
	// ConfigDefaultPasswordFile default password file to use if neither the metadata, or passwordExtension find a password
	ConfigDefaultPasswordFile = "defaultPasswordFile"
	// ConfigDisableListener disable the filesystem listener that detects newly added keys automatically
	ConfigDisableListener = "disableListener"
	// ConfigSignerCacheSize the number of signing keys to keep in memory
	ConfigSignerCacheSize = "signerCacheSize"
	// ConfigSignerCacheTTL the time to keep an unused signing key in memory
	ConfigSignerCacheTTL = "signerCacheTTL"
	// ConfigMetadataFormat format to parse the metadata - supported: auto (from extension) / filename / toml / yaml / json (please quote "0x..." strings in YAML)
	ConfigMetadataFormat = "metadata.format"
	// ConfigMetadataKeyFileProperty use for toml/yaml/json to find the name of the file containing the keystorev3 file
	ConfigMetadataKeyFileProperty = "metadata.keyFileProperty"
	// ConfigMetadataPasswordFileProperty use for toml/yaml to find the name of the file containing the keystorev3 file
	ConfigMetadataPasswordFileProperty = "metadata.passwordFileProperty"
)

Variables

This section is empty.

Functions

func InitConfig

func InitConfig(section config.Section)

Types

type Config

type Config struct {
	Path                string
	DefaultPasswordFile string
	SignerCacheSize     string
	SignerCacheTTL      string
	DisableListener     bool
	Filenames           FilenamesConfig
	Metadata            MetadataConfig
}

func ReadConfig

func ReadConfig(section config.Section) *Config

type ConfigGeneric

type ConfigGeneric struct {
	Config
	WalletFileValidator func(ctx context.Context, addrString string, kv3 keystorev3.WalletFile) error
	AddressValidator    func(ctx context.Context, addrString string) (string, error)
}

type FilenamesConfig

type FilenamesConfig struct {
	PrimaryMatchRegex string
	PrimaryExt        string
	PasswordExt       string
	PasswordPath      string
	PasswordTrimSpace bool
	With0xPrefix      bool
}

type MetadataConfig

type MetadataConfig struct {
	Format               string
	KeyFileProperty      string
	PasswordFileProperty string
}

type SyncAddressCallback

type SyncAddressCallback func(context.Context, ethtypes.Address0xHex) error

type SyncCallback

type SyncCallback func(context.Context, string) error

type Wallet

type Wallet interface {
	ethsigner.WalletTypedData
	GetWalletFile(ctx context.Context, addr ethtypes.Address0xHex) (keystorev3.WalletFile, error)
	SetSyncAddressCallback(SyncAddressCallback)
	AddListener(listener chan<- ethtypes.Address0xHex)
}

This is a wrapper on the WalletStrIDs capability, that requires all lookups to keys to be ethereum addresses, and adds some other ethereum specific functionality.

Originally this library only provided this utility, and later we made the concept of an address more generic.

func NewFilesystemWallet

func NewFilesystemWallet(ctx context.Context, conf *Config, initialListeners ...chan<- ethtypes.Address0xHex) (ww Wallet, err error)

type WalletGeneric

type WalletGeneric interface {
	Initialize(ctx context.Context) error
	Refresh(ctx context.Context) error
	Close() error

	GetAccounts(ctx context.Context) ([]string, error)
	GetWalletFile(ctx context.Context, addr string) (keystorev3.WalletFile, error)
	SetSyncCallback(SyncCallback)
	AddListener(listener chan<- string)
}

Wallet is a directory containing a set of KeystoreV3 files, conforming to the ethsigner.Wallet interface and providing notifications when new keys are added to the wallet (via FS listener).

func NewFilesystemWalletGeneric

func NewFilesystemWalletGeneric(ctx context.Context, conf *ConfigGeneric, initialListeners ...chan<- string) (ww WalletGeneric, err error)

Jump to

Keyboard shortcuts

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