chainmaker_sdk_go

package module
v3.0.1 Latest Latest
Warning

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

Go to latest
Published: Dec 26, 2023 License: Apache-2.0 Imports: 64 Imported by: 0

README

ChainMaker Go SDK 接口说明

1 用户合约接口

1.1 创建合约待签名payload生成

参数说明

  • contractName: 合约名
  • version: 版本号
  • byteCodeStringOrFilePath: 支持传入合约二进制文件路径或Hex或Base64编码的string
  • runtime: 合约运行环境
  • kvs: 合约初始化参数
	CreateContractCreatePayload(contractName, version, byteCodeStringOrFilePath string, runtime common.RuntimeType,
		kvs []*common.KeyValuePair) (*common.Payload, error)
1.2 升级合约待签名payload生成

参数说明

  • contractName: 合约名
  • version: 版本号
  • byteCodeStringOrFilePath: 支持传入合约二进制文件路径或Hex或Base64编码的string
  • runtime: 合约运行环境
  • kvs: 合约升级参数
	CreateContractUpgradePayload(contractName, version, byteCodeStringOrFilePath string, runtime common.RuntimeType,
		kvs []*common.KeyValuePair) (*common.Payload, error)
1.3 冻结合约payload生成

参数说明

  • contractName: 合约名
	CreateContractFreezePayload(contractName string) (*common.Payload, error)
1.4 解冻合约payload生成

参数说明

  • contractName: 合约名
	CreateContractUnfreezePayload(contractName string) (*common.Payload, error)
1.5 吊销合约payload生成

参数说明

  • contractName: 合约名
	CreateContractRevokePayload(contractName string) (*common.Payload, error)
1.6 合约管理获取Payload签名

参数说明

  • payload: 待签名payload
	SignContractManagePayload(payload *common.Payload) (*common.EndorsementEntry, error)
1.7 发送合约管理请求(创建、更新、冻结、解冻、吊销)

参数说明

  • payload: 交易payload
  • endorsers: 背书签名信息列表
  • timeout: 超时时间,单位:s,若传入-1,将使用默认超时时间:10s
  • withSyncResult: 是否同步获取交易执行结果 当为true时,若成功调用,common.TxResponse.ContractResult.Result为common.TransactionInfo 当为false时,若成功调用,common.TxResponse.ContractResult为空,可以通过common.TxResponse.TxId查询交易结果
  • payer: gas扣费代扣人
	SendContractManageRequest(payload *common.Payload, endorsers []*common.EndorsementEntry, timeout int64,
		withSyncResult bool) (*common.TxResponse, error)
	SendContractManageRequestWithPayer(payload *common.Payload, endorsers []*common.EndorsementEntry,
		payer *common.EndorsementEntry, timeout int64, withSyncResult bool) (*common.TxResponse, error)
1.8 合约调用

参数说明

  • contractName: 合约名称
  • method: 合约方法
  • txId: 交易ID 格式要求:长度为64字节,字符在a-z0-9 可为空,若为空字符串,将自动生成txId
  • kvs: 合约参数
  • timeout: 超时时间,单位:s,若传入-1,将使用默认超时时间:10s
  • withSyncResult: 是否同步获取交易执行结果 当为true时,若成功调用,common.TxResponse.ContractResult.Result为common.TransactionInfo 当为false时,若成功调用,common.TxResponse.ContractResult为空,可以通过common.TxResponse.TxId查询交易结果
  • limit: transaction limitation,执行交易时的资源消耗上限,设为nil则不设置上限
	InvokeContract(contractName, method, txId string, kvs []*common.KeyValuePair, timeout int64,
		withSyncResult bool) (*common.TxResponse, error)
	InvokeContractWithLimit(contractName, method, txId string, kvs []*common.KeyValuePair, timeout int64,
		withSyncResult bool, limit *common.Limit) (*common.TxResponse, error)
1.9 合约查询接口调用

参数说明

  • contractName: 合约名称
  • method: 合约方法
  • kvs: 合约参数
  • timeout: 超时时间,单位:s,若传入-1,将使用默认超时时间:10s
	QueryContract(contractName, method string, kvs []*common.KeyValuePair, timeout int64) (*common.TxResponse, error)
1.10 构造待发送交易体

参数说明

  • contractName: 合约名称
  • method: 合约方法
  • txId: 交易ID 格式要求:长度为64字节,字符在a-z0-9 可为空,若为空字符串,将自动生成txId
  • kvs: 合约参数
	GetTxRequest(contractName, method, txId string, kvs []*common.KeyValuePair) (*common.TxRequest, error)
1.11 发送已构造好的交易体

参数说明

  • txRequest: 已构造好的交易体
  • timeout: 超时时间,单位:s,若传入-1,将使用默认超时时间:10s
  • withSyncResult: 是否同步获取交易执行结果 当为true时,若成功调用,common.TxResponse.ContractResult.Result为common.TransactionInfo 当为false时,若成功调用,common.TxResponse.ContractResult为空,可以通过common.TxResponse.TxId查询交易结果
	SendTxRequest(txRequest *common.TxRequest, timeout int64, withSyncResult bool) (*common.TxResponse, error)

2 系统合约接口

2.1 根据交易Id查询交易

参数说明

  • txId: 交易ID
	GetTxByTxId(txId string) (*common.TransactionInfo, error)
2.2 根据交易Id查询包含rwset的交易

参数说明

  • txId: 交易ID
	GetTxWithRWSetByTxId(txId string) (*common.TransactionInfoWithRWSet, error)
2.3 根据区块高度查询区块

参数说明

  • blockHeight: 指定区块高度,若为-1,将返回最新区块
  • withRWSet: 是否返回读写集
	GetBlockByHeight(blockHeight uint64, withRWSet bool) (*common.BlockInfo, error)
2.4 根据区块高度查询完整区块,该方法已弃用,请优先使用GetBlockByHeight

参数说明

  • blockHeight: 指定区块高度,若为-1,将返回最新区块
	//Deprecated
	GetFullBlockByHeight(blockHeight uint64) (*store.BlockWithRWSet, error)
2.5 根据区块哈希查询区块

参数说明

  • blockHash: 指定区块Hash
  • withRWSet: 是否返回读写集
	GetBlockByHash(blockHash string, withRWSet bool) (*common.BlockInfo, error)
2.6 根据交易Id查询区块

参数说明

  • txId: 交易ID
  • withRWSet: 是否返回读写集
	GetBlockByTxId(txId string, withRWSet bool) (*common.BlockInfo, error)
2.7 查询最新的配置块

参数说明

  • withRWSet: 是否返回读写集
	GetLastConfigBlock(withRWSet bool) (*common.BlockInfo, error)
2.8 查询最新区块

参数说明

  • withRWSet: 是否返回读写集
	GetLastBlock(withRWSet bool) (*common.BlockInfo, error)
2.9 查询节点加入的链信息
  • 返回ChainId清单
	GetNodeChainList() (*discovery.ChainList, error)
2.10 查询链信息
  • 包括:当前链最新高度,链节点信息
	GetChainInfo() (*discovery.ChainInfo, error)
2.11 根据交易Id获取区块高度

参数说明

  • txId: 交易ID
	GetBlockHeightByTxId(txId string) (uint64, error)
2.12 根据区块Hash获取区块高度

参数说明

  • blockHash: 指定区块Hash
	GetBlockHeightByHash(blockHash string) (uint64, error)
2.13 查询当前最新区块高度
	GetCurrentBlockHeight() (uint64, error)
2.14 根据区块高度查询区块头

参数说明

  • blockHeight: 指定区块高度,若为-1,将返回最新区块头
	GetBlockHeaderByHeight(blockHeight uint64) (*common.BlockHeader, error)
2.15 根据Key查询状态数据

参数说明

  • contractName 合约名
  • key 状况数据中的Key 返回值说明
  • []byte Value
	GetStateByKey(contractName string, key string, options ...Option) ([]byte, error)
2.16 根据Key前缀获得匹配的KV列表

参数说明

  • contractName 合约名
  • prefix 前缀
  • options 可选项 返回值说明
  • []*common.KeyValuePair
	GetStateByPrefix(contractName string, prefix string, options ...Option) ([]*common.KeyValuePair, error)
2.17 系统合约调用

参数说明

  • contractName: 合约名称
  • method: 合约方法
  • txId: 交易ID 格式要求:长度为64字节,字符在a-z0-9 可为空,若为空字符串,将自动生成txId
  • kvs: 合约参数
  • timeout: 超时时间,单位:s,若传入-1,将使用默认超时时间:10s
  • withSyncResult: 是否同步获取交易执行结果 当为true时,若成功调用,common.TxResponse.ContractResult.Result为common.TransactionInfo 当为false时,若成功调用,common.TxResponse.ContractResult为空,可以通过common.TxResponse.TxId查询交易结果
	InvokeSystemContract(contractName, method, txId string, kvs []*common.KeyValuePair, timeout int64,
		withSyncResult bool) (*common.TxResponse, error)
2.18 系统合约查询接口调用

参数说明

  • contractName: 合约名称
  • method: 合约方法
  • kvs: 合约参数
  • timeout: 超时时间,单位:s,若传入-1,将使用默认超时时间:10s
	QuerySystemContract(contractName, method string, kvs []*common.KeyValuePair, timeout int64) (*common.TxResponse, error)
2.19 根据交易Id获取Merkle路径

参数说明

  • txId: 交易ID
	GetMerklePathByTxId(txId string) ([]byte, error)
2.20 开放系统合约

参数说明

  • grantContractList: 需要开放的系统合约字符串数组
	CreateNativeContractAccessGrantPayload(grantContractList []string) (*common.Payload, error)
2.21 弃用系统合约

参数说明

  • revokeContractList: 需要弃用的系统合约字符串数组
	CreateNativeContractAccessRevokePayload(revokeContractList []string) (*common.Payload, error)
2.22 查询指定合约的信息,包括系统合约和用户合约

参数说明

  • contractName: 指定查询的合约名字,包括系统合约和用户合约
	GetContractInfo(contractName string) (*common.Contract, error)
2.23 根据合约名查询合约的字节码

参数说明

  • contractName: 合约名或者合约地址 返回值说明
  • []byte 合约的字节码
  • error 错误
	GetContractByteCode(contractName string) ([]byte, error)
2.24 查询所有的合约名单,包括系统合约和用户合约

返回值说明

  • []*common.Contract: 链上所有的合约列表,包括系统合约和用户合约
	GetContractList() ([]*common.Contract, error)
2.25 查询已禁用的系统合约名单

返回值说明

  • []string: 链上已禁用的系统合约名字列表
	GetDisabledNativeContractList() ([]string, error)
2.26 根据区块高度获得区块,应对超大block,可设置返回block的截断规则

参数说明

  • blockHeight: 指定区块高度
  • withRWSet: 是否返回读写集
  • truncateLength 截断的长度设置,如果此参数为>0,超过此长度的剩余数据将被丢弃。如果<=0则不截断
  • truncateModel 截断的模式设置:hash,truncate,empty
	GetBlockByHeightTruncate(blockHeight uint64, withRWSet bool, truncateLength int,
		truncateModel string) (*common.BlockInfo, error)

3 链配置接口

3.1 查询最新链配置
	GetChainConfig() (*config.ChainConfig, error)
3.2 根据指定区块高度查询最近链配置

参数说明

  • blockHeight: 指定区块高度 如果当前区块就是配置块,直接返回当前区块的链配置
	GetChainConfigByBlockHeight(blockHeight uint64) (*config.ChainConfig, error)
3.3 查询最新链配置序号Sequence
  • 用于链配置更新
	GetChainConfigSequence() (uint64, error)
3.4 链配置更新获取Payload签名

参数说明

  • payload: 待签名payload
	SignChainConfigPayload(payload *common.Payload) (*common.EndorsementEntry, error)
3.5 发送链配置更新请求

参数说明

  • payload: 待签名payload
  • endorsers: 背书签名信息列表
  • timeout: 超时时间,单位:s,若传入-1,将使用默认超时时间:10s
  • withSyncResult: 是否同步获取交易执行结果 当为true时,若成功调用,common.TxResponse.ContractResult.Result为common.TransactionInfo 当为false时,若成功调用,common.TxResponse.ContractResult为空,可以通过common.TxResponse.TxId查询交易结果
	SendChainConfigUpdateRequest(payload *common.Payload, endorsers []*common.EndorsementEntry, timeout int64,
		withSyncResult bool) (*common.TxResponse, error)

以下CreateChainConfigXXXXXXPayload方法,用于生成链配置待签名payload,在进行多签收集后(需机构Admin权限账号签名),用于链配置的更新

3.6 更新Core模块待签名payload生成

参数说明

  • txSchedulerTimeout: 交易调度器从交易池拿到交易后, 进行调度的时间,其值范围为(0, 60], 若设置为0,则抛出错误
  • txSchedulerValidateTimeout: 交易调度器从区块中拿到交易后, 进行验证的超时时间,其值范围为(0, 60], 若设置为0,则抛出错误
	CreateChainConfigCoreUpdatePayload(txSchedulerTimeout, txSchedulerValidateTimeout uint64) (*common.Payload, error)
3.7 更新链配置的区块相关参数待签名payload生成

参数说明

  • txTimestampVerify: 是否需要开启交易时间戳校验
  • blockTimestampVerify: 是否需要开启区块头时间戳校验
  • txTimeout: 交易时间戳的过期时间(秒),其值范围为[600, +∞)
  • blockTimeout: 区块头时间戳的过期时间(秒),其值范围为[10, +∞)
  • blockTxCapacity: 区块中最大交易数,其值范围为(0, +∞]
  • blockSize: 区块最大限制,单位MB,其值范围为(0, +∞]
  • blockInterval: 出块间隔,单位:ms,其值范围为[10, +∞]
  • txParamterSize: 交易的参数的最大值限制,单位:MB,其值范围为[0,100]
	CreateChainConfigBlockUpdatePayload(txTimestampVerify, blockTimestampVerify bool, txTimeout,
		blockTimeout, blockTxCapacity, blockSize, blockInterval, txParamterSize uint32) (*common.Payload, error)
3.8 添加信任组织根证书待签名payload生成

参数说明

  • trustRootOrgId: 组织Id
  • trustRootCrt: 根证书
	CreateChainConfigTrustRootAddPayload(trustRootOrgId string, trustRootCrt []string) (*common.Payload, error)
3.9 更新信任组织根证书待签名payload生成

参数说明

  • trustRootOrgId: 组织Id
  • trustRootCrt: 根证书
	CreateChainConfigTrustRootUpdatePayload(trustRootOrgId string, trustRootCrt []string) (*common.Payload, error)
3.10 删除信任组织根证书待签名payload生成

参数说明

  • orgIdOrPKPubkeyPEM: cert模式下传组织Id,public模式下传公钥PEM
	CreateChainConfigTrustRootDeletePayload(orgIdOrPKPubkeyPEM string) (*common.Payload, error)
3.11 添加信任成员证书待签名payload生成

参数说明

  • trustMemberOrgId: 组织Id
  • trustMemberNodeId: 节点Id
  • trustMemberRole: 成员角色
  • trustMemberInfo: 成员信息内容
	CreateChainConfigTrustMemberAddPayload(trustMemberOrgId, trustMemberNodeId,
		trustMemberRole, trustMemberInfo string) (*common.Payload, error)
3.12 删除信任成员证书待签名payload生成

参数说明

  • trustMemberInfo: 成员信息内容
	CreateChainConfigTrustMemberDeletePayload(trustMemberInfo string) (*common.Payload, error)
3.13 添加权限配置待签名payload生成

参数说明

  • permissionResourceName: 权限名
  • policy: 权限规则
	CreateChainConfigPermissionAddPayload(permissionResourceName string,
		policy *accesscontrol.Policy) (*common.Payload, error)
3.14 更新权限配置待签名payload生成

参数说明

  • permissionResourceName: 权限名
  • policy: 权限规则
	CreateChainConfigPermissionUpdatePayload(permissionResourceName string,
		policy *accesscontrol.Policy) (*common.Payload, error)
3.15 删除权限配置待签名payload生成

参数说明

  • permissionResourceName: 权限名
	CreateChainConfigPermissionDeletePayload(permissionResourceName string) (*common.Payload, error)
3.16 添加共识节点地址待签名payload生成

参数说明

  • nodeOrgId: 节点组织Id
  • nodeIds: 节点Id
	CreateChainConfigConsensusNodeIdAddPayload(nodeOrgId string, nodeIds []string) (*common.Payload, error)
3.17 更新共识节点地址待签名payload生成

参数说明

  • nodeOrgId: 节点组织Id
  • nodeOldNodeId: 节点原Id
  • nodeNewNodeId: 节点新Id
	CreateChainConfigConsensusNodeIdUpdatePayload(nodeOrgId, nodeOldNodeId, nodeNewNodeId string) (*common.Payload, error)
3.18 删除共识节点地址待签名payload生成

参数说明

  • nodeOrgId: 节点组织Id
  • nodeId: 节点Id
	CreateChainConfigConsensusNodeIdDeletePayload(nodeOrgId, nodeId string) (*common.Payload, error)
3.19 添加共识节点待签名payload生成

参数说明

  • nodeOrgId: 节点组织Id
  • nodeIds: 节点Id
	CreateChainConfigConsensusNodeOrgAddPayload(nodeOrgId string, nodeIds []string) (*common.Payload, error)
3.20 更新共识节点待签名payload生成

参数说明

  • nodeOrgId: 节点组织Id
  • nodeIds: 节点Id
	CreateChainConfigConsensusNodeOrgUpdatePayload(nodeOrgId string, nodeIds []string) (*common.Payload, error)
3.21 删除共识节点待签名payload生成

参数说明

  • nodeOrgId: 节点组织Id
	CreateChainConfigConsensusNodeOrgDeletePayload(nodeOrgId string) (*common.Payload, error)
3.22 添加共识扩展字段待签名payload生成

参数说明

  • kvs: 字段key、value对
	CreateChainConfigConsensusExtAddPayload(kvs []*common.KeyValuePair) (*common.Payload, error)
3.23 更新共识扩展字段待签名payload生成

参数说明

  • kvs: 字段key、value对
	CreateChainConfigConsensusExtUpdatePayload(kvs []*common.KeyValuePair) (*common.Payload, error)
3.24 删除共识扩展字段待签名payload生成

参数说明

  • keys: 待删除字段
	CreateChainConfigConsensusExtDeletePayload(keys []string) (*common.Payload, error)
3.25 修改地址类型payload生成

参数说明

  • addrType: 地址类型,0-ChainMaker; 1-ZXL
	CreateChainConfigAlterAddrTypePayload(addrType string) (*common.Payload, error)
3.26 启用或停用Gas计费开关payload生成
	CreateChainConfigEnableOrDisableGasPayload() (*common.Payload, error)
3.27 开启或关闭链配置的Gas优化payload生成
	CreateChainConfigOptimizeChargeGasPayload(enable bool) (*common.Payload, error)
3.28 查询最新权限配置列表
	GetChainConfigPermissionList() ([]*config.ResourcePolicy, error)
3.29 添加vm类型到vm支持列表的未签名payload生成
	CreateChainConfigVMSupportListAddPayload(vmType string) (*common.Payload, error)

4 证书管理接口

4.1 用户证书添加

参数说明

  • 在common.TxResponse.ContractResult.Result字段中返回成功添加的certHash
	AddCert() (*common.TxResponse, error)
4.2 用户证书删除

参数说明

  • certHashes: 证书Hash列表
	DeleteCert(certHashes []string) (*common.TxResponse, error)
4.3 用户证书查询

参数说明

  • certHashes: 证书Hash列表 返回值说明
  • *common.CertInfos: 包含证书Hash和证书内容的列表
	QueryCert(certHashes []string) (*common.CertInfos, error)
4.4 获取用户证书哈希
	GetCertHash() ([]byte, error)
4.5 生成证书管理操作Payload(三合一接口)

参数说明

  • method: CERTS_FROZEN(证书冻结)/CERTS_UNFROZEN(证书解冻)/CERTS_REVOCATION(证书吊销)
  • kvs: 证书管理操作参数
	CreateCertManagePayload(method string, kvs []*common.KeyValuePair) *common.Payload
4.6 生成证书冻结操作Payload

参数说明

  • certs: X509证书列表
	CreateCertManageFrozenPayload(certs []string) *common.Payload
4.7 生成证书解冻操作Payload

参数说明

  • certs: X509证书列表
	CreateCertManageUnfrozenPayload(certs []string) *common.Payload
4.8 生成证书吊销操作Payload

参数说明

  • certs: X509证书列表
	CreateCertManageRevocationPayload(certCrl string) *common.Payload
4.9 待签payload签名

一般需要使用具有管理员权限账号进行签名 参数说明

  • payload: 待签名payload
	SignCertManagePayload(payload *common.Payload) (*common.EndorsementEntry, error)
4.10 发送证书管理请求(证书冻结、解冻、吊销)

参数说明

  • payload: 交易payload
  • endorsers: 背书签名信息列表
  • timeout: 超时时间,单位:s,若传入-1,将使用默认超时时间:10s
  • withSyncResult: 是否同步获取交易执行结果 当为true时,若成功调用,common.TxResponse.ContractResult.Result为common.TransactionInfo 当为false时,若成功调用,common.TxResponse.ContractResult为空,可以通过common.TxResponse.TxId查询交易结果
	SendCertManageRequest(payload *common.Payload, endorsers []*common.EndorsementEntry, timeout int64,
		withSyncResult bool) (*common.TxResponse, error)

5 消息订阅接口

5.1 区块订阅

参数说明

  • startBlock: 订阅起始区块高度,包含起始区块。若为-1,表示订阅实时最新区块
  • endBlock: 订阅结束区块高度,包含结束区块。若为-1,表示订阅实时最新区块
  • withRwSet: 是否返回读写集
  • onlyHeader: 若设置为true,将忽略withRwSet选项,仅返回区块头(common.BlockHeader),若设置为false,将返回common.BlockInfo
	SubscribeBlock(ctx context.Context, startBlock, endBlock int64, withRWSet, onlyHeader bool) (<-chan interface{}, error)
5.2 交易订阅

参数说明

  • startBlock: 订阅起始区块高度,包含起始区块。若为-1,表示订阅实时最新区块
  • endBlock: 订阅结束区块高度,包含结束区块。若为-1,表示订阅实时最新区块
  • contractName :指定订阅指定合约的交易,可以传用户合约名称或系统合约名称,若为空,表示订阅所有合约的交易
  • txIds: 订阅txId列表,若为空,表示订阅所有txId
	SubscribeTx(ctx context.Context, startBlock, endBlock int64, contractName string,
		txIds []string) (<-chan interface{}, error)
5.3 合约事件订阅

参数说明

  • startBlock: 订阅起始区块高度,包含起始区块。若为-1,表示订阅实时最新区块
  • endBlock: 订阅结束区块高度,包含结束区块。若为-1,表示订阅实时最新区块
  • contractName :指定订阅的合约名称
  • topic :指定订阅主题
	SubscribeContractEvent(ctx context.Context, startBlock, endBlock int64, contractName,
		topic string) (<-chan interface{}, error)
5.4 多合一订阅

参数说明

  • txType: 订阅交易类型,目前已支持:区块消息订阅(common.TxType_SUBSCRIBE_BLOCK_INFO)、交易消息订阅(common.TxType_SUBSCRIBE_TX_INFO)
  • payloadBytes: 消息订阅参数payload
	Subscribe(ctx context.Context, payloadBytes *common.Payload) (<-chan interface{}, error)

6 证书压缩

开启证书压缩可以减小交易包大小,提升处理性能

6.1 启用压缩证书功能
	EnableCertHash() error
6.2 停用压缩证书功能
	DisableCertHash() error

7 层级属性加密类接口

注意:层级属性加密模块 Id 使用 / 作为分隔符,例如: Org1/Ou1/Member1

7.1 生成层级属性参数初始化交易 payload

参数说明

  • orgId: 参与方组织 id
  • hibeParams: 传入序列化后的hibeParams byte数组
	CreateHibeInitParamsTxPayloadParams(orgId string, hibeParams []byte) ([]*common.KeyValuePair, error)
7.2 生成层级属性加密交易 payload,加密参数已知

参数说明

  • plaintext: 待加密交易消息明文
  • receiverIds: 消息接收者 id 列表,需和 paramsList 一一对应
  • paramsBytesList: 消息接收者对应的加密参数,需和 receiverIds 一一对应
  • txId: 以交易 Id 作为链上存储 hibeMsg 的 Key, 如果不提供存储的信息可能被覆盖
  • keyType: 对明文进行对称加密的方法,请传入 common 中 crypto 包提供的方法,目前提供AES和SM4两种方法
	CreateHibeTxPayloadParamsWithHibeParams(plaintext []byte, receiverIds []string, paramsBytesList [][]byte, txId string,
		keyType crypto.KeyType) ([]*common.KeyValuePair, error)
7.3 生成层级属性加密交易 payload,参数由链上查询得出

参数说明

  • contractName: 合约名
  • queryParamsMethod: 链上查询 hibe.Params 的合约方法
  • plaintext: 待加密交易消息明文
  • receiverIds: 消息接收者 id 列表,需和 paramsList 一一对应
  • paramsList: 消息接收者对应的加密参数,需和 receiverIds 一一对应
  • receiverOrgIds: 链上查询 hibe Params 的 Key 列表,需要和 receiverIds 一一对应
  • txId: 以交易 Id 作为链上存储 hibeMsg 的 Key, 如果不提供存储的信息可能被覆盖
  • keyType: 对明文进行对称加密的方法,请传入 common 中 crypto 包提供的方法,目前提供AES和SM4两种方法
  • timeout: (内部查询 HibeParams 的)超时时间,单位:s,若传入-1,将使用默认超时时间:10s
	CreateHibeTxPayloadParamsWithoutHibeParams(contractName, queryParamsMethod string, plaintext []byte,
		receiverIds []string, receiverOrgIds []string, txId string, keyType crypto.KeyType,
		timeout int64) ([]*common.KeyValuePair, error)
7.4 查询某一组织的加密公共参数,返回其序列化后的byte数组

参数说明

  • contractName: 合约名
  • method: 查询的合约方法名
  • orgId: 参与方 id
  • timeout: 查询超时时间,单位:s,若传入-1,将使用默认超时时间:10s
	QueryHibeParamsWithOrgId(contractName, method, orgId string, timeout int64) ([]byte, error)
7.5 已知交易id,根据私钥解密密文交易

参数说明

  • localId: 本地层级属性加密 id
  • hibeParams: hibeParams 序列化后的byte数组
  • hibePrivKey: hibe私钥序列化后的byte数组
  • txId: 层级属性加密交易 id
  • keyType: 对加密信息进行对称解密的方法,请和加密时使用的方法保持一致,请传入 common 中 crypto 包提供的方法,目前提供AES和SM4两种方法
	DecryptHibeTxByTxId(localId string, hibeParams []byte, hibePrvKey []byte, txId string,
		keyType crypto.KeyType) ([]byte, error)

8 数据归档接口

(注意:请使用归档工具cmc进行归档操作,以下接口是归档原子接口,并不包括归档完整流程)

8.1 获取已归档区块高度,该方法已弃用,请优先使用GetArchiveStatus

参数说明

  • 输出已归档的区块高度
	//Deprecated
	GetArchivedBlockHeight() (uint64, error)
8.2 获取节点归档状态详细信息

参数说明

  • 输出:输出节点支持的归档类型:ExtraDB(外部数据库),ArchiveCenter(归档中心)
  • 输出:已归档的区块高度
  • 输出:节点允许的归档高度: 高度必须小于(CurrBlockHeight-UnarchivedHeight),UnarchivedHeight在chainmaker.yml storage中设置
  • 输出:当前节点的归档状态:Normal(正常), Archiving(正在归档), Restoring(正在恢复)
  • 输出:当前节点上可恢复区块的暂存文件信息
	GetArchiveStatus() (*store.ArchiveStatus, error)

8.3 构造数据归档区块Payload

参数说明

  • targetBlockHeight: 归档目标区块高度,节点ArchiveStatus.Process为Normal时才可发送成功
	CreateArchiveBlockPayload(targetBlockHeight uint64) (*common.Payload, error)
8.4 构造归档数据恢复Payload

参数说明

  • fullBlock: 完整区块数据(对应结构:store.BlockWithRWSet)
	CreateRestoreBlockPayload(fullBlock []byte) (*common.Payload, error)
8.6 发送归档请求

参数说明

  • payload: 指向payload对象的指针
  • timeout: 超时时间,单位:s,若传入-1,将使用默认超时时间:10s
  • 备注:必须在ArchiveStatus.Process归档状态为Normal时才可调用成功
	SendArchiveBlockRequest(payload *common.Payload, timeout int64) (*common.TxResponse, error)
8.7 归档数据恢复

参数说明

  • payload: 指向payload对象的指针
  • timeout: 超时时间,单位:s,若传入-1,将使用默认超时时间:10s
  • 备注:必须在ArchiveStatus.Process归档状态为Normal时才可调用成功
	SendRestoreBlockRequest(payload *common.Payload, timeout int64) (*common.TxResponse, error)
8.8 根据交易Id查询已归档交易

参数说明

  • txId: 交易ID
	GetArchivedTxByTxId(txId string) (*common.TransactionInfo, error)
8.9 根据区块高度查询已归档区块

参数说明

  • blockHeight: 指定区块高度
  • withRWSet: 是否返回读写集
	GetArchivedBlockByHeight(blockHeight uint64, withRWSet bool) (*common.BlockInfo, error)
8.11 根据区块哈希查询已归档区块

参数说明

  • blockHash: 指定区块Hash
  • withRWSet: 是否返回读写集
	GetArchivedBlockByHash(blockHash string, withRWSet bool) (*common.BlockInfo, error)
8.12 根据交易Id查询已归档区块

参数说明

  • txId: 交易ID
  • withRWSet: 是否返回读写集
	GetArchivedBlockByTxId(txId string, withRWSet bool) (*common.BlockInfo, error)

9 隐私计算系统合约接口

9.1 保存隐私合约计算结果,包括合约部署

参数说明

  • contractName: 合约名称
  • contractVersion: 合约版本号
  • isDeployment: 是否是部署合约
  • codeHash: 合约字节码hash值
  • reportHash: Enclave report hash值
  • result: 隐私合约执行结果
  • codeHeader: solodity合部署合约时合约字节码的header数据
  • txId: 交易Id
  • rwSet: 隐私合约执行产生的读写集
  • sign: Enclave对执行结果数据的结果签名
  • events: 合约执行产生的事件
  • privateReq: 用户调用隐私计算请求时的request序列化字节数组
  • withSyncResult: 是否同步返回调用结果
  • timeout: 发送交易的超时时间
	SaveData(contractName string, contractVersion string, isDeployment bool, codeHash []byte, reportHash []byte,
		result *common.ContractResult, codeHeader []byte, txId string, rwSet *common.TxRWSet, sign []byte,
		events *common.StrSlice, privateReq []byte, withSyncResult bool, timeout int64) (*common.TxResponse, error)
9.2 保存远程证明

参数说明

  • proof: 远程证明
  • txId: 交易Id
  • withSyncResult: 是否同步返回调用结果
  • timeout: 交易发送超时时间
	SaveRemoteAttestationProof(proof, txId string, withSyncResult bool, timeout int64) (*common.TxResponse, error)
9.3 构建上传Enclave CA证书的报文

参数说明

  • caCert: Enclave CA证书
  • txId: 交易Id
	CreateSaveEnclaveCACertPayload(caCert, txId string) (*common.Payload, error)
9.4 获取Enclave CA证书
	GetEnclaveCACert() ([]byte, error)
9.5 隐私计算调用者权限验证

参数说明

  • payload: 用户签名验证的payload内容
  • orgIds: 组织Id的slice,注意和signPairs里面SignInfo的证书顺序一致
  • signPairs: 用户多签的签名和证书slice
	CheckCallerCertAuth(payload string, orgIds []string, signPairs []*syscontract.SignInfo) (*common.TxResponse, error)
9.6 获取Enclave的report

参数说明

  • enclaveId: Enclave的Id,当前固定为"global_enclave_id"
	GetEnclaveReport(enclaveId string) ([]byte, error)
9.7 获取隐私证明材料

参数说明

  • enclaveId: Enclave的Id,当前固定为"global_enclave_id"
	GetEnclaveProof(enclaveId string) ([]byte, error)
9.8 获取隐私合约计算结果

参数说明

  • contractName: 合约名称
  • key: 计算结果对应的键值
	GetData(contractName, key string) ([]byte, error)
9.9 保存隐私目录

参数说明

  • orderId: 隐私目录的主键,供以后查询使用
  • txId: 交易ID
  • privateDir:
  • withSyncResult: 是否同步等待交易结果
  • timeout: 等待交易结果的超时时间
	SaveDir(orderId, txId string, privateDir *common.StrSlice, withSyncResult bool,
		timeout int64) (*common.TxResponse, error)
9.10 获取用户部署的隐私合约

参数说明

  • contractName: 合约名称
  • codeHash: 代码哈希
	GetContract(contractName, codeHash string) (*common.PrivateGetContract, error)
9.11 获取用户的隐私目录

参数说明

  • orderId: 隐私目录的主键
	GetDir(orderId string) ([]byte, error)
9.12 构建上传隐私计算环境的report的报文

参数说明

  • enclaveId: 隐私计算环境的标识
  • report: 隐私计算环境的report
  • txId: 交易ID
	CreateSaveEnclaveReportPayload(enclaveId, report, txId string) (*common.Payload, error)
9.13 获取隐私计算环境的加密公钥

参数说明

  • enclaveId: 隐私计算环境的标识
	GetEnclaveEncryptPubKey(enclaveId string) ([]byte, error)
9.14 获取隐私计算环境的验签公钥

参数说明

  • enclaveId: 隐私计算环境的标识
	GetEnclaveVerificationPubKey(enclaveId string) ([]byte, error)
9.15 获取隐私证明材料中的Challenge

参数说明

  • enclaveId: 隐私计算环境的标识
	GetEnclaveChallenge(enclaveId string) ([]byte, error)
9.16 获取隐私证明材料中的Signature

参数说明

  • enclaveId: 隐私计算环境的标识
	GetEnclaveSignature(enclaveId string) ([]byte, error)

10 系统类接口

10.1 SDK停止接口

关闭连接池连接,释放资源

	Stop() error
10.2 获取链版本
	GetChainMakerServerVersion() (string, error)
	GetChainMakerServerVersionCustom(ctx context.Context) (string, error)

11 公钥身份类接口

11.1 构造添加公钥身份请求

参数说明

  • pubkey: 公钥信息
  • orgId: 组织id
  • role: 角色,支持client,light,common
	CreatePubkeyAddPayload(pubkey string, orgId string, role string) (*common.Payload, error)
11.2 构造删除公钥身份请求

参数说明

  • pubkey: 公钥信息
  • orgId: 组织id
	CreatePubkeyDelPayload(pubkey string, orgId string) (*common.Payload, error)
11.3 构造查询公钥身份请求

参数说明

  • pubkey: 公钥信息
	CreatePubkeyQueryPayload(pubkey string) (*common.Payload, error)
11.4 发送公钥身份管理请求(添加、删除)

参数说明

  • payload: 交易payload
  • endorsers: 背书签名信息列表
  • timeout: 超时时间,单位:s,若传入-1,将使用默认超时时间:10s
  • withSyncResult: 是否同步获取交易执行结果 当为true时,若成功调用,common.TxResponse.ContractResult.Result为common.TransactionInfo 当为false时,若成功调用,common.TxResponse.ContractResult为空,可以通过common.TxResponse.TxId查询交易结果
	SendPubkeyManageRequest(payload *common.Payload, endorsers []*common.EndorsementEntry, timeout int64,
		withSyncResult bool) (*common.TxResponse, error)

12 多签类接口

12.1 发起多签请求

参数说明

  • payload: 待签名payload
  • endorsers: 背书签名信息列表
  • timeout: 超时时间,单位:s,若传入-1,将使用默认超时时间:10s
  • withSyncResult: 是否同步获取交易执行结果 当为true时,若成功调用,common.TxResponse.ContractResult.Result为common.TransactionInfo 当为false时,若成功调用,common.TxResponse.ContractResult为空,可以通过common.TxResponse.TxId查询交易结果
  • payer: 指定gas代扣账户
	MultiSignContractReq(payload *common.Payload, endorsers []*common.EndorsementEntry, timeout int64,
		withSyncResult bool) (*common.TxResponse, error)
	MultiSignContractReqWithPayer(payload *common.Payload, endorsers []*common.EndorsementEntry,
		payer *common.EndorsementEntry, timeout int64, withSyncResult bool) (*common.TxResponse, error)
12.2 发起多签投票

参数说明

  • payload: 待签名payload
  • endorser: 投票人对多签请求 payload 的签名信息
  • isAgree: 投票人对多签请求是否同意,true为同意,false则反对
  • timeout: 超时时间,单位:s,若传入-1,将使用默认超时时间:10s
  • withSyncResult: 是否同步获取交易执行结果 当为true时,若成功调用,common.TxResponse.ContractResult.Result为common.TransactionInfo 当为false时,若成功调用,common.TxResponse.ContractResult为空,可以通过common.TxResponse.TxId查询交易结果
  • payer: 指定gas代扣账户
	MultiSignContractVote(payload *common.Payload, endorser *common.EndorsementEntry, isAgree bool,
		timeout int64, withSyncResult bool) (*common.TxResponse, error)
	MultiSignContractVoteWithGasLimit(payload *common.Payload, endorser *common.EndorsementEntry, isAgree bool,
		timeout int64, gasLimit uint64, withSyncResult bool) (*common.TxResponse, error)
	MultiSignContractVoteWithGasLimitAndPayer(payload *common.Payload, endorser *common.EndorsementEntry,
		payer *common.EndorsementEntry, isAgree bool, timeout int64, gasLimit uint64,
		withSyncResult bool) (*common.TxResponse, error)
12.3 根据txId查询多签状态

参数说明

  • txId: 需要查询的多签请求交易Id
  • params: 格式化参数
	MultiSignContractQuery(txId string) (*common.TxResponse, error)
	MultiSignContractQueryWithParams(txId string, params []*common.KeyValuePair) (*common.TxResponse, error)
12.4 触发执行多签请求

参数说明

  • payload: 待签名payload
  • timeout: 超时时间,单位:s,若传入-1,将使用默认超时时间:10s
  • limit: 本次执行多签请求支付的 gas 上限
  • withSyncResult: 是否同步获取交易执行结果 当为true时,若成功调用,common.TxResponse.ContractResult.Result为common.TransactionInfo 当为false时,若成功调用,common.TxResponse.ContractResult为空,可以通过common.TxResponse.TxId查询交易结果
  • payer: 指定gas代扣账户
	MultiSignContractTrig(multiSignReqPayload *common.Payload,
		timeout int64, limit *common.Limit, withSyncResult bool) (*common.TxResponse, error)
	MultiSignContractTrigWithPayer(multiSignReqPayload *common.Payload, payer *common.EndorsementEntry,
		timeout int64, limit *common.Limit, withSyncResult bool) (*common.TxResponse, error)
12.5 根据发起多签请求所需的参数构建payload

参数说明

  • pairs: 发起多签请求所需的参数
  • gasLimit: 本次交易允许消费的最大gas, 0代表无限制
	CreateMultiSignReqPayload(pairs []*common.KeyValuePair) *common.Payload
	CreateMultiSignReqPayloadWithGasLimit(pairs []*common.KeyValuePair, gasLimit uint64) *common.Payload

13 gas管理相关接口

13.1 构造设置gas管理员Payload

参数说明

  • address: gas管理员的地址
	CreateSetGasAdminPayload(address string) (*common.Payload, error)
13.2 查询gas管理员

返回值说明

  • string: gas管理员的账号地址
	GetGasAdmin() (string, error)
13.3 构造充值gas账户Payload

参数说明

  • rechargeGasList: 一个或多个gas账户充值指定gas数量
	CreateRechargeGasPayload(rechargeGasList []*syscontract.RechargeGas) (*common.Payload, error)
13.4 查询gas账户余额

参数说明

  • address: 查询gas余额的账户地址
	GetGasBalance(address string) (int64, error)
13.5 构造退还gas账户Payload

参数说明

  • address: 退还gas的账户地址
  • amount: 退还gas的数量
	CreateRefundGasPayload(address string, amount int64) (*common.Payload, error)
13.6 构造冻结指定gas账户Payload

参数说明

  • address: 冻结指定gas账户的账户地址
	CreateFrozenGasAccountPayload(address string) (*common.Payload, error)
13.7 构造解冻指定gas账户Payload

参数说明

  • address: 解冻指定gas账户的账户地址
	CreateUnfrozenGasAccountPayload(address string) (*common.Payload, error)
13.8 查询gas账户的状态

参数说明

  • address: 解冻指定gas账户的账户地址 返回值说明
  • bool: true表示账号未被冻结,false表示账号已被冻结
	GetGasAccountStatus(address string) (bool, error)
13.9 发送gas管理类请求

参数说明

  • payload: 交易payload
  • endorsers: 背书签名信息列表
  • timeout: 超时时间,单位:s,若传入-1,将使用默认超时时间:10s
  • withSyncResult: 是否同步获取交易执行结果 当为true时,若成功调用,common.TxResponse.ContractResult.Result为common.TransactionInfo 当为false时,若成功调用,common.TxResponse.ContractResult为空,可以通过common.TxResponse.TxId查询交易结果
	SendGasManageRequest(payload *common.Payload, endorsers []*common.EndorsementEntry, timeout int64,
		withSyncResult bool) (*common.TxResponse, error)
13.10 为payload添加gas limit

参数说明

  • payload: 交易payload
  • limit: transaction limitation,执行交易时的资源消耗上限
	AttachGasLimit(payload *common.Payload, limit *common.Limit) *common.Payload
13.11 估算交易的gas消耗量

参数说明

  • payload: 待估算gas消耗量的交易payload 返回值说明
  • uint64: 估算出的gas消耗量
	EstimateGas(payload *common.Payload) (uint64, error)
13.12 构造配置账户基础gas消耗数量Payload

参数说明

  • amount: 调用合约消耗的基础的 gas 数量
	CreateSetInvokeBaseGasPayload(invokeBaseGas int64) (*common.Payload, error)
13.13 设置链配置的 default gas_price 参数

参数说明

  • invokeGasPrice: 调用合约中所带参数消耗的每个字节的 gas 价格,支持格式为10进制整数|小数
	CreateSetInvokeGasPricePayload(invokeGasPrice string) (*common.Payload, error)
13.14 设置链配置的 install_base gas 参数

参数说明

  • amount: 安装|升级合约消耗的基础的 gas 数量
	CreateSetInstallBaseGasPayload(installBaseGas int64) (*common.Payload, error)
13.15 设置链配置的 install gas_price 参数

参数说明

  • invokeGasPrice: 安装|升级合约中所带参数消耗的每个字节的 gas 价格,支持格式为10进制整数|小数
	CreateSetInstallGasPricePayload(installGasPrice string) (*common.Payload, error)

14 别名相关接口

14.1 添加别名
	AddAlias() (*common.TxResponse, error)
14.2 构造更新别名的证书Payload

参数说明

  • alias: 带更新证书的别名
  • newCertPEM: 新的证书,此新证书将替换掉alias关联的证书
	CreateUpdateCertByAliasPayload(alias, newCertPEM string) *common.Payload
14.3 签名更新别名的证书Payload

参数说明

  • payload: 交易payload
	SignUpdateCertByAliasPayload(payload *common.Payload) (*common.EndorsementEntry, error)
14.4 发起更新别名的证书交易

参数说明

  • payload: 交易payload
  • endorsers: 背书签名信息列表
  • timeout: 超时时间,单位:s,若传入-1,将使用默认超时时间:10s
  • withSyncResult: 是否同步获取交易执行结果 当为true时,若成功调用,common.TxResponse.ContractResult.Result为common.TransactionInfo 当为false时,若成功调用,common.TxResponse.ContractResult为空,可以通过common.TxResponse.TxId查询交易结果
	UpdateCertByAlias(payload *common.Payload, endorsers []*common.EndorsementEntry,
		timeout int64, withSyncResult bool) (*common.TxResponse, error)
14.5 查询别名详细信息

参数说明

  • aliases: 带查询的证书别名切片,根据这些别名查询返回AliasInfos
	QueryCertsAlias(aliases []string) (*common.AliasInfos, error)
14.6 构造删除别名Payload

参数说明

  • aliases: 带删除的证书别名切片
	CreateDeleteCertsAliasPayload(aliases []string) *common.Payload
14.7 签名删除别名Payload

参数说明

  • payload: 交易payload
	SignDeleteAliasPayload(payload *common.Payload) (*common.EndorsementEntry, error)
14.8 发起删除别名交易

参数说明

  • payload: 交易payload
  • endorsers: 背书签名信息列表
  • timeout: 超时时间,单位:s,若传入-1,将使用默认超时时间:10s
  • withSyncResult: 是否同步获取交易执行结果 当为true时,若成功调用,common.TxResponse.ContractResult.Result为common.TransactionInfo 当为false时,若成功调用,common.TxResponse.ContractResult为空,可以通过common.TxResponse.TxId查询交易结果
	DeleteCertsAlias(payload *common.Payload, endorsers []*common.EndorsementEntry,
		timeout int64, withSyncResult bool) (*common.TxResponse, error)

15 交易池相关接口

15.1 获取交易池状态
	GetPoolStatus() (*txpool.TxPoolStatus, error)
15.2 获取不同交易类型和阶段中的交易Id列表

参数说明

  • txType: 交易类型 在pb的txpool包中进行了定义
  • txStage: 交易阶段 在pb的txpool包中进行了定义 返回值说明
  • []string: 交易Id列表
	GetTxIdsByTypeAndStage(txType txpool.TxType, txStage txpool.TxStage) ([]string, error)
15.3 根据txIds获取交易池中存在的txs,并返回交易池缺失的tx的txIds

参数说明

  • txIds: 交易Id列表 返回值说明
  • []*common.Transaction: 交易池中存在的txs
  • []string: 交易池缺失的tx的txIds
	GetTxsInPoolByTxIds(txIds []string) ([]*common.Transaction, []string, error)
15.4 根据txId查询交易的状态

参数说明

  • txId: 交易Id 返回值说明
  • txpool.TxStatus: 交易状态
	GetTxStatus(txId string) (txpool.TxStatus, error)
15.5 获取所有共识节点的身份标识

返回值说明

  • []string: 共识节点身份标识
  • err: 当查询的节点非共识节点时或共识节点内部查询中出现错误,返回error
	GetConsensusValidators() ([]string, error)
15.6 获取节点正在共识的区块高度

返回值说明

  • uint64: 节点正在共识的区块高度
  • err: 当查询的节点非共识节点时或共识节点内部查询中出现错误,返回error
	GetConsensusHeight() (uint64, error)
15.7 获取共识节点的状态

返回值说明

  • []byte: 查询的共识节点状态
  • err: 当查询的节点非共识节点时或共识节点内部查询中出现错误,返回error
	GetConsensusStateJSON() ([]byte, error)
15.8 构造raft切换到tbft Payload

参数说明

  • extConfig: 应用到tbft共识的ext_config
	CreateRaftToTbftPayload(extConfig []*common.KeyValuePair) (*common.Payload, error)
15.9 构造tbft切换到raft Payload

参数说明

  • extConfig: 应用到raft共识的ext_config
	CreateTbftToRaftPayload(extConfig []*common.KeyValuePair) (*common.Payload, error)

16 DPoS相关接口

16.1 增发
	Mint(address string, amount string) (*common.Payload, error)
16.2 转账
	Transfer(address string, amount string) (*utils.BigInteger, error)
16.3 查询账户余额
	BalanceOf(address string) (*utils.BigInteger, error)
16.4 转移管理员权限
	TransferOwnership(address string) (*common.Payload, error)
16.5 查询合约管理地址
	Owner() (string, error)
16.6 查询ERC20合约的精度
	Decimals() (string, error)
16.7 查询Token总供应量
	Total() (string, error)
16.8 查询所有的候选人
	GetAllCandidates() (*syscontract.ValidatorVector, error)
16.9 查询指定验证人的信息
	GetValidatorByAddress(address string) (*syscontract.Validator, error)
16.10 抵押权益到验证人
	Delegate(to string, value string) (*syscontract.Delegation, error)
16.11 查询指定地址的抵押信息
	GetDelegationsByAddress(address string) (*syscontract.DelegationInfo, error)
16.12 查询指定地址的抵押信息
	GetUserDelegationByValidator(delegator string, validator string) (*syscontract.Delegation, error)
16.13 从验证人解除抵押的权益
	UnDelegate(from string, value string) (*syscontract.UnbondingDelegation, error)
16.14 根据世代id查询世代信息
	GetEpochById(id string) (*syscontract.Epoch, error)
16.15 查询当前世代信息
	GetLastEpoch() (*syscontract.Epoch, error)
16.16 Stake合约中设置验证人的NodeID
	SetNodeId(nodeId string) (string, error)
16.17 Stake合约中查询验证人的NodeID
	GetNodeId(address string) (string, error)
16.18 获取设置的最小质押数量
	GetMinSelfDelegation() (int, error)
16.19 查看世代中区块数
	GetEpochValidatorNumber() (int, error)
16.20 查看世代中区块数
	GetEpochBlockNumber() (int, error)
16.21 查询Stake合约的系统地址
	GetStakeContractAddress() (string, error)
16.22 查询收到解质押退款间隔的世代数
	GetUnboundingIntervalEpochNumber() (string, error)
16.23 查询当前世代中每出一个块激励的权益数
	GetDistributionPerBlock() (int, error)
16.24 修改世代中每个块激励的权益数
	SetDistributionPerBlock(distributionPerBlock int) (*common.Payload, error)
16.25 查询当前世代中gas兑换比例
	GetGasExchangeRate() (int, error)
16.26 修改世代中gas兑换比例
	SetGasExchangeRate(gasExchangeRate int) (*common.Payload, error)
16.27 查询世代中激励明细
	GetDistributionByEpochId(epochId string) (*EpochAmountDetail, error)
16.28 同时修改世代出块数量和世代验证者数量
	SetEpochBlockNumberAndValidatorNumber(
		epochBlockNumber int,
		epochValidatorNumber int) (*common.Payload, error)
16.29 查询惩罚账户余额
	GetSlashingBalance() (string, error)
16.30 查询惩罚账户地址
	GetSlashingAddress() (string, error)
16.31 查询世代中惩罚明细
	GetSlashingByEpochId(epochId string) (*SlashingDetail, error)

Documentation

Overview

Package chainmaker_sdk_go define chainmaker sdk go

Index

Constants

View Source
const (
	// KEY_ALIAS key of alias
	KEY_ALIAS = "alias"
	// KEY_ALIASES key of aliases
	KEY_ALIASES = "aliases"
	// KEY_CERT key of cert
	KEY_CERT = "cert"
)
View Source
const (
	// MaxConnCnt 单ChainMaker节点最大连接数
	MaxConnCnt = 1024
	// DefaultGetTxTimeout 查询交易超时时间
	DefaultGetTxTimeout = 10
	// DefaultSendTxTimeout 发送交易超时时间
	DefaultSendTxTimeout = 10
	// DefaultRpcClientMaxReceiveMessageSize 默认grpc客户端接收message最大值 4M
	DefaultRpcClientMaxReceiveMessageSize = 4
	// DefaultRpcClientMaxSendMessageSize 默认grpc客户端发送message最大值 4M
	DefaultRpcClientMaxSendMessageSize = 4
)
View Source
const (
	// HibeMsgKey as a payload parameter
	HibeMsgKey = "hibe_msg"

	// HibeMsgIdKey Key as a hibeMsgMap parameter
	HibeMsgIdKey = "tx_id"

	// HibeMsgCipherTextKey Key as a hibeMsgMap parameter
	// The value of the key (CT) is the hibe_msg's message (ciphertext)
	HibeMsgCipherTextKey = "CT"

	// HibeParamsKey The value of the key (org_id) is the unique identifier of a HIBE params
	HibeParamsKey = "org_id"

	// HibeParamsValueKey The value of the key (params) is the Hibe's params
	HibeParamsValueKey = "params"
)

hibe msg's Keys

View Source
const ContractResultCode_OK uint32 = 0 //todo pb create const

ContractResultCode_OK ContractResultCode_OK

View Source
const (
	// DefaultAuthType is default cert auth type
	DefaultAuthType = ""
)
View Source
const (
	// ZXLAddressPrefix define zhixinlian address prefix
	ZXLAddressPrefix = "ZX"
)

Variables

View Source
var AuthTypeToStringMap = map[AuthType]string{
	PermissionedWithCert: "permissionedwithcert",
	PermissionedWithKey:  "permissionedwithkey",
	Public:               "public",
}

AuthTypeToStringMap define auth type to string map

View Source
var StringToAuthTypeMap = map[string]AuthType{
	"permissionedwithcert": PermissionedWithCert,
	"permissionedwithkey":  PermissionedWithKey,
	"public":               Public,
}

StringToAuthTypeMap define string to auth type map

Functions

func GetCMAddressFromCertPEM

func GetCMAddressFromCertPEM(certPEM string) (string, error)

GetCMAddressFromCertPEM get chainmaker address from cert pem

func GetCMAddressFromCertPath

func GetCMAddressFromCertPath(certPath string) (string, error)

GetCMAddressFromCertPath get chainmaker address from cert file path

func GetCMAddressFromPKHex

func GetCMAddressFromPKHex(pkHex string, hashType crypto.HashType) (string, error)

GetCMAddressFromPKHex get chainmaker address from public key hex

func GetCMAddressFromPKPEM

func GetCMAddressFromPKPEM(pkPEM string, hashType crypto.HashType) (string, error)

GetCMAddressFromPKPEM get chainmaker address from public key pem

func GetEVMAddressFromCertBytes

func GetEVMAddressFromCertBytes(certBytes []byte) (string, error)

GetEVMAddressFromCertBytes get evm address from cert bytes

func GetEVMAddressFromCertPath

func GetEVMAddressFromCertPath(certFilePath string) (string, error)

GetEVMAddressFromCertPath get evm address from cert file path

func GetEVMAddressFromPKHex

func GetEVMAddressFromPKHex(pkHex string, hashType crypto.HashType) (string, error)

GetEVMAddressFromPKHex get evm address from public key hex

func GetEVMAddressFromPKPEM

func GetEVMAddressFromPKPEM(pkPEM string, hashType crypto.HashType) (string, error)

GetEVMAddressFromPKPEM get evm address from public key pem

func GetEVMAddressFromPrivateKeyBytes

func GetEVMAddressFromPrivateKeyBytes(privateKeyBytes []byte, hashType crypto.HashType) (string, error)

GetEVMAddressFromPrivateKeyBytes get evm address from private key bytes

func GetEVMAddressFromPrivateKeyPath

func GetEVMAddressFromPrivateKeyPath(privateKeyFilePath string, hashType crypto.HashType) (string, error)

GetEVMAddressFromPrivateKeyPath get evm address from private key file path

func GetP11Handle

func GetP11Handle() interface{}

GetP11Handle get global thread-safe pkcs11 handler returns:

  • interface{}

func GetZXAddressFromCertPEM

func GetZXAddressFromCertPEM(certPEM string) (string, error)

GetZXAddressFromCertPEM get zhixinlian address from cert pem

func GetZXAddressFromCertPath

func GetZXAddressFromCertPath(certPath string) (string, error)

GetZXAddressFromCertPath get zhixinlian address from cert file path

func GetZXAddressFromPKHex

func GetZXAddressFromPKHex(pkHex string, hashType crypto.HashType) (string, error)

GetZXAddressFromPKHex get zhixinlian address from public key hex

func GetZXAddressFromPKPEM

func GetZXAddressFromPKPEM(pkPEM string, hashType crypto.HashType) (string, error)

GetZXAddressFromPKPEM get zhixinlian address from public key pem

func KMSEnabled

func KMSEnabled() bool

KMSEnabled return if kms is enabled returns:

  • bool

func NewCanonicalTxFetcherPools

func NewCanonicalTxFetcherPools(config *ChainClientConfig) (map[string]ConnectionPool, error)

NewCanonicalTxFetcherPools 创建连接池 args:

  • *ChainClientConfig

returns:

  • map[string]ConnectionPool
  • error

func SM3 added in v3.0.1

func SM3(data []byte) (string, error)

SM3 sum of data in SM3, returns sum hex

func SignPayload

func SignPayload(keyPem, certPem []byte, payload *common.Payload) (*common.EndorsementEntry, error)

SignPayload sign payload Deprecated: use ./utils.MakeEndorserWithPem

func SignPayloadWithPath

func SignPayloadWithPath(keyFilePath, crtFilePath string, payload *common.Payload) (*common.EndorsementEntry, error)

SignPayloadWithPath use key/cert file path to sign payload Deprecated: SignPayloadWithPath use ./utils.MakeEndorserWithPath instead.

Types

type AmountByRate

type AmountByRate map[string]string

AmountByRate 按照质押比例计算的金额

type ArchiveCenterConfig added in v3.0.1

type ArchiveCenterConfig struct {
	ChainGenesisHash     string //
	ArchiveCenterHttpUrl string
	ReqeustSecondLimit   int // http请求的超时间隔,默认5秒
	RpcAddress           string
	TlsEnable            bool
	Tls                  utils.TlsConfig
	MaxSendMsgSize       int
	MaxRecvMsgSize       int
}

ArchiveCenterConfig 定义归档中心配置

func NewArchiveCenterConfig added in v3.0.1

func NewArchiveCenterConfig(httpUrl, rpcUrl, chainGenesisHash string,
	requestSecondLimit, maxRpcSend, maxRpcRecv int, tlsEnable bool, tlsCfg utils.TlsConfig) *ArchiveCenterConfig

NewArchiveCenterConfig 根据传入参数创建新的归档中心对象 @param httpUrl @param chainGenesisHash @param requestSecondLimit @return *ArchiveCenterHttpConfig

type ArchiveCenterGrpcClient added in v3.0.1

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

ArchiveCenterGrpcClient 归档服务的归档中心GRPC客户端实现

func NewArchiveCenterGrpcClient added in v3.0.1

func NewArchiveCenterGrpcClient(config *ArchiveCenterConfig, log utils.Logger) *ArchiveCenterGrpcClient

NewArchiveCenterGrpcClient 构造ArchiveCenterGrpcClient @param config @param log @return *ArchiveCenterGrpcClient

func (*ArchiveCenterGrpcClient) ArchiveBlock added in v3.0.1

func (a *ArchiveCenterGrpcClient) ArchiveBlock(block *common.BlockInfo) error

ArchiveBlock 向归档中心提交一个归档区块 @param block @return error

func (*ArchiveCenterGrpcClient) ArchiveBlocks added in v3.0.1

func (a *ArchiveCenterGrpcClient) ArchiveBlocks(bi BlockIterator,
	heightNoticeCallback func(ProcessMessage) error) error

ArchiveBlocks 向归档中心Stream提交要归档的区块 @param bi @return error

func (*ArchiveCenterGrpcClient) ArchiveCenterConfig added in v3.0.1

func (a *ArchiveCenterGrpcClient) ArchiveCenterConfig() *ArchiveCenterConfig

ArchiveCenterConfig 获得配置参数 @return *ArchiveCenterConfig

func (*ArchiveCenterGrpcClient) Close added in v3.0.1

func (client *ArchiveCenterGrpcClient) Close() error

Close 关闭连接 @return error

func (*ArchiveCenterGrpcClient) GetArchivedStatus added in v3.0.1

func (a *ArchiveCenterGrpcClient) GetArchivedStatus() (archivedHeight uint64, inArchive bool, code uint32, err error)

GetArchivedStatus 获得归档中心的归档状态 @return archivedHeight @return inArchive @return code @return err

func (*ArchiveCenterGrpcClient) GetBlockByHash added in v3.0.1

func (a *ArchiveCenterGrpcClient) GetBlockByHash(blockHash string, withRWSet bool) (*common.BlockInfo, error)

GetBlockByHash 根据Hash获得区块 @param blockHash @param withRWSet @return *common.BlockInfo @return error

func (*ArchiveCenterGrpcClient) GetBlockByHeight added in v3.0.1

func (a *ArchiveCenterGrpcClient) GetBlockByHeight(blockHeight uint64, withRWSet bool) (*common.BlockInfo, error)

GetBlockByHeight 根据高度获得区块 @param blockHeight @param withRWSet @return *common.BlockInfo @return error

func (*ArchiveCenterGrpcClient) GetBlockByTxId added in v3.0.1

func (a *ArchiveCenterGrpcClient) GetBlockByTxId(txId string, withRWSet bool) (*common.BlockInfo, error)

GetBlockByTxId 根据TxId获得所在区块 @param txId @param withRWSet @return *common.BlockInfo @return error

func (*ArchiveCenterGrpcClient) GetChainConfigByBlockHeight added in v3.0.1

func (a *ArchiveCenterGrpcClient) GetChainConfigByBlockHeight(blockHeight uint64) (*config.ChainConfig, error)

GetChainConfigByBlockHeight 获得链配置 @param blockHeight @return *config.ChainConfig @return error

func (*ArchiveCenterGrpcClient) GetTxByTxId added in v3.0.1

func (a *ArchiveCenterGrpcClient) GetTxByTxId(txId string) (*common.TransactionInfo, error)

GetTxByTxId 根据TxId获得交易 @param txId @return *common.TransactionInfo @return error

func (*ArchiveCenterGrpcClient) GetTxWithRWSetByTxId added in v3.0.1

func (a *ArchiveCenterGrpcClient) GetTxWithRWSetByTxId(txId string) (*common.TransactionInfoWithRWSet, error)

GetTxWithRWSetByTxId 根据TxId获得交易和读写集 @param txId @return *common.TransactionInfoWithRWSet @return error

func (*ArchiveCenterGrpcClient) GrpcCallOption added in v3.0.1

func (client *ArchiveCenterGrpcClient) GrpcCallOption() []grpc.CallOption

GrpcCallOption Grpc选项 @return []grpc.CallOption

func (*ArchiveCenterGrpcClient) Register added in v3.0.1

func (a *ArchiveCenterGrpcClient) Register(genesisBlock *common.BlockInfo) error

Register 将创世区块注册到归档中心 @param genesisBlock @return error

type ArchiveCenterHttpClient added in v3.0.1

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

ArchiveCenterHttpClient 归档服务的归档中心HTTP客户端实现,只读

func NewArchiveCenterHttpClient added in v3.0.1

func NewArchiveCenterHttpClient(config *ArchiveCenterConfig, log utils.Logger) *ArchiveCenterHttpClient

NewArchiveCenterHttpClient ArchiveCenterHttpClient构造函数 @param config @param log @return *ArchiveCenterHttpClient

func (*ArchiveCenterHttpClient) ArchiveBlock added in v3.0.1

func (a *ArchiveCenterHttpClient) ArchiveBlock(block *common.BlockInfo) error

ArchiveBlock 只读查询,不支持归档区块 @param block @return error

func (*ArchiveCenterHttpClient) ArchiveBlocks added in v3.0.1

func (a *ArchiveCenterHttpClient) ArchiveBlocks(bi BlockIterator, _ func(ProcessMessage) error) error

ArchiveBlocks 只读查询,不支持归档区块 @param bi @return error

func (*ArchiveCenterHttpClient) ArchiveCenterConfig added in v3.0.1

func (a *ArchiveCenterHttpClient) ArchiveCenterConfig() *ArchiveCenterConfig

ArchiveCenterConfig 获得归档中心配置 @return *ArchiveCenterConfig

func (*ArchiveCenterHttpClient) Close added in v3.0.1

func (_ *ArchiveCenterHttpClient) Close() error

Close 关闭 @return error

func (*ArchiveCenterHttpClient) GetArchivedStatus added in v3.0.1

func (a *ArchiveCenterHttpClient) GetArchivedStatus() (archivedHeight uint64, inArchive bool, code uint32, err error)

GetArchivedStatus 获得归档中心状态 @return archivedHeight @return inArchive @return code @return err

func (*ArchiveCenterHttpClient) GetBlockByHash added in v3.0.1

func (a *ArchiveCenterHttpClient) GetBlockByHash(blockHash string, withRWSet bool) (*common.BlockInfo, error)

GetBlockByHash 根据Hash获得区块 @param blockHash @param withRWSet @return *common.BlockInfo @return error

func (*ArchiveCenterHttpClient) GetBlockByHeight added in v3.0.1

func (a *ArchiveCenterHttpClient) GetBlockByHeight(blockHeight uint64, withRWSet bool) (*common.BlockInfo, error)

GetBlockByHeight 根据高度获得区块 @param blockHeight @param withRWSet @return *common.BlockInfo @return error

func (*ArchiveCenterHttpClient) GetBlockByTxId added in v3.0.1

func (a *ArchiveCenterHttpClient) GetBlockByTxId(txId string, withRWSet bool) (*common.BlockInfo, error)

GetBlockByTxId 根据TxId获得区块 @param txId @param withRWSet @return *common.BlockInfo @return error

func (*ArchiveCenterHttpClient) GetChainConfigByBlockHeight added in v3.0.1

func (a *ArchiveCenterHttpClient) GetChainConfigByBlockHeight(blockHeight uint64) (*config.ChainConfig, error)

GetChainConfigByBlockHeight 根据高度获得链配置 @param blockHeight @return *config.ChainConfig @return error

func (*ArchiveCenterHttpClient) GetTxByTxId added in v3.0.1

func (a *ArchiveCenterHttpClient) GetTxByTxId(txId string) (*common.TransactionInfo, error)

GetTxByTxId 根据TxId获得交易 @param txId @return *common.TransactionInfo @return error

func (*ArchiveCenterHttpClient) GetTxWithRWSetByTxId added in v3.0.1

func (a *ArchiveCenterHttpClient) GetTxWithRWSetByTxId(txId string) (*common.TransactionInfoWithRWSet, error)

GetTxWithRWSetByTxId 根据TxId获得交易和读写集 @param txId @return *common.TransactionInfoWithRWSet @return error

func (*ArchiveCenterHttpClient) Register added in v3.0.1

func (a *ArchiveCenterHttpClient) Register(genesis *common.BlockInfo) error

Register 只读查询,不支持注册 @param genesis @return error

type ArchiveCenterQueryParam added in v3.0.1

type ArchiveCenterQueryParam struct {
	ChainGenesisHash string `json:"chain_genesis_hash,omitempty"`
	Start            uint64 `json:"start,omitempty"`
	End              uint64 `json:"end,omitempty"`
	BlockHash        string `json:"block_hash,omitempty"`
	Height           uint64 `json:"height,omitempty"`
	TxId             string `json:"tx_id,omitempty"`
	WithRwSet        bool   `json:"with_rwset,omitempty"`
	TruncateLength   int    `json:"truncate_length,omitempty"`
	TruncateModel    string `json:"truncate_model,omitempty"`
}

ArchiveCenterQueryParam 定义归档中心通用请求头

type ArchiveCenterResponse added in v3.0.1

type ArchiveCenterResponse struct {
	Code     int    `json:"code"` // 错误码,0代表成功.其余代表失败
	ErrorMsg string `json:"errorMsg"`
}

ArchiveCenterResponse 定义了归档中心通用返回头信息

type ArchiveCenterResponseBlockHeader added in v3.0.1

type ArchiveCenterResponseBlockHeader struct {
	ArchiveCenterResponse
	Data *common.BlockHeader `json:"data"`
}

ArchiveCenterResponseBlockHeader 定义区块头返回结构

type ArchiveCenterResponseBlockInfo added in v3.0.1

type ArchiveCenterResponseBlockInfo struct {
	ArchiveCenterResponse
	Data *common.BlockInfo `json:"data"`
}

ArchiveCenterResponseBlockInfo 定义区块返回结构

type ArchiveCenterResponseBlockWithRwSet added in v3.0.1

type ArchiveCenterResponseBlockWithRwSet struct {
	ArchiveCenterResponse
	Data *common.BlockInfo `json:"data"`
}

ArchiveCenterResponseBlockWithRwSet 定义带读写集区块

type ArchiveCenterResponseChainConfig added in v3.0.1

type ArchiveCenterResponseChainConfig struct {
	ArchiveCenterResponse
	Data *config.ChainConfig `json:"data"`
}

ArchiveCenterResponseChainConfig 定义链配置返回结构

type ArchiveCenterResponseHeight added in v3.0.1

type ArchiveCenterResponseHeight struct {
	ArchiveCenterResponse
	Data *uint64 `json:"data"`
}

ArchiveCenterResponseHeight 定义块高返回结构

type ArchiveCenterResponseMerklePath added in v3.0.1

type ArchiveCenterResponseMerklePath struct {
	ArchiveCenterResponse
	Data []byte `json:"data"`
}

ArchiveCenterResponseMerklePath 定义merkle path 返回结构

type ArchiveCenterResponseTransaction added in v3.0.1

type ArchiveCenterResponseTransaction struct {
	ArchiveCenterResponse
	Data *common.TransactionInfo `json:"data"`
}

ArchiveCenterResponseTransaction 定义交易返回结构

type ArchiveCenterResponseTransactionWithRwSet added in v3.0.1

type ArchiveCenterResponseTransactionWithRwSet struct {
	ArchiveCenterResponse
	Data *common.TransactionInfoWithRWSet `json:"data"`
}

ArchiveCenterResponseTransactionWithRwSet 定义读写集交易

type ArchiveConfig

type ArchiveConfig struct {
	Dest string
	// contains filtered or unexported fields
}

ArchiveConfig Archive配置

func NewArchiveConfig

func NewArchiveConfig(opts ...ArchiveOption) *ArchiveConfig

NewArchiveConfig new archive config args:

  • ...ArchiveOption

returns:

  • *ArchiveConfig

type ArchiveMySqlClient added in v3.0.1

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

ArchiveMySqlClient 归档服务的MySQL客户端实现

func NewArchiveMySqlClient added in v3.0.1

func NewArchiveMySqlClient(chainId string, config *ArchiveConfig, cc SDKInterface,
	log utils.Logger) *ArchiveMySqlClient

NewArchiveMySqlClient creates a new ArchiveMySqlClient @param chainId @param config @param cc @param log @return *ArchiveMySqlClient

func NewArchiveMySqlClient2 added in v3.0.1

func NewArchiveMySqlClient2(chainId, dbDest string, secretKey string, cc SDKInterface,
	log utils.Logger) *ArchiveMySqlClient

NewArchiveMySqlClient2 creates a new ArchiveMySqlClient @param chainId @param dbDest @param secretKey @param cc @param log @return *ArchiveMySqlClient

func (*ArchiveMySqlClient) ArchiveBlock added in v3.0.1

func (a *ArchiveMySqlClient) ArchiveBlock(block *common.BlockInfo) error

ArchiveBlock 归档一个区块 @param block @return error

func (*ArchiveMySqlClient) ArchiveBlocks added in v3.0.1

func (a *ArchiveMySqlClient) ArchiveBlocks(bi BlockIterator, heightNoticeCallback func(ProcessMessage) error) error

ArchiveBlocks 归档多个区块 @param bi @param heightNoticeCallback @return error

func (*ArchiveMySqlClient) Close added in v3.0.1

func (a *ArchiveMySqlClient) Close() error

Close 关闭与归档数据源的链接 @return err

func (*ArchiveMySqlClient) GetArchivedStatus added in v3.0.1

func (a *ArchiveMySqlClient) GetArchivedStatus() (archivedHeight uint64, inArchive bool, code uint32, err error)

GetArchivedStatus get archived status @return archivedHeight @return inArchive @return code @return err

func (*ArchiveMySqlClient) GetBlockByHash added in v3.0.1

func (a *ArchiveMySqlClient) GetBlockByHash(blockHash string, withRWSet bool) (*common.BlockInfo, error)

GetBlockByHash get block by hash @param blockHash @param withRWSet @return *common.BlockInfo @return error

func (*ArchiveMySqlClient) GetBlockByHeight added in v3.0.1

func (a *ArchiveMySqlClient) GetBlockByHeight(height uint64, withRWSet bool) (*common.BlockInfo, error)

GetBlockByHeight get block by height @param height @param withRWSet @return *common.BlockInfo @return error

func (*ArchiveMySqlClient) GetBlockByTxId added in v3.0.1

func (a *ArchiveMySqlClient) GetBlockByTxId(txId string, withRWSet bool) (*common.BlockInfo, error)

GetBlockByTxId get block by txId @param txId @param withRWSet @return *common.BlockInfo @return error

func (*ArchiveMySqlClient) GetChainConfigByBlockHeight added in v3.0.1

func (a *ArchiveMySqlClient) GetChainConfigByBlockHeight(blockHeight uint64) (*config.ChainConfig, error)

GetChainConfigByBlockHeight get chain config by block height @param blockHeight @return *config.ChainConfig @return error

func (*ArchiveMySqlClient) GetTxByTxId added in v3.0.1

func (a *ArchiveMySqlClient) GetTxByTxId(txId string) (*common.TransactionInfo, error)

GetTxByTxId get transaction by txId @param txId @return *common.TransactionInfo @return error

func (*ArchiveMySqlClient) GetTxWithRWSetByTxId added in v3.0.1

func (a *ArchiveMySqlClient) GetTxWithRWSetByTxId(txId string) (*common.TransactionInfoWithRWSet, error)

GetTxWithRWSetByTxId get transaction with rwset by txId @param txId @return *common.TransactionInfoWithRWSet @return error

func (*ArchiveMySqlClient) Register added in v3.0.1

func (a *ArchiveMySqlClient) Register(genesis *common.BlockInfo) error

Register register archive client @param genesis @return error

type ArchiveOption

type ArchiveOption func(config *ArchiveConfig)

ArchiveOption define archive option func

func WithDest added in v3.0.1

func WithDest(dest string) ArchiveOption

WithDest 设置Archive的目标路径 @param dest @return ArchiveOption

func WithSecretKey

func WithSecretKey(key string) ArchiveOption

WithSecretKey 设置Archive的secret key args:

  • string

returns:

  • ArchiveOption

func WithType added in v3.0.1

func WithType(archiveType string) ArchiveOption

WithType 设置Archive的类型 @param archiveType @return ArchiveOption

type ArchiveService added in v3.0.1

type ArchiveService interface {

	// ## 2 系统合约接口
	// ### 2.1 根据交易Id查询交易
	// **参数说明**
	//   - txId: 交易ID
	// “`go
	GetTxByTxId(txId string) (*common.TransactionInfo, error)

	// ### 2.2 根据交易Id查询包含rwset的交易
	// **参数说明**
	//   - txId: 交易ID
	// “`go
	GetTxWithRWSetByTxId(txId string) (*common.TransactionInfoWithRWSet, error)

	// ### 2.3 根据区块高度查询区块
	// **参数说明**
	//   - blockHeight: 指定区块高度,若为-1,将返回最新区块
	//   - withRWSet: 是否返回读写集
	// “`go
	GetBlockByHeight(blockHeight uint64, withRWSet bool) (*common.BlockInfo, error)

	// ### 2.5 根据区块哈希查询区块
	// **参数说明**
	//   - blockHash: 指定区块Hash
	//   - withRWSet: 是否返回读写集
	// “`go
	GetBlockByHash(blockHash string, withRWSet bool) (*common.BlockInfo, error)

	// ### 2.6 根据交易Id查询区块
	// **参数说明**
	//   - txId: 交易ID
	//   - withRWSet: 是否返回读写集
	// “`go
	GetBlockByTxId(txId string, withRWSet bool) (*common.BlockInfo, error)

	// GetChainConfigByBlockHeight 获取指定高度的区块的配置
	// @param blockHeight
	// @return *config.ChainConfig
	// @return error
	GetChainConfigByBlockHeight(blockHeight uint64) (*config.ChainConfig, error)
	// Register 注册一个新的链到归档中心
	// @param genesis 新链的创世区块
	// @return error
	Register(genesis *common.BlockInfo) error

	// ArchiveBlock 归档一个区块
	// @param block
	// @return error
	ArchiveBlock(block *common.BlockInfo) error

	// ArchiveBlocks 传入一个区块查询的迭代器,按顺序将区块归档
	// @param bi 区块迭代器
	// @return error
	ArchiveBlocks(bi BlockIterator, heightNoticeCallback func(ProcessMessage) error) error

	// GetArchivedStatus 获得归档的状态
	// @return archivedHeight
	// @return inArchive
	// @return code
	// @return err
	GetArchivedStatus() (archivedHeight uint64, inArchive bool, code uint32, err error)

	// Close 关闭与归档数据源的链接
	// @return err
	Close() error
}

ArchiveService 归档服务

type AuthType

type AuthType uint32

AuthType define auth type of chain client

const (
	// PermissionedWithCert permissioned with certificate
	PermissionedWithCert AuthType = iota + 1

	// PermissionedWithKey permissioned with public key
	PermissionedWithKey

	// Public public key
	Public
)

type BlockIterator added in v3.0.1

type BlockIterator interface {
	// Next 是否有下一个值
	// @return bool
	Next() bool
	// Value 取值
	// @return *common.BlockInfo
	// @return error
	Value() (*common.BlockInfo, error)
	// Release 释放资源
	Release()
	// Total 总数
	// @return uint64
	Total() uint64
	// Current 当前索引
	// @return uint64
	Current() uint64
}

BlockIterator 区块查询迭代器

type CertAliasSigner

type CertAliasSigner struct {
	PrivateKey crypto.PrivateKey
	HashType   crypto.HashType
	OrgId      string
	CertAlias  string
}

CertAliasSigner define a cert alias signer in PermissionedWithCert mode

func (*CertAliasSigner) NewMember

func (signer *CertAliasSigner) NewMember() (*accesscontrol.Member, error)

NewMember new *accesscontrol.Member

func (*CertAliasSigner) Sign

func (signer *CertAliasSigner) Sign(payload *common.Payload) ([]byte, error)

Sign sign payload

type CertHashSigner

type CertHashSigner struct {
	PrivateKey crypto.PrivateKey
	HashType   crypto.HashType
	OrgId      string
	CertHash   []byte
}

CertHashSigner define a cert hash signer in PermissionedWithCert mode

func (*CertHashSigner) NewMember

func (signer *CertHashSigner) NewMember() (*accesscontrol.Member, error)

NewMember new *accesscontrol.Member

func (*CertHashSigner) Sign

func (signer *CertHashSigner) Sign(payload *common.Payload) ([]byte, error)

Sign sign payload

type CertModeSigner

type CertModeSigner struct {
	PrivateKey crypto.PrivateKey
	Cert       *bcx509.Certificate
	OrgId      string
}

CertModeSigner define a classic cert signer in PermissionedWithCert mode

func (*CertModeSigner) NewMember

func (signer *CertModeSigner) NewMember() (*accesscontrol.Member, error)

NewMember new *accesscontrol.Member

func (*CertModeSigner) Sign

func (signer *CertModeSigner) Sign(payload *common.Payload) ([]byte, error)

Sign sign payload

type ChainClient

type ChainClient struct {
	ConfigModel *utils.ChainClientConfigModel
	// contains filtered or unexported fields
}

ChainClient define chainmaker chain client to interact with node

func CreateChainClient

func CreateChainClient(pool ConnectionPool, userCrtBytes, privKey, userCrtHash []byte, orgId, chainId string,
	enabledCrtHash int) (*ChainClient, error)

CreateChainClient create chain client and init chain client, returns *ChainClient args:

  • ConnectionPool
  • []byte
  • []byte
  • []byte
  • string
  • string
  • int

returns:

  • *ChainClient
  • error

func NewChainClient

func NewChainClient(opts ...ChainClientOption) (*ChainClient, error)

NewChainClient new chain client args:

  • ...ChainClientOption

returns:

  • *ChainClient
  • error

func (*ChainClient) AddAlias

func (cc *ChainClient) AddAlias() (*common.TxResponse, error)

AddAlias add cert alias to block chain network returns:

  • *common.TxResponse
  • error

func (*ChainClient) AddCert

func (cc *ChainClient) AddCert() (*common.TxResponse, error)

AddCert add ChainClient myself cert hash to chain returns:

  • *common.TxResponse
  • error

func (*ChainClient) ArchiveBlocks added in v3.0.1

func (cc *ChainClient) ArchiveBlocks(archiveHeight uint64, mode string,
	heightNotice func(ProcessMessage) error) error

ArchiveBlocks 归档指定区块高度范围的区块 @param beginHeight @param endHeight @param mode @param heightNotice @return error

func (*ChainClient) ArchiveCenterConfig added in v3.0.1

func (cc *ChainClient) ArchiveCenterConfig() *ArchiveCenterConfig

ArchiveCenterConfig 获取归档中心的配置信息

func (*ChainClient) AttachGasLimit

func (cc *ChainClient) AttachGasLimit(payload *common.Payload, limit *common.Limit) *common.Payload

AttachGasLimit attach gas limit for payload

func (*ChainClient) BalanceOf

func (cc *ChainClient) BalanceOf(address string) (*utils.BigInteger, error)

BalanceOf 查询账户金额

func (*ChainClient) ChangeSigner

func (cc *ChainClient) ChangeSigner(signerPrivKey crypto.PrivateKey, signerCrt *bcx509.Certificate,
	publicModeHashType crypto.HashType) error

ChangeSigner change ChainClient siger. signerCrt passes nil in Public or PermissionedWithKey mode publicModeHashType must be set in Public mode else set to zero value. args:

  • crypto.PrivateKey
  • *bcx509.Certificate
  • crypto.HashType

returns:

  • error

func (*ChainClient) CheckCallerCertAuth

func (cc *ChainClient) CheckCallerCertAuth(payload string, orgIds []string, signPairs []*syscontract.SignInfo) (
	*common.TxResponse, error)

CheckCallerCertAuth CheckCallerCertAuth

func (*ChainClient) CheckNewBlockChainConfig

func (cc *ChainClient) CheckNewBlockChainConfig() error

CheckNewBlockChainConfig check chain configuration and load new chain dynamically returns:

  • error

func (*ChainClient) CreateArchiveBlockPayload

func (cc *ChainClient) CreateArchiveBlockPayload(targetBlockHeight uint64) (*common.Payload, error)

CreateArchiveBlockPayload create `archive block` payload args:

  • uint64

returns:

  • *common.Payload
  • error

func (*ChainClient) CreateCertManageFrozenPayload

func (cc *ChainClient) CreateCertManageFrozenPayload(certs []string) *common.Payload

CreateCertManageFrozenPayload create `cert manage frozen` payload args:

  • []string

returns:

  • *common.Payload

func (*ChainClient) CreateCertManagePayload

func (cc *ChainClient) CreateCertManagePayload(method string, kvs []*common.KeyValuePair) *common.Payload

CreateCertManagePayload create `cert manage` payload args:

  • string
  • []*common.KeyValuePair

returns:

  • *common.Payload

func (*ChainClient) CreateCertManageRevocationPayload

func (cc *ChainClient) CreateCertManageRevocationPayload(certCrl string) *common.Payload

CreateCertManageRevocationPayload create `cert manage revocation` payload args:

  • string

returns:

  • *common.Payload

func (*ChainClient) CreateCertManageUnfrozenPayload

func (cc *ChainClient) CreateCertManageUnfrozenPayload(certs []string) *common.Payload

CreateCertManageUnfrozenPayload create `cert manage unfrozen` payload args:

  • []string

returns:

  • *common.Payload

func (*ChainClient) CreateChainConfigAlterAddrTypePayload

func (cc *ChainClient) CreateChainConfigAlterAddrTypePayload(addrType string) (*common.Payload, error)

CreateChainConfigAlterAddrTypePayload create chain config alter address type payload args:

  • string

returns:

  • *common.Payload
  • error

func (*ChainClient) CreateChainConfigBlockUpdatePayload

func (cc *ChainClient) CreateChainConfigBlockUpdatePayload(txTimestampVerify, blockTimestampVerify bool, txTimeout,
	blockTimeout, blockTxCapacity, blockSize, blockInterval, txParamterSize uint32) (*common.Payload, error)

CreateChainConfigBlockUpdatePayload create chain config block update payload args:

  • txTimestampVerify: 是否需要开启交易时间戳校验
  • blockTimestampVerify: 是否需要开启区块头时间戳校验
  • txTimeout: 交易时间戳的过期时间(秒),其值范围为[600, +∞)
  • blockTimeout: 区块头时间戳的过期时间(秒),其值范围为[10, +∞)
  • blockTxCapacity: 区块中最大交易数,其值范围为(0, +∞]
  • blockSize: 区块最大限制,单位MB,其值范围为(0, +∞]
  • blockInterval: 出块间隔,单位:ms,其值范围为[10, +∞]
  • txParamterSize: 交易的参数的最大值限制,单位:MB,其值范围为[0,100]

returns:

  • *common.Payload
  • error

func (*ChainClient) CreateChainConfigConsensusExtAddPayload

func (cc *ChainClient) CreateChainConfigConsensusExtAddPayload(kvs []*common.KeyValuePair) (*common.Payload, error)

CreateChainConfigConsensusExtAddPayload create chain config consensus ext add payload args:

  • []*common.KeyValuePair

returns:

  • *common.Payload
  • error

func (*ChainClient) CreateChainConfigConsensusExtDeletePayload

func (cc *ChainClient) CreateChainConfigConsensusExtDeletePayload(keys []string) (*common.Payload, error)

CreateChainConfigConsensusExtDeletePayload create chain config consensus ext delete payload args:

  • []string

returns:

  • *common.Payload
  • error

func (*ChainClient) CreateChainConfigConsensusExtUpdatePayload

func (cc *ChainClient) CreateChainConfigConsensusExtUpdatePayload(kvs []*common.KeyValuePair) (*common.Payload, error)

CreateChainConfigConsensusExtUpdatePayload create chain config consensus ext update payload args:

  • []*common.KeyValuePair

returns:

  • *common.Payload
  • error

func (*ChainClient) CreateChainConfigConsensusNodeIdAddPayload

func (cc *ChainClient) CreateChainConfigConsensusNodeIdAddPayload(nodeOrgId string,
	nodeIds []string) (*common.Payload, error)

CreateChainConfigConsensusNodeIdAddPayload create chain config consensus node id add payload args:

  • string
  • []string

returns:

  • *common.Payload
  • error

func (*ChainClient) CreateChainConfigConsensusNodeIdDeletePayload

func (cc *ChainClient) CreateChainConfigConsensusNodeIdDeletePayload(nodeOrgId,
	nodeId string) (*common.Payload, error)

CreateChainConfigConsensusNodeIdDeletePayload create chain config consensus node id delete payload args:

  • string
  • string

returns:

  • *common.Payload
  • error

func (*ChainClient) CreateChainConfigConsensusNodeIdUpdatePayload

func (cc *ChainClient) CreateChainConfigConsensusNodeIdUpdatePayload(nodeOrgId, nodeOldIds,
	nodeNewIds string) (*common.Payload, error)

CreateChainConfigConsensusNodeIdUpdatePayload create chain config consensus node id update payload args:

  • string
  • string
  • string

returns:

  • *common.Payload
  • error

func (*ChainClient) CreateChainConfigConsensusNodeOrgAddPayload

func (cc *ChainClient) CreateChainConfigConsensusNodeOrgAddPayload(nodeOrgId string,
	nodeIds []string) (*common.Payload, error)

CreateChainConfigConsensusNodeOrgAddPayload create chain config consensus node org add payload args:

  • string
  • []string

returns:

  • *common.Payload
  • error

func (*ChainClient) CreateChainConfigConsensusNodeOrgDeletePayload

func (cc *ChainClient) CreateChainConfigConsensusNodeOrgDeletePayload(nodeOrgId string) (*common.Payload, error)

CreateChainConfigConsensusNodeOrgDeletePayload create chain config consensus node org delete payload args:

  • string

returns:

  • *common.Payload
  • error

func (*ChainClient) CreateChainConfigConsensusNodeOrgUpdatePayload

func (cc *ChainClient) CreateChainConfigConsensusNodeOrgUpdatePayload(nodeOrgId string,
	nodeIds []string) (*common.Payload, error)

CreateChainConfigConsensusNodeOrgUpdatePayload create chain config consensus node org update payload args:

  • string
  • []string

returns:

  • *common.Payload
  • error

func (*ChainClient) CreateChainConfigCoreUpdatePayload

func (cc *ChainClient) CreateChainConfigCoreUpdatePayload(txSchedulerTimeout,
	txSchedulerValidateTimeout uint64) (*common.Payload, error)

CreateChainConfigCoreUpdatePayload create chain config core update payload args:

  • uint64
  • uint64

returns:

  • *common.Payload
  • error

func (*ChainClient) CreateChainConfigEnableMultiSignManualRunPayload

func (cc *ChainClient) CreateChainConfigEnableMultiSignManualRunPayload(enable bool) (*common.Payload, error)

CreateChainConfigEnableMultiSignManualRunPayload create chain config for multi-sign to `enable_manual_run` flag payload args:

  • bool

returns:

  • *common.Payload
  • error

func (*ChainClient) CreateChainConfigEnableOrDisableGasPayload

func (cc *ChainClient) CreateChainConfigEnableOrDisableGasPayload() (*common.Payload, error)

CreateChainConfigEnableOrDisableGasPayload create chain config enable or disable gas payload returns:

  • *common.Payload
  • error

func (*ChainClient) CreateChainConfigOptimizeChargeGasPayload

func (cc *ChainClient) CreateChainConfigOptimizeChargeGasPayload(enable bool) (*common.Payload, error)

CreateChainConfigOptimizeChargeGasPayload create chain config optimize charge gas payload args:

  • bool

returns:

  • *common.Payload
  • error

func (*ChainClient) CreateChainConfigPermissionAddPayload

func (cc *ChainClient) CreateChainConfigPermissionAddPayload(permissionResourceName string,
	policy *accesscontrol.Policy) (*common.Payload, error)

CreateChainConfigPermissionAddPayload create chain config permission add payload args:

  • string
  • *accesscontrol.Policy

returns:

  • *common.Payload
  • error

func (*ChainClient) CreateChainConfigPermissionDeletePayload

func (cc *ChainClient) CreateChainConfigPermissionDeletePayload(resourceName string) (*common.Payload, error)

CreateChainConfigPermissionDeletePayload create chain config permission delete payload args:

  • string

returns:

  • *common.Payload
  • error

func (*ChainClient) CreateChainConfigPermissionUpdatePayload

func (cc *ChainClient) CreateChainConfigPermissionUpdatePayload(permissionResourceName string,
	policy *accesscontrol.Policy) (*common.Payload, error)

CreateChainConfigPermissionUpdatePayload create chain config permission update payload args:

  • string
  • *accesscontrol.Policy

returns:

  • *common.Payload
  • error

func (*ChainClient) CreateChainConfigTrustMemberAddPayload

func (cc *ChainClient) CreateChainConfigTrustMemberAddPayload(trustMemberOrgId, trustMemberNodeId,
	trustMemberRole, trustMemberInfo string) (*common.Payload, error)

CreateChainConfigTrustMemberAddPayload create chain config trust member add payload args:

  • string
  • string
  • string
  • string

returns:

  • *common.Payload
  • error

func (*ChainClient) CreateChainConfigTrustMemberDeletePayload

func (cc *ChainClient) CreateChainConfigTrustMemberDeletePayload(trustMemberInfo string) (*common.Payload, error)

CreateChainConfigTrustMemberDeletePayload create chain config trust member delete payload args:

  • string

returns:

  • *common.Payload
  • error

func (*ChainClient) CreateChainConfigTrustRootAddPayload

func (cc *ChainClient) CreateChainConfigTrustRootAddPayload(trustRootOrgId string,
	trustRootCrt []string) (*common.Payload, error)

CreateChainConfigTrustRootAddPayload create chain config trust root add payload args:

  • string
  • []string

returns:

  • *common.Payload
  • error

func (*ChainClient) CreateChainConfigTrustRootDeletePayload

func (cc *ChainClient) CreateChainConfigTrustRootDeletePayload(orgIdOrPKPubkeyPEM string) (*common.Payload, error)

CreateChainConfigTrustRootDeletePayload create chain config trust root delete payload args:

  • string

returns:

  • *common.Payload
  • error

func (*ChainClient) CreateChainConfigTrustRootUpdatePayload

func (cc *ChainClient) CreateChainConfigTrustRootUpdatePayload(trustRootOrgId string,
	trustRootCrt []string) (*common.Payload, error)

CreateChainConfigTrustRootUpdatePayload create chain config trust root update payload args:

  • string
  • []string

returns:

  • *common.Payload
  • error

func (*ChainClient) CreateChainConfigVMSupportListAddPayload added in v3.0.1

func (cc *ChainClient) CreateChainConfigVMSupportListAddPayload(vmType string) (*common.Payload, error)

CreateChainConfigVMSupportListAddPayload create VM support list add payload args:

  • string

returns:

  • *common.Payload
  • error

func (*ChainClient) CreateContractCreatePayload

func (cc *ChainClient) CreateContractCreatePayload(contractName, version, byteCodeStringOrFilePath string,
	runtime common.RuntimeType, kvs []*common.KeyValuePair) (*common.Payload, error)

CreateContractCreatePayload create user contract creation payload

func (*ChainClient) CreateContractFreezePayload

func (cc *ChainClient) CreateContractFreezePayload(contractName string) (*common.Payload, error)

CreateContractFreezePayload create user contract freeze payload

func (*ChainClient) CreateContractRevokePayload

func (cc *ChainClient) CreateContractRevokePayload(contractName string) (*common.Payload, error)

CreateContractRevokePayload create user contract revoke payload

func (*ChainClient) CreateContractUnfreezePayload

func (cc *ChainClient) CreateContractUnfreezePayload(contractName string) (*common.Payload, error)

CreateContractUnfreezePayload create user contract unfreeze payload

func (*ChainClient) CreateContractUpgradePayload

func (cc *ChainClient) CreateContractUpgradePayload(contractName, version, byteCodeStringOrFilePath string,
	runtime common.RuntimeType, kvs []*common.KeyValuePair) (*common.Payload, error)

CreateContractUpgradePayload create user contract upgrade payload

func (*ChainClient) CreateDeleteCertsAliasPayload

func (cc *ChainClient) CreateDeleteCertsAliasPayload(aliases []string) *common.Payload

CreateDeleteCertsAliasPayload create `delete certs alias` payload args:

  • []string

returns:

  • *common.Payload

func (*ChainClient) CreateFrozenGasAccountPayload

func (cc *ChainClient) CreateFrozenGasAccountPayload(address string) (*common.Payload, error)

CreateFrozenGasAccountPayload create frozen gas account payload

func (*ChainClient) CreateGetHotColdDataSeparateMaxHeightPayload added in v3.0.1

func (cc *ChainClient) CreateGetHotColdDataSeparateMaxHeightPayload() (*common.Payload, error)

CreateGetHotColdDataSeparateMaxHeightPayload create `get hot cold data separate ` payload

func (*ChainClient) CreateGetHotColdDataSeparatePayload

func (cc *ChainClient) CreateGetHotColdDataSeparatePayload(jobID string) (*common.Payload, error)

CreateGetHotColdDataSeparatePayload create `get hot cold data separate ` payload

func (*ChainClient) CreateGetSnapshotStatusPayload

func (cc *ChainClient) CreateGetSnapshotStatusPayload() (*common.Payload, error)

CreateGetSnapshotStatusPayload create `get snapshot status ` payload

func (*ChainClient) CreateHibeInitParamsTxPayloadParams

func (cc *ChainClient) CreateHibeInitParamsTxPayloadParams(orgId string,
	hibeParams []byte) ([]*common.KeyValuePair, error)

CreateHibeInitParamsTxPayloadParams CreateHibeInitParamsTxPayloadParams

func (*ChainClient) CreateHibeTxPayloadParamsWithHibeParams

func (cc *ChainClient) CreateHibeTxPayloadParamsWithHibeParams(plaintext []byte, receiverIds []string,
	paramsBytesList [][]byte, txId string, keyType crypto.KeyType) ([]*common.KeyValuePair, error)

CreateHibeTxPayloadParamsWithHibeParams CreateHibeTxPayloadParamsWithHibeParams

func (*ChainClient) CreateHibeTxPayloadParamsWithoutHibeParams

func (cc *ChainClient) CreateHibeTxPayloadParamsWithoutHibeParams(contractName, queryParamsMethod string,
	plaintext []byte, receiverIds []string, receiverOrgIds []string, txId string, keyType crypto.KeyType,
	timeout int64) ([]*common.KeyValuePair, error)

CreateHibeTxPayloadParamsWithoutHibeParams CreateHibeTxPayloadParamsWithoutHibeParams

func (*ChainClient) CreateHotColdDataSeparateBlockPayload

func (cc *ChainClient) CreateHotColdDataSeparateBlockPayload(startHeight, endHeight uint64) (*common.Payload, error)

CreateHotColdDataSeparateBlockPayload create `hot cold separate block` payload

func (*ChainClient) CreateMultiSignReqPayload

func (cc *ChainClient) CreateMultiSignReqPayload(
	pairs []*common.KeyValuePair) *common.Payload

CreateMultiSignReqPayload create multi sign req payload

func (*ChainClient) CreateMultiSignReqPayloadWithGasLimit added in v3.0.1

func (cc *ChainClient) CreateMultiSignReqPayloadWithGasLimit(
	pairs []*common.KeyValuePair, gasLimit uint64) *common.Payload

CreateMultiSignReqPayloadWithGasLimit create multi sign req payload

func (*ChainClient) CreateNativeContractAccessGrantPayload

func (cc *ChainClient) CreateNativeContractAccessGrantPayload(grantContractList []string) (*common.Payload, error)

CreateNativeContractAccessGrantPayload create `native contract access grant` payload for grant access to a native contract

func (*ChainClient) CreateNativeContractAccessRevokePayload

func (cc *ChainClient) CreateNativeContractAccessRevokePayload(revokeContractList []string) (*common.Payload, error)

CreateNativeContractAccessRevokePayload create `native contract access revoke` payload for revoke access to a native contract

func (*ChainClient) CreatePayload

func (cc *ChainClient) CreatePayload(txId string, txType common.TxType, contractName, method string,
	kvs []*common.KeyValuePair, seq uint64, limit *common.Limit) *common.Payload

CreatePayload create unsigned payload args:

  • string
  • common.TxType
  • string
  • string
  • []*common.KeyValuePair
  • uint64
  • *common.Limit

returns:

  • *common.Payload

func (*ChainClient) CreatePubkeyAddPayload

func (cc *ChainClient) CreatePubkeyAddPayload(pubkey string, orgId string, role string) (*common.Payload, error)

CreatePubkeyAddPayload create pubkey add payload

func (*ChainClient) CreatePubkeyDelPayload

func (cc *ChainClient) CreatePubkeyDelPayload(pubkey string, orgId string) (*common.Payload, error)

CreatePubkeyDelPayload create pubkey delete payload

func (*ChainClient) CreatePubkeyQueryPayload

func (cc *ChainClient) CreatePubkeyQueryPayload(pubkey string) (*common.Payload, error)

CreatePubkeyQueryPayload create pubkey query payload

func (*ChainClient) CreateRaftToTbftPayload

func (cc *ChainClient) CreateRaftToTbftPayload(extConfig []*common.KeyValuePair) (*common.Payload, error)

CreateRaftToTbftPayload create switch consensus raft to tbft payload args:

  • []*common.KeyValuePair

returns:

  • *common.Payload
  • error

func (*ChainClient) CreateRechargeGasPayload

func (cc *ChainClient) CreateRechargeGasPayload(rechargeGasList []*syscontract.RechargeGas) (*common.Payload, error)

CreateRechargeGasPayload create recharge gas payload

func (*ChainClient) CreateRefundGasPayload

func (cc *ChainClient) CreateRefundGasPayload(address string, amount int64) (*common.Payload, error)

CreateRefundGasPayload create refund gas payload

func (*ChainClient) CreateRestoreBlockPayload

func (cc *ChainClient) CreateRestoreBlockPayload(fullBlock []byte) (*common.Payload, error)

CreateRestoreBlockPayload create `restore block` payload args:

  • []byte

returns:

  • *common.Payload
  • error

func (*ChainClient) CreateRestoreBlocksPayload added in v3.0.1

func (cc *ChainClient) CreateRestoreBlocksPayload(fullBlocks [][]byte) (*common.Payload, error)

CreateRestoreBlocksPayload create `restore blocks` payload args:

  • [][]byte

returns:

  • *common.Payload
  • error

func (*ChainClient) CreateSaveEnclaveCACertPayload

func (cc *ChainClient) CreateSaveEnclaveCACertPayload(enclaveCACert string, txId string) (*common.Payload, error)

CreateSaveEnclaveCACertPayload CreateSaveEnclaveCACertPayload

func (*ChainClient) CreateSaveEnclaveReportPayload

func (cc *ChainClient) CreateSaveEnclaveReportPayload(enclaveId, report, txId string) (*common.Payload, error)

CreateSaveEnclaveReportPayload CreateSaveEnclaveReportPayload

func (*ChainClient) CreateSetGasAdminPayload

func (cc *ChainClient) CreateSetGasAdminPayload(address string) (*common.Payload, error)

CreateSetGasAdminPayload create set gas admin payload

func (*ChainClient) CreateSetInstallBaseGasPayload added in v3.0.1

func (cc *ChainClient) CreateSetInstallBaseGasPayload(amount int64) (*common.Payload, error)

CreateSetInstallBaseGasPayload create set_install_base_gas payload

func (*ChainClient) CreateSetInstallGasPricePayload added in v3.0.1

func (cc *ChainClient) CreateSetInstallGasPricePayload(gasPrice string) (*common.Payload, error)

CreateSetInstallGasPricePayload create set_install_gas_price payload

func (*ChainClient) CreateSetInvokeBaseGasPayload

func (cc *ChainClient) CreateSetInvokeBaseGasPayload(amount int64) (*common.Payload, error)

CreateSetInvokeBaseGasPayload create set invoke base gas payload

func (*ChainClient) CreateSetInvokeGasPricePayload added in v3.0.1

func (cc *ChainClient) CreateSetInvokeGasPricePayload(gasPrice string) (*common.Payload, error)

CreateSetInvokeGasPricePayload create set invoke gas price payload

func (*ChainClient) CreateSnapshotBlockPayload

func (cc *ChainClient) CreateSnapshotBlockPayload(targetSnapshotHeight uint64) (*common.Payload, error)

CreateSnapshotBlockPayload create `snapshot block` payload

func (*ChainClient) CreateSubscribeBlockPayload

func (cc *ChainClient) CreateSubscribeBlockPayload(startBlock, endBlock int64,
	withRWSet, onlyHeader bool) *common.Payload

CreateSubscribeBlockPayload create subscribe block payload

func (*ChainClient) CreateSubscribeContractEventPayload

func (cc *ChainClient) CreateSubscribeContractEventPayload(startBlock, endBlock int64,
	contractName, topic string) *common.Payload

CreateSubscribeContractEventPayload create subscribe contract event payload

func (*ChainClient) CreateSubscribeTxPayload

func (cc *ChainClient) CreateSubscribeTxPayload(startBlock, endBlock int64,
	contractName string, txIds []string) *common.Payload

CreateSubscribeTxPayload create subscribe tx payload

func (*ChainClient) CreateTbftToRaftPayload

func (cc *ChainClient) CreateTbftToRaftPayload(extConfig []*common.KeyValuePair) (*common.Payload, error)

CreateTbftToRaftPayload create switch consensus tbft to raft payload args:

  • []*common.KeyValuePair

returns:

  • *common.Payload
  • error

func (*ChainClient) CreateUnfrozenGasAccountPayload

func (cc *ChainClient) CreateUnfrozenGasAccountPayload(address string) (*common.Payload, error)

CreateUnfrozenGasAccountPayload create unfrozen gas account payload

func (*ChainClient) CreateUpdateCertByAliasPayload

func (cc *ChainClient) CreateUpdateCertByAliasPayload(alias, newCertPEM string) *common.Payload

CreateUpdateCertByAliasPayload create `update cert by alias` payload args:

  • string
  • string

returns:

  • *common.Payload

func (*ChainClient) Decimals

func (cc *ChainClient) Decimals() (string, error)

Decimals 查询ERC20合约的精度

func (*ChainClient) DecryptHibeTxByTxId

func (cc *ChainClient) DecryptHibeTxByTxId(localId string, hibeParams []byte, hibePrvKey []byte, txId string,
	keyType crypto.KeyType) ([]byte, error)

DecryptHibeTxByTxId DecryptHibeTxByTxId

func (*ChainClient) Delegate

func (cc *ChainClient) Delegate(to string, value string) (*syscontract.Delegation, error)

Delegate 抵押权益到验证人

func (*ChainClient) DeleteCert

func (cc *ChainClient) DeleteCert(certHashes []string) (*common.TxResponse, error)

DeleteCert delete myself cert hash on chain args:

  • []string

returns:

  • *common.TxResponse
  • error

func (*ChainClient) DeleteCertsAlias

func (cc *ChainClient) DeleteCertsAlias(payload *common.Payload, endorsers []*common.EndorsementEntry,
	timeout int64, withSyncResult bool) (*common.TxResponse, error)

DeleteCertsAlias delete certs alias on chain args:

  • *common.Payload
  • []*common.EndorsementEntry
  • int64
  • bool

returns:

  • *common.TxResponse
  • error

func (*ChainClient) DisableCertHash

func (cc *ChainClient) DisableCertHash() error

DisableCertHash disable cert hash logic returns:

  • error

func (*ChainClient) EasyCodecItemToParamsMap

func (cc *ChainClient) EasyCodecItemToParamsMap(items []*serialize.EasyCodecItem) map[string][]byte

EasyCodecItemToParamsMap easy codec items to params map

func (*ChainClient) EnableAlias

func (cc *ChainClient) EnableAlias() error

EnableAlias enable cert alias logic returns:

  • error

func (*ChainClient) EnableCertHash

func (cc *ChainClient) EnableCertHash() error

EnableCertHash Cert Hash logic returns:

  • error

func (*ChainClient) EstimateGas

func (cc *ChainClient) EstimateGas(payload *common.Payload) (uint64, error)

EstimateGas estimate gas used of payload

func (*ChainClient) EthCall added in v3.0.1

func (cc *ChainClient) EthCall(from, to ethbase.Address,
	gas uint64, gasPrice, value *ethbase.SafeUint256, data []byte) (*common.TxResponse, error)

EthCall 以太坊eth_call模拟,相当于查询合约 @param from @param to @param gas @param gasPrice @param value @param data @return *common.TxResponse @return error

func (*ChainClient) EthEstimateGas added in v3.0.1

func (cc *ChainClient) EthEstimateGas(from *ethbase.Address, to ethbase.Address,
	gas uint64, gasPrice, value *ethbase.SafeUint256, data []byte) (uint64, error)

EthEstimateGas 以太坊预估Gas @param from @param to @param gas @param gasPrice @param value @param data @return uint64 @return error

func (*ChainClient) EthSendRawTx added in v3.0.1

func (cc *ChainClient) EthSendRawTx(rawTx []byte, timeout int64, withSyncResult bool) (*common.TxResponse, error)

EthSendRawTx 发送以太坊交易

func (*ChainClient) GenerateTxRequest

func (cc *ChainClient) GenerateTxRequest(payload *common.Payload,
	endorsers []*common.EndorsementEntry) (*common.TxRequest, error)

GenerateTxRequest sign payload and generate *common.TxRequest args:

  • *common.Payload
  • []*common.EndorsementEntry

returns:

  • *common.TxRequest
  • error

func (*ChainClient) GenerateTxRequestBySigner

func (cc *ChainClient) GenerateTxRequestBySigner(payload *common.Payload, endorsers []*common.EndorsementEntry,
	signer Signer) (*common.TxRequest, error)

GenerateTxRequestBySigner sign payload and generate *common.TxRequest use signer to sign payload if it is not nil. use cc.privateKey to sign payload if signer is nil. args:

  • *common.Payload
  • []*common.EndorsementEntry
  • Signer

returns:

  • *common.TxRequest
  • error

func (*ChainClient) GenerateTxRequestWithPayer added in v3.0.1

func (cc *ChainClient) GenerateTxRequestWithPayer(payload *common.Payload,
	endorsers []*common.EndorsementEntry, payer *common.EndorsementEntry) (*common.TxRequest, error)

GenerateTxRequestWithPayer sign payload and generate *common.TxRequest with payer

func (*ChainClient) GetAccountContractTxHistory added in v3.0.1

func (cc *ChainClient) GetAccountContractTxHistory(memberInfo []byte, contractName string,
	options ...Option) (
	[]*storePb.TxHistory, error)

GetAccountContractTxHistory 根据账户名、合约名和合约地址获取账户合约交易历史 @param memberInfo @param contractName @param contractAddr @param options @return []*storePb.TxHistory @return error

func (*ChainClient) GetAllCandidates

func (cc *ChainClient) GetAllCandidates() (*syscontract.ValidatorVector, error)

GetAllCandidates 查询所有的候选人

func (*ChainClient) GetArchiveService added in v3.0.1

func (cc *ChainClient) GetArchiveService() ArchiveService

GetArchiveService 获取归档中心服务 lazy load @return ArchiveService

func (*ChainClient) GetArchiveStatus added in v3.0.1

func (cc *ChainClient) GetArchiveStatus() (*store.ArchiveStatus, error)

GetArchiveStatus get peer archive status

func (*ChainClient) GetArchivedBlockByHash

func (cc *ChainClient) GetArchivedBlockByHash(blockHash string, withRWSet bool) (*common.BlockInfo, error)

GetArchivedBlockByHash get archived block by block hash, returns *common.BlockInfo args:

  • string
  • bool

returns:

  • *common.BlockInfo
  • error

func (*ChainClient) GetArchivedBlockByHeight

func (cc *ChainClient) GetArchivedBlockByHeight(blockHeight uint64, withRWSet bool) (*common.BlockInfo, error)

GetArchivedBlockByHeight get archived block by block height, returns *common.BlockInfo args:

  • uint64
  • bool

returns:

  • *common.BlockInfo
  • error

func (*ChainClient) GetArchivedBlockByTxId

func (cc *ChainClient) GetArchivedBlockByTxId(txId string, withRWSet bool) (*common.BlockInfo, error)

GetArchivedBlockByTxId get archived block by tx id, returns *common.BlockInfo args:

  • string
  • bool

returns:

  • *common.BlockInfo
  • error

func (*ChainClient) GetArchivedBlockHeight

func (cc *ChainClient) GetArchivedBlockHeight() (uint64, error)

GetArchivedBlockHeight get archived block height

func (*ChainClient) GetArchivedTxByTxId

func (cc *ChainClient) GetArchivedTxByTxId(txId string) (*common.TransactionInfo, error)

GetArchivedTxByTxId get archived tx by tx id, returns *common.TransactionInfo args:

  • string

returns:

  • *common.TransactionInfo
  • error

func (*ChainClient) GetAuthType

func (cc *ChainClient) GetAuthType() AuthType

GetAuthType get auth type of cc returns:

  • AuthType

func (*ChainClient) GetBlockByHash

func (cc *ChainClient) GetBlockByHash(blockHash string, withRWSet bool) (*common.BlockInfo, error)

GetBlockByHash get block by block hash, returns *common.BlockInfo

func (*ChainClient) GetBlockByHeight

func (cc *ChainClient) GetBlockByHeight(blockHeight uint64, withRWSet bool) (*common.BlockInfo, error)

GetBlockByHeight get block by block height, returns *common.BlockInfo

func (*ChainClient) GetBlockByHeightTruncate

func (cc *ChainClient) GetBlockByHeightTruncate(blockHeight uint64, withRWSet bool, truncateLength int,
	truncateModel string) (*common.BlockInfo, error)

GetBlockByHeightTruncate 根据区块高度获得区块,应对超大block,可设置返回block的截断规则。 @param blockHeight @param withRWSet @param truncateLength 截断的长度设置,如果此参数为>0,超过此长度的剩余数据将被丢弃。如果<=0则不截断 @param truncateModel 截断的模式设置:hash,truncate,empty @return *common.BlockInfo @return error

func (*ChainClient) GetBlockByTxId

func (cc *ChainClient) GetBlockByTxId(txId string, withRWSet bool) (*common.BlockInfo, error)

GetBlockByTxId get block by tx id, returns *common.BlockInfo

func (*ChainClient) GetBlockHeaderByHeight

func (cc *ChainClient) GetBlockHeaderByHeight(blockHeight uint64) (*common.BlockHeader, error)

GetBlockHeaderByHeight get block header by block height

func (*ChainClient) GetBlockHeightByHash

func (cc *ChainClient) GetBlockHeightByHash(blockHash string) (uint64, error)

GetBlockHeightByHash get block height by block hash

func (*ChainClient) GetBlockHeightByTxId

func (cc *ChainClient) GetBlockHeightByTxId(txId string) (uint64, error)

GetBlockHeightByTxId get block height by tx id

func (*ChainClient) GetCertHash

func (cc *ChainClient) GetCertHash() ([]byte, error)

GetCertHash get cert hash on chain returns:

  • []byte
  • error

func (*ChainClient) GetCertPEM

func (cc *ChainClient) GetCertPEM() []byte

GetCertPEM get cert pem of cc returns:

  • []byte

func (*ChainClient) GetChainConfig

func (cc *ChainClient) GetChainConfig() (*config.ChainConfig, error)

GetChainConfig get chain config returns:

  • *config.ChainConfig
  • error

func (*ChainClient) GetChainConfigByBlockHeight

func (cc *ChainClient) GetChainConfigByBlockHeight(blockHeight uint64) (*config.ChainConfig, error)

GetChainConfigByBlockHeight get chain config by block height args:

  • uint64

returns:

  • *config.ChainConfig
  • error

func (*ChainClient) GetChainConfigPermissionList

func (cc *ChainClient) GetChainConfigPermissionList() ([]*config.ResourcePolicy, error)

GetChainConfigPermissionList get chain config returns:

  • []*config.ResourcePolicy
  • error

func (*ChainClient) GetChainConfigSequence

func (cc *ChainClient) GetChainConfigSequence() (uint64, error)

GetChainConfigSequence get chain config sequence returns:

  • uint64
  • error

func (*ChainClient) GetChainInfo

func (cc *ChainClient) GetChainInfo() (*discovery.ChainInfo, error)

GetChainInfo get chain info

func (*ChainClient) GetChainMakerServerVersion

func (cc *ChainClient) GetChainMakerServerVersion() (string, error)

GetChainMakerServerVersion get chainmaker version returns:

  • string
  • error

func (*ChainClient) GetChainMakerServerVersionCustom added in v3.0.1

func (cc *ChainClient) GetChainMakerServerVersionCustom(ctx context.Context) (string, error)

GetChainMakerServerVersionCustom get chainmaker version

func (*ChainClient) GetConsensusHeight

func (cc *ChainClient) GetConsensusHeight() (uint64, error)

GetConsensusHeight get latest consensus height returns:

  • uint64
  • error

func (*ChainClient) GetConsensusStateJSON

func (cc *ChainClient) GetConsensusStateJSON() ([]byte, error)

GetConsensusStateJSON get consensus state returns:

  • []byte
  • error

func (*ChainClient) GetConsensusValidators

func (cc *ChainClient) GetConsensusValidators() ([]string, error)

GetConsensusValidators get validators returns:

  • []string
  • error

func (*ChainClient) GetContract

func (cc *ChainClient) GetContract(contractName, codeHash string) (*common.PrivateGetContract, error)

GetContract GetContract

func (*ChainClient) GetContractByteCode

func (cc *ChainClient) GetContractByteCode(contractName string) ([]byte, error)

GetContractByteCode get contract obj by contract name @param contractName @return []byte @return error

func (*ChainClient) GetContractInfo

func (cc *ChainClient) GetContractInfo(contractName string) (*common.Contract, error)

GetContractInfo get contract info by contract name, returns *common.Contract

func (*ChainClient) GetContractList

func (cc *ChainClient) GetContractList() ([]*common.Contract, error)

GetContractList get all contracts from block chain, include user contract and system contract

func (*ChainClient) GetCurrentBlockHeight

func (cc *ChainClient) GetCurrentBlockHeight() (uint64, error)

GetCurrentBlockHeight get current block height

func (*ChainClient) GetData

func (cc *ChainClient) GetData(contractName, key string) ([]byte, error)

GetData GetData

func (*ChainClient) GetDelegationsByAddress

func (cc *ChainClient) GetDelegationsByAddress(address string) (*syscontract.DelegationInfo, error)

GetDelegationsByAddress 查询指定地址的抵押信息

func (*ChainClient) GetDir

func (cc *ChainClient) GetDir(orderId string) ([]byte, error)

GetDir GetDir

func (*ChainClient) GetDisabledNativeContractList

func (cc *ChainClient) GetDisabledNativeContractList() ([]string, error)

GetDisabledNativeContractList get all disabled native contracts, returns contracts name list

func (*ChainClient) GetDistributionByEpochId

func (cc *ChainClient) GetDistributionByEpochId(epochId string) (*EpochAmountDetail, error)

GetDistributionByEpochId 查询世代中激励明细 args:

  • string

returns:

  • *EpochAmountDetail
  • error

func (*ChainClient) GetDistributionPerBlock

func (cc *ChainClient) GetDistributionPerBlock() (int, error)

GetDistributionPerBlock 获取区块奖励数量 returns:

  • int
  • error

func (*ChainClient) GetEnabledCrtHash

func (cc *ChainClient) GetEnabledCrtHash() bool

GetEnabledCrtHash check whether the cert hash logic is enabled returns:

  • bool

func (*ChainClient) GetEnclaveCACert

func (cc *ChainClient) GetEnclaveCACert() ([]byte, error)

GetEnclaveCACert GetEnclaveCACert

func (*ChainClient) GetEnclaveChallenge

func (cc *ChainClient) GetEnclaveChallenge(enclaveId string) ([]byte, error)

GetEnclaveChallenge GetEnclaveChallenge

func (*ChainClient) GetEnclaveEncryptPubKey

func (cc *ChainClient) GetEnclaveEncryptPubKey(enclaveId string) ([]byte, error)

GetEnclaveEncryptPubKey GetEnclaveEncryptPubKey

func (*ChainClient) GetEnclaveProof

func (cc *ChainClient) GetEnclaveProof(enclaveId string) ([]byte, error)

GetEnclaveProof GetEnclaveProof

func (*ChainClient) GetEnclaveReport

func (cc *ChainClient) GetEnclaveReport(enclaveId string) ([]byte, error)

GetEnclaveReport GetEnclaveReport

func (*ChainClient) GetEnclaveSignature

func (cc *ChainClient) GetEnclaveSignature(enclaveId string) ([]byte, error)

GetEnclaveSignature GetEnclaveSignature

func (*ChainClient) GetEnclaveVerificationPubKey

func (cc *ChainClient) GetEnclaveVerificationPubKey(enclaveId string) ([]byte, error)

GetEnclaveVerificationPubKey GetEnclaveVerificationPubKey

func (*ChainClient) GetEpochBlockNumber

func (cc *ChainClient) GetEpochBlockNumber() (int, error)

GetEpochBlockNumber 获取世代中包含区块数 returns:

  • int
  • error

func (*ChainClient) GetEpochById

func (cc *ChainClient) GetEpochById(id string) (*syscontract.Epoch, error)

GetEpochById 查询指定世代信息

func (*ChainClient) GetEpochValidatorNumber

func (cc *ChainClient) GetEpochValidatorNumber() (int, error)

GetEpochValidatorNumber 获取世代中验证者数量 returns:

  • int
  • error

func (*ChainClient) GetFullBlockByHeight

func (cc *ChainClient) GetFullBlockByHeight(blockHeight uint64) (*store.BlockWithRWSet, error)

GetFullBlockByHeight Deprecated, get full block by block height, returns *store.BlockWithRWSet

func (*ChainClient) GetGasAccountStatus

func (cc *ChainClient) GetGasAccountStatus(address string) (bool, error)

GetGasAccountStatus get gas account status

func (*ChainClient) GetGasAdmin

func (cc *ChainClient) GetGasAdmin() (string, error)

GetGasAdmin get gas admin on chain, returns gas admin address

func (*ChainClient) GetGasBalance

func (cc *ChainClient) GetGasBalance(address string) (int64, error)

GetGasBalance returns gas balance of address

func (*ChainClient) GetGasExchangeRate

func (cc *ChainClient) GetGasExchangeRate() (int, error)

GetGasExchangeRate 获取gas兑换比例 returns:

  • int
  • error

func (*ChainClient) GetHashType

func (cc *ChainClient) GetHashType() crypto.HashType

GetHashType get hash type of cc returns:

  • crypto.HashType

func (*ChainClient) GetLastBlock

func (cc *ChainClient) GetLastBlock(withRWSet bool) (*common.BlockInfo, error)

GetLastBlock get last block

func (*ChainClient) GetLastConfigBlock

func (cc *ChainClient) GetLastConfigBlock(withRWSet bool) (*common.BlockInfo, error)

GetLastConfigBlock get last config block

func (*ChainClient) GetLastEpoch

func (cc *ChainClient) GetLastEpoch() (*syscontract.Epoch, error)

GetLastEpoch 查询当前世代信息

func (*ChainClient) GetLocalCertAlias

func (cc *ChainClient) GetLocalCertAlias() string

GetLocalCertAlias get local cert alias of cc returns:

  • string

func (*ChainClient) GetMerklePathByTxId

func (cc *ChainClient) GetMerklePathByTxId(txId string) ([]byte, error)

GetMerklePathByTxId get merkle path by tx id

func (*ChainClient) GetMinSelfDelegation

func (cc *ChainClient) GetMinSelfDelegation() (int, error)

GetMinSelfDelegation 获取最小质押数量 returns:

  • int
  • error

func (*ChainClient) GetNodeChainList

func (cc *ChainClient) GetNodeChainList() (*discovery.ChainList, error)

GetNodeChainList get node chain list

func (*ChainClient) GetNodeId

func (cc *ChainClient) GetNodeId(address string) (string, error)

GetNodeId Stake合约中查询验证人的NodeID

func (*ChainClient) GetPoolStatus

func (cc *ChainClient) GetPoolStatus() (*txpool.TxPoolStatus, error)

GetPoolStatus Returns the max size of config transaction pool and common transaction pool, the num of config transaction in queue and pendingCache, and the the num of common transaction in queue and pendingCache.

func (*ChainClient) GetPrivateKey

func (cc *ChainClient) GetPrivateKey() crypto.PrivateKey

GetPrivateKey get private key of cc returns:

  • crypto.PrivateKey

func (*ChainClient) GetPublicKey

func (cc *ChainClient) GetPublicKey() crypto.PublicKey

GetPublicKey get public key of cc returns:

  • crypto.PublicKey

func (*ChainClient) GetSlashingAddress

func (cc *ChainClient) GetSlashingAddress() (string, error)

GetSlashingAddress 查询惩罚账户地址

func (*ChainClient) GetSlashingBalance

func (cc *ChainClient) GetSlashingBalance() (string, error)

GetSlashingBalance 查询惩罚账户余额

func (*ChainClient) GetSlashingByEpochId

func (cc *ChainClient) GetSlashingByEpochId(epochId string) (*SlashingDetail, error)

GetSlashingByEpochId 查询世代中惩罚明细 args:

  • string

returns:

  • *SlashingDetail
  • error

func (*ChainClient) GetSlashingPerBlock

func (cc *ChainClient) GetSlashingPerBlock() (int, error)

GetSlashingPerBlock 获取区块惩罚数量 returns:

  • int
  • error

func (*ChainClient) GetStakeContractAddress

func (cc *ChainClient) GetStakeContractAddress() (string, error)

GetStakeContractAddress Stake合约中查询验证人的NodeID

func (*ChainClient) GetStateByKey

func (cc *ChainClient) GetStateByKey(contractName string, key string, options ...Option) ([]byte, error)

GetStateByKey get contract state obj by contract name & key & Options @param contractName @param key @param Options @return []byte @return error

func (*ChainClient) GetStateByPrefix

func (cc *ChainClient) GetStateByPrefix(contractName string, prefix string, options ...Option) (
	[]*common.KeyValuePair, error)

GetStateByPrefix get state KVs by contract name & prefix & Options @param contractName @param prefix @param Options @return []*common.KeyValuePair @return error

func (*ChainClient) GetStateKeyHistory added in v3.0.1

func (cc *ChainClient) GetStateKeyHistory(contractName string, key string, options ...Option) (
	[]*storePb.KeyModification, error)

GetStateKeyHistory 根据合约名和key获取状态数据变动历史 @param contractName @param key @param options @return []*storePb.KeyModification @return error

func (*ChainClient) GetTxByTxId

func (cc *ChainClient) GetTxByTxId(txId string) (*common.TransactionInfo, error)

GetTxByTxId get tx by tx id, returns *common.TransactionInfo

func (*ChainClient) GetTxByTxIdTruncate

func (cc *ChainClient) GetTxByTxIdTruncate(txId string, withRWSet bool, truncateLength int,
	truncateModel string) (*common.TransactionInfoWithRWSet, error)

GetTxByTxIdTruncate 根据TxId获得Transaction对象,并根据参数进行截断 @param txId @param withRWSet @param truncateLength @param truncateModel @return *common.TransactionInfoWithRWSet @return error

func (*ChainClient) GetTxIdsByTypeAndStage

func (cc *ChainClient) GetTxIdsByTypeAndStage(txType txpool.TxType, txStage txpool.TxStage) ([]string, error)

GetTxIdsByTypeAndStage Returns config or common txIds in different stage. txType may be TxType_CONFIG_TX, TxType_COMMON_TX, (TxType_CONFIG_TX|TxType_COMMON_TX) txStage may be TxStage_IN_QUEUE, TxStage_IN_PENDING, (TxStage_IN_QUEUE|TxStage_IN_PENDING)

func (*ChainClient) GetTxRequest

func (cc *ChainClient) GetTxRequest(contractName, method, txId string, kvs []*common.KeyValuePair) (
	*common.TxRequest, error)

GetTxRequest build tx request, returns *common.TxRequest

func (*ChainClient) GetTxStatus

func (cc *ChainClient) GetTxStatus(txId string) (txpool.TxStatus, error)

GetTxStatus Get the transaction status by txId. return TxStatus.

func (*ChainClient) GetTxWithRWSetByTxId

func (cc *ChainClient) GetTxWithRWSetByTxId(txId string) (*common.TransactionInfoWithRWSet, error)

GetTxWithRWSetByTxId get tx with rwset by tx id

func (*ChainClient) GetTxsInPoolByTxIds

func (cc *ChainClient) GetTxsInPoolByTxIds(txIds []string) ([]*common.Transaction, []string, error)

GetTxsInPoolByTxIds Retrieve the transactions by the txIds from the txPool, return transactions in the txPool and txIds not in txPool. default query upper limit is 1w transaction, and error is returned if the limit is exceeded.

func (*ChainClient) GetUnboundingIntervalEpochNumber added in v3.0.1

func (cc *ChainClient) GetUnboundingIntervalEpochNumber() (string, error)

GetUnboundingIntervalEpochNumber 查询收到解质押退款间隔的世代数

func (*ChainClient) GetUserCrtHash

func (cc *ChainClient) GetUserCrtHash() []byte

GetUserCrtHash get user cert hash of cc returns:

  • []byte

func (*ChainClient) GetUserDelegationByValidator

func (cc *ChainClient) GetUserDelegationByValidator(
	delegator string, validator string) (*syscontract.Delegation, error)

GetUserDelegationByValidator 查询指定验证人的抵押信息

func (*ChainClient) GetValidatorByAddress

func (cc *ChainClient) GetValidatorByAddress(address string) (*syscontract.Validator, error)

GetValidatorByAddress 通过Address获取验证人的信息

func (*ChainClient) InvokeContract

func (cc *ChainClient) InvokeContract(contractName, method, txId string, kvs []*common.KeyValuePair, timeout int64,
	withSyncResult bool) (*common.TxResponse, error)

InvokeContract invoke contract

func (*ChainClient) InvokeContractBySigner

func (cc *ChainClient) InvokeContractBySigner(contractName, method, txId string, kvs []*common.KeyValuePair,
	timeout int64, withSyncResult bool, limit *common.Limit,
	signer Signer) (*common.TxResponse, error)

InvokeContractBySigner invoke contract with specified signer. use signer to sign payload if it is not nil. use cc.privateKey to sign payload if signer is nil.

func (*ChainClient) InvokeContractWithLimit

func (cc *ChainClient) InvokeContractWithLimit(contractName, method, txId string, kvs []*common.KeyValuePair,
	timeout int64, withSyncResult bool, limit *common.Limit) (*common.TxResponse, error)

InvokeContractWithLimit invoke contract with specified gas limit

func (*ChainClient) InvokeSystemContract

func (cc *ChainClient) InvokeSystemContract(contractName, method, txId string, kvs []*common.KeyValuePair,
	timeout int64, withSyncResult bool) (*common.TxResponse, error)

InvokeSystemContract invoke system contract

func (*ChainClient) IsArchiveCenterQueryFist added in v3.0.1

func (cc *ChainClient) IsArchiveCenterQueryFist() bool

IsArchiveCenterQueryFist check whether to query archive data from archivecenter first

func (*ChainClient) IsEnableNormalKey

func (cc *ChainClient) IsEnableNormalKey() bool

IsEnableNormalKey whether to use normal key returns:

  • bool

func (*ChainClient) KMSConfig

func (cc *ChainClient) KMSConfig() *KMSConfig

KMSConfig get kms config of cc returns:

  • *KMSConfig

func (*ChainClient) Mint

func (cc *ChainClient) Mint(
	address string, amount string) (*common.Payload, error)

Mint ERC20合约中的Mint发行Token

func (*ChainClient) MultiSignContractQuery

func (cc *ChainClient) MultiSignContractQuery(txId string) (*common.TxResponse, error)

MultiSignContractQuery query online multi sign

func (*ChainClient) MultiSignContractQueryWithParams added in v3.0.1

func (cc *ChainClient) MultiSignContractQueryWithParams(
	txId string, params []*common.KeyValuePair) (*common.TxResponse, error)

MultiSignContractQueryWithParams query online multi sign

func (*ChainClient) MultiSignContractReq

func (cc *ChainClient) MultiSignContractReq(payload *common.Payload, endorsers []*common.EndorsementEntry,
	timeout int64, withSyncResult bool) (*common.TxResponse, error)

MultiSignContractReq send online multi sign contract request to node

func (*ChainClient) MultiSignContractReqWithPayer added in v3.0.1

func (cc *ChainClient) MultiSignContractReqWithPayer(payload *common.Payload, endorsers []*common.EndorsementEntry,
	payer *common.EndorsementEntry, timeout int64, withSyncResult bool) (*common.TxResponse, error)

MultiSignContractReqWithPayer send online multi sign contract request to node

func (*ChainClient) MultiSignContractTrig

func (cc *ChainClient) MultiSignContractTrig(multiSignReqPayload *common.Payload,
	timeout int64, limit *common.Limit, withSyncResult bool) (*common.TxResponse, error)

MultiSignContractTrig send online multi sign trig request to node this function is plugin after v2.3.1

func (*ChainClient) MultiSignContractTrigWithPayer added in v3.0.1

func (cc *ChainClient) MultiSignContractTrigWithPayer(multiSignReqPayload *common.Payload,
	payer *common.EndorsementEntry, timeout int64, limit *common.Limit,
	withSyncResult bool) (*common.TxResponse, error)

MultiSignContractTrigWithPayer send online multi sign trig request to node this function is plugin after v2.3.1

func (*ChainClient) MultiSignContractVote

func (cc *ChainClient) MultiSignContractVote(multiSignReqPayload *common.Payload,
	endorser *common.EndorsementEntry, isAgree bool, timeout int64, withSyncResult bool) (*common.TxResponse, error)

MultiSignContractVote send online multi sign vote request to node

func (*ChainClient) MultiSignContractVoteWithGasLimit added in v3.0.1

func (cc *ChainClient) MultiSignContractVoteWithGasLimit(multiSignReqPayload *common.Payload,
	endorser *common.EndorsementEntry, isAgree bool, timeout int64,
	gasLimit uint64, withSyncResult bool) (*common.TxResponse, error)

MultiSignContractVoteWithGasLimit send online multi sign vote request to node

func (*ChainClient) MultiSignContractVoteWithGasLimitAndPayer added in v3.0.1

func (cc *ChainClient) MultiSignContractVoteWithGasLimitAndPayer(multiSignReqPayload *common.Payload,
	endorser *common.EndorsementEntry, payer *common.EndorsementEntry, isAgree bool, timeout int64,
	gasLimit uint64, withSyncResult bool) (*common.TxResponse, error)

MultiSignContractVoteWithGasLimitAndPayer send online multi sign vote request to node

func (*ChainClient) Owner

func (cc *ChainClient) Owner() (string, error)

Owner 查询合约管理地址

func (*ChainClient) Pkcs11Config

func (cc *ChainClient) Pkcs11Config() *Pkcs11Config

Pkcs11Config get pkcs11 config of cc returns:

  • *Pkcs11Config

func (*ChainClient) QueryCert

func (cc *ChainClient) QueryCert(certHashes []string) (*common.CertInfos, error)

QueryCert query cert on chain, returns *common.CertInfos args:

  • []string

returns:

  • *common.CertInfos
  • error

func (*ChainClient) QueryCertsAlias

func (cc *ChainClient) QueryCertsAlias(aliases []string) (*common.AliasInfos, error)

QueryCertsAlias query cert alias on chain, returns *common.AliasInfos args:

  • []string

returns:

  • *common.AliasInfos
  • error

func (*ChainClient) QueryContract

func (cc *ChainClient) QueryContract(contractName, method string, kvs []*common.KeyValuePair,
	timeout int64) (*common.TxResponse, error)

QueryContract query contract

func (*ChainClient) QueryDockerHibeParamsWithOrgId added in v3.0.1

func (cc *ChainClient) QueryDockerHibeParamsWithOrgId(contractName, method, orgId string, timeout int64) (
	[]byte, error)

QueryDockerHibeParamsWithOrgId query docker hibe params with org id

func (*ChainClient) QueryHibeParamsWithOrgId

func (cc *ChainClient) QueryHibeParamsWithOrgId(contractName, method, orgId string, timeout int64) ([]byte, error)

QueryHibeParamsWithOrgId QueryHibeParamsWithOrgId

func (*ChainClient) QuerySystemContract

func (cc *ChainClient) QuerySystemContract(contractName, method string, kvs []*common.KeyValuePair,
	timeout int64) (*common.TxResponse, error)

QuerySystemContract query system contract

func (*ChainClient) RestoreBlocks added in v3.0.1

func (cc *ChainClient) RestoreBlocks(restoreHeight uint64, _ string,
	heightNotice func(message ProcessMessage) error) error

RestoreBlocks 从归档服务查询已归档区块恢复到节点账本中 @param endHeight @return error

func (*ChainClient) SaveData

func (cc *ChainClient) SaveData(contractName string, contractVersion string, isDeployment bool, codeHash []byte,
	reportHash []byte, result *common.ContractResult, codeHeader []byte, txId string, rwSet *common.TxRWSet,
	sign []byte, events *common.StrSlice, privateReq []byte, withSyncResult bool,
	timeout int64) (*common.TxResponse, error)

SaveData SaveData

func (*ChainClient) SaveDir

func (cc *ChainClient) SaveDir(orderId, txId string,
	privateDir *common.StrSlice, withSyncResult bool, timeout int64) (*common.TxResponse, error)

SaveDir SaveDir

func (*ChainClient) SaveEnclaveCACert

func (cc *ChainClient) SaveEnclaveCACert(
	enclaveCACert, txId string, withSyncResult bool, timeout int64) (*common.TxResponse, error)

SaveEnclaveCACert SaveEnclaveCACert

func (*ChainClient) SaveEnclaveReport

func (cc *ChainClient) SaveEnclaveReport(
	enclaveId, report, txId string, withSyncResult bool, timeout int64) (*common.TxResponse, error)

SaveEnclaveReport SaveEnclaveReport

func (*ChainClient) SaveRemoteAttestationProof

func (cc *ChainClient) SaveRemoteAttestationProof(proof, txId string, withSyncResult bool,
	timeout int64) (*common.TxResponse, error)

SaveRemoteAttestationProof SaveRemoteAttestationProof

func (*ChainClient) SendArchiveBlockRequest

func (cc *ChainClient) SendArchiveBlockRequest(payload *common.Payload, timeout int64) (*common.TxResponse, error)

SendArchiveBlockRequest send `archive block` request to node grpc server args:

  • *common.Payload
  • int64

returns:

  • *common.TxResponse
  • error

func (*ChainClient) SendCertManageRequest

func (cc *ChainClient) SendCertManageRequest(payload *common.Payload, endorsers []*common.EndorsementEntry,
	timeout int64, withSyncResult bool) (*common.TxResponse, error)

SendCertManageRequest send cert manage request to node args:

  • *common.Payload
  • []*common.EndorsementEntry
  • int64
  • bool

returns:

  • *common.TxResponse
  • error

func (*ChainClient) SendChainConfigUpdateRequest

func (cc *ChainClient) SendChainConfigUpdateRequest(payload *common.Payload, endorsers []*common.EndorsementEntry,
	timeout int64, withSyncResult bool) (*common.TxResponse, error)

SendChainConfigUpdateRequest send chain config update request to node args:

  • *common.Payload
  • []*common.EndorsementEntry
  • int64
  • bool

returns:

  • *common.TxResponse
  • error

func (*ChainClient) SendContractManageRequest

func (cc *ChainClient) SendContractManageRequest(payload *common.Payload, endorsers []*common.EndorsementEntry,
	timeout int64, withSyncResult bool) (*common.TxResponse, error)

SendContractManageRequest send user contract manage request to node

func (*ChainClient) SendContractManageRequestWithPayer added in v3.0.1

func (cc *ChainClient) SendContractManageRequestWithPayer(payload *common.Payload, endorsers []*common.EndorsementEntry,
	payer *common.EndorsementEntry, timeout int64, withSyncResult bool) (*common.TxResponse, error)

SendContractManageRequestWithPayer send user contract manage request to node with payer

func (*ChainClient) SendGasManageRequest

func (cc *ChainClient) SendGasManageRequest(payload *common.Payload, endorsers []*common.EndorsementEntry,
	timeout int64, withSyncResult bool) (*common.TxResponse, error)

SendGasManageRequest send gas manage request to node

func (*ChainClient) SendHotColdDataSeparateRequest

func (cc *ChainClient) SendHotColdDataSeparateRequest(payload *common.Payload,
	timeout int64) (*common.TxResponse, error)

SendHotColdDataSeparateRequest send `hot cold data separate req` request to node grpc server

func (*ChainClient) SendMultiSigningRequest

func (cc *ChainClient) SendMultiSigningRequest(payload *common.Payload, endorsers []*common.EndorsementEntry,
	timeout int64, withSyncResult bool) (*common.TxResponse, error)

SendMultiSigningRequest SendMultiSigningRequest

func (*ChainClient) SendPayloadRequest

func (cc *ChainClient) SendPayloadRequest(payload *common.Payload, endorsers []*common.EndorsementEntry,
	timeout int64, withSyncResult bool) (*common.TxResponse, error)

SendPayloadRequest send payload request to node

func (*ChainClient) SendPubkeyManageRequest

func (cc *ChainClient) SendPubkeyManageRequest(payload *common.Payload, endorsers []*common.EndorsementEntry,
	timeout int64, withSyncResult bool) (*common.TxResponse, error)

SendPubkeyManageRequest send pubkey manage request to node

func (*ChainClient) SendRestoreBlockRequest

func (cc *ChainClient) SendRestoreBlockRequest(payload *common.Payload, timeout int64) (*common.TxResponse, error)

SendRestoreBlockRequest send `restore block` request to node grpc server args:

  • *common.Payload
  • int64

returns:

  • *common.TxResponse
  • error

func (*ChainClient) SendSnapshotRequest

func (cc *ChainClient) SendSnapshotRequest(payload *common.Payload, timeout int64) (*common.TxResponse, error)

SendSnapshotRequest send `snapshot req` request to node grpc server

func (*ChainClient) SendTxRequest

func (cc *ChainClient) SendTxRequest(txRequest *common.TxRequest, timeout int64,
	withSyncResult bool) (*common.TxResponse, error)

SendTxRequest send tx request to node

func (*ChainClient) SetDistributionPerBlock

func (cc *ChainClient) SetDistributionPerBlock(distributionPerBlock int) (*common.Payload, error)

SetDistributionPerBlock 设置区块奖励数量 args:

  • int

returns:

  • *common.Payload
  • error

func (*ChainClient) SetEpochBlockNumber

func (cc *ChainClient) SetEpochBlockNumber(epochBlockNumber int) (*common.Payload, error)

SetEpochBlockNumber 设置世代中区块数 args:

  • int

returns:

  • *common.Payload
  • error

func (*ChainClient) SetEpochBlockNumberAndValidatorNumber

func (cc *ChainClient) SetEpochBlockNumberAndValidatorNumber(
	epochBlockNumber int,
	epochValidatorNumber int) (*common.Payload, error)

SetEpochBlockNumberAndValidatorNumber 设置区块数量和验证者数量,区块数量需要是验证者数量的整数倍 args:

  • int
  • int

returns:

  • *common.Payload
  • error

func (*ChainClient) SetEpochValidatorNumber

func (cc *ChainClient) SetEpochValidatorNumber(epochValidatorNumber int) (*common.Payload, error)

SetEpochValidatorNumber 设置世代中验证者数量 args:

  • int

returns:

  • *common.Payload
  • error

func (*ChainClient) SetGasExchangeRate

func (cc *ChainClient) SetGasExchangeRate(gasExchangeRate int) (*common.Payload, error)

SetGasExchangeRate 设置gas兑换比例 args:

  • int

returns:

  • *common.Payload
  • error

func (*ChainClient) SetMinSelfDelegation

func (cc *ChainClient) SetMinSelfDelegation(minSelfDelegation int) (*common.Payload, error)

SetMinSelfDelegation 设置最小质押数量 args:

  • int

returns:

  • *common.Payload
  • error

func (*ChainClient) SetNodeId

func (cc *ChainClient) SetNodeId(nodeId string) (string, error)

SetNodeId Stake合约中设置验证人的NodeID

func (*ChainClient) SetSlashingPerBlock

func (cc *ChainClient) SetSlashingPerBlock(slashingPerBlock int) (*common.Payload, error)

SetSlashingPerBlock 设置区块惩罚数量 args:

  • int

returns:

  • *common.Payload
  • error

func (*ChainClient) SignCertManagePayload

func (cc *ChainClient) SignCertManagePayload(payload *common.Payload) (*common.EndorsementEntry, error)

SignCertManagePayload sign `cert manage` payload args:

  • *common.Payload

returns:

  • *common.EndorsementEntry
  • error

func (*ChainClient) SignChainConfigPayload

func (cc *ChainClient) SignChainConfigPayload(payload *common.Payload) (*common.EndorsementEntry, error)

SignChainConfigPayload sign chain config payload args:

  • *common.Payload

returns:

  • *common.EndorsementEntry
  • error

func (*ChainClient) SignContractManagePayload

func (cc *ChainClient) SignContractManagePayload(payload *common.Payload) (*common.EndorsementEntry, error)

SignContractManagePayload sign user contract manage payload

func (*ChainClient) SignDeleteAliasPayload

func (cc *ChainClient) SignDeleteAliasPayload(payload *common.Payload) (*common.EndorsementEntry, error)

SignDeleteAliasPayload sign `delete alias` payload args:

  • *common.Payload

returns:

  • *common.EndorsementEntry
  • error

func (*ChainClient) SignHotColdDataSeparatePayload

func (cc *ChainClient) SignHotColdDataSeparatePayload(payload *common.Payload) (*common.Payload, error)

SignHotColdDataSeparatePayload sign hot cold data separate payload, currently do nothing

func (*ChainClient) SignPayload

func (cc *ChainClient) SignPayload(payload *common.Payload) (*common.EndorsementEntry, error)

SignPayload sign payload, returns *common.EndorsementEntry args:

  • *common.Payload

returns:

  • *common.EndorsementEntry
  • error

func (*ChainClient) SignSnapshotPayload

func (cc *ChainClient) SignSnapshotPayload(payload *common.Payload) (*common.Payload, error)

SignSnapshotPayload sign snapshot payload, currently do nothing

func (*ChainClient) SignUpdateCertByAliasPayload

func (cc *ChainClient) SignUpdateCertByAliasPayload(payload *common.Payload) (*common.EndorsementEntry, error)

SignUpdateCertByAliasPayload sign `update cert by alias` payload args:

  • *common.Payload

returns:

  • *common.EndorsementEntry
  • error

func (*ChainClient) Stop

func (cc *ChainClient) Stop() error

Stop stop chain client returns:

  • error

func (*ChainClient) Subscribe

func (cc *ChainClient) Subscribe(ctx context.Context, payload *common.Payload) (<-chan interface{}, error)

Subscribe returns channel of subscribed items

func (*ChainClient) SubscribeBlock

func (cc *ChainClient) SubscribeBlock(ctx context.Context, startBlock, endBlock int64, withRWSet,
	onlyHeader bool) (<-chan interface{}, error)

SubscribeBlock block subscription, returns channel of subscribed blocks

func (*ChainClient) SubscribeContractEvent

func (cc *ChainClient) SubscribeContractEvent(ctx context.Context, startBlock, endBlock int64,
	contractName, topic string) (<-chan interface{}, error)

SubscribeContractEvent contract event subscription, returns channel of subscribed contract events

func (*ChainClient) SubscribeTx

func (cc *ChainClient) SubscribeTx(ctx context.Context, startBlock, endBlock int64, contractName string,
	txIds []string) (<-chan interface{}, error)

SubscribeTx tx subscription, returns channel of subscribed txs

func (*ChainClient) Total

func (cc *ChainClient) Total() (string, error)

Total 查询Token总供应量

func (*ChainClient) Transfer

func (cc *ChainClient) Transfer(to string, value string) (*utils.BigInteger, error)

Transfer 转账

func (*ChainClient) TransferOwnership

func (cc *ChainClient) TransferOwnership(
	address string) (*common.Payload, error)

TransferOwnership ERC20合约中转移owner权限

func (*ChainClient) UnDelegate

func (cc *ChainClient) UnDelegate(from string, value string) (*syscontract.UnbondingDelegation, error)

UnDelegate 从验证人解除抵押的权益

func (*ChainClient) UpdateCertByAlias

func (cc *ChainClient) UpdateCertByAlias(payload *common.Payload, endorsers []*common.EndorsementEntry,
	timeout int64, withSyncResult bool) (*common.TxResponse, error)

UpdateCertByAlias update cert by alias on chain args:

  • *common.Payload
  • []*common.EndorsementEntry
  • int64
  • bool

returns:

  • *common.TxResponse
  • error

type ChainClientConfig

type ChainClientConfig struct {
	ConfigModel *utils.ChainClientConfigModel
	// contains filtered or unexported fields
}

ChainClientConfig define chain client configuration

type ChainClientOption

type ChainClientOption func(*ChainClientConfig)

ChainClientOption define chain client option func

func AddChainClientNodeConfig

func AddChainClientNodeConfig(nodeConfig *NodeConfig) ChainClientOption

AddChainClientNodeConfig 添加ChainMaker节点地址及连接数配置 args:

  • *NodeConfig

returns:

  • ChainClientOption

func WithArchiveCenterHttpConfig added in v3.0.1

func WithArchiveCenterHttpConfig(conf *ArchiveCenterConfig) ChainClientOption

WithArchiveCenterHttpConfig 设置归档中心http接口

func WithArchiveCenterQueryFirst added in v3.0.1

func WithArchiveCenterQueryFirst(first bool) ChainClientOption

WithArchiveCenterQueryFirst 设置优先从归档中心查询

func WithArchiveConfig

func WithArchiveConfig(conf *ArchiveConfig) ChainClientOption

WithArchiveConfig 设置Archive配置 args:

  • *ArchiveConfig

returns:

  • ChainClientOption

func WithAuthType

func WithAuthType(authType string) ChainClientOption

WithAuthType specified auth type args:

  • string

returns:

  • ChainClientOption

func WithChainClientAlias

func WithChainClientAlias(alias string) ChainClientOption

WithChainClientAlias specified cert alias args:

  • string

returns:

  • ChainClientOption

func WithChainClientChainId

func WithChainClientChainId(chainId string) ChainClientOption

WithChainClientChainId 添加ChainId args:

  • string

returns:

  • ChainClientOption

func WithChainClientLogger

func WithChainClientLogger(logger utils.Logger) ChainClientOption

WithChainClientLogger 设置Logger对象,便于日志打印 args:

  • utils.Logger

returns:

  • ChainClientOption

func WithChainClientOrgId

func WithChainClientOrgId(orgId string) ChainClientOption

WithChainClientOrgId 添加OrgId args:

  • string

returns:

  • ChainClientOption

func WithConfPath

func WithConfPath(confPath string) ChainClientOption

WithConfPath 设置配置文件路径 args:

  • string

returns:

  • ChainClientOption

func WithCryptoConfig

func WithCryptoConfig(conf *CryptoConfig) ChainClientOption

WithCryptoConfig 设置crypto配置 args:

  • *CryptoConfig

returns:

  • ChainClientOption

func WithEnableNormalKey

func WithEnableNormalKey(enableNormalKey bool) ChainClientOption

WithEnableNormalKey specified use normal key or not args:

  • bool

returns:

  • ChainClientOption

func WithEnableSyncCanonicalTxResult

func WithEnableSyncCanonicalTxResult(enable bool) ChainClientOption

WithEnableSyncCanonicalTxResult 设置是否启用 同步获取权威的公认的交易结果,即超过半数共识的交易。默认不启用。 args:

  • bool

returns:

  • ChainClientOption

func WithKMSConfig

func WithKMSConfig(conf *KMSConfig) ChainClientOption

WithKMSConfig 设置kms配置 args:

  • *KMSConfig

returns:

  • ChainClientOption

func WithPkcs11Config

func WithPkcs11Config(conf *Pkcs11Config) ChainClientOption

WithPkcs11Config 设置pkcs11配置 args:

  • *Pkcs11Config

returns:

  • ChainClientOption

func WithRPCClientConfig

func WithRPCClientConfig(conf *RPCClientConfig) ChainClientOption

WithRPCClientConfig 设置grpc客户端配置 args:

  • *RPCClientConfig

returns:

  • ChainClientOption

func WithUserCrtBytes

func WithUserCrtBytes(userCrtBytes []byte) ChainClientOption

WithUserCrtBytes 添加用户证书文件内容配置 args:

  • []byte

returns:

  • ChainClientOption

func WithUserCrtFilePath

func WithUserCrtFilePath(userCrtFilePath string) ChainClientOption

WithUserCrtFilePath 添加用户证书文件路径配置 args:

  • string

returns:

  • ChainClientOption

func WithUserEncKeyPwd

func WithUserEncKeyPwd(pwd string) ChainClientOption

WithUserEncKeyPwd 配置国密双证书模式下用户私钥密码 args:

  • string

returns:

  • ChainClientOption

func WithUserKeyBytes

func WithUserKeyBytes(userKeyBytes []byte) ChainClientOption

WithUserKeyBytes 添加用户私钥文件内容配置 args:

  • []byte

returns:

  • ChainClientOption

func WithUserKeyFilePath

func WithUserKeyFilePath(userKeyFilePath string) ChainClientOption

WithUserKeyFilePath 添加用户私钥文件路径配置 args:

  • string

returns:

  • ChainClientOption

func WithUserKeyPwd

func WithUserKeyPwd(pwd string) ChainClientOption

WithUserKeyPwd 配置用户私钥密码 args:

  • string

returns:

  • ChainClientOption

func WithUserSignCrtBytes

func WithUserSignCrtBytes(userSignCrtBytes []byte) ChainClientOption

WithUserSignCrtBytes 添加用户签名证书文件内容配置 args:

  • []byte

returns:

  • ChainClientOption

func WithUserSignCrtFilePath

func WithUserSignCrtFilePath(userSignCrtFilePath string) ChainClientOption

WithUserSignCrtFilePath 添加用户签名证书文件路径配置 args:

  • string

returns:

  • ChainClientOption

func WithUserSignKeyBytes

func WithUserSignKeyBytes(userSignKeyBytes []byte) ChainClientOption

WithUserSignKeyBytes 添加用户签名私钥文件内容配置 args:

  • []byte

returns:

  • ChainClientOption

func WithUserSignKeyFilePath

func WithUserSignKeyFilePath(userSignKeyFilePath string) ChainClientOption

WithUserSignKeyFilePath 添加用户签名私钥文件路径配置 args:

  • string

returns:

  • ChainClientOption

func WithUserSignKeyPwd

func WithUserSignKeyPwd(pwd string) ChainClientOption

WithUserSignKeyPwd 配置用户签名私钥密码 args:

  • string

returns:

  • ChainClientOption

type ClientConnectionPool

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

ClientConnectionPool 客户端连接池结构定义

func NewConnPool

func NewConnPool(config *ChainClientConfig) (*ClientConnectionPool, error)

NewConnPool 创建连接池 args:

  • *ChainClientConfig

returns:

  • *ClientConnectionPool
  • error

func NewConnPoolWithOptions

func NewConnPoolWithOptions(opts ...ChainClientOption) (*ClientConnectionPool, error)

NewConnPoolWithOptions new conn pool with optioins, returns *ClientConnectionPool args:

  • ...ChainClientOption

returns:

  • *ClientConnectionPool
  • error

func (*ClientConnectionPool) Close

func (pool *ClientConnectionPool) Close() error

Close 关闭连接池 returns:

  • error

type ConnectionPool

type ConnectionPool interface {
	Close() error
	// contains filtered or unexported methods
}

ConnectionPool grpc connection pool interface

type CryptoConfig

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

CryptoConfig define crypto config

func NewCryptoConfig

func NewCryptoConfig(opts ...CryptoOption) *CryptoConfig

NewCryptoConfig 根据传入参数创建新的CryptoConfig对象 args:

  • ...CryptoOption

returns:

  • *CryptoConfig

type CryptoOption

type CryptoOption func(config *CryptoConfig)

CryptoOption define crypto option func

func WithHashAlgo

func WithHashAlgo(hashType string) CryptoOption

WithHashAlgo 公钥模式下:添加用户哈希算法配置 args:

  • string

returns:

  • CryptoOption

type DelegatorRate

type DelegatorRate map[string]float64

DelegatorRate 质押比例

type EpochAmountDetail

type EpochAmountDetail map[string]AmountByRate

EpochAmountDetail 一个世代中,每个节点出块奖励总和分配明细

type KMSConfig

type KMSConfig struct {
	// kms enable flag
	Enabled bool
	//Public cloud or private cloud
	IsPublic bool
	//KMS SecretId
	SecretId string
	//KMS SecretKey
	SecretKey string
	//KMS server address, ip or dns
	Address string
	//KMS server region
	Region string
	//KMS sdk scheme, http or https
	SdkScheme string
	//Optional settings,style "{k1:v1, k2:v2}".
	ExtParams string
}

KMSConfig kms配置

func NewKMSConfig

func NewKMSConfig(enabled bool, isPublic bool, secretId, secretKey,
	serverAddress, serverRegion, sdkScheme, extParams string) *KMSConfig

NewKMSConfig new kms config args:

  • bool
  • bool
  • string
  • string
  • string
  • string
  • string
  • string

returns:

  • *KMSConfig

type NodeConfig

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

NodeConfig 节点配置

func NewNodeConfig

func NewNodeConfig(opts ...NodeOption) *NodeConfig

NewNodeConfig new node config, returns *NodeConfig args:

  • ...NodeOption

returns:

  • *NodeConfig

type NodeOption

type NodeOption func(config *NodeConfig)

NodeOption define node option func

func WithNodeAddr

func WithNodeAddr(addr string) NodeOption

WithNodeAddr 设置节点地址 args:

  • string

returns:

  • NodeOption

func WithNodeCACerts

func WithNodeCACerts(caCerts []string) NodeOption

WithNodeCACerts 添加CA证书内容 args:

  • []string

returns:

  • NodeOption

func WithNodeCAPaths

func WithNodeCAPaths(caPaths []string) NodeOption

WithNodeCAPaths 添加CA证书路径 args:

  • []string

returns:

  • NodeOption

func WithNodeConnCnt

func WithNodeConnCnt(connCnt int) NodeOption

WithNodeConnCnt 设置节点连接数 args:

  • int

returns:

  • NodeOption

func WithNodeTLSHostName

func WithNodeTLSHostName(tlsHostName string) NodeOption

WithNodeTLSHostName use tls host name args:

  • string

returns:

  • NodeOption

func WithNodeUseTLS

func WithNodeUseTLS(useTLS bool) NodeOption

WithNodeUseTLS 设置是否启动TLS开关 args:

  • bool

returns:

  • NodeOption

type Option

type Option func(*resultOperator) error

Option define result operator func

func Format

func Format(format string) Option

Format build a result operator func with specific format

func Paging

func Paging(pageSize, pageIndex int) Option

Paging build a result operator func with specific page size and page index, for paging use

type PermissionedWithKeyModeSigner

type PermissionedWithKeyModeSigner struct {
	PrivateKey crypto.PrivateKey
	HashType   crypto.HashType
	OrgId      string
}

PermissionedWithKeyModeSigner define a signer in PermissionedWithKey mode

func (*PermissionedWithKeyModeSigner) NewMember

func (signer *PermissionedWithKeyModeSigner) NewMember() (*accesscontrol.Member, error)

NewMember new *accesscontrol.Member

func (*PermissionedWithKeyModeSigner) Sign

func (signer *PermissionedWithKeyModeSigner) Sign(payload *common.Payload) ([]byte, error)

Sign sign payload

type Pkcs11Config

type Pkcs11Config struct {
	// 是否开启pkcs11, 如果为 ture 则下面所有的字段都是必填
	Enabled bool
	// interface type of lib, support pkcs11 and sdf
	Type string
	// path to the .so file of pkcs11 interface
	Library string
	// label for the slot to be used
	Label string
	// password to logon the HSM(Hardware security module)
	Password string
	// size of HSM session cache
	SessionCacheSize int
	// hash algorithm used to compute SKI, eg, SHA256
	Hash string
}

Pkcs11Config pkcs11配置

func NewPkcs11Config

func NewPkcs11Config(enabled bool, typ, libPath, label, password string,
	sessionCacheSize int, hashAlgo string) *Pkcs11Config

NewPkcs11Config new pkcs11 config args:

  • bool
  • string
  • string
  • string
  • string
  • int
  • string

returns:

  • *Pkcs11Config

type ProcessMessage added in v3.0.1

type ProcessMessage struct {
	CurrentHeight uint64
	Total         uint64
	Error         error
}

ProcessMessage 处理过程通知消息

type PublicModeSigner

type PublicModeSigner struct {
	PrivateKey crypto.PrivateKey
	HashType   crypto.HashType
}

PublicModeSigner define a signer in Public mode

func (*PublicModeSigner) NewMember

func (signer *PublicModeSigner) NewMember() (*accesscontrol.Member, error)

NewMember new *accesscontrol.Member

func (*PublicModeSigner) Sign

func (signer *PublicModeSigner) Sign(payload *common.Payload) ([]byte, error)

Sign sign payload

type RPCClientConfig

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

RPCClientConfig RPC Client 链接配置

func NewRPCClientConfig

func NewRPCClientConfig(opts ...RPCClientOption) *RPCClientConfig

NewRPCClientConfig new rpc client config args:

  • ...RPCClientOption

returns:

  • *RPCClientConfig

type RPCClientOption

type RPCClientOption func(config *RPCClientConfig)

RPCClientOption define rpc client option func

func WithRPCClientGetTxTimeout

func WithRPCClientGetTxTimeout(timeout int64) RPCClientOption

WithRPCClientGetTxTimeout 设置RPC Client的查询交易超时时间 args:

  • int64

returns:

  • RPCClientOption

func WithRPCClientMaxReceiveMessageSize

func WithRPCClientMaxReceiveMessageSize(size int) RPCClientOption

WithRPCClientMaxReceiveMessageSize 设置RPC Client的Max Receive Message Size args:

  • int

returns:

  • RPCClientOption

func WithRPCClientMaxSendMessageSize

func WithRPCClientMaxSendMessageSize(size int) RPCClientOption

WithRPCClientMaxSendMessageSize 设置RPC Client的Max Send Message Size args:

  • int

returns:

  • RPCClientOption

func WithRPCClientSendTxTimeout

func WithRPCClientSendTxTimeout(timeout int64) RPCClientOption

WithRPCClientSendTxTimeout 设置RPC Client的发送交易超时时间 args:

  • int64

returns:

  • RPCClientOption

type SDKInterface

type SDKInterface interface {
	// ## 1 用户合约接口
	// ### 1.1 创建合约待签名payload生成
	// **参数说明**
	//   - contractName: 合约名
	//   - version: 版本号
	//   - byteCodeStringOrFilePath: 支持传入合约二进制文件路径或Hex或Base64编码的string
	//   - runtime: 合约运行环境
	//   - kvs: 合约初始化参数
	// “`go
	CreateContractCreatePayload(contractName, version, byteCodeStringOrFilePath string, runtime common.RuntimeType,
		kvs []*common.KeyValuePair) (*common.Payload, error)

	// ### 1.2 升级合约待签名payload生成
	// **参数说明**
	//   - contractName: 合约名
	//   - version: 版本号
	//   - byteCodeStringOrFilePath: 支持传入合约二进制文件路径或Hex或Base64编码的string
	//   - runtime: 合约运行环境
	//   - kvs: 合约升级参数
	// “`go
	CreateContractUpgradePayload(contractName, version, byteCodeStringOrFilePath string, runtime common.RuntimeType,
		kvs []*common.KeyValuePair) (*common.Payload, error)

	// ### 1.3 冻结合约payload生成
	// **参数说明**
	//   - contractName: 合约名
	// “`go
	CreateContractFreezePayload(contractName string) (*common.Payload, error)

	// ### 1.4 解冻合约payload生成
	// **参数说明**
	//   - contractName: 合约名
	// “`go
	CreateContractUnfreezePayload(contractName string) (*common.Payload, error)

	// ### 1.5 吊销合约payload生成
	// **参数说明**
	//   - contractName: 合约名
	// “`go
	CreateContractRevokePayload(contractName string) (*common.Payload, error)

	// ### 1.6 合约管理获取Payload签名
	// **参数说明**
	//   - payload: 待签名payload
	// “`go
	SignContractManagePayload(payload *common.Payload) (*common.EndorsementEntry, error)

	// ### 1.7 发送合约管理请求(创建、更新、冻结、解冻、吊销)
	// **参数说明**
	//   - payload: 交易payload
	//   - endorsers: 背书签名信息列表
	//   - timeout: 超时时间,单位:s,若传入-1,将使用默认超时时间:10s
	//   - withSyncResult: 是否同步获取交易执行结果
	//            当为true时,若成功调用,common.TxResponse.ContractResult.Result为common.TransactionInfo
	//            当为false时,若成功调用,common.TxResponse.ContractResult为空,可以通过common.TxResponse.TxId查询交易结果
	//   - payer: gas扣费代扣人
	// “`go
	SendContractManageRequest(payload *common.Payload, endorsers []*common.EndorsementEntry, timeout int64,
		withSyncResult bool) (*common.TxResponse, error)
	SendContractManageRequestWithPayer(payload *common.Payload, endorsers []*common.EndorsementEntry,
		payer *common.EndorsementEntry, timeout int64, withSyncResult bool) (*common.TxResponse, error)

	// ### 1.8 合约调用
	// **参数说明**
	//   - contractName: 合约名称
	//   - method: 合约方法
	//   - txId: 交易ID
	//           格式要求:长度为64字节,字符在a-z0-9
	//           可为空,若为空字符串,将自动生成txId
	//   - kvs: 合约参数
	//   - timeout: 超时时间,单位:s,若传入-1,将使用默认超时时间:10s
	//   - withSyncResult: 是否同步获取交易执行结果
	//            当为true时,若成功调用,common.TxResponse.ContractResult.Result为common.TransactionInfo
	//            当为false时,若成功调用,common.TxResponse.ContractResult为空,可以通过common.TxResponse.TxId查询交易结果
	//   - limit: transaction limitation,执行交易时的资源消耗上限,设为nil则不设置上限
	// “`go
	InvokeContract(contractName, method, txId string, kvs []*common.KeyValuePair, timeout int64,
		withSyncResult bool) (*common.TxResponse, error)
	InvokeContractWithLimit(contractName, method, txId string, kvs []*common.KeyValuePair, timeout int64,
		withSyncResult bool, limit *common.Limit) (*common.TxResponse, error)

	// ### 1.9 合约查询接口调用
	// **参数说明**
	//   - contractName: 合约名称
	//   - method: 合约方法
	//   - kvs: 合约参数
	//   - timeout: 超时时间,单位:s,若传入-1,将使用默认超时时间:10s
	// “`go
	QueryContract(contractName, method string, kvs []*common.KeyValuePair, timeout int64) (*common.TxResponse, error)

	// ### 1.10 构造待发送交易体
	// **参数说明**
	//   - contractName: 合约名称
	//   - method: 合约方法
	//   - txId: 交易ID
	//           格式要求:长度为64字节,字符在a-z0-9
	//           可为空,若为空字符串,将自动生成txId
	//   - kvs: 合约参数
	// “`go
	GetTxRequest(contractName, method, txId string, kvs []*common.KeyValuePair) (*common.TxRequest, error)

	// ### 1.11 发送已构造好的交易体
	// **参数说明**
	//   - txRequest: 已构造好的交易体
	//   - timeout: 超时时间,单位:s,若传入-1,将使用默认超时时间:10s
	//   - withSyncResult: 是否同步获取交易执行结果
	//            当为true时,若成功调用,common.TxResponse.ContractResult.Result为common.TransactionInfo
	//            当为false时,若成功调用,common.TxResponse.ContractResult为空,可以通过common.TxResponse.TxId查询交易结果
	// “`go
	SendTxRequest(txRequest *common.TxRequest, timeout int64, withSyncResult bool) (*common.TxResponse, error)

	// ## 2 系统合约接口
	// ### 2.1 根据交易Id查询交易
	// **参数说明**
	//   - txId: 交易ID
	// “`go
	GetTxByTxId(txId string) (*common.TransactionInfo, error)

	// ### 2.2 根据交易Id查询包含rwset的交易
	// **参数说明**
	//   - txId: 交易ID
	// “`go
	GetTxWithRWSetByTxId(txId string) (*common.TransactionInfoWithRWSet, error)

	// ### 2.3 根据区块高度查询区块
	// **参数说明**
	//   - blockHeight: 指定区块高度,若为-1,将返回最新区块
	//   - withRWSet: 是否返回读写集
	// “`go
	GetBlockByHeight(blockHeight uint64, withRWSet bool) (*common.BlockInfo, error)

	// ### 2.4 根据区块高度查询完整区块,该方法已弃用,请优先使用GetBlockByHeight
	// **参数说明**
	//   - blockHeight: 指定区块高度,若为-1,将返回最新区块
	// “`go
	//Deprecated
	GetFullBlockByHeight(blockHeight uint64) (*store.BlockWithRWSet, error)

	// ### 2.5 根据区块哈希查询区块
	// **参数说明**
	//   - blockHash: 指定区块Hash
	//   - withRWSet: 是否返回读写集
	// “`go
	GetBlockByHash(blockHash string, withRWSet bool) (*common.BlockInfo, error)

	// ### 2.6 根据交易Id查询区块
	// **参数说明**
	//   - txId: 交易ID
	//   - withRWSet: 是否返回读写集
	// “`go
	GetBlockByTxId(txId string, withRWSet bool) (*common.BlockInfo, error)

	// ### 2.7 查询最新的配置块
	// **参数说明**
	//   - withRWSet: 是否返回读写集
	// “`go
	GetLastConfigBlock(withRWSet bool) (*common.BlockInfo, error)

	// ### 2.8 查询最新区块
	// **参数说明**
	//   - withRWSet: 是否返回读写集
	// “`go
	GetLastBlock(withRWSet bool) (*common.BlockInfo, error)

	// ### 2.9 查询节点加入的链信息
	//    - 返回ChainId清单
	// “`go
	GetNodeChainList() (*discovery.ChainList, error)

	// ### 2.10 查询链信息
	//   - 包括:当前链最新高度,链节点信息
	// “`go
	GetChainInfo() (*discovery.ChainInfo, error)

	// ### 2.11 根据交易Id获取区块高度
	// **参数说明**
	//   - txId: 交易ID
	// “`go
	GetBlockHeightByTxId(txId string) (uint64, error)

	// ### 2.12 根据区块Hash获取区块高度
	// **参数说明**
	//   - blockHash: 指定区块Hash
	// “`go
	GetBlockHeightByHash(blockHash string) (uint64, error)

	// ### 2.13 查询当前最新区块高度
	// “`go
	GetCurrentBlockHeight() (uint64, error)

	// ### 2.14 根据区块高度查询区块头
	// **参数说明**
	//   - blockHeight: 指定区块高度,若为-1,将返回最新区块头
	// “`go
	GetBlockHeaderByHeight(blockHeight uint64) (*common.BlockHeader, error)

	// ### 2.15 根据Key查询状态数据
	// **参数说明**
	//   - contractName 合约名
	//   - key 状况数据中的Key
	// **返回值说明**
	//   - []byte Value
	// “`go
	GetStateByKey(contractName string, key string, options ...Option) ([]byte, error)

	// ### 2.16 根据Key前缀获得匹配的KV列表
	// **参数说明**
	//   - contractName 合约名
	//   - prefix 前缀
	//   - options 可选项
	// **返回值说明**
	//   - []*common.KeyValuePair
	// “`go
	GetStateByPrefix(contractName string, prefix string, options ...Option) ([]*common.KeyValuePair, error)

	// ### 2.17 系统合约调用
	// **参数说明**
	//   - contractName: 合约名称
	//   - method: 合约方法
	//   - txId: 交易ID
	//           格式要求:长度为64字节,字符在a-z0-9
	//           可为空,若为空字符串,将自动生成txId
	//   - kvs: 合约参数
	//   - timeout: 超时时间,单位:s,若传入-1,将使用默认超时时间:10s
	//   - withSyncResult: 是否同步获取交易执行结果
	//            当为true时,若成功调用,common.TxResponse.ContractResult.Result为common.TransactionInfo
	//            当为false时,若成功调用,common.TxResponse.ContractResult为空,可以通过common.TxResponse.TxId查询交易结果
	// “`go
	InvokeSystemContract(contractName, method, txId string, kvs []*common.KeyValuePair, timeout int64,
		withSyncResult bool) (*common.TxResponse, error)

	// ### 2.18 系统合约查询接口调用
	// **参数说明**
	//   - contractName: 合约名称
	//   - method: 合约方法
	//   - kvs: 合约参数
	//   - timeout: 超时时间,单位:s,若传入-1,将使用默认超时时间:10s
	// “`go
	QuerySystemContract(contractName, method string, kvs []*common.KeyValuePair, timeout int64) (*common.TxResponse, error)

	// ### 2.19 根据交易Id获取Merkle路径
	// **参数说明**
	//   - txId: 交易ID
	// “`go
	GetMerklePathByTxId(txId string) ([]byte, error)

	// ### 2.20 开放系统合约
	// **参数说明**
	//   - grantContractList: 需要开放的系统合约字符串数组
	// “`go
	CreateNativeContractAccessGrantPayload(grantContractList []string) (*common.Payload, error)

	// ### 2.21 弃用系统合约
	// **参数说明**
	//   - revokeContractList: 需要弃用的系统合约字符串数组
	// “`go
	CreateNativeContractAccessRevokePayload(revokeContractList []string) (*common.Payload, error)

	// ### 2.22 查询指定合约的信息,包括系统合约和用户合约
	// **参数说明**
	//   - contractName: 指定查询的合约名字,包括系统合约和用户合约
	// “`go
	GetContractInfo(contractName string) (*common.Contract, error)

	// ### 2.23 根据合约名查询合约的字节码
	// **参数说明**
	//   - contractName: 合约名或者合约地址
	// **返回值说明**
	//   - []byte 合约的字节码
	//   - error 错误
	// “`go
	GetContractByteCode(contractName string) ([]byte, error)

	// ### 2.24 查询所有的合约名单,包括系统合约和用户合约
	// **返回值说明**
	//   - []*common.Contract: 链上所有的合约列表,包括系统合约和用户合约
	// “`go
	GetContractList() ([]*common.Contract, error)

	// ### 2.25 查询已禁用的系统合约名单
	// **返回值说明**
	//   - []string: 链上已禁用的系统合约名字列表
	// “`go
	GetDisabledNativeContractList() ([]string, error)

	// ### 2.26 根据区块高度获得区块,应对超大block,可设置返回block的截断规则
	// **参数说明**
	//   - blockHeight: 指定区块高度
	//   - withRWSet: 是否返回读写集
	//   - truncateLength 截断的长度设置,如果此参数为>0,超过此长度的剩余数据将被丢弃。如果<=0则不截断
	//   - truncateModel 截断的模式设置:hash,truncate,empty
	// “`go
	GetBlockByHeightTruncate(blockHeight uint64, withRWSet bool, truncateLength int,
		truncateModel string) (*common.BlockInfo, error)

	// ## 3 链配置接口
	// ### 3.1 查询最新链配置
	// “`go
	GetChainConfig() (*config.ChainConfig, error)

	// ### 3.2 根据指定区块高度查询最近链配置
	// **参数说明**
	//   - blockHeight: 指定区块高度
	//     如果当前区块就是配置块,直接返回当前区块的链配置
	// “`go
	GetChainConfigByBlockHeight(blockHeight uint64) (*config.ChainConfig, error)

	// ### 3.3 查询最新链配置序号Sequence
	//   - 用于链配置更新
	// “`go
	GetChainConfigSequence() (uint64, error)

	// ### 3.4 链配置更新获取Payload签名
	// **参数说明**
	//   - payload: 待签名payload
	// “`go
	SignChainConfigPayload(payload *common.Payload) (*common.EndorsementEntry, error)

	// ### 3.5 发送链配置更新请求
	// **参数说明**
	//   - payload: 待签名payload
	//   - endorsers: 背书签名信息列表
	//   - timeout: 超时时间,单位:s,若传入-1,将使用默认超时时间:10s
	//   - withSyncResult: 是否同步获取交易执行结果
	//            当为true时,若成功调用,common.TxResponse.ContractResult.Result为common.TransactionInfo
	//            当为false时,若成功调用,common.TxResponse.ContractResult为空,可以通过common.TxResponse.TxId查询交易结果
	// “`go
	SendChainConfigUpdateRequest(payload *common.Payload, endorsers []*common.EndorsementEntry, timeout int64,
		withSyncResult bool) (*common.TxResponse, error)

	// ### 3.6 更新Core模块待签名payload生成
	// **参数说明**
	//   - txSchedulerTimeout: 交易调度器从交易池拿到交易后, 进行调度的时间,其值范围为(0, 60], 若设置为0,则抛出错误
	//   - txSchedulerValidateTimeout: 交易调度器从区块中拿到交易后, 进行验证的超时时间,其值范围为(0, 60], 若设置为0,则抛出错误
	// “`go
	CreateChainConfigCoreUpdatePayload(txSchedulerTimeout, txSchedulerValidateTimeout uint64) (*common.Payload, error)

	// ### 3.7 更新链配置的区块相关参数待签名payload生成
	// **参数说明**
	//   - txTimestampVerify: 是否需要开启交易时间戳校验
	//   - blockTimestampVerify: 是否需要开启区块头时间戳校验
	//   - txTimeout: 交易时间戳的过期时间(秒),其值范围为[600, +∞)
	//   - blockTimeout: 区块头时间戳的过期时间(秒),其值范围为[10, +∞)
	//   - blockTxCapacity: 区块中最大交易数,其值范围为(0, +∞]
	//   - blockSize: 区块最大限制,单位MB,其值范围为(0, +∞]
	//   - blockInterval: 出块间隔,单位:ms,其值范围为[10, +∞]
	//   - txParamterSize: 交易的参数的最大值限制,单位:MB,其值范围为[0,100]
	// “`go
	CreateChainConfigBlockUpdatePayload(txTimestampVerify, blockTimestampVerify bool, txTimeout,
		blockTimeout, blockTxCapacity, blockSize, blockInterval, txParamterSize uint32) (*common.Payload, error)

	// ### 3.8 添加信任组织根证书待签名payload生成
	// **参数说明**
	//   - trustRootOrgId: 组织Id
	//   - trustRootCrt: 根证书
	// “`go
	CreateChainConfigTrustRootAddPayload(trustRootOrgId string, trustRootCrt []string) (*common.Payload, error)

	// ### 3.9 更新信任组织根证书待签名payload生成
	// **参数说明**
	//   - trustRootOrgId: 组织Id
	//   - trustRootCrt: 根证书
	// “`go
	CreateChainConfigTrustRootUpdatePayload(trustRootOrgId string, trustRootCrt []string) (*common.Payload, error)

	// ### 3.10 删除信任组织根证书待签名payload生成
	// **参数说明**
	//   - orgIdOrPKPubkeyPEM: cert模式下传组织Id,public模式下传公钥PEM
	// “`go
	CreateChainConfigTrustRootDeletePayload(orgIdOrPKPubkeyPEM string) (*common.Payload, error)

	// ### 3.11 添加信任成员证书待签名payload生成
	// **参数说明**
	//   - trustMemberOrgId: 组织Id
	//   - trustMemberNodeId: 节点Id
	//   - trustMemberRole: 成员角色
	//   - trustMemberInfo: 成员信息内容
	// “`go
	CreateChainConfigTrustMemberAddPayload(trustMemberOrgId, trustMemberNodeId,
		trustMemberRole, trustMemberInfo string) (*common.Payload, error)

	// ### 3.12 删除信任成员证书待签名payload生成
	// **参数说明**
	//   - trustMemberInfo: 成员信息内容
	// “`go
	CreateChainConfigTrustMemberDeletePayload(trustMemberInfo string) (*common.Payload, error)

	// ### 3.13 添加权限配置待签名payload生成
	// **参数说明**
	//   - permissionResourceName: 权限名
	//   - policy: 权限规则
	// “`go
	CreateChainConfigPermissionAddPayload(permissionResourceName string,
		policy *accesscontrol.Policy) (*common.Payload, error)

	// ### 3.14 更新权限配置待签名payload生成
	// **参数说明**
	//   - permissionResourceName: 权限名
	//   - policy: 权限规则
	// “`go
	CreateChainConfigPermissionUpdatePayload(permissionResourceName string,
		policy *accesscontrol.Policy) (*common.Payload, error)

	// ### 3.15 删除权限配置待签名payload生成
	// **参数说明**
	//   - permissionResourceName: 权限名
	// “`go
	CreateChainConfigPermissionDeletePayload(permissionResourceName string) (*common.Payload, error)

	// ### 3.16 添加共识节点地址待签名payload生成
	// **参数说明**
	//   - nodeOrgId: 节点组织Id
	//   - nodeIds: 节点Id
	// “`go
	CreateChainConfigConsensusNodeIdAddPayload(nodeOrgId string, nodeIds []string) (*common.Payload, error)

	// ### 3.17 更新共识节点地址待签名payload生成
	// **参数说明**
	//   - nodeOrgId: 节点组织Id
	//   - nodeOldNodeId: 节点原Id
	//   - nodeNewNodeId: 节点新Id
	// “`go
	CreateChainConfigConsensusNodeIdUpdatePayload(nodeOrgId, nodeOldNodeId, nodeNewNodeId string) (*common.Payload, error)

	// ### 3.18 删除共识节点地址待签名payload生成
	// **参数说明**
	//   - nodeOrgId: 节点组织Id
	//   - nodeId: 节点Id
	// “`go
	CreateChainConfigConsensusNodeIdDeletePayload(nodeOrgId, nodeId string) (*common.Payload, error)

	// ### 3.19 添加共识节点待签名payload生成
	// **参数说明**
	//   - nodeOrgId: 节点组织Id
	//   - nodeIds: 节点Id
	// “`go
	CreateChainConfigConsensusNodeOrgAddPayload(nodeOrgId string, nodeIds []string) (*common.Payload, error)

	// ### 3.20 更新共识节点待签名payload生成
	// **参数说明**
	//   - nodeOrgId: 节点组织Id
	//   - nodeIds: 节点Id
	// “`go
	CreateChainConfigConsensusNodeOrgUpdatePayload(nodeOrgId string, nodeIds []string) (*common.Payload, error)

	// ### 3.21 删除共识节点待签名payload生成
	// **参数说明**
	//   - nodeOrgId: 节点组织Id
	// “`go
	CreateChainConfigConsensusNodeOrgDeletePayload(nodeOrgId string) (*common.Payload, error)

	// ### 3.22 添加共识扩展字段待签名payload生成
	// **参数说明**
	//   - kvs: 字段key、value对
	// “`go
	CreateChainConfigConsensusExtAddPayload(kvs []*common.KeyValuePair) (*common.Payload, error)

	// ### 3.23 更新共识扩展字段待签名payload生成
	// **参数说明**
	//   - kvs: 字段key、value对
	// “`go
	CreateChainConfigConsensusExtUpdatePayload(kvs []*common.KeyValuePair) (*common.Payload, error)

	// ### 3.24 删除共识扩展字段待签名payload生成
	// **参数说明**
	//   - keys: 待删除字段
	// “`go
	CreateChainConfigConsensusExtDeletePayload(keys []string) (*common.Payload, error)

	// ### 3.25 修改地址类型payload生成
	// **参数说明**
	//   - addrType: 地址类型,0-ChainMaker; 1-ZXL
	// “`go
	CreateChainConfigAlterAddrTypePayload(addrType string) (*common.Payload, error)

	// ### 3.26 启用或停用Gas计费开关payload生成
	// “`go
	CreateChainConfigEnableOrDisableGasPayload() (*common.Payload, error)

	// ### 3.27 开启或关闭链配置的Gas优化payload生成
	// “`go
	CreateChainConfigOptimizeChargeGasPayload(enable bool) (*common.Payload, error)

	// ### 3.28 查询最新权限配置列表
	// “`go
	GetChainConfigPermissionList() ([]*config.ResourcePolicy, error)

	// ### 3.29 添加vm类型到vm支持列表的未签名payload生成
	// “`go
	CreateChainConfigVMSupportListAddPayload(vmType string) (*common.Payload, error)

	// ## 4 证书管理接口
	// ### 4.1 用户证书添加
	// **参数说明**
	//   - 在common.TxResponse.ContractResult.Result字段中返回成功添加的certHash
	// “`go
	AddCert() (*common.TxResponse, error)

	// ### 4.2 用户证书删除
	// **参数说明**
	//   - certHashes: 证书Hash列表
	// “`go
	DeleteCert(certHashes []string) (*common.TxResponse, error)

	// ### 4.3 用户证书查询
	// **参数说明**
	//   - certHashes: 证书Hash列表
	// **返回值说明**
	//   - *common.CertInfos: 包含证书Hash和证书内容的列表
	// “`go
	QueryCert(certHashes []string) (*common.CertInfos, error)

	// ### 4.4 获取用户证书哈希
	// “`go
	GetCertHash() ([]byte, error)

	// ### 4.5 生成证书管理操作Payload(三合一接口)
	// **参数说明**
	//   - method: CERTS_FROZEN(证书冻结)/CERTS_UNFROZEN(证书解冻)/CERTS_REVOCATION(证书吊销)
	//   - kvs: 证书管理操作参数
	// “`go
	CreateCertManagePayload(method string, kvs []*common.KeyValuePair) *common.Payload

	// ### 4.6 生成证书冻结操作Payload
	// **参数说明**
	//   - certs: X509证书列表
	// “`go
	CreateCertManageFrozenPayload(certs []string) *common.Payload

	// ### 4.7 生成证书解冻操作Payload
	// **参数说明**
	//   - certs: X509证书列表
	// “`go
	CreateCertManageUnfrozenPayload(certs []string) *common.Payload

	// ### 4.8 生成证书吊销操作Payload
	// **参数说明**
	//   - certs: X509证书列表
	// “`go
	CreateCertManageRevocationPayload(certCrl string) *common.Payload

	// ### 4.9 待签payload签名
	//  *一般需要使用具有管理员权限账号进行签名*
	// **参数说明**
	//   - payload: 待签名payload
	// “`go
	SignCertManagePayload(payload *common.Payload) (*common.EndorsementEntry, error)

	// ### 4.10 发送证书管理请求(证书冻结、解冻、吊销)
	// **参数说明**
	//   - payload: 交易payload
	//   - endorsers: 背书签名信息列表
	//   - timeout: 超时时间,单位:s,若传入-1,将使用默认超时时间:10s
	//   - withSyncResult: 是否同步获取交易执行结果
	//            当为true时,若成功调用,common.TxResponse.ContractResult.Result为common.TransactionInfo
	//            当为false时,若成功调用,common.TxResponse.ContractResult为空,可以通过common.TxResponse.TxId查询交易结果
	// “`go
	SendCertManageRequest(payload *common.Payload, endorsers []*common.EndorsementEntry, timeout int64,
		withSyncResult bool) (*common.TxResponse, error)

	// ## 5 消息订阅接口
	// ### 5.1 区块订阅
	// **参数说明**
	//   - startBlock: 订阅起始区块高度,包含起始区块。若为-1,表示订阅实时最新区块
	//   - endBlock: 订阅结束区块高度,包含结束区块。若为-1,表示订阅实时最新区块
	//   - withRwSet: 是否返回读写集
	//   - onlyHeader: 若设置为true,将忽略withRwSet选项,仅返回区块头(common.BlockHeader),若设置为false,将返回common.BlockInfo
	// “`go
	SubscribeBlock(ctx context.Context, startBlock, endBlock int64, withRWSet, onlyHeader bool) (<-chan interface{}, error)

	// ### 5.2 交易订阅
	// **参数说明**
	//   - startBlock: 订阅起始区块高度,包含起始区块。若为-1,表示订阅实时最新区块
	//   - endBlock: 订阅结束区块高度,包含结束区块。若为-1,表示订阅实时最新区块
	//   - contractName :指定订阅指定合约的交易,可以传用户合约名称或系统合约名称,若为空,表示订阅所有合约的交易
	//   - txIds: 订阅txId列表,若为空,表示订阅所有txId
	// “`go
	SubscribeTx(ctx context.Context, startBlock, endBlock int64, contractName string,
		txIds []string) (<-chan interface{}, error)

	// ### 5.3 合约事件订阅
	// **参数说明**
	//   - startBlock: 订阅起始区块高度,包含起始区块。若为-1,表示订阅实时最新区块
	//   - endBlock: 订阅结束区块高度,包含结束区块。若为-1,表示订阅实时最新区块
	//   - contractName :指定订阅的合约名称
	//   - topic :指定订阅主题
	// “`go
	SubscribeContractEvent(ctx context.Context, startBlock, endBlock int64, contractName,
		topic string) (<-chan interface{}, error)

	// ### 5.4 多合一订阅
	// **参数说明**
	//   - txType: 订阅交易类型,目前已支持:区块消息订阅(common.TxType_SUBSCRIBE_BLOCK_INFO)、交易消息订阅(common.TxType_SUBSCRIBE_TX_INFO)
	//   - payloadBytes: 消息订阅参数payload
	// “`go
	Subscribe(ctx context.Context, payloadBytes *common.Payload) (<-chan interface{}, error)

	// ## 6 证书压缩
	// *开启证书压缩可以减小交易包大小,提升处理性能*
	// ### 6.1 启用压缩证书功能
	// “`go
	EnableCertHash() error

	// ### 6.2 停用压缩证书功能
	// “`go
	DisableCertHash() error

	// ## 7 层级属性加密类接口
	// > 注意:层级属性加密模块 `Id` 使用 `/` 作为分隔符,例如: Org1/Ou1/Member1
	// ### 7.1 生成层级属性参数初始化交易 payload
	// **参数说明**
	//   - orgId: 参与方组织 id
	//   - hibeParams: 传入序列化后的hibeParams byte数组
	// “`go
	CreateHibeInitParamsTxPayloadParams(orgId string, hibeParams []byte) ([]*common.KeyValuePair, error)

	// ### 7.2 生成层级属性加密交易 payload,加密参数已知
	// **参数说明**
	//   - plaintext: 待加密交易消息明文
	//   - receiverIds: 消息接收者 id 列表,需和 paramsList 一一对应
	//   - paramsBytesList: 消息接收者对应的加密参数,需和 receiverIds 一一对应
	//   - txId: 以交易 Id 作为链上存储 hibeMsg 的 Key, 如果不提供存储的信息可能被覆盖
	//   - keyType: 对明文进行对称加密的方法,请传入 common 中 crypto 包提供的方法,目前提供AES和SM4两种方法
	// “`go
	CreateHibeTxPayloadParamsWithHibeParams(plaintext []byte, receiverIds []string, paramsBytesList [][]byte, txId string,
		keyType crypto.KeyType) ([]*common.KeyValuePair, error)

	// ### 7.3 生成层级属性加密交易 payload,参数由链上查询得出
	// **参数说明**
	//   - contractName: 合约名
	//   - queryParamsMethod: 链上查询 hibe.Params 的合约方法
	//   - plaintext: 待加密交易消息明文
	//   - receiverIds: 消息接收者 id 列表,需和 paramsList 一一对应
	//   - paramsList: 消息接收者对应的加密参数,需和 receiverIds 一一对应
	//   - receiverOrgIds: 链上查询 hibe Params 的 Key 列表,需要和 receiverIds 一一对应
	//   - txId: 以交易 Id 作为链上存储 hibeMsg 的 Key, 如果不提供存储的信息可能被覆盖
	//   - keyType: 对明文进行对称加密的方法,请传入 common 中 crypto 包提供的方法,目前提供AES和SM4两种方法
	//   - timeout: (内部查询 HibeParams 的)超时时间,单位:s,若传入-1,将使用默认超时时间:10s
	// “`go
	CreateHibeTxPayloadParamsWithoutHibeParams(contractName, queryParamsMethod string, plaintext []byte,
		receiverIds []string, receiverOrgIds []string, txId string, keyType crypto.KeyType,
		timeout int64) ([]*common.KeyValuePair, error)

	// ### 7.4 查询某一组织的加密公共参数,返回其序列化后的byte数组
	// **参数说明**
	//   - contractName: 合约名
	//   - method: 查询的合约方法名
	//   - orgId: 参与方 id
	//   - timeout: 查询超时时间,单位:s,若传入-1,将使用默认超时时间:10s
	// “`go
	QueryHibeParamsWithOrgId(contractName, method, orgId string, timeout int64) ([]byte, error)

	// ### 7.5 已知交易id,根据私钥解密密文交易
	// **参数说明**
	//   - localId: 本地层级属性加密 id
	//   - hibeParams: hibeParams 序列化后的byte数组
	//   - hibePrivKey: hibe私钥序列化后的byte数组
	//   - txId: 层级属性加密交易 id
	//   - keyType: 对加密信息进行对称解密的方法,请和加密时使用的方法保持一致,请传入 common 中 crypto 包提供的方法,目前提供AES和SM4两种方法
	// “`go
	DecryptHibeTxByTxId(localId string, hibeParams []byte, hibePrvKey []byte, txId string,
		keyType crypto.KeyType) ([]byte, error)

	// ## 8 数据归档接口
	// **(注意:请使用归档工具cmc进行归档操作,以下接口是归档原子接口,并不包括归档完整流程)**
	// ### 8.1 获取已归档区块高度,该方法已弃用,请优先使用GetArchiveStatus
	// **参数说明**
	//   - 输出已归档的区块高度
	// “`go
	//Deprecated
	GetArchivedBlockHeight() (uint64, error)
	// “`
	// ### 8.2 获取节点归档状态详细信息
	// **参数说明**
	//   - 输出:输出节点支持的归档类型:ExtraDB(外部数据库),ArchiveCenter(归档中心)
	//   - 输出:已归档的区块高度
	//   - 输出:节点允许的归档高度: 高度必须小于(CurrBlockHeight-UnarchivedHeight),UnarchivedHeight在chainmaker.yml storage中设置
	//   - 输出:当前节点的归档状态:Normal(正常), Archiving(正在归档), Restoring(正在恢复)
	//   - 输出:当前节点上可恢复区块的暂存文件信息
	// “`go
	GetArchiveStatus() (*store.ArchiveStatus, error)

	// “`
	// ### 8.3 构造数据归档区块Payload
	// **参数说明**
	//   - targetBlockHeight: 归档目标区块高度,节点ArchiveStatus.Process为Normal时才可发送成功
	// “`go
	CreateArchiveBlockPayload(targetBlockHeight uint64) (*common.Payload, error)

	// ### 8.4 构造归档数据恢复Payload
	// **参数说明**
	//   - fullBlock: 完整区块数据(对应结构:store.BlockWithRWSet)
	// “`go
	CreateRestoreBlockPayload(fullBlock []byte) (*common.Payload, error)

	// ### 8.6 发送归档请求
	// **参数说明**
	//   - payload: 指向payload对象的指针
	//   - timeout: 超时时间,单位:s,若传入-1,将使用默认超时时间:10s
	//   - 备注:必须在ArchiveStatus.Process归档状态为Normal时才可调用成功
	// “`go
	SendArchiveBlockRequest(payload *common.Payload, timeout int64) (*common.TxResponse, error)

	// ### 8.7 归档数据恢复
	// **参数说明**
	//   - payload: 指向payload对象的指针
	//   - timeout: 超时时间,单位:s,若传入-1,将使用默认超时时间:10s
	//   - 备注:必须在ArchiveStatus.Process归档状态为Normal时才可调用成功
	// “`go
	SendRestoreBlockRequest(payload *common.Payload, timeout int64) (*common.TxResponse, error)

	// ### 8.8 根据交易Id查询已归档交易
	// **参数说明**
	//   - txId: 交易ID
	// “`go
	GetArchivedTxByTxId(txId string) (*common.TransactionInfo, error)

	// ### 8.9 根据区块高度查询已归档区块
	// **参数说明**
	//   - blockHeight: 指定区块高度
	//   - withRWSet: 是否返回读写集
	// “`go
	GetArchivedBlockByHeight(blockHeight uint64, withRWSet bool) (*common.BlockInfo, error)

	// ### 8.11 根据区块哈希查询已归档区块
	// **参数说明**
	//   - blockHash: 指定区块Hash
	//   - withRWSet: 是否返回读写集
	// “`go
	GetArchivedBlockByHash(blockHash string, withRWSet bool) (*common.BlockInfo, error)

	// ### 8.12 根据交易Id查询已归档区块
	// **参数说明**
	//   - txId: 交易ID
	//   - withRWSet: 是否返回读写集
	// “`go
	GetArchivedBlockByTxId(txId string, withRWSet bool) (*common.BlockInfo, error)

	// ## 9 隐私计算系统合约接口
	// ### 9.1 保存隐私合约计算结果,包括合约部署
	// **参数说明**
	//   - contractName: 合约名称
	//   - contractVersion: 合约版本号
	//   - isDeployment: 是否是部署合约
	//   - codeHash: 合约字节码hash值
	//   - reportHash: Enclave report hash值
	//   - result: 隐私合约执行结果
	//   - codeHeader: solodity合部署合约时合约字节码的header数据
	//   - txId: 交易Id
	//   - rwSet: 隐私合约执行产生的读写集
	//   - sign: Enclave对执行结果数据的结果签名
	//   - events: 合约执行产生的事件
	//   - privateReq: 用户调用隐私计算请求时的request序列化字节数组
	//   - withSyncResult: 是否同步返回调用结果
	//   - timeout: 发送交易的超时时间
	// “`go
	SaveData(contractName string, contractVersion string, isDeployment bool, codeHash []byte, reportHash []byte,
		result *common.ContractResult, codeHeader []byte, txId string, rwSet *common.TxRWSet, sign []byte,
		events *common.StrSlice, privateReq []byte, withSyncResult bool, timeout int64) (*common.TxResponse, error)

	// ### 9.2 保存远程证明
	// **参数说明**
	//   - proof: 远程证明
	//   - txId: 交易Id
	//   - withSyncResult: 是否同步返回调用结果
	//   - timeout: 交易发送超时时间
	// “`go
	SaveRemoteAttestationProof(proof, txId string, withSyncResult bool, timeout int64) (*common.TxResponse, error)

	// ### 9.3 构建上传Enclave CA证书的报文
	// **参数说明**
	//   - caCert: Enclave CA证书
	//   - txId: 交易Id
	// “`go
	CreateSaveEnclaveCACertPayload(caCert, txId string) (*common.Payload, error)

	// ### 9.4 获取Enclave CA证书
	// “`go
	GetEnclaveCACert() ([]byte, error)

	// ### 9.5 隐私计算调用者权限验证
	// **参数说明**
	//   - payload: 用户签名验证的payload内容
	//   - orgIds: 组织Id的slice,注意和signPairs里面SignInfo的证书顺序一致
	//   - signPairs: 用户多签的签名和证书slice
	// “`go
	CheckCallerCertAuth(payload string, orgIds []string, signPairs []*syscontract.SignInfo) (*common.TxResponse, error)

	// ### 9.6 获取Enclave的report
	// **参数说明**
	//   - enclaveId: Enclave的Id,当前固定为"global_enclave_id"
	// “`go
	GetEnclaveReport(enclaveId string) ([]byte, error)

	// ### 9.7 获取隐私证明材料
	// **参数说明**
	//   - enclaveId: Enclave的Id,当前固定为"global_enclave_id"
	// “`go
	GetEnclaveProof(enclaveId string) ([]byte, error)

	// ### 9.8 获取隐私合约计算结果
	// **参数说明**
	//   - contractName: 合约名称
	//   - key: 计算结果对应的键值
	// “`go
	GetData(contractName, key string) ([]byte, error)

	// ### 9.9 保存隐私目录
	// **参数说明**
	//   - orderId: 隐私目录的主键,供以后查询使用
	//   - txId: 交易ID
	//   - privateDir:
	//   - withSyncResult: 是否同步等待交易结果
	//   - timeout: 等待交易结果的超时时间
	// “`go
	SaveDir(orderId, txId string, privateDir *common.StrSlice, withSyncResult bool,
		timeout int64) (*common.TxResponse, error)

	// ### 9.10 获取用户部署的隐私合约
	// **参数说明**
	//   - contractName: 合约名称
	//   - codeHash: 代码哈希
	// “`go
	GetContract(contractName, codeHash string) (*common.PrivateGetContract, error)

	// ### 9.11 获取用户的隐私目录
	// **参数说明**
	//   - orderId: 隐私目录的主键
	// “`go
	GetDir(orderId string) ([]byte, error)

	// ### 9.12 构建上传隐私计算环境的report的报文
	// **参数说明**
	//   - enclaveId: 隐私计算环境的标识
	//   - report: 隐私计算环境的report
	//   - txId: 交易ID
	// “`go
	CreateSaveEnclaveReportPayload(enclaveId, report, txId string) (*common.Payload, error)

	// ### 9.13 获取隐私计算环境的加密公钥
	// **参数说明**
	//   - enclaveId: 隐私计算环境的标识
	// “`go
	GetEnclaveEncryptPubKey(enclaveId string) ([]byte, error)

	// ### 9.14 获取隐私计算环境的验签公钥
	// **参数说明**
	//   - enclaveId: 隐私计算环境的标识
	// “`go
	GetEnclaveVerificationPubKey(enclaveId string) ([]byte, error)

	// ### 9.15 获取隐私证明材料中的Challenge
	// **参数说明**
	//   - enclaveId: 隐私计算环境的标识
	// “`go
	GetEnclaveChallenge(enclaveId string) ([]byte, error)

	// ### 9.16 获取隐私证明材料中的Signature
	// **参数说明**
	//   - enclaveId: 隐私计算环境的标识
	// “`go
	GetEnclaveSignature(enclaveId string) ([]byte, error)

	// ## 10 系统类接口
	// ### 10.1 SDK停止接口
	// *关闭连接池连接,释放资源*
	// “`go
	Stop() error

	// ### 10.2 获取链版本
	// “`go
	GetChainMakerServerVersion() (string, error)
	GetChainMakerServerVersionCustom(ctx context.Context) (string, error)

	// ## 11 公钥身份类接口
	// ### 11.1 构造添加公钥身份请求
	// **参数说明**
	//   - pubkey: 公钥信息
	//   - orgId: 组织id
	//   - role:   角色,支持client,light,common
	// “`go
	CreatePubkeyAddPayload(pubkey string, orgId string, role string) (*common.Payload, error)

	// ### 11.2 构造删除公钥身份请求
	// **参数说明**
	//   - pubkey: 公钥信息
	//   - orgId: 组织id
	// “`go
	CreatePubkeyDelPayload(pubkey string, orgId string) (*common.Payload, error)

	// ### 11.3 构造查询公钥身份请求
	// **参数说明**
	//   - pubkey: 公钥信息
	// “`go
	CreatePubkeyQueryPayload(pubkey string) (*common.Payload, error)

	// ### 11.4 发送公钥身份管理请求(添加、删除)
	// **参数说明**
	//   - payload: 交易payload
	//   - endorsers: 背书签名信息列表
	//   - timeout: 超时时间,单位:s,若传入-1,将使用默认超时时间:10s
	//   - withSyncResult: 是否同步获取交易执行结果
	//            当为true时,若成功调用,common.TxResponse.ContractResult.Result为common.TransactionInfo
	//            当为false时,若成功调用,common.TxResponse.ContractResult为空,可以通过common.TxResponse.TxId查询交易结果
	// “`go
	SendPubkeyManageRequest(payload *common.Payload, endorsers []*common.EndorsementEntry, timeout int64,
		withSyncResult bool) (*common.TxResponse, error)

	// ## 12 多签类接口
	// ### 12.1 发起多签请求
	// **参数说明**
	//   - payload: 待签名payload
	//   - endorsers: 背书签名信息列表
	//   - timeout: 超时时间,单位:s,若传入-1,将使用默认超时时间:10s
	//   - withSyncResult: 是否同步获取交易执行结果
	//            当为true时,若成功调用,common.TxResponse.ContractResult.Result为common.TransactionInfo
	//            当为false时,若成功调用,common.TxResponse.ContractResult为空,可以通过common.TxResponse.TxId查询交易结果
	//   - payer: 指定gas代扣账户
	// “`go
	MultiSignContractReq(payload *common.Payload, endorsers []*common.EndorsementEntry, timeout int64,
		withSyncResult bool) (*common.TxResponse, error)
	MultiSignContractReqWithPayer(payload *common.Payload, endorsers []*common.EndorsementEntry,
		payer *common.EndorsementEntry, timeout int64, withSyncResult bool) (*common.TxResponse, error)

	// ### 12.2 发起多签投票
	// **参数说明**
	//   - payload: 待签名payload
	//   - endorser: 投票人对多签请求 payload 的签名信息
	//   - isAgree: 投票人对多签请求是否同意,true为同意,false则反对
	//   - timeout: 超时时间,单位:s,若传入-1,将使用默认超时时间:10s
	//   - withSyncResult: 是否同步获取交易执行结果
	//            当为true时,若成功调用,common.TxResponse.ContractResult.Result为common.TransactionInfo
	//            当为false时,若成功调用,common.TxResponse.ContractResult为空,可以通过common.TxResponse.TxId查询交易结果
	//   - payer: 指定gas代扣账户
	// “`go
	MultiSignContractVote(payload *common.Payload, endorser *common.EndorsementEntry, isAgree bool,
		timeout int64, withSyncResult bool) (*common.TxResponse, error)
	MultiSignContractVoteWithGasLimit(payload *common.Payload, endorser *common.EndorsementEntry, isAgree bool,
		timeout int64, gasLimit uint64, withSyncResult bool) (*common.TxResponse, error)
	MultiSignContractVoteWithGasLimitAndPayer(payload *common.Payload, endorser *common.EndorsementEntry,
		payer *common.EndorsementEntry, isAgree bool, timeout int64, gasLimit uint64,
		withSyncResult bool) (*common.TxResponse, error)

	// ### 12.3 根据txId查询多签状态
	// **参数说明**
	//   - txId: 需要查询的多签请求交易Id
	//   - params: 格式化参数
	// “`go
	MultiSignContractQuery(txId string) (*common.TxResponse, error)
	MultiSignContractQueryWithParams(txId string, params []*common.KeyValuePair) (*common.TxResponse, error)

	// ### 12.4 触发执行多签请求
	// **参数说明**
	//   - payload: 待签名payload
	//   - timeout: 超时时间,单位:s,若传入-1,将使用默认超时时间:10s
	//   - limit: 本次执行多签请求支付的 gas 上限
	//   - withSyncResult: 是否同步获取交易执行结果
	//            当为true时,若成功调用,common.TxResponse.ContractResult.Result为common.TransactionInfo
	//            当为false时,若成功调用,common.TxResponse.ContractResult为空,可以通过common.TxResponse.TxId查询交易结果
	//   - payer: 指定gas代扣账户
	// “`go
	MultiSignContractTrig(multiSignReqPayload *common.Payload,
		timeout int64, limit *common.Limit, withSyncResult bool) (*common.TxResponse, error)
	MultiSignContractTrigWithPayer(multiSignReqPayload *common.Payload, payer *common.EndorsementEntry,
		timeout int64, limit *common.Limit, withSyncResult bool) (*common.TxResponse, error)

	// ### 12.5 根据发起多签请求所需的参数构建payload
	// **参数说明**
	//   - pairs: 发起多签请求所需的参数
	//   - gasLimit: 本次交易允许消费的最大gas, 0代表无限制
	// “`go
	CreateMultiSignReqPayload(pairs []*common.KeyValuePair) *common.Payload
	CreateMultiSignReqPayloadWithGasLimit(pairs []*common.KeyValuePair, gasLimit uint64) *common.Payload

	// ## 13 gas管理相关接口
	// ### 13.1 构造设置gas管理员Payload
	// **参数说明**
	//   - address: gas管理员的地址
	// “`go
	CreateSetGasAdminPayload(address string) (*common.Payload, error)

	// ### 13.2 查询gas管理员
	// **返回值说明**
	//   - string: gas管理员的账号地址
	// “`go
	GetGasAdmin() (string, error)

	// ### 13.3 构造充值gas账户Payload
	// **参数说明**
	//   - rechargeGasList: 一个或多个gas账户充值指定gas数量
	// “`go
	CreateRechargeGasPayload(rechargeGasList []*syscontract.RechargeGas) (*common.Payload, error)

	// ### 13.4 查询gas账户余额
	// **参数说明**
	//   - address: 查询gas余额的账户地址
	// “`go
	GetGasBalance(address string) (int64, error)

	// ### 13.5 构造退还gas账户Payload
	// **参数说明**
	//   - address: 退还gas的账户地址
	//   - amount: 退还gas的数量
	// “`go
	CreateRefundGasPayload(address string, amount int64) (*common.Payload, error)

	// ### 13.6 构造冻结指定gas账户Payload
	// **参数说明**
	//   - address: 冻结指定gas账户的账户地址
	// “`go
	CreateFrozenGasAccountPayload(address string) (*common.Payload, error)

	// ### 13.7 构造解冻指定gas账户Payload
	// **参数说明**
	//   - address: 解冻指定gas账户的账户地址
	// “`go
	CreateUnfrozenGasAccountPayload(address string) (*common.Payload, error)

	// ### 13.8 查询gas账户的状态
	// **参数说明**
	//   - address: 解冻指定gas账户的账户地址
	// **返回值说明**
	//   - bool: true表示账号未被冻结,false表示账号已被冻结
	// “`go
	GetGasAccountStatus(address string) (bool, error)

	// ### 13.9 发送gas管理类请求
	// **参数说明**
	//   - payload: 交易payload
	//   - endorsers: 背书签名信息列表
	//   - timeout: 超时时间,单位:s,若传入-1,将使用默认超时时间:10s
	//   - withSyncResult: 是否同步获取交易执行结果
	//            当为true时,若成功调用,common.TxResponse.ContractResult.Result为common.TransactionInfo
	//            当为false时,若成功调用,common.TxResponse.ContractResult为空,可以通过common.TxResponse.TxId查询交易结果
	// “`go
	SendGasManageRequest(payload *common.Payload, endorsers []*common.EndorsementEntry, timeout int64,
		withSyncResult bool) (*common.TxResponse, error)

	// ### 13.10 为payload添加gas limit
	// **参数说明**
	//   - payload: 交易payload
	//   - limit: transaction limitation,执行交易时的资源消耗上限
	// “`go
	AttachGasLimit(payload *common.Payload, limit *common.Limit) *common.Payload

	// ### 13.11 估算交易的gas消耗量
	// **参数说明**
	//   - payload: 待估算gas消耗量的交易payload
	// **返回值说明**
	//   - uint64: 估算出的gas消耗量
	// “`go
	EstimateGas(payload *common.Payload) (uint64, error)

	// ### 13.12 构造配置账户基础gas消耗数量Payload
	// **参数说明**
	//   - amount: 调用合约消耗的基础的 gas 数量
	// “`go
	CreateSetInvokeBaseGasPayload(invokeBaseGas int64) (*common.Payload, error)

	// ### 13.13 设置链配置的 default gas_price 参数
	// **参数说明**
	//   - invokeGasPrice: 调用合约中所带参数消耗的每个字节的 gas 价格,支持格式为10进制整数|小数
	// “`go
	CreateSetInvokeGasPricePayload(invokeGasPrice string) (*common.Payload, error)

	// ### 13.14 设置链配置的 install_base gas 参数
	// **参数说明**
	//   - amount: 安装|升级合约消耗的基础的 gas 数量
	// “`go
	CreateSetInstallBaseGasPayload(installBaseGas int64) (*common.Payload, error)

	// ### 13.15 设置链配置的 install gas_price 参数
	// **参数说明**
	//   - invokeGasPrice: 安装|升级合约中所带参数消耗的每个字节的 gas 价格,支持格式为10进制整数|小数
	// “`go
	CreateSetInstallGasPricePayload(installGasPrice string) (*common.Payload, error)

	// ## 14 别名相关接口
	// ### 14.1 添加别名
	// “`go
	AddAlias() (*common.TxResponse, error)

	// ### 14.2 构造更新别名的证书Payload
	// **参数说明**
	//   - alias: 带更新证书的别名
	//   - newCertPEM: 新的证书,此新证书将替换掉alias关联的证书
	// “`go
	CreateUpdateCertByAliasPayload(alias, newCertPEM string) *common.Payload

	// ### 14.3 签名更新别名的证书Payload
	// **参数说明**
	//   - payload: 交易payload
	// “`go
	SignUpdateCertByAliasPayload(payload *common.Payload) (*common.EndorsementEntry, error)

	// ### 14.4 发起更新别名的证书交易
	// **参数说明**
	//   - payload: 交易payload
	//   - endorsers: 背书签名信息列表
	//   - timeout: 超时时间,单位:s,若传入-1,将使用默认超时时间:10s
	//   - withSyncResult: 是否同步获取交易执行结果
	//            当为true时,若成功调用,common.TxResponse.ContractResult.Result为common.TransactionInfo
	//            当为false时,若成功调用,common.TxResponse.ContractResult为空,可以通过common.TxResponse.TxId查询交易结果
	// “`go
	UpdateCertByAlias(payload *common.Payload, endorsers []*common.EndorsementEntry,
		timeout int64, withSyncResult bool) (*common.TxResponse, error)

	// ### 14.5 查询别名详细信息
	// **参数说明**
	//   - aliases: 带查询的证书别名切片,根据这些别名查询返回AliasInfos
	// “`go
	QueryCertsAlias(aliases []string) (*common.AliasInfos, error)

	// ### 14.6 构造删除别名Payload
	// **参数说明**
	//   - aliases: 带删除的证书别名切片
	// “`go
	CreateDeleteCertsAliasPayload(aliases []string) *common.Payload

	// ### 14.7 签名删除别名Payload
	// **参数说明**
	//   - payload: 交易payload
	// “`go
	SignDeleteAliasPayload(payload *common.Payload) (*common.EndorsementEntry, error)

	// ### 14.8 发起删除别名交易
	// **参数说明**
	//   - payload: 交易payload
	//   - endorsers: 背书签名信息列表
	//   - timeout: 超时时间,单位:s,若传入-1,将使用默认超时时间:10s
	//   - withSyncResult: 是否同步获取交易执行结果
	//            当为true时,若成功调用,common.TxResponse.ContractResult.Result为common.TransactionInfo
	//            当为false时,若成功调用,common.TxResponse.ContractResult为空,可以通过common.TxResponse.TxId查询交易结果
	// “`go
	DeleteCertsAlias(payload *common.Payload, endorsers []*common.EndorsementEntry,
		timeout int64, withSyncResult bool) (*common.TxResponse, error)

	// ## 15 交易池相关接口
	// ### 15.1 获取交易池状态
	// “`go
	GetPoolStatus() (*txpool.TxPoolStatus, error)

	// ### 15.2 获取不同交易类型和阶段中的交易Id列表
	// **参数说明**
	//   - txType: 交易类型 在pb的txpool包中进行了定义
	//   - txStage: 交易阶段 在pb的txpool包中进行了定义
	// **返回值说明**
	//   - []string: 交易Id列表
	// “`go
	GetTxIdsByTypeAndStage(txType txpool.TxType, txStage txpool.TxStage) ([]string, error)

	// ### 15.3 根据txIds获取交易池中存在的txs,并返回交易池缺失的tx的txIds
	// **参数说明**
	//   - txIds: 交易Id列表
	// **返回值说明**
	//   - []*common.Transaction: 交易池中存在的txs
	//   - []string: 交易池缺失的tx的txIds
	// “`go
	GetTxsInPoolByTxIds(txIds []string) ([]*common.Transaction, []string, error)

	// ### 15.4 根据txId查询交易的状态
	// **参数说明**
	//   - txId: 交易Id
	// **返回值说明**
	//   - txpool.TxStatus: 交易状态
	// “`go
	GetTxStatus(txId string) (txpool.TxStatus, error)

	// ### 15.5 获取所有共识节点的身份标识
	// **返回值说明**
	//   - []string: 共识节点身份标识
	//   - err: 当查询的节点非共识节点时或共识节点内部查询中出现错误,返回error
	// “`go
	GetConsensusValidators() ([]string, error)

	// ### 15.6 获取节点正在共识的区块高度
	// **返回值说明**
	//   - uint64: 节点正在共识的区块高度
	//   - err: 当查询的节点非共识节点时或共识节点内部查询中出现错误,返回error
	// “`go
	GetConsensusHeight() (uint64, error)

	// ### 15.7 获取共识节点的状态
	// **返回值说明**
	//   - []byte: 查询的共识节点状态
	//   - err: 当查询的节点非共识节点时或共识节点内部查询中出现错误,返回error
	// “`go
	GetConsensusStateJSON() ([]byte, error)

	// ### 15.8 构造raft切换到tbft Payload
	// **参数说明**
	//   - extConfig: 应用到tbft共识的ext_config
	// “`go
	CreateRaftToTbftPayload(extConfig []*common.KeyValuePair) (*common.Payload, error)

	// ### 15.9 构造tbft切换到raft Payload
	// **参数说明**
	//   - extConfig: 应用到raft共识的ext_config
	// “`go
	CreateTbftToRaftPayload(extConfig []*common.KeyValuePair) (*common.Payload, error)

	// ## 16 DPoS相关接口
	// ### 16.1 增发
	// “`go
	Mint(address string, amount string) (*common.Payload, error)

	// ### 16.2 转账
	// “`go
	Transfer(address string, amount string) (*utils.BigInteger, error)

	// ### 16.3 查询账户余额
	// “`go
	BalanceOf(address string) (*utils.BigInteger, error)

	// ### 16.4 转移管理员权限
	// “`go
	TransferOwnership(address string) (*common.Payload, error)

	// ### 16.5 查询合约管理地址
	// “`go
	Owner() (string, error)

	// ### 16.6 查询ERC20合约的精度
	// “`go
	Decimals() (string, error)

	// ### 16.7 查询Token总供应量
	// “`go
	Total() (string, error)

	// ### 16.8 查询所有的候选人
	// “`go
	GetAllCandidates() (*syscontract.ValidatorVector, error)

	// ### 16.9 查询指定验证人的信息
	// “`go
	GetValidatorByAddress(address string) (*syscontract.Validator, error)

	// ### 16.10 抵押权益到验证人
	// “`go
	Delegate(to string, value string) (*syscontract.Delegation, error)

	// ### 16.11 查询指定地址的抵押信息
	// “`go
	GetDelegationsByAddress(address string) (*syscontract.DelegationInfo, error)

	// ### 16.12 查询指定地址的抵押信息
	// “`go
	GetUserDelegationByValidator(delegator string, validator string) (*syscontract.Delegation, error)

	// ### 16.13 从验证人解除抵押的权益
	// “`go
	UnDelegate(from string, value string) (*syscontract.UnbondingDelegation, error)

	// ### 16.14 根据世代id查询世代信息
	// “`go
	GetEpochById(id string) (*syscontract.Epoch, error)

	// ### 16.15 查询当前世代信息
	// “`go
	GetLastEpoch() (*syscontract.Epoch, error)

	// ### 16.16 Stake合约中设置验证人的NodeID
	// “`go
	SetNodeId(nodeId string) (string, error)

	// ### 16.17 Stake合约中查询验证人的NodeID
	// “`go
	GetNodeId(address string) (string, error)

	// ### 16.18 获取设置的最小质押数量
	// “`go
	GetMinSelfDelegation() (int, error)

	// ### 16.19 查看世代中区块数
	// “`go
	GetEpochValidatorNumber() (int, error)

	// ### 16.20 查看世代中区块数
	// “`go
	GetEpochBlockNumber() (int, error)

	// ### 16.21 查询Stake合约的系统地址
	// “`go
	GetStakeContractAddress() (string, error)

	// ### 16.22 查询收到解质押退款间隔的世代数
	// “`go
	GetUnboundingIntervalEpochNumber() (string, error)

	// ### 16.23 查询当前世代中每出一个块激励的权益数
	// “`go
	GetDistributionPerBlock() (int, error)

	// ### 16.24 修改世代中每个块激励的权益数
	// “`go
	SetDistributionPerBlock(distributionPerBlock int) (*common.Payload, error)

	// ### 16.25 查询当前世代中gas兑换比例
	// “`go
	GetGasExchangeRate() (int, error)

	// ### 16.26 修改世代中gas兑换比例
	// “`go
	SetGasExchangeRate(gasExchangeRate int) (*common.Payload, error)

	// ### 16.27 查询世代中激励明细
	// “`go
	GetDistributionByEpochId(epochId string) (*EpochAmountDetail, error)

	// ### 16.28 同时修改世代出块数量和世代验证者数量
	// “`go
	SetEpochBlockNumberAndValidatorNumber(
		epochBlockNumber int,
		epochValidatorNumber int) (*common.Payload, error)

	// ### 16.29 查询惩罚账户余额
	// “`go
	GetSlashingBalance() (string, error)

	// ### 16.30 查询惩罚账户地址
	// “`go
	GetSlashingAddress() (string, error)

	// ### 16.31 查询世代中惩罚明细
	// “`go
	GetSlashingByEpochId(epochId string) (*SlashingDetail, error)

	// EthSendRawTx 发送经过rlp编码后的以太坊交易
	EthSendRawTx(rawTx []byte, timeout int64, withSyncResult bool) (*common.TxResponse, error)

	// EthEstimateGas ETH交易情况下的Gas预估
	// @return func
	EthEstimateGas(from *ethbase.Address, to ethbase.Address,
		gas uint64, gasPrice, value *ethbase.SafeUint256, data []byte) (uint64, error)

	// EthCall ETH交易情况下的Call(合约查询)
	// @return func
	EthCall(from, to ethbase.Address,
		gas uint64, gasPrice, value *ethbase.SafeUint256, data []byte) (*common.TxResponse, error)

	// ArchiveBlocks 归档指定区块高度范围的区块到归档服务
	// @param beginHeight
	// @param endHeight
	// @param mode
	// @param heightNoticeCallback 归档进度通知
	// @return error
	ArchiveBlocks(archiveHeight uint64, mode string, heightNoticeCallback func(ProcessMessage) error) error

	// RestoreBlocks 从归档服务中恢复到指定高度的区块到节点中
	// @param restoreHeight 指定恢复高度
	// @param heightNoticeCallback 恢复进度通知
	// @return error
	RestoreBlocks(restoreHeight uint64, mode string, heightNoticeCallback func(ProcessMessage) error) error

	GetStateKeyHistory(contractName string, key string, options ...Option) ([]*storePb.KeyModification, error)
	GetAccountContractTxHistory(memberInfo []byte, contractName string, options ...Option) ([]*storePb.TxHistory, error)
}

SDKInterface # ChainMaker Go SDK 接口说明

type Signer

type Signer interface {
	// Sign sign payload
	Sign(payload *common.Payload) (signature []byte, err error)
	// NewMember new *accesscontrol.Member
	NewMember() (*accesscontrol.Member, error)
}

Signer define interface of all kinds of signer in different mode

type SlashingDetail

type SlashingDetail struct {
	EpochId               uint64
	SlashingBalanceBefore *utils.BigInteger
	SlashingBalanceAfter  *utils.BigInteger
	Validators            []string
	Details               []*SlashingDetailPerValidator
}

SlashingDetail 每一个世代的惩罚明细

type SlashingDetailPerValidator

type SlashingDetailPerValidator struct {
	ValidatorAddress string
	DelegationRate   *DelegatorRate
	SlashingAmount   *utils.BigInteger
	DelegationBefore []*syscontract.Delegation
	DelegationAfter  []*syscontract.Delegation
}

SlashingDetailPerValidator 每一个世代中的,每一个验证者惩罚明细

Jump to

Keyboard shortcuts

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