account

package
v0.0.0-...-640f24c Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2018 License: LGPL-3.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DEFAULT_BOOKKEEPER_COUNT = 4
	WALLET_FILENAME          = "wallet.dat"
)

Variables

This section is empty.

Functions

func ClearBytes

func ClearBytes(arr []byte, len int)

func DoubleHash

func DoubleHash(pwd []byte) []byte

func GetBookkeepers

func GetBookkeepers() []keypair.PublicKey

Types

type Account

type Account struct {
	PrivateKey keypair.PrivateKey
	PublicKey  keypair.PublicKey
	Address    common.Address
}

func NewAccount

func NewAccount(encrypt string) *Account

func NewAccountWithPrivatekey

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

func (*Account) PrivKey

func (ac *Account) PrivKey() keypair.PrivateKey

func (*Account) PubKey

func (ac *Account) PubKey() keypair.PublicKey

type Client

type Client interface {
	Sign(context *ct.ContractContext) bool
	ContainsAccount(pubKey keypair.PublicKey) bool
	GetAccount(pubKey keypair.PublicKey) (*Account, error)
	GetDefaultAccount() (*Account, error)
	GetBookkeepers() ([]keypair.PublicKey, error)
}

func GetClient

func GetClient() Client

type ClientImpl

type ClientImpl struct {
	FileStore
	// contains filtered or unexported fields
}

func Create

func Create(path string, encrypt string, passwordKey []byte) *ClientImpl

TODO: adjust contract folder structure

func NewClient

func NewClient(path string, password []byte, create bool) *ClientImpl

func Open

func Open(path string, passwordKey []byte) *ClientImpl

func (*ClientImpl) AddContract

func (cl *ClientImpl) AddContract(ct *contract.Contract) error

func (*ClientImpl) ChangePassword

func (cl *ClientImpl) ChangePassword(oldPassword []byte, newPassword []byte) bool

func (*ClientImpl) ContainsAccount

func (cl *ClientImpl) ContainsAccount(pubKey keypair.PublicKey) bool

func (*ClientImpl) CreateAccount

func (cl *ClientImpl) CreateAccount(encrypt string) (*Account, error)

func (*ClientImpl) CreateAccountByPrivateKey

func (cl *ClientImpl) CreateAccountByPrivateKey(privateKey []byte) (*Account, error)

func (*ClientImpl) DecryptPrivateKey

func (cl *ClientImpl) DecryptPrivateKey(prikey []byte) ([]byte, error)

func (*ClientImpl) EncryptPrivateKey

func (cl *ClientImpl) EncryptPrivateKey(prikey []byte) ([]byte, error)

func (*ClientImpl) GetAccount

func (cl *ClientImpl) GetAccount(pubKey keypair.PublicKey) (*Account, error)

func (*ClientImpl) GetAccountByProgramHash

func (cl *ClientImpl) GetAccountByProgramHash(programHash common.Address) *Account

func (*ClientImpl) GetBookkeepers

func (cl *ClientImpl) GetBookkeepers() ([]keypair.PublicKey, error)

func (*ClientImpl) GetContract

func (cl *ClientImpl) GetContract(programHash common.Address) *ct.Contract

func (*ClientImpl) GetDefaultAccount

func (cl *ClientImpl) GetDefaultAccount() (*Account, error)

func (*ClientImpl) LoadAccount

func (cl *ClientImpl) LoadAccount() map[common.Address]*Account

func (*ClientImpl) LoadContracts

func (cl *ClientImpl) LoadContracts() map[common.Address]*ct.Contract

func (*ClientImpl) SaveAccount

func (cl *ClientImpl) SaveAccount(ac *Account) error

func (*ClientImpl) Sign

func (cl *ClientImpl) Sign(context *ct.ContractContext) bool

type ClientStore

type ClientStore interface {
	BuildDatabase(path string)

	SaveStoredData(name string, value []byte)

	LoadStoredData(name string) []byte

	LoadAccount() map[common.Address]*Account

	LoadContracts() map[common.Address]*ct.Contract
}

type FileData

type FileData struct {
	PublicKeyHash       string
	PrivateKeyEncrypted string
	Address             string
	ScriptHash          string
	RawData             string
	PasswordHash        string
	IV                  string
	MasterKey           string
}

type FileStore

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

func (*FileStore) BuildDatabase

func (cs *FileStore) BuildDatabase(path string)

func (*FileStore) LoadAccountData

func (cs *FileStore) LoadAccountData(index int) ([]byte, []byte, error)

func (*FileStore) LoadContractData

func (cs *FileStore) LoadContractData(index int) ([]byte, []byte, []byte, error)

func (*FileStore) LoadStoredData

func (cs *FileStore) LoadStoredData(name string) ([]byte, error)

func (*FileStore) SaveAccountData

func (cs *FileStore) SaveAccountData(pubkeyhash []byte, prikeyenc []byte) error

func (*FileStore) SaveContractData

func (cs *FileStore) SaveContractData(ct *ct.Contract) error

func (*FileStore) SaveStoredData

func (cs *FileStore) SaveStoredData(name string, value []byte) error

Jump to

Keyboard shortcuts

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