accounts

package
v0.11.0 Latest Latest
Warning

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

Go to latest
Published: Aug 28, 2019 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Account

type Account struct {
	Type chain.Type `json:"type"`
	Name string     `json:"name"`

	PublicKey  *keys.PublicKey  `json:"publicKey"`
	PrivateKey *keys.PrivateKey `json:"privateKey"`
}

func GenerateNewAccount added in v0.10.8

func GenerateNewAccount(t chain.Type, name string) (Account, error)

func NewAccount

func NewAccount(t chain.Type, name string, privkey *keys.PrivateKey, pubkey *keys.PublicKey) (Account, error)

todo: if we create the privkey out side of server(eg: in client), this function failed to store the account privkey properly because the PrivateKey's field is private that cannot be serialized. need to be fixed.

func (Account) Address

func (acc Account) Address() keys.Address

func (Account) Bytes

func (acc Account) Bytes() []byte

func (*Account) Data

func (t *Account) Data() serialize.Data

func (*Account) FromBytes

func (acc *Account) FromBytes(msg []byte) *Account

func (*Account) NewDataInstance

func (t *Account) NewDataInstance() serialize.Data

func (*Account) SetData

func (t *Account) SetData(a interface{}) error

func (Account) Sign

func (acc Account) Sign(msg []byte) ([]byte, error)

func (Account) String

func (acc Account) String() string

type AccountData

type AccountData struct {
	Type chain.Type
	Name string

	PublicKeyData  []byte
	PrivateKeyData []byte
}

func (*AccountData) SerialTag

func (ad *AccountData) SerialTag() string

type Wallet

type Wallet interface {
	//returns the account that the wallet holds
	Accounts() []Account

	Add(Account) error

	Delete(Account) error

	GetAccount(address keys.Address) (Account, error)

	SignWithAccountIndex([]byte, int) (keys.PublicKey, []byte, error)

	SignWithAddress([]byte, keys.Address) (keys.PublicKey, []byte, error)

	Close()
}

func NewWallet

func NewWallet(config config.Server, dbDir string) Wallet

type WalletStore

type WalletStore struct {
	sync.Mutex
	// contains filtered or unexported fields
}

WalletStore keeps a session storage of accounts on the Full Node

func (WalletStore) Accounts

func (ws WalletStore) Accounts() []Account

Accounts returns all the accounts in the wallet store

func (*WalletStore) Add

func (ws *WalletStore) Add(account Account) error

func (WalletStore) Close

func (ws WalletStore) Close()

func (*WalletStore) Delete

func (ws *WalletStore) Delete(account Account) error

func (WalletStore) GetAccount

func (ws WalletStore) GetAccount(address keys.Address) (Account, error)

func (WalletStore) SignWithAccountIndex

func (ws WalletStore) SignWithAccountIndex(msg []byte, index int) (keys.PublicKey, []byte, error)

func (WalletStore) SignWithAddress

func (ws WalletStore) SignWithAddress(msg []byte, address keys.Address) (keys.PublicKey, []byte, error)

Jump to

Keyboard shortcuts

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