accounts

package
v0.0.0-...-5fb9e85 Latest Latest
Warning

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

Go to latest
Published: Jan 1, 2022 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package accounts

@author: xwc1125

Package accounts

@author: xwc1125

Index

Constants

View Source
const (
	ContractDomain = "chain5j.contract" // 合约域
	DomainLinkFlag = "@"                // 域连接符
	CodeHashKey    = "code_hash"        // codeHash的键
	RootKey        = "root_hash"        // root的键
	PartnerKey     = "partner"          // 配偶的键
	LostKey        = "lost"             // 丢失的键
)

Variables

View Source
var (
	ErrFormatAddrNotExist = "address not exists: addr=%s"
)

Functions

func DecodeAccountOpData

func DecodeAccountOpData(input []byte, data *AccountOpData) error

DecodeAccountOpData 从交易input中解析出操作处理对象

Types

type AccountMap

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

AccountMap 地址到账户名称的映射

type AccountOp

type AccountOp uint
const (
	RegisterAccountOp      AccountOp = iota // 注册账户操作
	FrozenAccountOp                         // 冻结账户操作
	UpdateDataPermissionOp                  // 更新权限操作
	RegisterDomainOp                        // 注册域操作
	SetPartnerOp                            // 设置伙伴操作
	LostRequestOp                           // 丢失请求操作
	FoundRequestOp                          // 找回请求操作
	LostResetOp                             // 丢失重置操作
)

type AccountOpData

type AccountOpData struct {
	Operation AccountOp // 操作类型
	Data      []byte    // 具体操作内容
}

AccountOpData 账户操作处理的对象

type AccountStore

type AccountStore struct {
	Nonce     uint64                          `json:"nonce,omitempty"`     // nonce,只要账户信息被修改,此值就得修改
	Balance   *big.Int                        `json:"balance,omitempty"`   // balance
	Addresses map[types.Address]*AddressStore `json:"addresses,omitempty"` // 地址集合

	CN     string `json:"cn"`     // 用户名称 common name,不带域的
	Domain string `json:"domain"` // 所在域

	IsAdmin              bool         `json:"is_admin,omitempty"`               // 是否为管理员
	IsFrozen             bool         `json:"is_frozen,omitempty"`              // 账户是否被冻结
	EnableDeployContract bool         `json:"enable_deploy_contract,omitempty"` // 是否允许部署合约
	Permissions          *Permissions `json:"permissions,omitempty" rlp:"nil"`  // 管理员权限

	XXX map[string][]byte `json:"xxx,omitempty" rlp:"nil"` // 扩展字段
}

AccountStore 账户存储

func NewAccountStore

func NewAccountStore(cn, domain string) *AccountStore

func (*AccountStore) AccountName

func (store *AccountStore) AccountName() string

AccountName 账户名称

func (*AccountStore) AuthorizedRegisterDomain

func (store *AccountStore) AuthorizedRegisterDomain() bool

AuthorizedRegisterDomain 注册域的权限是否已授予

func (*AccountStore) AuthorizedRegisterUser

func (store *AccountStore) AuthorizedRegisterUser() bool

AuthorizedRegisterUser 注册用户的权限是否已授予

func (*AccountStore) CodeHash

func (store *AccountStore) CodeHash() []byte

CodeHash 获取codeHash

func (*AccountStore) ContainAddress

func (store *AccountStore) ContainAddress(address types.Address) bool

ContainAddress 账户是否存在指定地址

func (*AccountStore) Copy

func (store *AccountStore) Copy() *AccountStore

func (*AccountStore) DecodeRLP

func (store *AccountStore) DecodeRLP(s *rlp.Stream) error

func (*AccountStore) EncodeRLP

func (store *AccountStore) EncodeRLP(w io.Writer) error

func (*AccountStore) GetAddressStore

func (store *AccountStore) GetAddressStore(address types.Address) (*AddressStore, error)

GetAddressStore 根据地址获取地址集

func (*AccountStore) IsContract

func (store *AccountStore) IsContract() bool

IsContract 判断账户是否为合约地址

func (*AccountStore) MarshalJSON

func (store *AccountStore) MarshalJSON() ([]byte, error)

func (*AccountStore) Normalize

func (store *AccountStore) Normalize()

Normalize CN 和 domain 转化为小写

func (*AccountStore) Partner

func (store *AccountStore) Partner() string

Partner 获取配偶地址

func (*AccountStore) SetAddress

func (store *AccountStore) SetAddress(addr types.Address, addrStore *AddressStore)

SetAddress 设置地址集

func (*AccountStore) SetCodeHash

func (store *AccountStore) SetCodeHash(hash []byte)

SetCodeHash 设置codeHash

func (*AccountStore) SetPartner

func (store *AccountStore) SetPartner(cn, domain string)

SetPartner 设置配偶[用于密码丢失找回]

func (*AccountStore) SetStorageRoot

func (store *AccountStore) SetStorageRoot(hash types.Hash)

SetStorageRoot 设置存储的rootHash

func (*AccountStore) StorageRoot

func (store *AccountStore) StorageRoot() types.Hash

StorageRoot 获取存储的rootHash

type AddressStore

type AddressStore struct {
	KVS map[string][]byte `json:"kvs,omitempty" rlp:"nil"`
}

AddressStore 账户下的地址属性

func (*AddressStore) DecodeRLP

func (store *AddressStore) DecodeRLP(s *rlp.Stream) error

func (*AddressStore) EncodeRLP

func (store *AddressStore) EncodeRLP(w io.Writer) error

type DomainStore

type DomainStore struct {
	Admin  string `json:"admin"`  // 管理员名称、不包含域
	Number uint64 `json:"number"` // 域生成时所在区块
}

DomainStore 域名存储

type FrozenAccountData

type FrozenAccountData struct {
	CN     string
	Domain string
	Frozen bool
}

FrozenAccountData 冻结/解冻账户的数据对象

func (*FrozenAccountData) Normalize

func (data *FrozenAccountData) Normalize()

type LostRequest

type LostRequest struct {
	CN          string
	Domain      string
	RecoverAddr types.Address
}

LostRequest 密钥丢失处理的数据对象

func (*LostRequest) Normalize

func (req *LostRequest) Normalize()

type LostStore

type LostStore struct {
	*LostRequest
	TimeStamp uint64
}

LostStore 密钥丢失存储对象

type PartnerData

type PartnerData struct {
	CN     string
	Domain string
}

PartnerData 合作伙伴的数据对象

func (*PartnerData) Normalize

func (data *PartnerData) Normalize()

type Permissions

type Permissions struct {
	EnableRegisterUser      bool `json:"enable_register_user,omitempty"`      // 是否允许注册用户
	EnableUpdateUser        bool `json:"enable_update_user,omitempty"`        // 是否允许更新用户权限
	EnableFrozenUser        bool `json:"enable_frozen_user,omitempty"`        // 是否允许冻结用户
	EnableRegisterDomain    bool `json:"enable_register_domain,omitempty"`    // 是否允许建立新的域名
	EnableRegisterSubdomain bool `json:"enable_register_subdomain,omitempty"` // 是否允许建立子域
}

Permissions 用户权限

type UpdatePermissionData

type UpdatePermissionData struct {
	CN          string
	Domain      string
	Permissions Permissions
}

UpdatePermissionData 更新账户权限的数据对象

func (*UpdatePermissionData) Normalize

func (data *UpdatePermissionData) Normalize()

Jump to

Keyboard shortcuts

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