【问题标题】:Hyperledger Composer issue identity but missing business cardHyperledger Composer 发布身份但缺少名片
【发布时间】:2017-11-17 00:46:33
【问题描述】:

我正在使用 Node.js 应用程序和“composer-client”npm 模块进行概念验证。

我尝试了不同的命令,例如添加参与者、添加资产和执行交易,一切似乎都正常工作。

但是,当我尝试颁发新身份时,我没有得到预期的结果。我使用以下代码执行我的 Node.js 应用程序:

var businessNetwork = new BusinessNetworkConnection();
return businessNetwork.connect('admin@tutorial-network')
.then(() => {
  return businessNetwork.issueIdentity('org.acme.biznet.Trader#Trader_001', 'usr001')
})
.then((result) => {
  console.log(`userID = ${result.userID}`);
  console.log(`userSecret = ${result.userSecret}`);
})
.catch((error) => {
  console.error(error);
});

然后,UserId 和 UserSecret 将显示在控制台日志中。之后,我尝试对 Business Network 执行 ping 操作:

var businessNetwork = new BusinessNetworkConnection();
return businessNetwork.connect('usr001@tutorial-network')
.then(() => {
  return businessNetwork.ping();
})
.then((result) => {
  console.log(`participant = ${result.participant ? result.participant : '<no participant found>'}`);
})
.catch((error) => {
  console.error(error);
});

但是,我收到以下错误消息:

{ Error: Card not found: usr001@tutorial-network
at IdCard.fromDirectory.catch.cause (/home/user.name/git_repositories/nodejs/first.blockchain.test/node_modules/composer-common/lib/cardstore/filesystemcardstore.js:73:27)
at <anonymous>
cause: 
{ Error: Unable to read card directory: /home/user.name/.composer/cards/user001@tutorial-network

如果我执行命令composer identity list -c admin@tutorial-network,我会得到以下输出:

$class:      org.hyperledger.composer.system.Identity
  identityId:  9b49f67c262c0ae23e1e0c4a8dc61c4a12b5119df2b6a49fa2e02fa56b8818c3
  name:        usr001
  issuer:      27c582d674ddf0f230854814b7cfd04553f3d0eac55e37d915386c614a5a1de9
  certificate: 
  state:       ISSUED
  participant: resource:org.acme.biznet.Trader#Trader_001

但是,我找不到名片。

【问题讨论】:

    标签: hyperledger-fabric hyperledger hyperledger-composer


    【解决方案1】:

    它对我有用。我正在使用作曲家 0.15.1。

    var businessNetwork = new BusinessNetworkConnection();
    
    return businessNetwork.connect('admin@carauction-network')
    .then(() => {
      return businessNetwork.ping();
    })
    .then((result) => {
      console.log(`participant = ${result.participant ? result.participant : '<no participant found>'}`);
    })
    .catch((error) => {
      console.error(error);
    });
    

    输出是这样的

    linux1@fabric:~/eventclient$ node event.js
    participant = org.hyperledger.composer.system.NetworkAdmin#admin
    

    您可能需要将身份证导入钱包?

    composer card import --file networkadmin.card
    

    【讨论】:

    • 一旦你发行了你的file.card,你有没有把它导入钱包?如果是,从 node.js 代码发出该文件时,它保存在哪里?我找不到它。
    【解决方案2】:

    上周晚些时候我遇到了类似的问题。从 V0.14 到 V0.15 的部分升级说明指出,我们必须删除(如果存在)~/.composer~/.composer-connection-profiles~/.composer-credentials。我在第一次升级到 v01.5 时跳过了这一步,遇到了您看到的错误。返回并删除这三个文件夹,重新安装二进制文件并重新检查 docker 映像状态。错误消失了,并且没有再次出现。

    【讨论】:

      【解决方案3】:

      您将新卡命名为 user001,而不是 user001@@tutorial-network。尝试仅使用 user001 作为连接卡名称进行连接。

      【讨论】:

        【解决方案4】:

        我使用以下命令使用从 javascript 获得的注册密码为参与者创建了一张卡片。

        composer card create -u usr001 -s <enrollment_secret> -f usr001.card -n tutorial-network -p connection.json
        

        您可能在所遵循的教程之前的某个步骤中创建了所需的 connection.json。如果此文件不明确可用,您可以从作曲家钱包中获取它。在当前版本中,它可以位于 /home/your_user/.composer/cards/。如果您只是按照教程进行操作,则此目录中的任何 connection.json 都可以。 之后,您必须使用以下命令将创建的凭证添加到钱包中:

        composer card import -f usr001.card
        

        您用于测试已颁发身份的代码是正确的。

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 2016-05-25
          • 2014-09-27
          • 1970-01-01
          • 2023-03-10
          • 2019-03-16
          • 2017-10-18
          • 1970-01-01
          • 2016-08-02
          相关资源
          最近更新 更多