filesystem

package module
v1.18.1 Latest Latest
Warning

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

Go to latest
Published: Aug 1, 2023 License: Apache-2.0 Imports: 11 Imported by: 18

README

go-eth2-wallet-store-filesystem

Tag License GoDoc Travis CI codecov.io Go Report Card

Filesystem-based store for the Ethereum 2 wallet.

Table of Contents

Install

go-eth2-wallet-store-filesystem is a standard Go module which can be installed with:

go get github.com/wealdtech/go-eth2-wallet-store-filesystem

Usage

In normal operation this module should not be used directly. Instead, it should be configured to be used as part of go-eth2-wallet.

The filesystem store has the following options:

  • location: the base directory in which to store wallets. If this is not configured it defaults to a sensible operating system-specific values:
    • for Linux: $HOME/.config/ethereum2/wallets
    • for OSX: $HOME/Library/Application Support/ethereum2/wallets
    • for Windows: %APPDATA%\ethereum2\wallets
  • passphrase: a key used to encrypt all data written to the store. If this is not configured data is written to the store unencrypted (although wallet- and account-specific private information may be protected by their own passphrases)
Example
package main

import (
	e2wallet "github.com/wealdtech/go-eth2-wallet"
	filesystem "github.com/wealdtech/go-eth2-wallet-store-filesystem"
)

func main() {
    // Set up and use a simple store
    store := filesystem.New()
    e2wallet.UseStore(store)

    // Set up and use an encrypted store
    store := filesystem.New(filesystem.WithPassphrase([]byte("my secret")))
    e2wallet.UseStore(store)

    // Set up and use an encrypted store at a custom location
    store := filesystem.New(filesystem.WithPassphrase([]byte("my secret")), filesystem.WithLocation("/home/user/wallets"))
    e2wallet.UseStore(store)

    // Use e2wallet operations as normal.
}

Maintainers

Jim McDonald: @mcdee.

Contribute

Contributions welcome. Please check out the issues.

License

Apache-2.0 © 2019 Weald Technology Trading Ltd

Documentation

Overview

Package filesystem is an Ethereum wallet store on a local filesystem.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(opts ...Option) wtypes.Store

New creates a new filesystem store. If the path is not supplied a default path is used.

Types

type Option

type Option interface {
	// contains filtered or unexported methods
}

Option gives options to New.

func WithLocation

func WithLocation(b string) Option

WithLocation sets the on-filesystem location for the store.

func WithPassphrase

func WithPassphrase(passphrase []byte) Option

WithPassphrase sets the encryption for the store.

type Store

type Store struct {
	// contains filtered or unexported fields
}

Store is the store for the wallet.

func (*Store) Location added in v1.6.0

func (s *Store) Location() string

Location returns the location of this store.

func (*Store) Name

func (s *Store) Name() string

Name returns the name of this store.

func (*Store) RetrieveAccount

func (s *Store) RetrieveAccount(walletID uuid.UUID, accountID uuid.UUID) ([]byte, error)

RetrieveAccount retrieves account-level data. It will return an error if it cannot retrieve the data.

func (*Store) RetrieveAccounts

func (s *Store) RetrieveAccounts(walletID uuid.UUID) <-chan []byte

RetrieveAccounts retrieves all account-level data for a wallet.

func (*Store) RetrieveAccountsIndex added in v1.5.0

func (s *Store) RetrieveAccountsIndex(walletID uuid.UUID) ([]byte, error)

RetrieveAccountsIndex retrieves the account index.

func (*Store) RetrieveBatch added in v1.18.0

func (s *Store) RetrieveBatch(_ context.Context, walletID uuid.UUID) ([]byte, error)

RetrieveBatch retrieves the batch of accounts for a given wallet.

func (*Store) RetrieveWallet

func (s *Store) RetrieveWallet(walletName string) ([]byte, error)

RetrieveWallet retrieves wallet-level data. It will fail if it cannot retrieve the data.

func (*Store) RetrieveWalletByID added in v1.4.0

func (s *Store) RetrieveWalletByID(walletID uuid.UUID) ([]byte, error)

RetrieveWalletByID retrieves wallet-level data. It will fail if it cannot retrieve the data.

func (*Store) RetrieveWallets

func (s *Store) RetrieveWallets() <-chan []byte

RetrieveWallets retrieves wallet-level data for all wallets.

func (*Store) StoreAccount

func (s *Store) StoreAccount(walletID uuid.UUID, accountID uuid.UUID, data []byte) error

StoreAccount stores an account. It will fail if it cannot store the data. Note this will overwrite an existing account with the same ID. It will not, however, allow multiple accounts with the same name to co-exist in the same wallet.

func (*Store) StoreAccountsIndex added in v1.5.0

func (s *Store) StoreAccountsIndex(walletID uuid.UUID, data []byte) error

StoreAccountsIndex stores the account index.

func (*Store) StoreBatch added in v1.18.0

func (s *Store) StoreBatch(_ context.Context, walletID uuid.UUID, _ string, data []byte) error

StoreBatch stores wallet batch data. It will fail if it cannot store the data.

func (*Store) StoreWallet

func (s *Store) StoreWallet(walletID uuid.UUID, _ string, data []byte) error

StoreWallet stores wallet-level data. It will fail if it cannot store the data. Note that this will overwrite any existing data; it is up to higher-level functions to check for the presence of a wallet with the wallet name and handle clashes accordingly.

Jump to

Keyboard shortcuts

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