Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Account ¶
type Account interface {
// ID provides the ID for the account.
ID() uuid.UUID
// Name provides the name for the account.
Name() string
// PublicKey provides the public key for the account.
PublicKey() types.PublicKey
// Path provides the path for the account.
// Can be empty if the account is not derived from a path.
Path() string
// Lock locks the account. A locked account cannot sign.
Lock()
// Unlock unlocks the account. An unlocked account can sign.
Unlock([]byte) error
// IsUnlocked returns true if the account is unlocked.
IsUnlocked() bool
// Sign signs data with the account.
Sign(data []byte, domain uint64) (types.Signature, error)
}
Account is the interface for all Ethereum 2 accounts.
type AccountMetadata ¶ added in v1.8.0
type AccountMetadata interface {
// WalletID provides the ID for the wallet.
WalletID() uuid.UUID
// ID provides the ID for the account.
ID() uuid.UUID
// Name provides the name for the account.
Name() string
}
AccountMetadata provides metadata for an account. It is used for various accounting purposes, for example to ensure that no two accounts with the same name exist in a single wallet.
type AccountPrivateKeyProvider ¶ added in v1.2.0
type AccountPrivateKeyProvider interface {
// PrivateKey provides the private key for the account.
PrivateKey() (types.PrivateKey, error)
}
AccountPrivateKeyProvider is the interface for accounts that can provide a private key.
type Encryptor ¶
type Encryptor interface {
// Name() provides the name of the encryptor
Name() string
// Version() provides the version of the encryptor
Version() uint
// Encrypt encrypts a byte array with its encryption mechanism and key
Encrypt(data []byte, key []byte) (map[string]interface{}, error)
// Decrypt encrypts a byte array with its encryption mechanism and key
Decrypt(data map[string]interface{}, key []byte) ([]byte, error)
}
Encryptor is the interface for encrypting and decrypting sensitive information in wallets.
type Store ¶
type Store interface {
// Name provides the name of the store
Name() string
// StoreWallet stores wallet data. It will fail if it cannot store the data.
StoreWallet(walletID uuid.UUID, walletName string, data []byte) error
// RetrieveWallet retrieves wallet data for all wallets.
RetrieveWallets() <-chan []byte
// RetrieveWallet retrieves wallet data for a wallet with a given name.
// It will fail if it cannot retrieve the data.
RetrieveWallet(walletName string) ([]byte, error)
// RetrieveWalletByID retrieves wallet data for a wallet with a given ID.
// It will fail if it cannot retrieve the data.
RetrieveWalletByID(walletID uuid.UUID) ([]byte, error)
// StoreAccount stores account data. It will fail if it cannot store the data.
StoreAccount(walletID uuid.UUID, accountID uuid.UUID, data []byte) error
// RetrieveAccounts retrieves account information for all accounts.
RetrieveAccounts(walletID uuid.UUID) <-chan []byte
// RetrieveAccount retrieves account data for a wallet with a given ID.
// It will fail if it cannot retrieve the data.
RetrieveAccount(walletID uuid.UUID, accountID uuid.UUID) ([]byte, error)
// StoreAccountsIndex stores the index of accounts for a given wallet.
StoreAccountsIndex(walletID uuid.UUID, data []byte) error
// RetrieveAccountsIndex retrieves the index of accounts for a given wallet.
RetrieveAccountsIndex(walletID uuid.UUID) ([]byte, error)
}
Store is the interface for wallet stores. It is used to store and access data provided by wallets, both wallets themselves as well as keys inside the wallets.
type StoreLocationProvider ¶ added in v1.9.0
type StoreLocationProvider interface {
Location() string
}
StoreLocationProvider provides the location of the store.
type StoreProvider ¶ added in v1.9.0
type StoreProvider interface {
// Store returns the store.
Store() Store
}
StoreProvider is the interface provides a store.
type Wallet ¶
type Wallet interface {
// ID provides the ID for the wallet.
ID() uuid.UUID
// Name provides the name for the wallet.
Name() string
// Type provides the type of the wallet.
Type() string
// Version provides the version of the wallet.
Version() uint
// Lock locks the wallet. A locked account cannot create new accounts.
Lock()
// Unlock unlocks the wallet. An unlocked account can create new accounts.
Unlock([]byte) error
// IsUnlocked returns true if the wallet is unlocked.
IsUnlocked() bool
// CreateAccount creates a new account in the wallet.
// The only rule for names is that they cannot start with an underscore (_) character.
// This will error if an account with the name already exists.
CreateAccount(name string, passphrase []byte) (Account, error)
// Accounts provides all accounts in the wallet.
Accounts() <-chan Account
// AccountByID provides a single account from the wallet given its ID.
// This will error if the account is not found.
AccountByID(id uuid.UUID) (Account, error)
// AccountByName provides a single account from the wallet given its name.
// This will error if the account is not found.
AccountByName(name string) (Account, error)
}
Wallet is the interface for wallets. A wallet contains one or more accounts. Each account has its own security mechanism.
type WalletAccountImporter ¶ added in v1.2.0
type WalletAccountImporter interface {
// ImportAccount creates a new account in the wallet from an existing private key.
// The only rule for names is that they cannot start with an underscore (_) character.
// This will error if an account with the name already exists.
ImportAccount(name string, key []byte, passphrase []byte) (Account, error)
}
WalletAccountImporter is the interface for wallets that can import accounts.
type WalletExporter ¶ added in v1.2.0
type WalletExporter interface {
// Export exports the entire wallet, protected by an additional passphrase.
Export(passphrase []byte) ([]byte, error)
}
WalletExporter is the interface for wallets that can export themselves.
type WalletKeyProvider ¶ added in v1.2.0
WalletKeyProvider is the interface for wallets that can provide a key.