Documentation
¶
Index ¶
- Constants
- func CheckAddr(addr btypes.Address) (ret bool)
- func CreateAndSaveAccount(ctx bcontext.Context, addr btypes.Address) (acc *account.QOSAccount, success bool)
- func FetchBankerCA() (caBanker *[]byte)
- func FetchQscCA() (caQsc *[]byte)
- func GetAccount(ctx bcontext.Context, addr btypes.Address) (acc *account.QOSAccount)
- func RegisterCodec(cdc *amino.Codec)
- func SaveAccount(ctx bcontext.Context, acc *account.QOSAccount) bool
- func VerifyCA(pubkey crypto.PubKey, ca *CA) bool
- type AddrCoin
- type CA
- type TransItem
- type TransferTx
- func (tx TransferTx) CalcGas() btypes.BigInt
- func (tx TransferTx) Exec(ctx context.Context) (result btypes.Result, crossTxQcp *txs.TxQcp)
- func (tx TransferTx) GetGasPayer() btypes.Address
- func (tx TransferTx) GetSignData() (ret []byte)
- func (tx TransferTx) GetSigner() []btypes.Address
- func (tx TransferTx) ValidateData(ctx context.Context) bool
- type TxCreateQSC
- func (tx TxCreateQSC) CalcGas() btypes.BigInt
- func (tx TxCreateQSC) Exec(ctx context.Context) (ret btypes.Result, crossTxQcps *btxs.TxQcp)
- func (tx TxCreateQSC) GetGasPayer() (ret btypes.Address)
- func (tx TxCreateQSC) GetSignData() (ret []byte)
- func (tx TxCreateQSC) GetSigner() (ret []btypes.Address)
- func (tx TxCreateQSC) ValidateData(ctx context.Context) bool
- type TxIssueQsc
- func (tx *TxIssueQsc) CalcGas() types.BigInt
- func (tx *TxIssueQsc) Exec(ctx context.Context) (ret types.Result, crossTxQcps *btxs.TxQcp)
- func (tx *TxIssueQsc) GetGasPayer() types.Address
- func (tx *TxIssueQsc) GetSignData() (ret []byte)
- func (tx *TxIssueQsc) GetSigner() (singer []types.Address)
- func (tx *TxIssueQsc) ValidateData(ctx context.Context) bool
Constants ¶
View Source
const BASEGAS_CREATEQSC int64 = 10000 //创建qsc需要的最少qos数
Variables ¶
This section is empty.
Functions ¶
func CreateAndSaveAccount ¶
func CreateAndSaveAccount(ctx bcontext.Context, addr btypes.Address) (acc *account.QOSAccount, success bool)
通过地址创建QOSAccount 若账户存在,返回账户 & false
func FetchQscCA ¶
func FetchQscCA() (caQsc *[]byte)
func GetAccount ¶
通过地址获取QOSAccount
func RegisterCodec ¶
func SaveAccount ¶
func SaveAccount(ctx bcontext.Context, acc *account.QOSAccount) bool
Types ¶
type CA ¶
type CA struct {
Qcpname string `json:"qcpname"`
Banker bool `json:"banker"`
Pubkey crypto.PubKey `json:"pubkey"`
Signature []byte `json:"signature"`
Info string `json:"info"`
}
CA结构体 todo: CA具体格式确定后会更改
type TransferTx ¶
type TransferTx struct {
Senders []TransItem `json:"senders"` // 发送集合
Receivers []TransItem `json:"receivers"` // 接收集合
}
func (TransferTx) ValidateData ¶
func (tx TransferTx) ValidateData(ctx context.Context) bool
数据校验 1.Senders、Receivers不为空,地址不重复,币值大于0 2.Senders、Receivers 币值总和对应币种相等 3.Senders中账号对应币种币值足够
type TxCreateQSC ¶
type TxCreateQSC struct {
QscName string `json:"qscname"` //从CA信息获取
CreateAddr btypes.Address `json:"createaddr"` //QSC创建账户
QscPubkey crypto.PubKey `json:"qscpubkey"` //从CA信息获取
Banker btypes.Address `json:"banker"` //从CA信息获取
Extrate string `json:"extrate"` //qcs:qos汇率(amino不支持binary形式的浮点数序列化,精度同qos erc20 [.0000])
CAqsc []byte `json:"caqsc"` //CA信息
CAbanker []byte `json:"cabanker"` //CA信息
Description string `json:"description"` //描述信息
AccInit []AddrCoin `json:"accinit"` //初始化时接受qsc的账户
}
功能:"创建QSC" 对应的Tx结构
func NewCreateQsc ¶
func NewCreateQsc(cdc *go_amino.Codec, caqsc *[]byte, cabank *[]byte, createAddr btypes.Address, accs *[]AddrCoin, extrate string, dsp string) (rTx *TxCreateQSC)
创建 TxCreateQSC结构体 备注:CA提供两个证书,联盟链证书 & Banker证书(banker字段)
两种证书通过 qscName 字段关联起来
func (TxCreateQSC) CalcGas ¶
func (tx TxCreateQSC) CalcGas() btypes.BigInt
功能:计算gas 规则:基准值 + 每个初始化用户收10qos
func (TxCreateQSC) Exec ¶
功能:tx执行 描述:
保存链信息并检查是否已经创建(qscname, pubkey, 是否已经注册)
查询banker是否存在,若不存在,
向账户 AccInit 分发qsc
func (TxCreateQSC) ValidateData ¶
func (tx TxCreateQSC) ValidateData(ctx context.Context) bool
功能:检测合法性 备注:
1,成员字段的合法性 2,creator的账户余额是否够gas抵扣
type TxIssueQsc ¶
type TxIssueQsc struct {
QscName string `json:"qscName"` //发币账户名
Amount types.BigInt `json:"amount"` //金额
Banker types.Address `json:"banker"` //banker地址
}
功能:发币 对应的Tx结构
func NewTxIssueQsc ¶
构建 TxIsssueQsc 结构体
func (*TxIssueQsc) GetGasPayer ¶
func (tx *TxIssueQsc) GetGasPayer() types.Address
gas付费人 no gas, no payer
func (*TxIssueQsc) ValidateData ¶
func (tx *TxIssueQsc) ValidateData(ctx context.Context) bool
功能:检测TxIssuQsc结构体字段是否合法
Click to show internal directories.
Click to hide internal directories.