vault

package
v0.3.6-alpha Latest Latest
Warning

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

Go to latest
Published: Sep 13, 2018 License: Apache-2.0 Imports: 23 Imported by: 33

Documentation

Index

Constants

View Source
const (
	WalletIVLength        = 16
	WalletMasterKeyLength = 32
	WalletFileName        = "wallet.dat"
)
View Source
const (
	WalletStoreVersion = "0.0.1"
)

Variables

This section is empty.

Functions

func GetBookKeepers

func GetBookKeepers(account *Account) []*crypto.PubKey

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
	PrivateKeyEncrypted string
	ContractData        string
}

type HeaderData

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

type VaultStore

type VaultStore interface {
	GetUnspentsFromProgramHash(programHash Uint160) (map[Uint256][]*transaction.UTXOUnspent, error)
}
var Store VaultStore

type Wallet

type Wallet interface {
	Sign(context *ct.ContractContext) error
	GetAccount(pubKey *crypto.PubKey) (*Account, error)
	GetDefaultAccount() (*Account, error)
	GetUnspent() (map[Uint256][]*transaction.UTXOUnspent, error)
}

func GetWallet

func GetWallet() Wallet

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, privateKeyHex string) (*WalletImpl, error)

func (*WalletImpl) ChangePassword

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

func (*WalletImpl) CreateAccount

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

func (*WalletImpl) GetAccount

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

func (*WalletImpl) GetContract

func (w *WalletImpl) GetContract() (*ct.Contract, error)

func (*WalletImpl) GetDefaultAccount

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

func (*WalletImpl) GetUnspent

func (w *WalletImpl) GetUnspent() (map[Uint256][]*transaction.UTXOUnspent, error)

func (*WalletImpl) Sign

func (w *WalletImpl) Sign(context *ct.ContractContext) 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, encryptedPrivateKey []byte, contract []byte) error

func (*WalletStore) SaveBasicData

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

Jump to

Keyboard shortcuts

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