account

package
v0.3.5 Latest Latest
Warning

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

Go to latest
Published: Aug 1, 2019 License: MIT Imports: 20 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
	RedeemScript []byte
	Address      string
}

A ELA standard account is a set of private key, public key, redeem script, program hash and address data. redeem script is (script content length)+(script content)+(script type), program hash is the sha256 value of redeem script and converted to ripemd160 format with a (Type) prefix. address is the base58 format of program hash, which is the string value show up on user interface as account address. With account, you can get the transfer address or sign transaction etc.

func AddMultiSig added in v0.3.0

func AddMultiSig(path string, password []byte, m int, pubKeys []*crypto.PublicKey) (*Account, error)

func NewAccount

func NewAccount() (*Account, error)

Create an account instance with private key and public key

func NewAccountWithPrivateKey

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

func NewMultiSigAccount added in v0.3.0

func NewMultiSigAccount(m int, pubKeys []*crypto.PublicKey) (*Account, error)

func (*Account) PrivKey

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

Get account private key

func (*Account) PubKey

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

Get account public key

func (*Account) Sign added in v0.3.0

func (ac *Account) Sign(data []byte) ([]byte, error)

Sign data with account

type AccountData

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

func GetWalletAccountData added in v0.3.0

func GetWalletAccountData(walletPath string) ([]AccountData, error)

func GetWalletMainAccountData added in v0.3.0

func GetWalletMainAccountData(walletPath string) (*AccountData, error)

type Client

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

func Add added in v0.3.0

func Add(path string, password []byte) (*Client, error)

func Create

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

func NewClient

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

func Open

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

func (*Client) CreateAccount

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

CreateAccount create a new Account then save it

func (*Client) CreateMultiSigAccount added in v0.3.0

func (cl *Client) CreateMultiSigAccount(m int, pubKeys []*crypto.PublicKey) (*Account, error)

func (*Client) DecryptPrivateKey added in v0.3.0

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

func (*Client) EncryptPrivateKey added in v0.3.0

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

func (*Client) GetAccount

func (cl *Client) GetAccount(pubKey *crypto.PublicKey) (*Account, error)

func (*Client) GetAccountByCodeHash added in v0.3.0

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

func (*Client) GetAccounts

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

func (*Client) GetMainAccount added in v0.3.0

func (cl *Client) GetMainAccount() *Account

func (*Client) HandleInterrupt added in v0.3.0

func (cl *Client) HandleInterrupt()

func (*Client) LoadAccounts added in v0.3.0

func (cl *Client) LoadAccounts() error

LoadAccounts loads all accounts from db to memory

func (*Client) SaveAccount added in v0.3.0

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

SaveAccount saves a Account to memory and db

func (*Client) Sign

func (cl *Client) 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, redeemScript []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