account

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jun 30, 2018 License: LGPL-3.0 Imports: 20 Imported by: 92

Documentation

Index

Constants

View Source
const (
	SCHEME = "did"
	METHOD = "ont"
	VER    = 0x41
)

Variables

This section is empty.

Functions

func CreateID added in v0.9.2

func CreateID(nonce []byte) (string, error)

func GenerateID added in v0.9.2

func GenerateID() (string, error)

func VerifyID added in v0.9.2

func VerifyID(id string) bool

Types

type Account

type Account struct {
	PrivateKey keypair.PrivateKey
	PublicKey  keypair.PublicKey
	Address    common.Address
	SigScheme  s.SignatureScheme
}

crypto object

func NewAccount

func NewAccount(encrypt string) *Account

func (*Account) PrivKey

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

func (*Account) PubKey

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

func (*Account) Scheme

func (this *Account) Scheme() s.SignatureScheme

type AccountData

type AccountData struct {
	keypair.ProtectedKey

	Label     string `json:"label"`
	PubKey    string `json:"publicKey"`
	SigSch    string `json:"signatureScheme"`
	IsDefault bool   `json:"isDefault"`
	Lock      bool   `json:"lock"`
}

* AccountData - for wallet read and save, no crypto object included *

func (*AccountData) GetKeyPair

func (this *AccountData) GetKeyPair() *keypair.ProtectedKey

func (*AccountData) SetKeyPair

func (this *AccountData) SetKeyPair(keyinfo *keypair.ProtectedKey)

func (*AccountData) SetLabel

func (this *AccountData) SetLabel(label string)

type AccountMetadata

type AccountMetadata struct {
	IsDefault bool   //Is default account
	Label     string //Lable of account
	KeyType   string //KeyType ECDSA,SM2 or EDDSA
	Curve     string //Curve of key type
	Address   string //Address(base58) of account
	PubKey    string //Public  key
	SigSch    string //Signature scheme
	Salt      []byte //Salt
	Key       []byte //PrivateKey in encrypted
	EncAlg    string //Encrypt alg of private key
	Hash      string //Hash alg
}

AccountMetadata all account info without private key

type Client

type Client interface {
	//NewAccount create a new account.
	NewAccount(label string, typeCode keypair.KeyType, curveCode byte, sigScheme s.SignatureScheme, passwd []byte) (*Account, error)
	//ImportAccount import a already exist account to wallet
	ImportAccount(accMeta *AccountMetadata) error
	//GetAccountByAddress return account object by address
	GetAccountByAddress(address string, passwd []byte) (*Account, error)
	//GetAccountByLabel return account object by label
	GetAccountByLabel(label string, passwd []byte) (*Account, error)
	//GetAccountByIndex return account object by index. Index start from 1
	GetAccountByIndex(index int, passwd []byte) (*Account, error)
	//GetDefaultAccount return default account
	GetDefaultAccount(passwd []byte) (*Account, error)
	//GetAccountMetadataByIndex return account Metadata info by address
	GetAccountMetadataByAddress(address string) *AccountMetadata
	//GetAccountMetadataByLabel return account Metadata info by label
	GetAccountMetadataByLabel(label string) *AccountMetadata
	//GetAccountMetadataByIndex return account Metadata info by index. Index start from 1
	GetAccountMetadataByIndex(index int) *AccountMetadata
	//GetDefaultAccountMetadata return default account Metadata info
	GetDefaultAccountMetadata() *AccountMetadata
	//GetAccountNum return total account number
	GetAccountNum() int
	//DeleteAccount delete account
	DeleteAccount(address string, passwd []byte) (*Account, error)
	//UnLockAccount can get account without password in expire time
	UnLockAccount(address string, expiredAt int, passwd []byte) error
	//LockAccount lock unlock account
	LockAccount(address string)
	//GetUnlockAccount return account which was unlock and in expired time
	GetUnlockAccount(address string) *Account
	//Set a new account to default account
	SetDefaultAccount(address string, passwd []byte) error
	//Set a new label to accont
	SetLabel(address, label string, passwd []byte) error
	//Change pasword to account
	ChangePassword(address string, oldPasswd, newPasswd []byte) error
	//Change sig scheme to account
	ChangeSigScheme(address string, sigScheme s.SignatureScheme, passwd []byte) error
	//Get the underlying wallet data
	GetWalletData() *WalletData
}

Client of wallet

func Open

func Open(path string) (Client, error)

type ClientImpl

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

func NewClientImpl

func NewClientImpl(path string) (*ClientImpl, error)

func (*ClientImpl) ChangePassword

func (this *ClientImpl) ChangePassword(address string, oldPasswd, newPasswd []byte) error

func (*ClientImpl) ChangeSigScheme

func (this *ClientImpl) ChangeSigScheme(address string, sigScheme s.SignatureScheme, passwd []byte) error

func (*ClientImpl) DeleteAccount

func (this *ClientImpl) DeleteAccount(address string, passwd []byte) (*Account, error)

func (*ClientImpl) GetAccountByAddress

func (this *ClientImpl) GetAccountByAddress(address string, passwd []byte) (*Account, error)

func (*ClientImpl) GetAccountByIndex

func (this *ClientImpl) GetAccountByIndex(index int, passwd []byte) (*Account, error)

Index start from 1

func (*ClientImpl) GetAccountByLabel

func (this *ClientImpl) GetAccountByLabel(label string, passwd []byte) (*Account, error)

func (*ClientImpl) GetAccountMetadataByAddress

func (this *ClientImpl) GetAccountMetadataByAddress(address string) *AccountMetadata

func (*ClientImpl) GetAccountMetadataByIndex

func (this *ClientImpl) GetAccountMetadataByIndex(index int) *AccountMetadata

Index start from 1

func (*ClientImpl) GetAccountMetadataByLabel

func (this *ClientImpl) GetAccountMetadataByLabel(label string) *AccountMetadata

func (*ClientImpl) GetAccountNum

func (this *ClientImpl) GetAccountNum() int

func (*ClientImpl) GetDefaultAccount

func (this *ClientImpl) GetDefaultAccount(passwd []byte) (*Account, error)

func (*ClientImpl) GetDefaultAccountMetadata

func (this *ClientImpl) GetDefaultAccountMetadata() *AccountMetadata

func (*ClientImpl) GetUnlockAccount

func (this *ClientImpl) GetUnlockAccount(address string) *Account

func (*ClientImpl) GetWalletData

func (this *ClientImpl) GetWalletData() *WalletData

func (*ClientImpl) ImportAccount

func (this *ClientImpl) ImportAccount(accMeta *AccountMetadata) error

func (*ClientImpl) LockAccount

func (this *ClientImpl) LockAccount(address string)

func (*ClientImpl) NewAccount

func (this *ClientImpl) NewAccount(label string, typeCode keypair.KeyType, curveCode byte, sigScheme s.SignatureScheme, passwd []byte) (*Account, error)

func (*ClientImpl) SetDefaultAccount

func (this *ClientImpl) SetDefaultAccount(address string, passwd []byte) error

func (*ClientImpl) SetLabel

func (this *ClientImpl) SetLabel(address, label string, passwd []byte) error

func (*ClientImpl) UnLockAccount

func (this *ClientImpl) UnLockAccount(address string, expiredAt int, passwd []byte) error

type ClientStore

type ClientStore interface {
	BuildDatabase(path string)

	SaveStoredData(name string, value []byte)

	LoadStoredData(name string) []byte

	LoadAccount() map[common.Address]*Account
}

type Controller added in v0.9.2

type Controller struct {
	ID     string `json:"id"`
	Public string `json:"publicKey,omitemtpy"`
	keypair.ProtectedKey
}

type Identity

type Identity struct {
	ID      string       `json:"ontid"`
	Label   string       `json:"label,omitempty"`
	Lock    bool         `json:"lock"`
	Control []Controller `json:"controls,omitempty"`
	Extra   interface{}  `json:"extra,omitempty"`
}

func NewIdentity added in v0.9.2

func NewIdentity(label string, keyType keypair.KeyType, param interface{}, password []byte) (*Identity, error)

type WalletData

type WalletData struct {
	Name       string               `json:"name"`
	Version    string               `json:"version"`
	Scrypt     *keypair.ScryptParam `json:"scrypt"`
	Identities []Identity           `json:"identities,omitempty"`
	Accounts   []*AccountData       `json:"accounts,omitempty"`
	Extra      string               `json:"extra,omitempty"`
}

func NewWalletData

func NewWalletData() *WalletData

func (*WalletData) AddAccount

func (this *WalletData) AddAccount(acc *AccountData)

func (*WalletData) AddIdentity added in v0.9.2

func (this *WalletData) AddIdentity(id *Identity)

func (*WalletData) Clone

func (this *WalletData) Clone() *WalletData

func (*WalletData) DelAccount

func (this *WalletData) DelAccount(address string)

func (*WalletData) GetAccountByAddress

func (this *WalletData) GetAccountByAddress(address string) (*AccountData, int)

func (*WalletData) GetAccountByIndex

func (this *WalletData) GetAccountByIndex(index int) *AccountData

func (*WalletData) Load

func (this *WalletData) Load(path string) error

func (*WalletData) Save

func (this *WalletData) Save(path string) error

func (*WalletData) ToDefaultSecurity

func (this *WalletData) ToDefaultSecurity(passwords [][]byte) error

func (*WalletData) ToLowSecurity

func (this *WalletData) ToLowSecurity(passwords [][]byte) error

Jump to

Keyboard shortcuts

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