cardano-foundation / cardano-wallet

HTTP server & command-line for managing UTxOs and HD wallets in Cardano.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Error while trying to restore wallet that was previously created with mnemonic_sentence

Red3nzo opened this issue · comments

commented

Just checking...

  • This is a cardano-wallet bug.
  • I am using the latest cardano-wallet release.
  • I am using the correct cardano-node version for that release of cardano-wallet.

Version

v2022-4-27

Platform

Linux Fedora Workstation 36

Installation method

IOHK Docker image

Network configuration

testnet

Context

When I try to restore a users wallet through cardano-wallet (testnet) I get this payload using the [POST] /wallets endpoint.

{
  "code": "wallet_already_exists",
  "message": "This operation would yield a wallet with the following id: 8209f39a872faa51a63c0f7bb8d748067cf7b2b0 However, I already know of a wallet with this id."
}

The following payload I send is the name,mnemonic_sentence & passphrase with the same arguments I gave it while creating the wallet. I even went as far as to change the name & passphrase but I still get the same wallet_already_exists error.

{
  "name": "Recovery Wallet",
  "mnemonic_sentence": [
    <15 KEYS>
  ],
  "passphrase": "wallet_pass_01"
}

I read that cardano-wallet should lookup a wallet and return its funds when a mnemonic_sentence derives a wallet that already exists. Is this correct still?

Description

Steps to Reproduce

  1. Create a wallet with [POST] /wallets route
  2. Later then try to recover the wallet with the same mnemonic_sentence used to create the wallet before
    ...

Expected behavior

Return wallet details for the recovered walletID; Users can create wallets within an application & later delete said application & try to recover their own wallets again. If cardano-wallet explicitly doesn't allow you to recover wallets that the db already has; that just creates very bad user experience as there is no way to delete the wallet from cardano-wallets DB if a users deletes an application (an iOS app or browser extension).

Actual behavior

cardano-wallet throws the error wallet_already_exists

You are trying to create a wallet again that you have already created in your cardano-wallet instance, therefore you get error message wallet_already_exists. This is expected.

Note that you only need to create wallet once. Once you do that, your wallet is available for you via other endpoints. In particular you can look up it's balance with getWallet.

BTW, you can delete wallet with deleteWallet.

commented

@piotr-iohk I understand that but how do I allow a user to recover a wallet if they have delete my application but haven't deleted the wallet from my cardano-wallet instance?

@thatsbrandon I don't know what exactly is your setup, but I suppose if you receive 409 from the api (i.e. "code": "wallet_already_exists",), which means that wallet exists on your server, then you can just return the wallet ID from the message ("message": "This operation would yield a wallet with the following id: 8209f39a872faa51a63c0f7bb8d748067cf7b2b0...)

Please note also that cardano-wallet is not designed to be used as a publicly available service. The cardano-wallet service is intended to be serving inside a protected network, by a local trusted users only (one of the use cases being a backedn for Daedalus wallet).

commented

I figured that was the case, thank you for your response ;)