Documentation ¶
Index ¶
- Constants
- Variables
- func DecodeKeyStoreJSON(keystoreJSONData EncryptedKeyJSON, password string) ([]byte, error)
- func IsNeighbor(b1, b2 Branch, shardSize uint32) bool
- func Uint32ToBytes(n uint32) []byte
- type Account
- func (Self *Account) Address() string
- func (Self *Account) Dump(password string, includeAddress bool, write bool, directory string) ([]byte, error)
- func (Self *Account) MakeKeyStoreJSON(password string) (EncryptedKeyJSON, error)
- func (Self *Account) PrivateKey() string
- func (Self *Account) UUID() uuid.UUID
- type Address
- func CreatAddressFromBytes(bs []byte) (Address, error)
- func CreatAddressFromIdentity(identity Identity, fullShardKey uint32) Address
- func CreatEmptyAddress(fullShardKey uint32) Address
- func CreatRandomAccountWithFullShardKey(fullShardKey uint32) (Address, error)
- func CreatRandomAccountWithoutFullShardKey() (Address, error)
- func NewAddress(recipient Recipient, fullShardKey uint32) Address
- func (Self *Address) AddressInBranch(branch Branch) Address
- func (Self *Address) AddressInShard(fullShardKey uint32) Address
- func (self *Address) GetChainID() uint32
- func (Self *Address) GetFullShardID(shardSize uint32) (uint32, error)
- func (Self *Address) IsEmpty() bool
- func (Self Address) MarshalJSON() (out []byte, err error)
- func (Self Address) ToBytes() []byte
- func (Self Address) ToHex() string
- func (Self *Address) UnmarshalJSON(data []byte) error
- type Branch
- type CoinbaseStats
- type CoinbaseStatses
- type CryptoJSON
- type EncryptedKeyJSON
- type Identity
- type Key
- type Recipient
- type UnprefixedAddress
Constants ¶
const ( RecipientLength = 20 KeyLength = 32 FullShardKeyLength = 4 )
const (
DefaultKeyStoreDirectory = "./keystore/"
)
DefaultKeyStoreDirectory default keystore dir
Variables ¶
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 ¶
IsNeighbor Check if the two branches are neighbor
Types ¶
type Account ¶
Account include Identity address and ID
func NewAccountWithKey ¶
NewAccountWithKey create new account with key
func NewAccountWithoutKey ¶
NewAccountWithoutKey new account without key,use random key
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
type Address ¶
Address include recipient and fullShardKey
func CreatAddressFromBytes ¶
CreatAddressFromBytes creat address from bytes
func CreatAddressFromIdentity ¶
CreatAddressFromIdentity creat address from identity
func CreatEmptyAddress ¶
CreatEmptyAddress creat empty address from fullShardKey
func CreatRandomAccountWithFullShardKey ¶
CreatRandomAccountWithFullShardKey creat random account with fullShardKey
func CreatRandomAccountWithoutFullShardKey ¶
CreatRandomAccountWithoutFullShardKey creat random account without fullShardKey
func NewAddress ¶
NewAddress new address with recipient and fullShardKey
func (*Address) AddressInBranch ¶
AddressInBranch return address depend new branch
func (*Address) AddressInShard ¶
AddressInShard return address depend new fullShardKey
func (*Address) GetChainID ¶
func (*Address) GetFullShardID ¶
GetFullShardID get fullShardID depend shardSize
func (Address) MarshalJSON ¶
MarshalJSON Address serialisation
func (*Address) UnmarshalJSON ¶
type Branch ¶
type Branch struct { // TODO Value->value Value uint32 }
Branch branch include it's value
func CreatBranch ¶
CreatBranch create branch depend shardSize and shardID
func (*Branch) GetFullShardID ¶
GetFullShardID get branch's fullShardId
func (*Branch) GetShardID ¶
GetShardID get branch branch's shardID
func (*Branch) GetShardSize ¶
GetShardSize get branch's shardSize
func (*Branch) IsInBranch ¶
IsInBranch check shardKey is in current branch
type CoinbaseStats ¶
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 ¶
CreatIdentityFromKey creat identity from key
func CreatRandomIdentity ¶
CreatRandomIdentity create a random identity
func NewIdentity ¶
NewIdentity new identity include recipient and key
func (*Identity) GetDefaultFullShardKey ¶
GetDefaultFullShardKey get identity's default fullShardKey
func (*Identity) GetRecipient ¶
GetRecipient Get it's recipient
type Recipient ¶
Recipient recipient type
func BytesToIdentityRecipient ¶
BytesToIdentityRecipient trans bytes to Recipient
func PublicKeyToRecipient ¶
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