0

我正在尝试执行indy-sdk包的createPairwise函数。

它抛出 INDY Error 212 => WalletItemNotFound。(我也执行了createAndStoreMyDid函数)

这是我的代码

let [myDid, myVerkey] = await sdk.createAndStoreMyDid(await indy.wallet.get(), {});

let theirVerkey = await sdk.keyForDid(await indy.pool.get(), await indy.wallet.get(), theirDid);

let meta = JSON.stringify({
    theirEndpointDid: theirEndpointDid,
    verified: false // Indicates that the owner of the agent has confirmed they want to stay connected with this person.
});

//FIXME: Check to see if pairwise exists
await sdk.createPairwise(await indy.wallet.get(), theirDid, myDid, meta);

有人可以帮帮我吗?

4

1 回答 1

3

在您的代码中,实际上有两个地方IndySDK 1.11.1可以 throw 212 WalletItemNotFound

1.第一个在这一行:

let theirVerkey = await sdk.keyForDid(await indy.pool.get(), await indy.wallet.get(), theirDid);

IndySDK 将首先尝试查看变量下的 DIDtheirDid是否不是您的 DID 之一,存储在您的钱包中。如果没有,它会尝试在账本上找到这个 DID。如果仍然没有找到,它会抛出 WalletItemNotFound。您可以在此处的 IndySDK Rust 代码中查看此行为:

https://github.com/hyperledger/indy-sdk/blob/v1.11.1/libindy/src/commands/did.rs#L331

2.但是我认为这实际上不是你的情况,你有这个错误来自

wait sdk.createPairwise(await indy.wallet.get(), theirDid, myDid, meta);

如果你看看这个方法是如何在 Rust 中实现的

https://github.com/hyperledger/indy-sdk/blob/v1.11.1/libindy/src/commands/pairwise.rs#L84

你会看到它需要get_indy_record两者theirDid并且myDid你已经提供了。因此,如果不先将两个 DID 都存储在钱包中,就无法创建成对记录。theirDid您可以通过调用 storeTheirDid方法确保您的钱包包含。在

sdk.storeTheirDid(wh, {did:'V4SGRU86Z58d6TV7PBUe6f', verkey: 'GJ1SzoWzavQYfNL9XkaJdrQejfztN4XqdsiV4ct3LXKL'} )

拨打此电话后,您将可以createPairwise毫无问题地在您和他们之间拨打电话。

IndySDK 版本/缓存说明

我想你可能正在使用一些旧版本的 IndySDK。在 IndySDK 中1.11.1,当keyForDid从分类帐中解析某些内容时,它实际上会缓存这些数据,因此您发布的代码实际上对我来说是开箱即用的,没有错误。

于 2019-09-29T10:57:11.053 回答