openwallet-foundation/credo-ts

Need help on backup and restore functionality

Closed this issue · 8 comments

I am working on a project requiring backing up and restoring the wallet with all its previous connections and credentials. Are there any workable functionalities to implement backup and restore in Aries Bifold wallet?

There are two methods available: import and export, which you can use to make an export/import of your wallet.

agent.wallet.export

Is this what you're looking for?

Yes, I am looking for this one. I found export import method in /packages/core/src/wallet/Wallet.ts . Are you talking about these methods? If not, could you let me know which file these two methods are written in? It would be much helpful.

It's in the IndySdkWallet or AskarWallet (dependant on which wallet you use).

However, you can access it from the wallet api directly (using agent.wallet.export):

https://github.com/hyperledger/aries-framework-javascript/blob/11366e540421517ce21e8cca8781741fc482be8e/packages/core/src/wallet/WalletApi.ts#L112-L118

I have worked on import and export modules. After export a new file is generated which is used to import the wallet. The import functions also works. But the problem arises after importing, new wallet doesn't set automatically. Even walletConfig.id doesn't change.
For import, I have delete the wallet using agent.wallet.delete() and called agent.wallet.import() afterward. I have also tried to initialize the wallet after import using agent.wallet.initialize(). Still didn't worked.
Can you help me this regard?

image

What wallet are you using? AskarWallet or IndySdkWallet?

For import, I have delete the wallet using agent.wallet.delete() and called agent.wallet.import() afterward

I think this is to prevent from overwriting a local wallet

Still didn't worked.

What do you mean exactly with still doesn't work? Are you getting an error?

I am using IndySdkWallet.
For import, I am deleting the current wallet and creating a new wallet. After import I am getting no error. The import functionality creates sqlite.db,sqlite.db-shm,sqlite.db-wal files in mobile storage. I am attaching a screenshot of after and before importing wallet. But the problem is after import the wallet doesn't load credentials or connections from the export file. And also it loses the pin related information of the wallet as I deleted the wallet. So I can't login using the same pin. It gives incorrect pin in the app though the salt remains same.
In short,

  • I have deleted wallet and import it afterward.
  • After import, wallet isn't functioning as expected.
    Am I following the correct sequence for importing?
    One notable point is,
    An empty wallet export file is around 8kb. And if i add some connection credentials, then the size increases. Now if I import in a empty wallet a file size of 50kb (includes some connection, credentials),in the app nothing shows after import. But if I export again, I get a export file size of 50kb, though the wallet shows empty. Logically the new export file should be 8kb as the wallet is empty. I think the import function is working, but it doesn't have any effect on the app.
    image

I have bypassed the pin authentication mechanism to enter the wallet. And the import function worked. Yet need some testing to check every functionality of the wallet. After deleting the previous wallet and importing a new one, the pin mechanism fails to verify the pin and always shows an incorrect pin alert.

Hi @Sshovon @TimoGlastra , I have been trying to implement the export and import functionality. But when I tried to set the path for export using react-native-fs. I want to know how you have set the path for the data to get exported and are you saving the data in local device or the cloud storage?