vault

package
v0.0.0-...-0c41aae Latest Latest
Warning

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

Go to latest
Published: Dec 14, 2020 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	WalletIVLength             = 16
	WalletMasterKeyLength      = 32
	WalletVersion              = 1
	MinCompatibleWalletVersion = 1
	MaxCompatibleWalletVersion = 1
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Account

type Account struct {
	PrivateKey  []byte
	PublicKey   *crypto.PubKey
	ProgramHash Uint160
}

func NewAccount

func NewAccount() (*Account, error)

func NewAccountWithPrivatekey

func NewAccountWithPrivatekey(privateKey []byte) (*Account, error)

func (*Account) PrivKey

func (a *Account) PrivKey() []byte

func (*Account) PubKey

func (a *Account) PubKey() *crypto.PubKey

type AccountData

type AccountData struct {
	Address       string
	ProgramHash   string
	SeedEncrypted string
	ContractData  string
}

type HeaderData

type HeaderData struct {
	PasswordHash string
	IV           string
	MasterKey    string
	Version      int
}

type Wallet

type Wallet interface {
	Sign(txn *transaction.Transaction) error
	GetAccount(pubKey *crypto.PubKey) (*Account, error)
	GetDefaultAccount() (*Account, error)
}

func GetWallet

func GetWallet() (Wallet, error)

type WalletData

type WalletData struct {
	HeaderData
	AccountData
}

type WalletImpl

type WalletImpl struct {
	*WalletStore
	// contains filtered or unexported fields
}

func NewWallet

func NewWallet(path string, password []byte, needAccount bool) (*WalletImpl, error)

func OpenWallet

func OpenWallet(path string, password []byte) (*WalletImpl, error)

func RecoverWallet

func RecoverWallet(path string, password []byte, seedHex string) (*WalletImpl, error)

func (*WalletImpl) ChangePassword

func (w *WalletImpl) ChangePassword(oldPassword []byte, newPassword []byte) bool

func (*WalletImpl) CreateAccount

func (w *WalletImpl) CreateAccount(seed []byte) error

func (*WalletImpl) GetAccount

func (w *WalletImpl) GetAccount(pubKey *crypto.PubKey) (*Account, error)

func (*WalletImpl) GetContract

func (w *WalletImpl) GetContract() (*program.ProgramContext, error)

func (*WalletImpl) GetDefaultAccount

func (w *WalletImpl) GetDefaultAccount() (*Account, error)

func (*WalletImpl) Sign

func (w *WalletImpl) Sign(txn *transaction.Transaction) error

type WalletStore

type WalletStore struct {
	sync.RWMutex

	Path string
	Data WalletData
}

func LoadStore

func LoadStore(fullPath string) (*WalletStore, error)

func NewStore

func NewStore(fullPath string) (*WalletStore, error)

func (*WalletStore) SaveAccountData

func (s *WalletStore) SaveAccountData(programHash []byte, encryptedSeed []byte, contract []byte) error

func (*WalletStore) SaveBasicData

func (s *WalletStore) SaveBasicData(version int, iv, masterKey, passwordHash []byte) error

Jump to

Keyboard shortcuts

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