Documentation ¶
Index ¶
- Constants
- Variables
- func CheckMnemonic(mnemonic string) error
- func GenerateMnemonic(bitSize int) (string, error)
- func NewErrAddressNotFound(addr string) error
- type AddressInfo
- type AddressNotFoundError
- type Vault
- func (v *Vault) AddressCount() int
- func (v *Vault) AddressFromPath(p string) *AddressInfo
- func (v *Vault) AddressInfo(addr string) *AddressInfo
- func (v *Vault) AddressInfos() []AddressInfo
- func (v *Vault) AllAccountAddresses() []AddressInfo
- func (v *Vault) AllValidatorAddresses() []AddressInfo
- func (v *Vault) Contains(addr string) bool
- func (v *Vault) ImportBLSPrivateKey(password string, prv *bls.PrivateKey) error
- func (v *Vault) ImportEd25519PrivateKey(password string, prv *ed25519.PrivateKey) error
- func (v *Vault) IsEncrypted() bool
- func (v *Vault) IsNeutered() bool
- func (v *Vault) Label(addr string) string
- func (v *Vault) Mnemonic(password string) (string, error)
- func (v *Vault) MnemonicSeed(password string) ([]byte, error)
- func (v *Vault) Neuter() *Vault
- func (v *Vault) NewBLSAccountAddress(label string) (*AddressInfo, error)
- func (v *Vault) NewEd25519AccountAddress(label, password string) (*AddressInfo, error)
- func (v *Vault) NewValidatorAddress(label string) (*AddressInfo, error)
- func (v *Vault) PrivateKeys(password string, addrs []string) ([]crypto.PrivateKey, error)
- func (v *Vault) SetLabel(addr, label string) error
- func (v *Vault) UpdatePassword(oldPassword, newPassword string, opts ...encrypter.Option) error
Constants ¶
View Source
const ( TypeFull = int(1) TypeNeutered = int(2) )
View Source
const ( PurposeBLS12381 = uint32(12381) PurposeBIP44 = uint32(44) PurposeImportPrivateKey = uint32(65535) PurposeBLS12381Hardened = PurposeBLS12381 + addresspath.HardenedKeyStart PurposeBIP44Hardened = PurposeBIP44 + addresspath.HardenedKeyStart PurposeImportPrivateKeyHardened = PurposeImportPrivateKey + addresspath.HardenedKeyStart )
Variables ¶
View Source
var ( // ErrAddressExists describes an error in which the address already exist // in wallet. ErrAddressExists = errors.New("address already exists") // ErrInvalidPath describes an error in which the key path is invalid. ErrInvalidPath = errors.New("the key path is invalid") // ErrNeutered describes an error in which the wallet is neutered. ErrNeutered = errors.New("wallet is neutered") // ErrInvalidCoinType describes an error in which the coin type is not valid. ErrInvalidCoinType = errors.New("invalid coin type") // ErrUnsupportedPurpose describes an error in which the purpose is not supported. ErrUnsupportedPurpose = errors.New("unsupported purpose") )
Functions ¶
func CheckMnemonic ¶ added in v0.13.0
CheckMnemonic validates a mnemonic (seed phrase) based on BIP-39.
func GenerateMnemonic ¶
GenerateMnemonic generates a new mnemonic (seed phrase) based on BIP-39 https://github.com/bitcoin/bips/blob/master/bip-0039.mediawiki
func NewErrAddressNotFound ¶
Types ¶
type AddressInfo ¶
type AddressNotFoundError ¶ added in v0.15.0
type AddressNotFoundError struct {
// contains filtered or unexported fields
}
AddressNotFoundError describes an error in which the address doesn't exist in wallet.
func (AddressNotFoundError) Error ¶ added in v0.15.0
func (e AddressNotFoundError) Error() string
type Vault ¶
type Vault struct { Type int `json:"type"` // Wallet type. 1: Full keys, 2: Neutered CoinType uint32 `json:"coin_type"` // Coin type: 21888 for Mainnet, 21777 for Testnet Addresses map[string]AddressInfo `json:"addresses"` // All addresses that are stored in the wallet Encrypter encrypter.Encrypter `json:"encrypter"` // Encryption algorithm KeyStore string `json:"key_store"` // KeyStore that stores the secrets and encrypts using Encrypter Purposes purposes `json:"purposes"` // Contains Purpose 12381 for BLS signature }
func CreateVaultFromMnemonic ¶
func (*Vault) AddressCount ¶
func (*Vault) AddressFromPath ¶ added in v0.18.0
func (v *Vault) AddressFromPath(p string) *AddressInfo
func (*Vault) AddressInfo ¶
func (v *Vault) AddressInfo(addr string) *AddressInfo
AddressInfo like it can return bls.PublicKey instead of string.
func (*Vault) AddressInfos ¶ added in v0.15.0
func (v *Vault) AddressInfos() []AddressInfo
func (*Vault) AllAccountAddresses ¶ added in v1.1.0
func (v *Vault) AllAccountAddresses() []AddressInfo
func (*Vault) AllValidatorAddresses ¶ added in v0.18.0
func (v *Vault) AllValidatorAddresses() []AddressInfo
func (*Vault) ImportBLSPrivateKey ¶ added in v1.5.0
func (v *Vault) ImportBLSPrivateKey(password string, prv *bls.PrivateKey) error
func (*Vault) ImportEd25519PrivateKey ¶ added in v1.6.0
func (v *Vault) ImportEd25519PrivateKey(password string, prv *ed25519.PrivateKey) error
func (*Vault) IsEncrypted ¶
func (*Vault) IsNeutered ¶
func (*Vault) MnemonicSeed ¶ added in v1.5.0
func (*Vault) NewBLSAccountAddress ¶ added in v0.15.0
func (v *Vault) NewBLSAccountAddress(label string) (*AddressInfo, error)
func (*Vault) NewEd25519AccountAddress ¶ added in v1.5.0
func (v *Vault) NewEd25519AccountAddress(label, password string) (*AddressInfo, error)
func (*Vault) NewValidatorAddress ¶ added in v0.15.0
func (v *Vault) NewValidatorAddress(label string) (*AddressInfo, error)
func (*Vault) PrivateKeys ¶ added in v0.10.0
PrivateKeys retrieves the private keys for the given addresses using the provided password.
Click to show internal directories.
Click to hide internal directories.