Hyperledger Composer issue identity but missing business card

余生颓废 提交于 2019-12-22 10:46:14

问题


I am working in a proof of concept with a Node.js application and 'composer-client' npm module.

I have tried different commands such as adding a participant, adding an asset and performing a transaction and everything seems to work correctly.

However, when I try to issue a new identity I do not get the results that I expect. I execute my Node.js application with the following code:

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);
});

Then, UserId and UserSecret are displayed at console log. After that, I try to do a ping to Business Network:

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);
});

However, I get the following error message:

{ 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

If I execute the command composer identity list -c admin@tutorial-network, I get the following output:

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

But, I am not able to find the business card.


回答1:


It works for me. I'm using composer 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);
});

Output is like this

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

You may need to import ID card to wallet ?

composer card import --file networkadmin.card



回答2:


I had a similar issue late last week. Part of the upgrade instructions from V0.14 to V0.15 states that we have to delete the (if existing) ~/.composer, ~/.composer-connection-profiles and ~/.composer-credentials. I skipped that step on my first upgrade to v01.5 and encountered the error you are seeing. Went back and deleted those three folders, reinstalled the binaries and rechecked docker image status. Error went away and has not reappeared.




回答3:


You named the new card user001, not user001@@tutorial-network. Try connecting with just user001 as your connection card name.




回答4:


I used the following command to create a card for the participant using the enrollment secret obtained from the javascript.

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

You probably created the connection.json needed in some step before in the tutorial you are following. If this file is not available explicitly, you may get it from the composer wallet. In the current version, it can be located in /home/your_user/.composer/cards/. If you are only following the tutorial, any connection.json in this directory will do. After that, you must add the credential created to the wallet using:

composer card import -f usr001.card

Your code for testing the issued identity is correct.



来源:https://stackoverflow.com/questions/47341554/hyperledger-composer-issue-identity-but-missing-business-card

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!