I accidentally deleted by my wallet file and mnemonic seed. Can I recover my wallet with my view key and spend key? If yes, then how do I do so?

up vote 31 down vote accepted

Yes, it is possible to restore your account with just the view and spend keys.

monero-wallet-cli has the --generate-from-keys <name> option, which will create a wallet with the given name, and prompt the user for: address, spendkey and viewkey.

Example:

$ monero-wallet-cli --generate-from-keys myWallet
Monero 'Helium Hydra' (v0.11.1.0-release)
Logging to monero-wallet-cli.log
Standard address: 45FofLeGb1oAR7fDhrNsmvHHxjaY3at6YLxHq7S9YvQ54sMSn6BxtHe9tKYKfQm1YgE4WUyhLcMPiCJ17LQAtnjAQA3Nmh4
Secret spend key: 4941baf224dc238d7329a8c9ef672b3340ccb26eaf460f6c4cc8afa97a735a0c
Secret view key: 8fc685263e28604ebca23e2877e0847d034dc380db3ba800238a481b8719ea09
Enter new wallet password: 
Confirm Password: 
Generated new wallet: 45FofLeGb1oAR7fDhrNsmvHHxjaY3at6YLxHq7S9YvQ54sMSn6BxtHe9tKYKfQm1YgE4WUyhLcMPiCJ17LQAtnjAQA3Nmh4
Restore from specific blockchain height (optional, default 0),
or alternatively from specific date (YYYY-MM-DD): 2017-11-25
Restore height is: 1450154
Is this okay?  (Y/Yes/N/No): Y
Starting refresh...
Refresh done, blocks received: 1419                             
Balance: 0.000000000000, unlocked balance: 0.000000000000
Background refresh thread started
[wallet 45FofL]:

If you don't remember your standard address, then there's a sligtly more complicated way, the --generate-from-json option. You then have to create a small JSON file with that information, called, data.json, for instance:

{
  "version": 1,
  "filename": "restoredwallet.bin",
  "password": "some string",
  "viewkey": "abcdabcd...",
  "spendkey": "1234124..."
}

Then:

./monero-wallet-cli --generate-from-json data.json

Once your wallet is recreated, you can view its reconstructed seed with the command:

seed

(only if viewkey is deterministic, non-deterministic wallets don't have seeds)

You can recover the wallet with this simplewallet command:

--generate-from-keys
  • 4
    You may want to apply formatting to the code. You could select the code and press ctrl-k, or click the {} icon in the editor topbar, or just surround the command with two `. – nicael Jul 19 '16 at 19:55

I tested simplewallet’s --generate-from-json option, using only the spendkey and the viewkey, and as expected, it worked. However, from Luigi's address test page, I learnt that the "Private View Key" is simply derived (Keccak-256 followed by "sc_reduce32") from the "Hexadecimal Seed", which is identical to the "Private Spend Key". Therefore, it is really beyond my comprehension why the --generate-from-json option is requiring the viewkey as well? Without the viewkey in the JSON file, simplewallet returns:

Error: At least one of Electrum-style word list and private view key
must be specified

For cold storage purposes, I would much rather depend on the actual 64 character hexadecimal spendkey, than on a 75 character mnemonic (counting only 25 times the first 3 letters), which I guess no one can (or would risk to) remember anyway, for which the dictionary or the algorithm might also change over time. In my opinion, the --generate-from-json option should just drop the viewkey requirement, and calculate it instead.

Using Luigi's website, one can obtain the viewkey from the spendkey:

  1. Type the spendkey in the field "2. Hexadecimal Seed:".
  2. Click on the button Gen 3. & 4..
  3. Copy the viewkey from the field "4. Private View Key:".

Although, I feel that the above isn't a reliable option, as it adds an external dependency. And more importantly, one shouldn't post their spendkey online to recover a (cold storage) wallet.

Edit: It appears that, at least using Safari on OS X, one can save the web page as a .webarchive file, and then perform the above steps while being offline.

Your Answer

 

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.