openwallet-foundation/credo-ts

Restoring wallet from local storage in bifold fails

Closed this issue · 3 comments

I am working on backup and restore wallet functionality in bifold. Backup functionality is working fine with agent.wallet.export. But when restoring the wallet by agent.wallet.import, I encountered an error:

Error importing wallet '': Error connecting to database pool
Caused by: error returned from database: (code: 26) file is not a database

In old version of bifold (v1.0.0-alpha.81), export function creates just one sqlite backup file. But current bifold version (v1.0.0-alpha.256) is creating two backup binary files: fileName-shm and fileName-wal. I am selecting the -wal file path for importing the wallet.

Backup functionality code snippet:

image

Created backup files:
image

Restore code snippet:
image

I am selecting -wal file by document picker and converting the content uri to relative path of the file.

image

When importing the wallet the encountered error is:
image

How can I mitigate this error?

Apart from the wal and shm files, you should be seeing a file without suffix (i.e. backup_wallet_arifshahriar028_1719384806907). That's the one you should select. The three files must be present (toghether in the same directory) when importing, since all of them are needed to open the SQLite database.

@genaris I was also expecting a file without suffix. But there is no file generated like this. But the older version of bifold generates only one file without suffix. Following is the generated files by the newer version of bifold:

image

Do you have any idea why the third file is not generating?

After agent.wallet.export(), I was using RNFS.unlink(filePath) which deleted the third file I was expecting.

image

After commenting out RNFS.unlink(), the exporting working fine.

@genaris thanks for your idea!