Documentation
¶
Index ¶
- Variables
- type Account
- type AccountManager
- type Manager
- func (manager *Manager) Accounts() []*Account
- func (manager *Manager) Contains(address common.Address) bool
- func (manager *Manager) DelValKey(addr common.Address, pwd string) error
- func (manager *Manager) Delete(address common.Address, passphrase string) error
- func (manager *Manager) Export(a *Account, passphrase, newPassphrase string) (keyJSON []byte, err error)
- func (manager *Manager) ExportECDSA(a *Account, passphrase string) (string, error)
- func (manager *Manager) ExportValKey(addr common.Address, pwd, newPwd string) (keyJSON []byte, err error)
- func (manager *Manager) Find(address common.Address) (*Account, bool)
- func (manager *Manager) GetUnlockedValKey() *keystore.Key
- func (manager *Manager) Import(keyJSON []byte, passphrase, newPassphrase string) (*Account, error)
- func (manager *Manager) ImportECDSA(priv *ecdsa.PrivateKey, passphrase string) (*Account, error)
- func (manager *Manager) ImportValKey(keyJSON []byte, pwd, newPwd string) (*ValAccount, error)
- func (manager *Manager) Lock(address common.Address) error
- func (manager *Manager) LockValKey() error
- func (manager *Manager) NewAccount(passphrase []byte) (*Account, error)
- func (manager *Manager) NewValKey(pwd string) (*ValAccount, error)
- func (manager *Manager) SignHash(account Account, hash []byte) (signature []byte, err error)
- func (manager *Manager) SignHashWithPassphrase(account Account, passphrase string, hash []byte) (signature []byte, err error)
- func (manager *Manager) SignTx(account Account, tx *types.Transaction) (*types.Transaction, error)
- func (manager *Manager) SignTxWithKey(key string, tx *types.Transaction, networkId *big.Int) (*types.Transaction, error)
- func (manager *Manager) SignTxWithPassphrase(account Account, passphrase string, tx *types.Transaction) (*types.Transaction, error)
- func (manager *Manager) Status(account Account) (string, error)
- func (manager *Manager) TimedUnlock(account *Account, passphrase string, timeout time.Duration) error
- func (manager *Manager) Unlock(account *Account, passphrase string) error
- func (manager *Manager) Unlocked() map[common.Address]*unlocked
- func (manager *Manager) Update(account *Account, passphrase, newPassphrase string) error
- func (manager *Manager) UseValKey(addr common.Address, pwd string, keep bool) (*keystore.Key, error)
- type Storage
- type ValAccount
- type Wallet
Constants ¶
This section is empty.
Variables ¶
Functions ¶
This section is empty.
Types ¶
type AccountManager ¶
type AccountManager interface { Accounts() []*Account NewAccount(passphrase []byte) (*Account, error) Delete(address common.Address, passphrase string) error Update(account *Account, passphrase, newPassphrase string) error Contains(address common.Address) bool Find(address common.Address) (*Account, bool) Lock(address common.Address) error Unlock(account *Account, passphrase string) error TimedUnlock(account *Account, passphrase string, timeout time.Duration) error Status(account Account) (string, error) ImportECDSA(priv *ecdsa.PrivateKey, passphrase string) (*Account, error) ExportECDSA(a *Account, passphrase string) (string, error) Import(keyJSON []byte, passphrase, newPassphrase string) (*Account, error) Export(a *Account, passphrase, newPassphrase string) (keyJSON []byte, err error) SignHash(account Account, hash []byte) (signature []byte, err error) SignTx(account Account, tx *types.Transaction) (*types.Transaction, error) SignHashWithPassphrase(account Account, passphrase string, hash []byte) (signature []byte, err error) SignTxWithPassphrase(account Account, passphrase string, tx *types.Transaction) (*types.Transaction, error) SignTxWithKey(key string, tx *types.Transaction, networkId *big.Int) (*types.Transaction, error) //NewValKey generates a new validator key that includes an ecdsa key and a bls key. NewValKey(pwd string) (*ValAccount, error) //UseValKey will unlock and return the required validator key. //If keep is true, then will store that validator key with plaintext, BE CAUTIOUS! //Will only keep at most one validator key. UseValKey(addr common.Address, pwd string, keep bool) (*keystore.Key, error) //GetUnlockedValKey gets the unlocked validator key GetUnlockedValKey() *keystore.Key //ExportValKey is like as Export, just do more check about validator key ExportValKey(addr common.Address, pwd, newPwd string) (keyJSON []byte, err error) ImportValKey(keyJSON []byte, pwd, newPwd string) (*ValAccount, error) //DelValKey will both try removing all unlocked validator keys and delete the specific key. DelValKey(addr common.Address, pwd string) error //LockValKey will remove all unlocked validator keys LockValKey() error }
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
func (*Manager) DelValKey ¶
DelValKey will both try removing all unlocked validator keys and delete the specific key.
func (*Manager) Delete ¶
Delete deletes the key matched by account if the passphrase is correct. If the account contains no filename, the address must match a unique key.
func (*Manager) Export ¶
func (manager *Manager) Export(a *Account, passphrase, newPassphrase string) (keyJSON []byte, err error)
Export exports as a JSON key, encrypted with newPassphrase.
func (*Manager) ExportECDSA ¶
ExportECDSA export a private key
func (*Manager) ExportValKey ¶
func (*Manager) GetUnlockedValKey ¶
func (*Manager) ImportECDSA ¶
ImportECDSA stores the given key into the key directory, encrypting it with the passphrase.
func (*Manager) ImportValKey ¶
func (manager *Manager) ImportValKey(keyJSON []byte, pwd, newPwd string) (*ValAccount, error)
func (*Manager) LockValKey ¶
func (*Manager) NewAccount ¶
func (*Manager) NewValKey ¶
func (manager *Manager) NewValKey(pwd string) (*ValAccount, error)
NewValKey generates a new validator key that includes an ecdsa key and a bls key.
func (*Manager) SignHash ¶
SignHash calculates a ECDSA signature for the given hash. The produced signature is in the [R || S || V] format where V is 0 or 1.
func (*Manager) SignHashWithPassphrase ¶
func (manager *Manager) SignHashWithPassphrase(account Account, passphrase string, hash []byte) (signature []byte, err error)
SignHashWithPassphrase signs hash if the private key matching the given address can be decrypted with the given passphrase. The produced signature is in the [R || S || V] format where V is 0 or 1.
func (*Manager) SignTx ¶
func (manager *Manager) SignTx(account Account, tx *types.Transaction) (*types.Transaction, error)
SignTx signs the given transaction with the requested account.
func (*Manager) SignTxWithKey ¶
func (manager *Manager) SignTxWithKey(key string, tx *types.Transaction, networkId *big.Int) (*types.Transaction, error)
func (*Manager) SignTxWithPassphrase ¶
func (manager *Manager) SignTxWithPassphrase(account Account, passphrase string, tx *types.Transaction) (*types.Transaction, error)
SignTxWithPassphrase signs the transaction if the private key matching the given address can be decrypted with the given passphrase.
func (*Manager) TimedUnlock ¶
func (*Manager) UseValKey ¶
func (manager *Manager) UseValKey(addr common.Address, pwd string, keep bool) (*keystore.Key, error)
UseValKey will unlock and return the required validator key. If keep is true, then will store that validator key with plaintext, BE CAUTIOUS! Will only keep at most one validator key.
type Storage ¶
type Storage interface { GetKey(addr common.Address, filename string, passphrase string) (*keystore.Key, error) StoreKey(filename string, key *keystore.Key, passphrase string) error ImportKey(key *keystore.Key, passphrase string) (string, error) JoinPath(filename string) string GetPath(addr common.Address) string }
type ValAccount ¶
type ValAccount struct { Account MainPubKey []byte //consensus compressed public key BlsPubKey []byte //compressed bls public key }
ValAccount is a validator account, for convenient
type Wallet ¶
type Wallet interface { // Contains returns whether an account is part of this particular wallet or not. Contains(account Account) bool // SignTx requests the wallet to sign the given transaction. // // It looks up the account specified either solely via its address contained within, // or optionally with the aid of any location metadata from the embedded URL field. // // If the wallet requires additional authentication to sign the request (e.g. // a password to decrypt the account, or a PIN code to verify the transaction), // an AuthNeededError instance will be returned, containing infos for the user // about which fields or actions are needed. The user may retry by providing // the needed details via SignTxWithPassphrase, or by other means (e.g. unlock // the account in a keystore). SignTx(account Account, tx *types.Transaction, networkId *big.Int) (*types.Transaction, error) }
Wallet represents a software or hardware wallet that might contain one or more accounts (derived from the same seed).