account

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Feb 19, 2019 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MAINACCOUNT      = "main-account"
	SUBACCOUNT       = "sub-account"
	KeystoreFileName = "keystore.dat"
	KeystoreVersion  = "1.0.0"

	MaxSignalQueueLen = 5
)

Variables

View Source
var IDReverse, _ = hex.DecodeString("a3d0eaa466df74983b5d7c543de6904f4c9418ead5ffd6d25814234a96db37b0")

Functions

func GetCorssChainSigners

func GetCorssChainSigners(code []byte) ([]*common.Uint160, error)

func GetSigners

func GetSigners(code []byte) ([]*common.Uint160, error)

func SignBySigner

func SignBySigner(txn *types.Transaction, acc *Account) ([]byte, error)

Types

type Account

type Account struct {
	PrivateKey  []byte
	PublicKey   *crypto.PublicKey
	ProgramHash common.Uint168
	Contract    contract.Contract
	Address     string
}

func NewAccount

func NewAccount() (*Account, error)

func NewAccountWithPrivateKey

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

func (*Account) PrivKey

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

func (*Account) PubKey

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

type AccountData

type AccountData struct {
	Address             string
	ProgramHash         string
	PrivateKeyEncrypted string
	Type                string
}

type Client

type Client interface {
	Sign(txn *types.Transaction) error

	ContainsAccount(pubKey *crypto.PublicKey) bool
	CreateAccount() (*Account, error)
	DeleteAccount(programHash common.Uint168) error
	GetAccount(pubKey *crypto.PublicKey) (*Account, error)
	GetDefaultAccount() (*Account, error)
	GetAccountByProgramHash(programHash common.Uint168) *Account
	GetAccounts() []*Account
}

type ClientImpl

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

func Create

func Create(path string, password []byte) (*ClientImpl, error)

func NewClient

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

func Open

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

func (*ClientImpl) CreateAccount

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

CreateAccount create a new Account then save it

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 *crypto.PublicKey) (*Account, error)

func (*ClientImpl) GetAccountByCodeHash

func (cl *ClientImpl) GetAccountByCodeHash(codeHash common.Uint160) *Account

func (*ClientImpl) GetAccounts

func (cl *ClientImpl) GetAccounts() []*Account

func (*ClientImpl) GetDefaultAccount

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

func (*ClientImpl) LoadAccounts

func (cl *ClientImpl) LoadAccounts() error

LoadAccounts loads all accounts from db to memory

func (*ClientImpl) ProcessSignals

func (cl *ClientImpl) ProcessSignals()

func (*ClientImpl) SaveAccount

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

SaveAccount saves a Account to memory and db

func (*ClientImpl) Sign

func (cl *ClientImpl) Sign(txn *types.Transaction) (*types.Transaction, error)

type FileData

type FileData struct {
	Version      string
	PasswordHash string
	IV           string
	MasterKey    string
	Account      []AccountData
}

type FileStore

type FileStore struct {
	// this lock could be hold by readDB, writeDB and interrupt signals.
	sync.Mutex
	// contains filtered or unexported fields
}

func (*FileStore) BuildDatabase

func (cs *FileStore) BuildDatabase(path string)

func (*FileStore) DeleteAccountData

func (cs *FileStore) DeleteAccountData(programHash string) error

func (*FileStore) LoadAccountData

func (cs *FileStore) LoadAccountData() ([]AccountData, error)

func (*FileStore) LoadStoredData

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

func (*FileStore) SaveAccountData

func (cs *FileStore) SaveAccountData(programHash []byte, encryptedPrivateKey []byte) error

func (*FileStore) SaveStoredData

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

func (*FileStore) SetPath

func (cs *FileStore) SetPath(path string)

Jump to

Keyboard shortcuts

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