wallet

package
v1.0.4 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2019 License: MIT Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PasswordLength    int   = 32
	ExpirationSeconds int64 = 5 * 60 * 60 * 24 * 30
)

Variables

View Source
var DefaultRootDerivationPath = DerivationPath{0x80000000 + 44, 0x80000000 + 3077, 0x80000000 + 0, 0, 0}

Functions

func DecryptData

func DecryptData(cipherdata, passphrase, iv []byte) ([]byte, error)

func EncryptData

func EncryptData(data, passphrase []byte) ([]byte, []byte, error)

func GenerateKeyPairFromMnemonic added in v1.0.2

func GenerateKeyPairFromMnemonic(mnemonic string, hdPath string) (string, string, error)

Types

type Account

type Account struct {
	Name   string
	PubKey string
}

type AccountNotFound

type AccountNotFound struct {
	LocalName string
}

func (AccountNotFound) Error

func (e AccountNotFound) Error() string

type BaseHDWallet added in v1.0.2

type BaseHDWallet struct {
	BaseWallet
	// contains filtered or unexported fields
}

func NewBaseHDWallet added in v1.0.2

func NewBaseHDWallet(name string, path string) *BaseHDWallet

func (*BaseHDWallet) GenerateFromMnemonic added in v1.0.2

func (w *BaseHDWallet) GenerateFromMnemonic(mnemonic string) (string, string, error)

func (*BaseHDWallet) GenerateNewMnemonic added in v1.0.2

func (w *BaseHDWallet) GenerateNewMnemonic() (string, error)

type BaseWallet

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

func NewBaseWallet

func NewBaseWallet(name string, path string) *BaseWallet

func (*BaseWallet) Close

func (w *BaseWallet) Close()

func (*BaseWallet) Create

func (w *BaseWallet) Create(name, passphrase, pubKeyStr, privKeyStr string) error

func (*BaseWallet) GenerateNewKey

func (w *BaseWallet) GenerateNewKey() (string, string, error)

func (*BaseWallet) GetUnlockedAccount

func (w *BaseWallet) GetUnlockedAccount(name string) (*PrivAccount, bool)

func (*BaseWallet) Info

func (w *BaseWallet) Info(name string) string

func (*BaseWallet) IsExist

func (w *BaseWallet) IsExist(name string) bool

func (*BaseWallet) IsLocked

func (w *BaseWallet) IsLocked(name string) bool

func (*BaseWallet) List

func (w *BaseWallet) List() []string

func (*BaseWallet) Load

func (w *BaseWallet) Load(name string) error

name should not be a path todo: check name

func (*BaseWallet) LoadAll

func (w *BaseWallet) LoadAll() error

func (*BaseWallet) Lock

func (w *BaseWallet) Lock(name string) error

w.locked hold all EncryptAccount and never modifies its content except add new account when unlock, a account being decrypted and added into unlock map

func (*BaseWallet) Name

func (w *BaseWallet) Name() string

func (*BaseWallet) Path

func (w *BaseWallet) Path() string

func (*BaseWallet) Start

func (w *BaseWallet) Start() error

func (*BaseWallet) Unlock

func (w *BaseWallet) Unlock(name, passphrase string) error

type DerivationPath added in v1.0.2

type DerivationPath []uint32

func ParseDerivationPath added in v1.0.2

func ParseDerivationPath(path string) (DerivationPath, error)

func (DerivationPath) String added in v1.0.2

func (path DerivationPath) String() string

String implements the stringer interface, converting a binary derivation path to its canonical representation.

type EncryptAccount

type EncryptAccount struct {
	Account
	Cipher     string // a cipher algorithm from aes
	CipherText string // encrypted privkey
	Iv         string // the iv
	Mac        string // the mac of passphrase
	Version    uint8  // version of format
}

type HDWallet added in v1.0.2

type HDWallet interface {
	Wallet

	GenerateNewMnemonic() (string, error)

	GenerateFromMnemonic(mnemonic string) (string, string, error)
}

type PrivAccount

type PrivAccount struct {
	Account
	PrivKey string
	Expire  int64
}

type ReentrantUnlockedAccountError

type ReentrantUnlockedAccountError struct {
	Name string
}

func (*ReentrantUnlockedAccountError) Error

type UnknownLockedAccountError

type UnknownLockedAccountError struct {
	Name string
}

func (*UnknownLockedAccountError) Error

func (e *UnknownLockedAccountError) Error() string

type UnmatchedPassphraseError

type UnmatchedPassphraseError struct {
}

func (UnmatchedPassphraseError) Error

func (e UnmatchedPassphraseError) Error() string

type Wallet

type Wallet interface {
	Name() string

	Path() string

	GenerateNewKey() (string, string, error) // return pubKey, privKey, error

	Create(name, passphrase, pubKeyStr, privKeyStr string) error

	GetUnlockedAccount(name string) (*PrivAccount, bool)

	Load(name string) error

	Lock(name string) error

	Unlock(name, passphrase string) error

	List() []string

	Info(name string) string

	Close()

	IsLocked(name string) bool

	IsExist(name string) bool
}

Directories

Path Synopsis
Package mock_wallet is a generated GoMock package.
Package mock_wallet is a generated GoMock package.

Jump to

Keyboard shortcuts

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