vault

package
v1.1.4 Latest Latest
Warning

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

Go to latest
Published: May 5, 2024 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TypeFull     = int(1)
	TypeNeutered = int(2)
)
View Source
const (
	PurposeBLS12381         = uint32(12381)
	PurposeImportPrivateKey = uint32(65535)
)

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

func CheckMnemonic(mnemonic string) error

CheckMnemonic validates a mnemonic (seed phrase) based on BIP-39.

func GenerateMnemonic

func GenerateMnemonic(bitSize int) (string, error)

GenerateMnemonic generates a new mnemonic (seed phrase) based on BIP-39 https://github.com/bitcoin/bips/blob/master/bip-0039.mediawiki

func H added in v0.18.0

func H[T constraints.Integer](i T) uint32

H hardens the value 'i' by adding it to 0x80000000 (2^31).

func NewErrAddressNotFound

func NewErrAddressNotFound(addr string) error

Types

type AddressInfo

type AddressInfo struct {
	Address   string `json:"address"`    // Address in the wallet
	PublicKey string `json:"public_key"` // Public key associated with the address
	Label     string `json:"label"`      // Label for the address
	Path      string `json:"path"`       // Path for the address
}

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 CreateVaultFromMnemonic(mnemonic string, coinType uint32) (*Vault, error)

func (*Vault) AddressCount

func (v *Vault) AddressCount() int

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) AllImportedPrivateKeysAddresses added in v0.18.0

func (v *Vault) AllImportedPrivateKeysAddresses() []AddressInfo

func (*Vault) AllValidatorAddresses added in v0.18.0

func (v *Vault) AllValidatorAddresses() []AddressInfo

func (*Vault) Contains

func (v *Vault) Contains(addr string) bool

func (*Vault) ImportPrivateKey

func (v *Vault) ImportPrivateKey(password string, prv *bls.PrivateKey) error

func (*Vault) IsEncrypted

func (v *Vault) IsEncrypted() bool

func (*Vault) IsNeutered

func (v *Vault) IsNeutered() bool

func (*Vault) Label

func (v *Vault) Label(addr string) string

func (*Vault) Mnemonic

func (v *Vault) Mnemonic(password string) (string, error)

func (*Vault) Neuter

func (v *Vault) Neuter() *Vault

func (*Vault) NewBLSAccountAddress added in v0.15.0

func (v *Vault) NewBLSAccountAddress(label 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

func (v *Vault) PrivateKeys(password string, addrs []string) ([]crypto.PrivateKey, error)

func (*Vault) SetLabel

func (v *Vault) SetLabel(addr, label string) error

func (*Vault) SortAddressesByAddressIndex added in v0.18.0

func (v *Vault) SortAddressesByAddressIndex(addrs ...AddressInfo)

func (*Vault) SortAddressesByAddressType added in v0.18.0

func (v *Vault) SortAddressesByAddressType(addrs ...AddressInfo)

func (*Vault) SortAddressesByPurpose added in v0.18.0

func (v *Vault) SortAddressesByPurpose(addrs ...AddressInfo)

func (*Vault) UpdatePassword

func (v *Vault) UpdatePassword(oldPassword, newPassword string, opts ...encrypter.Option) error

Jump to

Keyboard shortcuts

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