cardano-foundation / cardano-wallet

HTTP server & command-line for managing UTxOs and HD wallets in Cardano.
Apache License 2.0
766 stars 214 forks source link

How can I restore wallet from secret.key file from daedalus 0.15.1 #2395

Closed skazichris closed 3 years ago

skazichris commented 3 years ago

I got your contact from Nikola Glumac.

I understand that you're the right team to contact in terms of older cardano wallets. Would you happen to be so kind and review the following subject? https://github.com/input-output-hk/daedalus/issues/1234#issuecomment-734457593

Long story short: There are plenty of users stuck on the 0.15.1 daedalus wallet which suddenly stopped working and our ADA funds are stuck in it.

Your insight and help is much appreciated.

//BR, Chris

mkr-j commented 3 years ago

I am in a similar situation as skazichris. Looking forward to support from the dev team in restoring access to the stuck ADA coins. Re-enabling the import wallet feature to allow access through the secret.key file would be great.

Appreciate the help!

KtorZ commented 3 years ago

Questions for both of you @skazichris and @mkr-j:

mprymek commented 3 years ago

I'm in the same situation.

  • What operating system are you on / familiar with?

Linux, MacOS. Can use Windows if it's absolutely necessary :)

  • What is your level of expertise in IT?

Masters degree in computer science. Basic knowledge of Haskell. Good knowledge of Python, Go, C. For me personally, a good specification of secrets.key file format and a process how to obtain private keys or a wallet phrase from it could be enough.

KtorZ commented 3 years ago

@mprymek have a look at: https://github.com/input-output-hk/cardano-sl/pull/4278#issuecomment-600553878, there's a pre-compiled binary which should work on any GNU linux. This however requires that you still have access to the old wallet database AND the secret key file. The tool will extract all known encrypted keys from the keystore and spit them in a nicer JSON format.

There has been a few additions to the tools later that aren't in the pre-compiled version linked above but they are non-essential.

From there, the cardano-wallet gives you a way to import such credentials directly in the "byron-wallets" API (see the "random (xprv) tab in https://input-output-hk.github.io/cardano-wallet/api/edge/#operation/postByronWallet). Fields are named identically in the API and in the tool output. From there, your wallet should restore itself and you should be able to operate it as normal provided that you still remember the encryption passphrase. If you do not, it's hopeless.

If you do not have access to the acid-state database that the old wallet was using at the time and only have the keystore file, then let me know. I'll spend some time documenting the CDDL specification corresponding to the keystore serialization format and/or update the extraction tool to make the acid-state database optional (it's really only used to link the encrypted key to a wallet name and wallet id).

mprymek commented 3 years ago

Thanks a lot, @KtorZ. I think I have a backup of the acid-state db too but must find it and restore somewhere. And also recall the master password. Will take a while I'm afraid :)

mkr-j commented 3 years ago

Questions for both of you @skazichris and @mkr-j:

  • What operating system are you on / familiar with?
  • What is your level of expertise in IT?

I am on Windows. I've done some basic coding in the long past but generally am not too familiar with non-GUI operations. With some guidance, however, I'd be willing to attempt something a little more complex.

I do remember the encryption phase, but I do not see an acid-state database. My Daedalus version is 1.0.3769, wallet 0.8.2. Is the tool you referenced expected to work with this version of the wallet?

mprymek commented 3 years ago

@KtorZ I have some findings, probably not very good for me...

@mprymek have a look at: input-output-hk/cardano-sl#4278 (comment), there's a pre-compiled binary which should work on any GNU linux.

Sidenote: It doesn't work on "any" Linux distribution. It's dynamically linked and at least librocksdb.so.5.8 is a little bit problematic. It's not available in Ubuntu 20.04. I found it's available in Ubuntu 18.04.

I can confirm it's working on Ubuntu 18.04:

$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 18.04.1 LTS
Release:    18.04
Codename:   bionic

$ ./export-wallets --mainnet   --wallet-db-path ./state-wallet-mainnet/wallet-db   --keyfile ./state-wallet-mainnet/secret.key
No wallet for id: Ae2tdPwUPEZKHDtF6psSMU99Z7HnMAgSs4T7wpbWAGdHrh1RGM8GhLd3BRq
No wallet for id: Ae2tdPwUPEZ42xY2TByWhGPQ7UST7VsopbX4KAhQRdd6o5KyS9ZJxiEMzLX
[
    {
        "encrypted_root_private_key": "f6e79f49b8999a39d7e970e42d0a91224ecacefc3aa1edb342f34eb8bc6c2fc63e743b862b312a6f92ba0161d4d53c3ee5a2bd8085476d9575765c49dceecbe54b34ec47daf9b7ebc6bdb706622616451c000e85ba81c7449ae436a8cbbf3aab98e5cc704977bd11bb0ba8d5b5571a705704cb9334d27a048532eab49a698c2d",
        "name": "亜哀うめるтУуФф",
        "passphrase_hash": "31347c387c317c5743413633702f6a487a5777575278756756344e316854793470646c6d4f76665177653863775a575472784f79773d3d7c796341722f61326f4f777a736e4e746f4e655049416e4f6b7978426549494a6b59623039574b564a7159493d"
    },
    {
        "encrypted_root_private_key": "38e8de9c583441213fe34eecc4e28265267466877ba4048e3ab1fa9956366947aefaf5ba9779db67eead7fc9cd1354b994a5d8d9cd40ab874bfeb1b33649280cd33651377731e0e59e0233425a55257782c5adaa768da0567f43c1c6c0c18766ed0a547bb34eb472c120b170a8640279832ddf18002887f03c15dea59705422d",
        "name": "WALLET 💜 💛 💚 💙",
        "passphrase_hash": null
    }
]

But i found the original Daedalus version I have a backup of, was probably older than 0.15.

Don't know if it's of any value, but anyways:

$ ls
 GPUCache         Logs          Secrets-1.0   config.json   tls
'Local Storage'   Preferences   Wallet-1.0    storage

$ cat Wallet-1.0/events.version
0.14.2

Export does not work (pre-0.15 had a different DB format?):

$ ../export-wallets-qa/export-wallets --mainnet --wallet-db-path Wallet-1.0/ --keyfile Secrets-1.0/secret.key
export-wallets: user error (There's no acid-state database matching the given path.)

$ ls Wallet-1.0/
Archive                     checkpoints-0000000071.log  events-0000057291.log  open
checkpoints-0000000070.log  checkpoints.version         events.version         open.lock
rdlrt commented 3 years ago

Just to add, it's probably something zendesk support should have heaps of tickets above, but we have tons of users reporting on telegramnover past few months who - do not seem to have read the warnings and have their funds locked due to missing 12 word seed.

Atleast for those that have the spending password available, it would be really helpful if there's a published way from IOG to use as a workaround (rather than someone from community passing a python/js code and asking them to run - as that involves trust, and potentially mote susceptible to scams on crypto social platforms). If only the part regarding secret.key to master key (unencrypted with spending password) is available as a method from IOG, we could easily ask users to import their wallets into Yoroi 🙂

devilus commented 3 years ago

Hello @KtorZ and @mprymek I can confirm that unfortunately export-wallets-qa util doesn't works.

$ ls Secrets-1.0/
secret.key  secret.key.lock

$ ls Wallet-1.0/
Archive                     checkpoints-0000000009.log  events-0000002481.log  open
checkpoints-0000000008.log  checkpoints.version         events.version         open.lock

$ ./export-wallets --mainnet --wallet-db-path Wallet-1.0/ --keyfile Secrets-1.0/secret.key
export-wallets: user error (There's no acid-state database matching the given path.)
clovehitch commented 3 years ago

I'm trying to restore a wallet that was created with Daedalus 0.13.1

When using the utility I'm getting the error "user error (There's no acid-state database matching the given path.)"

I'm not %100 on what path or file I should be pointing this too. I have tried: DB-1.0/ Wallet-1.0-acid/ Wallet-1.0-sqlite.sqlite3

@mprymek mentioned that this utility might not work with this db version. Does anyone have any more information on this?

Any help would be appreciated, thank you.

khughes5 commented 3 years ago

I am in the same predicament.. i had my wallet in Daedalus 0.13.1 and although i can get the script to work under ubuntu 18.04 with the test data in the gzip, it seems not work with my 0.13.1 data (same as @clovehitch)

I still have 0.13.1 installed on my windows PC (it runs, just can't connect).. is upgrading to 0.15.1 (after taking a VM snapshot) to upgrade the data structure an option? i had a search around everywhere for the old installer.. but had no luck..

to be honest, this thread is the best lead i have found on this problem, and i have been looking for months! Really appreciate the assistance being given! It's hard to wait for the official import to be re-enabled (had hoped it would have been in FC3 - but no)

testbookbear commented 3 years ago

same error here. There's no acid-state database matching the given path events.version file shows 0.15.0. need to import wallet using secret.key. Please help

piotr-iohk commented 3 years ago

I have just checked some old Daedalus versions: 0.13.0, 0.13.1 and 0.15.1. From what I see, in all those versions the state directory looks as follows:

~/.local/share/Daedalus/mainnet$ ls -l
total 1036
drwxrwxr-x 7 piotr piotr   4096 sty 11 09:10 DB
-rw-r--r-- 1 piotr piotr 975704 sty 11 09:10 icon_large.png
-rw-r--r-- 1 piotr piotr   4800 sty 11 09:10 icon.png
drwxrwxr-x 3 piotr piotr   4096 sty 11 09:10 Logs
-rwxr-xr-x 1 piotr piotr    880 sty 11 09:10 namespaceHelper
drwxrwxr-x 2 piotr piotr   4096 sty 11 09:10 Secrets
drwxrwxr-x 4 piotr piotr   4096 sty 11 09:10 tls
drwxrwxr-x 3 piotr piotr   4096 sty 11 09:10 Wallet-acid
-rw-r--r-- 1 piotr piotr  45056 sty 11 09:10 Wallet-sqlite.sqlite3

Where:

~/.local/share/Daedalus/mainnet/Wallet-acid$ ls -l
total 16
drwxrwxr-x 2 piotr piotr 4096 sty 11 09:34 Archive
-rw-rw-r-- 1 piotr piotr  127 sty 11 09:34 checkpoints-0000000002.log
-rw-rw-r-- 1 piotr piotr    0 sty 11 09:34 checkpoints-0000000003.log
-rw-rw-r-- 1 piotr piotr    6 sty 11 09:33 checkpoints.version
-rw-rw-r-- 1 piotr piotr    0 sty 11 09:33 events-0000000000.log
-rw-rw-r-- 1 piotr piotr    6 sty 11 09:33 events.version
-rw-rw-r-- 1 piotr piotr    0 sty 11 09:33 open.lock

I am able to run the export-wallets tool on all three Daedalus versions like this:

$ ./export-wallets --wallet-db-path ~/.local/share/Daedalus/mainnet/Wallet \
                   --keyfile ~/.local/share/Daedalus/mainnet/Secrets/secret.key \
                   --mainnet
[]

It is a bit counter-intuitive but, I think, the "rule" would be: if you have those two items in your state directory: Wallet-acid and Wallet-sqlite.sqlite3 you should point --wallet-db-path to something like /path/to/state-dir/Wallet.

Please also note that Daedalus should not be running when you use export-wallets otherwise you'll get error:

export-wallets: StateIsLocked "/home/piotr/.local/share/Daedalus/mainnet/Wallet-acid/open.lock"
khughes5 commented 3 years ago

My Daedalus installation was on windows, would that make a difference?

My 0.13.1 directory structure looks like the following (its a copy, so date stamps are not original) : 10/01/2021 01:39 PM

. 10/01/2021 01:39 PM .. 10/01/2021 01:36 PM blob_storage 01/09/2020 12:05 PM 167 config.json 10/01/2021 01:39 PM DB-1.0 10/01/2021 01:39 PM GPUCache 10/01/2021 01:39 PM Local Storage 10/01/2021 01:39 PM Logs 01/09/2020 11:59 AM 533 Preferences 30/12/2018 01:31 PM 0 public.key 30/12/2018 01:31 PM 0 public.key.lock 10/01/2021 01:39 PM Secrets-1.0 10/01/2021 01:39 PM tls 10/01/2021 01:39 PM Wallet-1.0-acid 10/01/2021 01:39 PM Wallet-1.0-backup-2018-12-30T02_31_27 24/03/2019 09:28 PM 45,056 Wallet-1.0-sqlite.sqlite3 24/03/2019 09:04 PM webrtc_event_logs

The Wallet-1.0-acid directory contains : 10/01/2021 01:39 PM

. 10/01/2021 01:39 PM .. 10/01/2021 01:39 PM Archive 01/09/2020 12:04 PM 883,800 checkpoints-0000000737.log 01/09/2020 12:04 PM 0 checkpoints-0000000738.log 30/12/2018 01:31 PM 6 checkpoints.version 01/09/2020 12:04 PM 0 events-0001994441.log 30/12/2018 01:31 PM 6 events.version 30/12/2018 01:31 PM 0 open.lock

I have copied the files across onto a linux box now and trying to recover through there (as this is the only tool i have found so far).

I tried using "Wallet-1.0" in --wallet-db-path, with no luck.. i even tried renaming the wallet-1.0-acid and the sqlite3 file to exclude the 1.0 part trying to bring it inline with the example files but no luck there either..

Windows add/remove still shows 0.13.1 as the installed version (as does Daedalus.exe), the contents of my events.version file in Wallet-1.0-acid does show 0.15.0 though

piotr-iohk commented 3 years ago

Hi @khughes5, I just did the same, i.e. copied Daedalus (0.13.0) state dir from Windows to Linux:

My state directory looks as follows:

$ ls -l ~/Documents/daedalus-win/Daedalus/
total 84
drwxrwxr-x 3 piotr piotr  4096 sty 11 12:30  blob_storage
-rw-rw-r-- 1 piotr piotr    35 sty 11 12:19  config.json
drwxrwxr-x 7 piotr piotr  4096 sty 11 12:30  DB-1.0
drwxrwxr-x 2 piotr piotr  4096 sty 11 12:30  GPUCache
drwxrwxr-x 3 piotr piotr  4096 sty 11 12:30 'Local Storage'
-rw-rw-r-- 1 piotr piotr     0 sty 11 12:19  lockfile
drwxrwxr-x 3 piotr piotr  4096 sty 11 12:30  Logs
drwxrwxr-x 2 piotr piotr  4096 sty 11 12:30  Secrets-1.0
drwxrwxr-x 4 piotr piotr  4096 sty 11 12:30  tls
drwxrwxr-x 3 piotr piotr  4096 sty 11 12:33  Wallet-1.0-acid
-rw-rw-r-- 1 piotr piotr 45056 sty 11 12:19  Wallet-1.0-sqlite.sqlite3
drwxrwxr-x 2 piotr piotr  4096 sty 11 12:19  webrtc_event_logs

where:

$ ls -l ~/Documents/daedalus-win/Daedalus/Wallet-1.0-acid/
total 16
drwxrwxr-x 2 piotr piotr 4096 sty 11 12:40 Archive
-rw-rw-r-- 1 piotr piotr  127 sty 11 12:40 checkpoints-0000000004.log
-rw-rw-r-- 1 piotr piotr    0 sty 11 12:40 checkpoints-0000000005.log
-rw-rw-r-- 1 piotr piotr    6 sty 11 12:19 checkpoints.version
-rw-rw-r-- 1 piotr piotr    0 sty 11 12:29 events-0000000000.log
-rw-rw-r-- 1 piotr piotr    6 sty 11 12:19 events.version
-rw-rw-r-- 1 piotr piotr    0 sty 11 12:19 open.lock

With that I am able to run the tool like this:

$ ./export-wallets --mainnet \
--wallet-db-path ~/Documents/daedalus-win/Daedalus/Wallet-1.0 \
--keyfile ~/Documents/daedalus-win/Daedalus/Secrets-1.0/secret.key

[]

Is there any error you are seing?

khughes5 commented 3 years ago

@piotr-iohk - Thanks SO much!!!! i just got it to work! and thanks to @KtorZ for originally providing reference to the tools and @mprymek for the heads up on linux version

Before i was just copying a subset of files and Directories (Wallet-1.0-acid, Wallet-1.0-sqlite.sqlite3 and Secrets-1.0)..

This time i copied the whole Directory (c:\users\Name\AppData\Roaming\Daedalus) across into linux, dumped them in the user documents directory like you did and ran the tool as you specified.. it worked! I don't have a very good grasp on linux, so maybe i was screwing something else up before..

Now i am off to start looking at the whole API side, to try and see how to import the encrypted strings!!

PS for those following along (and like me have no linux exp), after a default install of Ubuntu 18.04 i had to run "sudo apt-get update" then "sudo apt-get install librocksdb5.8" to get the required library to be able to get the tool to run (you need an internet connection for that to work)

clovehitch commented 3 years ago

@khughes5 Did you figure out how to import the encrypted strings?

khughes5 commented 3 years ago

Unfortunately not yet (i am not a programmer).. and i don't even know if i am on the right track here.. but i was hoping to use my Daedalus flight 3.1.0 install on windows (which seems to run the cardano-node.exe on a random listening port), along with the method described in https://iohk.zendesk.com/hc/en-us/articles/900000672303-How-to-migrate-a-Byron-Legacy-wallet-to-cardano-wallet- with the payload replaced with that described in the random(from xprv) tab by KtorZ above..

the listening port number for cardano-wallet appears to be shown in FC3.1.0 under help/Deadalus Diagnostics.. but right now i am getting certificate errors when using curl against the port for a simple query (like https://localhost:64139/wallets) .. Even when i use the --cacert pointing to the \tls\client\client.pem file, it displays the error "the certificate chain was issued by an authority that is not trusted".. not sure if we are able to run the api calls via the FC developer tools/console interface..

again not sure if i am totally missing the mark here.. very open to help from anyone in the thread about what to do with the extracted information from the tool :)

piotr-iohk commented 3 years ago

@khughes5 I have a tool that can be handy for your use case, but you'll need to have ruby installed on your system. For Windows Ruby+Devkit 2.7.2-1 (x64) from https://rubyinstaller.org/downloads/ should be OK.

The tool (https://github.com/piotr-iohk/ikar) is a lightweit web app over cardano-wallet and can be easily connected with underalying cardano-wallet of your Daedalus instance.

  1. To start the tool (once you have ruby on your system):

    git clone https://github.com/piotr-iohk/ikar.git
    cd ikar
    bundle config set without 'development test'
    bundle install
    ruby app.rb
  2. Then point your browser to http://localhost:4444/ and click at "Discover" button. If you have Daedalus running you should get it on the list of discovered cardano-wallet servers, like this:

Screenshot from 2021-01-12 17-30-48

  1. Click "Connect"
  2. Then go to "Byron Wallets" -> "Create random (from xprv)"
  3. Paste the output of export-wallets command into the form like below and hit "Create"

Screenshot from 2021-01-12 17-33-46

  1. That's it. You should have your wallet now visible in Daedalus and once it is restored you should be able to migrate your funds to Shelley wallet from there.

Hope that helps!

khughes5 commented 3 years ago

@piotr-iohk I can't thank you enough!!! thanks so much, using your instructions (and install git for windows) i was able to easily import it into my Daedalus app, and transfer the ADA across to a new shelley wallet!!

That's a massive weight off my shoulders! and i can't thank you enough!!! I am sure i am not the first to be saved from everyones guidance and advice through this thread!!

devilus commented 3 years ago

I trying to rename "Wallet-1.0" to "Wallet-1.0-acid" but use "Wallet-1.0" in command line instead, so now the error "There's no acid-state database matching the given path." resolved:

./export-wallets --wallet-db-path /Wallet-1.0 --keyfile /Secrets-1.0/secret.key --mainnet

But now I get the error

export-wallets: Could not parse saved checkpoint due to the following error: Failed reading: safecopy: Cardano.Wallet.Kernel.DB.AcidState.DB: Cannot find getter associated with this version number: Version {unVersion = 2}
Empty call stack

CallStack (from HasCallStack):
  error, called at src/Data/Acid/Local.hs:329:7 in acid-state-0.15.0-KPx3nxg5ffCDH1G6VxHbSk:Data.Acid.Local

I used daedalus in 2018 last time and now I have only Secrets-1.0 and Wallet-1.0 folders backup. Also I remember decrypt pasword. Anyone can help? Thanks guys.

KtorZ commented 3 years ago

export-wallets-c1815b7d.tar.gz

@devilus

I triggered a compilation during lunch of the latest version of the export tool linked earlier. That version makes the acid-state database optional (as it is only really used to extract wallet names and map them to keys in the keystore). So you could use that to extract keys from your keystore. If you've a single one there's no ambiguity, and if you have multiple ones, you'd have to figure out which one is which by restoring them all and looking at the transaction history.

devilus commented 3 years ago

@KtorZ

Which linux version do you use? I can't find librocksdb.so.6 package for ubuntu 18.

./export-wallets --keyfile /Secrets-1.0/secret.key --mainnet
./export-wallets: error while loading shared libraries: librocksdb.so.6: cannot open shared object file: No such file or directory
KtorZ commented 3 years ago

The binary isn't statically linked sorry. That'd take a bit more work to do for Haskell system dependencies are typically dynamically linked. You need rocksdb to run that one unfortunately. On aptitude, you get the necessary dependencies by installing librocksdb-dev

apt get install librocksdb-dev
devilus commented 3 years ago

@KtorZ Thanks a lot :)

Ok now I have a restored key from secret key:

[
    {
        "encrypted_root_private_key": "_hash_string_",
        "is_passphrase_empty": false,
        "name": null,
        "id": "_id_string_",
        "passphrase_hash": "_hash_string_"
    }
]

Don't understand fully what I need to do now?

piotr-iohk commented 3 years ago

@devilus one option is to try with this -> https://github.com/input-output-hk/cardano-wallet/issues/2395#issuecomment-758784374.

(Probably you might want to change "name": null into something like "name": "My wallet")

devilus commented 3 years ago

@piotr-iohk I trying your solution right now :)

I have a lastest 3.1.0 version Daedalus Mainnet installed and synced with fresh wallet. But after https connection to node only "Tools->Generate mnemonics" menu active. What I'm doing wrong?

piotr-iohk commented 3 years ago

Did you click at Discover button and Connected to your Daedalus?

devilus commented 3 years ago

Yes sure.

After click "Discover"

image

After click "Connect"

image
piotr-iohk commented 3 years ago

Ok, I've noticed this sometimes happening when you were already connected to different Daedalus instance and now trying to re-connect to another one. The only solution for now is to restart ikar (i.e. kill ruby process and start ruby app.rb again) and try to discover and connect again. If this doesn't help, you may try making a request to Daedalus' underlying cardano-wallet via curl (just replace <PORT>, <USER>, <xprv> and <pass> with your data):

curl -X POST https://localhost:<PORT>/v2/byron-wallets \ 
-d '{"encrypted_root_private_key":"<xprv>","name":"My Old Byron Wallet","passphrase_hash":"<pass>","style":"random"}' \ 
--cert /Users/<USER>/Library/Application Support/Daedalus Mainnet/tls/client/client.pem \
--cacert /Users/<USER>/Library/Application Support/Daedalus Mainnet/tls/client/ca.crt \ 
-H "Content-Type: application/json"
devilus commented 3 years ago

@piotr-iohk Unfortunately doesn't work by curl. Where is my mistake?

curl -X POST http://localhost:4444/v2/byron-wallets --cert /Users/max/Library/Application\ Support/Daedalus\ Mainnet/tls/client/client.pem --cacert /Users/max/Library/Application\ Support/Daedalus\ Mainnet/tls/client/ca.crt -d '{"encrypted_root_private_key":"__KEY__","name":"My Old Byron Wallet","passphrase_hash":"__HASH__","style":"random"}' -H "Content-Type: application/json"

Response

<!DOCTYPE html>
<html>
<head>
  <style type="text/css">
  body { text-align:center;font-family:helvetica,arial;font-size:22px;
    color:#888;margin:20px}
  #c {margin:0 auto;width:500px;text-align:left}
  </style>
</head>
<body>
  <h2>Sinatra doesn’t know this ditty.</h2>
  <img src='http://localhost:4444/__sinatra__/404.png'>
  <div id="c">
    Try this:
    <pre>post &#x27;&#x2F;v2&#x2F;byron-wallets&#x27; do
  &quot;Hello World&quot;
end
</pre>
  </div>
</body>
</html>
piotr-iohk commented 3 years ago

Port should be a Daedalus' wallet port, so based on your screenshot from https://github.com/input-output-hk/cardano-wallet/issues/2395#issuecomment-759498554 61103.

devilus commented 3 years ago

I did it! Thank you guys @piotr-iohk @KtorZ for help!🥳

diego76 commented 3 years ago

The binary isn't statically linked sorry. That'd take a bit more work to do for Haskell system dependencies are typically dynamically linked. You need rocksdb to run that one unfortunately. On aptitude, you get the necessary dependencies by installing librocksdb-dev

apt get install librocksdb-dev

Hi, I still do not get how to install librocksdb.so.6. The libsrocksdb-dev package installs the 5.8.8 version. I have also downloaded from github the latest rocksdb, compiled and installed it. Still, I do not see the version 6 of librocksdb. Do I need a specific setup?

diego76 commented 3 years ago

The binary isn't statically linked sorry. That'd take a bit more work to do for Haskell system dependencies are typically dynamically linked. You need rocksdb to run that one unfortunately. On aptitude, you get the necessary dependencies by installing librocksdb-dev

apt get install librocksdb-dev

Hi, I still do not get how to install librocksdb.so.6. The libsrocksdb-dev package installs the 5.8.8 version. I have also downloaded from github the latest rocksdb, compiled and installed it. Still, I do not see the version 6 of librocksdb. Do I need a specific setup?

Ok, I got it. I modified the Makefile to create dynamic libraries (LIB_MODE?=shared). All good.

KtorZ commented 3 years ago

Note: there's now a pure typescript implementation of the extract-wallet tool above:

https://github.com/input-output-hk/daedalus/pull/2308

This should make it possible to restore the recovery feature in Daedalus and unlock those who haven't managed to go with the command-line way.

mprymek commented 3 years ago

Note: there's now a pure typescript implementation of the extract-wallet tool above:

input-output-hk/daedalus#2308

This should make it possible to restore the recovery feature in Daedalus and unlock those who haven't managed to go with the command-line way.

Wonderful!

Now I have this structure decoded from my secret.key:

{
  "encryptedPayload": {
    "data": [ /* some data */],
    "type": "Buffer"},
  "isEmptyPassphrase": false,
  "passphraseHash": {
    "data": [/* some data */],
    "type": "Buffer"},
  "walletId": "...some HEX..."
}

What can I do next? Can I test some passwords against the password hash? Can I somehow get the recovery phrase? Or anything else to do with that data?

KtorZ commented 3 years ago

@mprymek the best you can do now is to use these inputs to feed into the wallet server via:

https://input-output-hk.github.io/cardano-wallet/api/edge/#operation/postByronWallet

Screenshot from 2021-01-20 12-12-25

This will restore your wallet, and you'll be able to make a payment from it provided you remember the encryption passphrase.

KtorZ commented 3 years ago

Can I test some passwords against the password hash?

You could, although it's not straightfroward. The password hash is using a scrypt algorithm, ran on top of the a blake2b_256 hash of your passphrase, serialized as CBOR.

Can I somehow get the recovery phrase?

No. Never. There's a one way transformation from the recovery phrase to the wallet root private key. What you have in the keystore is the (encrypted) root private key; there's no way back to the recovery phrase.

mprymek commented 3 years ago

@mprymek the best you can do now is to use these inputs to feed into the wallet server via:

https://input-output-hk.github.io/cardano-wallet/api/edge/#operation/postByronWallet

This will restore your wallet, and you'll be able to make a payment from it provided you remember the encryption passphrase.

I'm sorry, I don't understand this. There's a required property mnemonic_sentence on this endpoint. I don't have it. How can I use this endpoint?! Everything I have is encryptedPayload, passphraseHash and walletId. None of them is used by this endpoint.

You could, although it's not straightfroward. The password hash is using a scrypt algorithm, ran on top of the a blake2b_256 hash of your passphrase, serialized as CBOR.

Could you please post a function which will accept a passphraseHash and a password and return true if matched, false otherwise?

KtorZ commented 3 years ago

@mprymek this endpoints accepts 6 different kind of input payloads. See the screenshot I've shared, you need the one labelled "random (from xprv)" which doesn't require a mnemonic sentence, the documentation has tabs you can click on.

Could you please post a function which will accept a passphraseHash and a password and return true if matched, false otherwise?

Not yet, but I'll see if I find time. In the meantime, you could let the server do it by trying to change the passphrase to something else. If the old passphrase doesn't match, the request will fail.

mprymek commented 3 years ago

@mprymek this endpoints accepts 6 different kind of input payloads. See the screenshot I've shared, you need the one labelled "random (from xprv)" which doesn't require a mnemonic sentence, the documentation has tabs you can click on.

Ah, ok, my bad. What should I feed to encrypted_root_private_key? Whole encryptedPayload converted to hex string?

Not yet, but I'll see if I find time. In the meantime, you could let the server do it by trying to change the passphrase to something else. If the old passphrase doesn't match, the request will fail.

Ok, thanks!

KtorZ commented 3 years ago

Ah, ok, my bad. What should I feed to encrypted_root_private_key? Whole encryptedPayload converted to hex string?

Exactly.

mprymek commented 3 years ago

It worked! My old wallet successfully imported into the current Daedalus!

Thank you, @KtorZ very very much!

chmieleslav commented 3 years ago

Dear @piotr-iohk , dear all,

I am trying to use the Ikar tool to restore my old Daedalus 0.11.2 wallet, but so far with no success:

Thank you very much in advance for your help

chmieleslav commented 3 years ago

Note: there's now a pure typescript implementation of the extract-wallet tool above: input-output-hk/daedalus#2308 This should make it possible to restore the recovery feature in Daedalus and unlock those who haven't managed to go with the command-line way.

Wonderful!

Now I have this structure decoded from my secret.key:

{
  "encryptedPayload": {
    "data": [ /* some data */],
    "type": "Buffer"},
  "isEmptyPassphrase": false,
  "passphraseHash": {
    "data": [/* some data */],
    "type": "Buffer"},
  "walletId": "...some HEX..."
}

What can I do next? Can I test some passwords against the password hash? Can I somehow get the recovery phrase? Or anything else to do with that data?

Dear @mprymek could you explain how you managed to do that? Many thanks in advance

KtorZ commented 3 years ago

@chmieleslav I am not familiar with Ikar but this:

Screenshot from 2021-02-05 17-40-19

looks like a drop-down menu where you may be able to select https as a protocol to run subsequent queries?

chmieleslav commented 3 years ago

Dear @KtorZ , thanks for your quick reply. The https connection / discovery didn't work for me either... I just installed the very last version of Daedalus, but the "import from earlier version " is not implemented... Is there a chance it gets implemented someday?

https://iohk.zendesk.com/hc/en-us/articles/900002473086-Wallet-import-feature-is-currently-disabled

I'm wondering if it WAS available in any earlier version of Daedalus which I could still use now... Otherwise I'll have to wait :(

piotr-iohk commented 3 years ago

@chmieleslav as far as I see from the screenshot you shared (https://github.com/input-output-hk/cardano-wallet/issues/2395#issuecomment-774123084) you are trying to connect Ikar to old Daedalus (0.11). That won't work as the underlying cardano-wallet won't even start (I think) on that old version of Daedalus.

The steps I have described in https://github.com/input-output-hk/cardano-wallet/issues/2395#issuecomment-758784374 will work for connecting to new Daedalus where you can import your wallet once you have your old key extracted from old Daedalus.

For extracting the old keys you can use this tool -> https://github.com/input-output-hk/cardano-wallet/issues/2395#issuecomment-759402979 following those steps -> https://github.com/input-output-hk/cardano-wallet/issues/2395#issuecomment-757901705. Unfortunately for this you'll need a Linux machine.

chmieleslav commented 3 years ago

But now I get the error

export-wallets: Could not parse saved checkpoint due to the following error: Failed reading: safecopy: Cardano.Wallet.Kernel.DB.AcidState.DB: Cannot find getter associated with this version number: Version {unVersion = 2}
Empty call stack

CallStack (from HasCallStack):
  error, called at src/Data/Acid/Local.hs:329:7 in acid-state-0.15.0-KPx3nxg5ffCDH1G6VxHbSk:Data.Acid.Local

I used daedalus in 2018 last time and now I have only Secrets-1.0 and Wallet-1.0 folders backup. Also I remember decrypt pasword. Anyone can help? Thanks guys.

Dear @devilus how did you solve the "Could not parse saved checkpoint due to the following error: Failed reading: safecopy" error? Thank you in advance