You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Ok, I have figured out what was wrong: I was trying to keep compatibility with the "old" JSON "wallet" format.
Passing the credentials as a Buffer instead of a string into the identity property to the gateway's connect function solves the problem.
Here is the code snippet for those who want to keep the compatibility back with the "User.id" JSON wallet file format (assuming 2 env vars: one to configure the wallet path and another the identity name to be used to transact, plus using more or less the same code structure used into asset-transfer-basic/application-gateway-typescript sample):
constwalletPath=process.env.WALLET_PATH||'/opt/node/wallet';constidentity=process.env.IDENTITY||'Admin';constwalletFile=fs.readFileSync(`${walletPath}/${identity}.id`,'utf8');constwallet=JSON.parse(walletFile);constnewIdentity: any=async()=>{constmspId=wallet.mspId;constcredentials=Buffer.from(wallet.credentials.certificate);// here is the "gotcha"return{ mspId, credentials };}constnewSigner: any=async()=>{constprivateKey=crypto.createPrivateKey(wallet.credentials.privateKey);returnsigners.newPrivateKeySigner(privateKey);}
Passing the credentials as a Buffer instead of a string into the
identity
property to the gateway'sconnect
function solves the problem.Here is the code snippet for those who want to keep the compatibility back with the "User.id" JSON wallet file format (assuming 2 env vars: one to configure the wallet path and another the identity name to be used to transact, plus using more or less the same code structure used into
asset-transfer-basic/application-gateway-typescript
sample):Originally posted by @jeffbicca in hyperledger/fabric#4358 (comment)
The text was updated successfully, but these errors were encountered: