account

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jul 13, 2019 License: LGPL-3.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RecipientLength    = 20
	KeyLength          = 32
	FullShardKeyLength = 4
)
View Source
const (
	DefaultKeyStoreDirectory = "./keystore/"
)

DefaultKeyStoreDirectory default keystore dir

Variables

View Source
var (
	// ErrGenIdentityKey error info : err generate identity key
	ErrGenIdentityKey = errors.New("ErrGenIdentityKey")
)

Functions

func DecodeKeyStoreJSON

func DecodeKeyStoreJSON(keystoreJSONData EncryptedKeyJSON, password string) ([]byte, error)

DecodeKeyStoreJSON decode key with password ,return plainText to create account

func IsNeighbor

func IsNeighbor(b1, b2 Branch, shardSize uint32) bool

IsNeighbor Check if the two branches are neighbor

func Uint32ToBytes

func Uint32ToBytes(n uint32) []byte

Uint32ToBytes trans uint32 num to bytes

Types

type Account

type Account struct {
	Identity   Identity
	QKCAddress Address
	ID         uuid.UUID
}

Account include Identity address and ID

func Load

func Load(path string, password string) (Account, error)

Load load a keystore file with password

func NewAccountWithKey

func NewAccountWithKey(key Key) (Account, error)

NewAccountWithKey create new account with key

func NewAccountWithoutKey

func NewAccountWithoutKey() (Account, error)

NewAccountWithoutKey new account without key,use random key

func (*Account) Address

func (Self *Account) Address() string

Address return it's real address

func (*Account) Dump

func (Self *Account) Dump(password string, includeAddress bool, write bool, directory string) ([]byte, error)

Dump dump a keystore file with it's password

func (*Account) MakeKeyStoreJSON

func (Self *Account) MakeKeyStoreJSON(password string) (EncryptedKeyJSON, error)

MakeKeyStoreJSON make encrypt Json depend on it's password

func (*Account) PrivateKey

func (Self *Account) PrivateKey() string

PrivateKey return it's key

func (*Account) UUID

func (Self *Account) UUID() uuid.UUID

UUID return it's uuid

type Address

type Address struct {
	Recipient    Recipient
	FullShardKey uint32
}

Address include recipient and fullShardKey

func CreatAddressFromBytes

func CreatAddressFromBytes(bs []byte) (Address, error)

CreatAddressFromBytes creat address from bytes

func CreatAddressFromIdentity

func CreatAddressFromIdentity(identity Identity, fullShardKey uint32) Address

CreatAddressFromIdentity creat address from identity

func CreatEmptyAddress

func CreatEmptyAddress(fullShardKey uint32) Address

CreatEmptyAddress creat empty address from fullShardKey

func CreatRandomAccountWithFullShardKey

func CreatRandomAccountWithFullShardKey(fullShardKey uint32) (Address, error)

CreatRandomAccountWithFullShardKey creat random account with fullShardKey

func CreatRandomAccountWithoutFullShardKey

func CreatRandomAccountWithoutFullShardKey() (Address, error)

CreatRandomAccountWithoutFullShardKey creat random account without fullShardKey

func NewAddress

func NewAddress(recipient Recipient, fullShardKey uint32) Address

NewAddress new address with recipient and fullShardKey

func (*Address) AddressInBranch

func (Self *Address) AddressInBranch(branch Branch) Address

AddressInBranch return address depend new branch

func (*Address) AddressInShard

func (Self *Address) AddressInShard(fullShardKey uint32) Address

AddressInShard return address depend new fullShardKey

func (*Address) GetChainID

func (self *Address) GetChainID() uint32

func (*Address) GetFullShardID

func (Self *Address) GetFullShardID(shardSize uint32) (uint32, error)

GetFullShardID get fullShardID depend shardSize

func (*Address) IsEmpty

func (Self *Address) IsEmpty() bool

IsEmpty check address is empty

func (Address) MarshalJSON

func (Self Address) MarshalJSON() (out []byte, err error)

MarshalJSON Address serialisation

func (Address) ToBytes

func (Self Address) ToBytes() []byte

func (Address) ToHex

func (Self Address) ToHex() string

ToHex return bytes included recipient and fullShardKey

func (*Address) UnmarshalJSON

func (Self *Address) UnmarshalJSON(data []byte) error

type Branch

type Branch struct {
	// TODO Value->value
	Value uint32
}

Branch branch include it's value

func CreatBranch

func CreatBranch(shardSize uint32, shardID uint32) (Branch, error)

CreatBranch create branch depend shardSize and shardID

func NewBranch

func NewBranch(value uint32) Branch

NewBranch new branch with value

func (*Branch) GetChainID

func (Self *Branch) GetChainID() uint32

GetChainID get branch's chainID

func (*Branch) GetFullShardID

func (Self *Branch) GetFullShardID() uint32

GetFullShardID get branch's fullShardId

func (*Branch) GetShardID

func (Self *Branch) GetShardID() uint32

GetShardID get branch branch's shardID

func (*Branch) GetShardSize

func (Self *Branch) GetShardSize() uint32

GetShardSize get branch's shardSize

func (*Branch) IsInBranch

func (Self *Branch) IsInBranch(fullShardKey uint32) bool

IsInBranch check shardKey is in current branch

type CoinbaseStats

type CoinbaseStats struct {
	Addr Recipient
	Cnt  uint32
}

type CoinbaseStatses

type CoinbaseStatses struct {
	CoinbaseStatsList []CoinbaseStats `json:"ReceiptCntList" gencodec:"required" bytesizeofslicelen:"4"`
}

type CryptoJSON

type CryptoJSON struct {
	Cipher       string                 `json:"cipher"`
	CipherText   string                 `json:"ciphertext"`
	CipherParams cipherParamsJSON       `json:"cipherparams"`
	KDF          string                 `json:"kdf"`
	KDFParams    map[string]interface{} `json:"kdfparams"`
	MAC          string                 `json:"mac"`
	Version      int                    `json:"version"`
}

CryptoJSON crypto data for keystore file

type EncryptedKeyJSON

type EncryptedKeyJSON struct {
	Address string     `json:"address"`
	Crypto  CryptoJSON `json:"crypto"`
	ID      string     `json:"id"`
	Version int        `json:"version"`
}

EncryptedKeyJSON keystore file included

type Identity

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

Identity include recipient and key

func CreatIdentityFromKey

func CreatIdentityFromKey(key Key) (Identity, error)

CreatIdentityFromKey creat identity from key

func CreatRandomIdentity

func CreatRandomIdentity() (Identity, error)

CreatRandomIdentity create a random identity

func NewIdentity

func NewIdentity(recipient Recipient, key Key) Identity

NewIdentity new identity include recipient and key

func (*Identity) GetDefaultFullShardKey

func (Self *Identity) GetDefaultFullShardKey() (uint32, error)

GetDefaultFullShardKey get identity's default fullShardKey

func (*Identity) GetKey

func (Self *Identity) GetKey() Key

GetKey get it's key

func (*Identity) GetRecipient

func (Self *Identity) GetRecipient() Recipient

GetRecipient Get it's recipient

type Key

type Key [KeyLength]byte

Key key type

func BytesToIdentityKey

func BytesToIdentityKey(b []byte) Key

BytesToIdentityKey trans bytes to Key

func (Key) Bytes

func (a Key) Bytes() []byte

Bytes return it's bytes

func (*Key) SetBytes

func (a *Key) SetBytes(b []byte)

SetBytes set bytes to it's value

type Recipient

type Recipient = common.Address

Recipient recipient type

func BytesToIdentityRecipient

func BytesToIdentityRecipient(b []byte) Recipient

BytesToIdentityRecipient trans bytes to Recipient

func PublicKeyToRecipient

func PublicKeyToRecipient(p ecdsa.PublicKey) Recipient

PublicKeyToRecipient publicKey to recipient

type UnprefixedAddress

type UnprefixedAddress Address

func (UnprefixedAddress) Address

func (Self UnprefixedAddress) Address() Address

func (UnprefixedAddress) MarshalText

func (Self UnprefixedAddress) MarshalText() (out []byte, err error)

MarshalJSON Address serialisation

func (*UnprefixedAddress) UnmarshalText

func (Self *UnprefixedAddress) UnmarshalText(dataWithout0x []byte) error

Jump to

Keyboard shortcuts

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