1. registerAuthorityIssuer

基本信息

  1. 接口名称:com.webank.weid.rpc.AuthorityIssuerService.registerAuthorityIssuer
  2. 接口定义:ResponseData<Boolean> registerAuthorityIssuer(RegisterAuthorityIssuerArgs args)
  3. 接口描述: 注册成为权威机构。
  4. 注意:这是一个需要权限的操作,目前只有合约的部署者(一般为SDK)才能正确执行。

接口入参: com.webank.weid.protocol.request.RegisterAuthorityIssuerArgs

名称类型非空说明备注
authorityIssuerAuthorityIssuerY AuthorityIssuer信息,见下
weIdPrivateKeyWeIdPrivateKeyY 交易私钥,见下

com.webank.weid.protocol.base.AuthorityIssuer

名称类型非空说明备注
weIdStringY授权机构WeIdentity DID
nameStringY授权机构名称机构名称必须小于32个字节,非空,且仅包含ASCII码可打印字符(ASCII值位于32~126)
createdLongN创建日期注册时不需要传入,SDK内置默认为当前时间
accValueStringY授权方累积判定值

com.webank.weid.protocol.base.WeIdPrivateKey

名称类型非空说明备注
privateKeyStringY私钥值使用十进制数字表示

接口返回: com.webank.weid.protocol.response.ResponseData<Boolean>;

名称类型说明备注
errorCodeInteger返回结果码
errorMessageString返回结果描述
resultBoolean返回结果值
transactionInfoTransactionInfo交易信息

com.webank.weid.protocol.response.TransactionInfo

名称类型说明备注
blockNumberBigInteger交易块高
transactionHashString交易hash
transactionIndexBigInteger交易索引

此方法返回code

enumcodedesc
SUCCESS0成功
WEID_INVALID100101无效的WeIdentity DID
AUTHORITY_ISSUER_ERROR100200授权标准异常
AUTHORITY_ISSUER_PRIVATE_KEY_ILLEGAL100202私钥格式非法
AUTHORITY_ISSUER_OPCODE_MISMATCH100205操作码不匹配
AUTHORITY_ISSUER_NAME_ILLEGAL100206名称格式非法
AUTHORITY_ISSUER_ACCVALUE_ILLEAGAL100207累计值格式非法
TRANSACTION_TIMEOUT160001超时
TRANSACTION_EXECUTE_ERROR160002交易错误
ILLEGAL_INPUT160004参数为空

调用示例

  1. AuthorityIssuerService authorityIssuerService = new AuthorityIssuerServiceImpl();
  2.  
  3. AuthorityIssuer authorityIssuer = new AuthorityIssuer();
  4. authorityIssuer.setWeId("did:weid:101:0x39e5e6f663ef77409144014ceb063713b65600e7");
  5. authorityIssuer.setName("webank1");
  6. authorityIssuer.setAccValue("0");
  7.  
  8. WeIdPrivateKey weIdPrivateKey = new WeIdPrivateKey();
  9. weIdPrivateKey.setPrivateKey("36162289879206412028682370838615850457668262092955617990245744195910144330785");
  10.  
  11. RegisterAuthorityIssuerArgs registerAuthorityIssuerArgs = new RegisterAuthorityIssuerArgs();
  12. registerAuthorityIssuerArgs.setAuthorityIssuer(authorityIssuer);
  13. registerAuthorityIssuerArgs.setWeIdPrivateKey(weIdPrivateKey);
  14.  
  15. ResponseData<Boolean> response = authorityIssuerService.registerAuthorityIssuer(registerAuthorityIssuerArgs);
  1. 返回结果如:
  2. result: true
  3. errorCode: 0
  4. errorMessage: success
  5. transactionInfo:(com.webank.weid.protocol.response.TransactionInfo)
  6. blockNumber: 29963
  7. transactionHash: 0x97a5cc2f4f7888e788a22e7c9bef1a293614bceec4721810511d07fc5b748f33
  8. transactionIndex: 0

时序图

sequenceDiagramparticipant 调用者participant AuthorityIssuerServiceparticipant WeIdServiceparticipant 区块链节点调用者->>AuthorityIssuerService: 调用RegisterAuthorityIssuer()AuthorityIssuerService->>AuthorityIssuerService: 入参非空、格式及合法性检查opt 入参校验失败AuthorityIssuerService—>>调用者: 报错,提示参数不合法并退出endAuthorityIssuerService->>WeIdService: 查询WeIdentity DID存在性WeIdService->>区块链节点: 链上查询WeIdentity DID属性区块链节点—>>WeIdService: 返回查询结果WeIdService—>>AuthorityIssuerService: 返回查询结果opt 在链上不存在AuthorityIssuerService—>>调用者: 报错并退出endAuthorityIssuerService->>区块链节点: 加载私钥,调用注册合约opt 身份校验Note over 区块链节点: 如果传入WeIdentity DID在链上不存在区块链节点->>区块链节点: 报错并退出end区块链节点->>区块链节点: 权限检查,执行合约写入AuthorityIssuer信息区块链节点—>>AuthorityIssuerService: 返回合约执行结果AuthorityIssuerService->>AuthorityIssuerService: 解析合约事件opt 失败,地址无效或无权限AuthorityIssuerService—>>调用者: 报错并退出endAuthorityIssuerService—>>调用者: 返回成功