almindor / etherwall

Ethereum QT5 Wallet
GNU General Public License v3.0
142 stars 59 forks source link

Error when trying to export geth account via context menu to directory #42

Closed UGatgithub closed 5 years ago

UGatgithub commented 7 years ago

When I right click (context menu) on an account, select Export geth account to directory and select a directory to export to, I get an Error exporting account for all the 3 accounts I currently have. (Export to QR code works).

almindor commented 7 years ago

Hmm works for me on Mac. I will try linux and windows later but can you look at logs to see if there's an error reported?

UGatgithub commented 7 years ago

Nothing in the error logs (tried all log levels). The only thing I see is what you find in the attached Windows screenshot. export error

UGatgithub commented 7 years ago

Did you check on your side?

almindor commented 7 years ago

Yes, worked ok but I didn't do windows yet. I'm moving to Canada tomorrow so I probably won't be able to look into this for a few days.

Are you using the bundled geth or a local version of geth?

UGatgithub commented 7 years ago

I use the latest geth 1.6.7 now, not the Etherwall bundled one but you can see the screenshot above that it was taken with 1.6.6. (Geth bundled with Ether-Wallet) and I can confirm it's actually happening for both of this Geth versions. When I just wanted to try with the Geth bundled with Etherwall, I got a fatal error (out of memory) and that Geth does not launch at all!

almindor commented 7 years ago

That's odd. I wonder if there's something specific about your setup. When I do export I just literally take the account json files from geth's data directory and copy them over to the destination folder. It's a rather simple operation so I'm wondering what can go wrong here.

UGatgithub commented 7 years ago

I think that this is the issue then as data directory is C://Users/username/AppData/Roaming/Ethereum Wallet while keystore is under C://Users/username/AppData/Roaming/Ethereum

UGatgithub commented 7 years ago

Did a test and copied keystore to C://Users/username/AppData/Roaming/Ethereum Wallet but still the same error. When you talk about the accounts json files you mean the contents of the keystore folder, correct?

almindor commented 7 years ago

Yes account json encrypted files in keystore. It literally takes the right file out and just copies it over that's why I'm confused on what goes wrong, especially since it didn't log.

I should be able to try in windows tomorrow, if I can't reproduce I'll send you a special debug version.

UGatgithub commented 7 years ago

OK, if I receive the debug version, I will test it. Meanwhile I tried if something changes if I run Etherwall as admin but still the same error.

UGatgithub commented 7 years ago

This evening I would have time to test if you can offer me a debug version.

almindor commented 7 years ago

Couldn't reproduce on my windows 8, going to build the debug version but I need more time. Due to how protobuf needs to be compiled from source now I need to get my mingw/qt5 combination to work (bloody windblows...)

UGatgithub commented 7 years ago

Ok, no problem take the time you need - FYI I run Etherwall on Windows 10 Pro.

almindor commented 7 years ago

So I looked at the codepath and the only places where I return false with no error (your case, false translates to that msg you got) are:

  1. when the list is empty
  2. when the destination file cannot be written to

I think your case is the file permissions problem somehow. I will add the error handling to that in the new version.

UGatgithub commented 7 years ago

Means no debug, I wait for the next version?

almindor commented 7 years ago

I have to get mingw/protobuf/hidapi compatible compilation setup in windows again. Once that's done I'll probably release 2.0.2 with more info by default but if there's some other blocker I'll give you the debug version here.

UGatgithub commented 7 years ago

Ok, so I wait and see :-)

almindor commented 7 years ago

Hey, here's the proposed 2.0.2 version with better logging. Can you copy the exe to your current etherwall dir and run this version?

You should see an error logged in your app log when it fails. No need to use debug, info level is fine.

Thanks

Etherwall_202.zip

UGatgithub commented 7 years ago

OK, I did it and got an Account export file error: Zugriff verweigert (means Access denied).

I repeated but started Etherwall as Admin, same issue. I switched the folder from Desktop to Documents to Downloads to Temp from SSD to the HDD, everywhere the same issue. Then I tried to save it to a USB connected SSD and got a slightly different message: Account export file error: Das System kann den angegebenen Pfad nicht finden (means The system can't find the selected path).

So the question is what needs to be done to get the right to store this file(s) into a folder on my laptop. The QR code can be saved to the folders but the export file(s) not.

UGatgithub commented 7 years ago

Side question: What are your recommendations for the Additional Geth args? I use --syncmode=fast --cache=2048 --maxpeers=24 but I am not sure if it is the optimum for my system resp. how to find that.

almindor commented 7 years ago

You use full node? Seems like good setting, note: syncmode=fast only applies on first full resync, if your chaindata is old you can save some size by re-syncing from scratch (make sure to ONLY delete chaindata folder!)

I'd use thin client tho, much easier heh.

On the permissions problem, I don't know what else to try. I'm thinking about building you a very basic "demo" app that allows to write some random data to a file somewhere and see if it fails too with the destinations you tried.

Are you sure the folders are writeable? If you go there and say, create a folder it all works?

UGatgithub commented 7 years ago

Yes the folders are writeable and as stated before it works to save the accounts QR code files from Etherwall to them, just the context menu export gives the error, the main menu export also works. Could it be the read and not the write that fails for the context menu export?

almindor commented 7 years ago

Hmm well the source is in your keystore folder under the datadir folder. I looked at the read-part of the code and it's possible an error is missed in that case.

I'll expand the code further but in the meantime can you try and look at your account files there? see if you can open them in say notepad (they're JSON).

Specifically try the files that failed for you on etherwall export (the account files end with the address in their name)

UGatgithub commented 7 years ago

All files can be opened and copied, no access issue. Just to clarify once more

Geth data director in Etherwall is set to C://Users/username/AppData/Roaming/Ethereum Wallet/

The keyfiles are in a different subfolder named Ethereum (as blockchain data) not Ethereum Wallet C://Users/username/AppData/Roaming/Ethereum/keystore

almindor commented 7 years ago

Wait a second, so your datadir points to C://Users/username/AppData/Roaming/Ethereum Wallet/ but your keystore is in C://Users/username/AppData/Roaming/Ethereum/keystore ??

How'd you even get that to work? :D This is quite non-standard, your keystore should be under the datadir folder. Did you use Mist alonside? I wonder if they do something strange there...

You don't have a keystore folder under C://Users/username/AppData/Roaming/Ethereum Wallet/ ? If not that explains the read error then. It's not finding anything, as I suspect it looks into C://Users/username/AppData/Roaming/Ethereum Wallet/keystore

UGatgithub commented 7 years ago

Exactly, that's what I already have written up somewhere in this thread but I tried and created a copy of the keystore under C://Users/username/AppData/Roaming/Ethereum Wallet/ and still get the export error. Yes I also use Ethereum Wallet and Mist but nowhere any issues except this export problem. Background is I had them installed before Etherwall.

Is this my issue? How can I fix it then? I tried to re-import the key - worked but still the same, no HD path. account

almindor commented 7 years ago

No, HDPATH is used with TREZOR hw wallet addresses. It's the "derivation path" for the device.

I think in your case the failure should be in https://github.com/almindor/etherwall/blob/master/src/helpers.cpp#L309-L336

Basically it doesn't read anything then gets empty string back and there we go.

Is there any possibility for you to install Qt5 (open source edition) and get this going with a debugger on? I should be able to walk you through. We should be able to check what folder Etherwall decided to use etc.

The other option is I build another debug version that logs everything, but I won't have that this week as I'm very busy lately.

UGatgithub commented 7 years ago

I never got a "Address keystore directory does not exist: ..." message, so it finds the directory, or?

I have no experience with qt5. Is this the right installer to use for Windows https://download.qt.io/official_releases/qt/5.9/5.9.1/qt-opensource-windows-x86-5.9.1.exe or would I have to compile that somehow (also no experience with that)?

almindor commented 7 years ago

Yes that's the correct installer.

You also need to get git (you can get the github for windows UI) and "checkout" Etherwall sources somewhere.

You then start "QtCreator" and open the Etherwall.pro file in where you checked out the sources. Make sure to create the default configurations once the project is opened (you'll understand when you get there).

Then you just select debug in the left bottom corner and "debug". Compilation will take a while but once it runs you should be ready to debug. I'll paste some pictures here on how it looks exactly today or tomorrow.

UGatgithub commented 7 years ago

Ok, I will try it out during an evening in the coming week. Looking forward to this as I am not a programmer but eager to learn new software stuff. As I read the git GUI is part of this Windows download: https://git-scm.com/download/win

UGatgithub commented 7 years ago

First there was no possibility to select a default configuration ... qt kit .. then I re-installed Qt5 completely and checked again but now I am stuck here: Running Windows Runtime device detection. C:/Qt/Qt5.9.1/5.9.1/winrt_armv7_msvc2015/bin/winrtrunner.exe --list-devices Found 1 Windows Runtime devices. Could not find qmake spec 'default'. Error while parsing file C:\Program Files\etherwall-master\Etherwall.pro. Giving up. Project ERROR: Cannot run compiler 'cl'. Maybe you forgot to setup the environment? Error while parsing file C:\Program Files\etherwall-master\Etherwall.pro. Giving up.

Could not determine which "make" command to run. Check the "make" step in the build configuration. Error while building/deploying project Etherwall (kit: Desktop Qt 5.9.1 MSVC2013 64bit) When executing step "qmake"

I don't know how / where to fix this setup issue now.

almindor commented 7 years ago

Hmm that's odd you should've had the Desktop kit, but it says it's invalid. Did you have any Qt installation before maybe/ I'm not sure what to do here, not remotely like this.

UGatgithub commented 7 years ago

I managed to get the kits installed and the system automatically detected one Windows runtime and selected kit: Desktop Qt 5.9.1 MSVC2013 64bit as default. With this kit I get now the compiler errors.

Error while parsing file C:\Program Files\etherwall-master\Etherwall.pro. Giving up. Project ERROR: Cannot run compiler 'cl'. Maybe you forgot to setup the environment? Error while parsing file C:\Program Files\etherwall-master\Etherwall.pro. Giving up.

Could not determine which "make" command to run. Check the "make" step in the build configuration. Error while building/deploying project Etherwall (kit: Desktop Qt 5.9.1 MSVC2013 64bit) When executing step "qmake"

almindor commented 7 years ago

There's something wrong with the Qt5 setup on your machine, the errors you're getting are all related to the kits/compilers.

I'll just build a special version that logs everything regarding the single account export.

If you do a wallet backup, does that work?

UGatgithub commented 7 years ago

Yes with Wallet => Export it is possible to save a .etherwall file

(I think I got one step forward with the compiler but have another error when compiling: In file included from ..\etherwall-master\src\accountmodel.h:35:0, from ..\etherwall-master\src\main.cpp:34: ..\etherwall-master\src\trezor/trezor.h:10:31: fatal error: proto/messages.pb.h: No such file or directory compilation terminated.)

almindor commented 7 years ago

Ah right so this is good news, your kit is now ok.

The steps here would be

git submodule init
git submodule update
./generate_protobuf.sh

But you'd need to have a unix-like environment and also have google protobuf and hidapi installed.

I'll prepare an archive for you later today. You'll put it "on top" of your sources and things should be compilable from there.

UGatgithub commented 7 years ago

OK, I will try again when I got the archive from you, Tomorrow night earliest from my side.

UGatgithub commented 7 years ago

Did you forget about the archive? ;-)

almindor commented 7 years ago

Nope, sorry just busy. The computer with windows I use is also often taken by my wife so... :D

almindor commented 7 years ago

Can you try the new 2.0.3 version of Etherwall? I added some additional fixes and checks to exports.

If still nothing I should have the debug version by tomorrow.

UGatgithub commented 7 years ago

One step forward!

I have three accounts whereof one can be exported but only if I copy the keystore folder from c:\Users\username\AppData\Roaming\Ethereum\ to c:\Users\username\AppData\Roaming\Ethereum Wallet\ This means Etherwall looks for the keystore folder in c:\Users\username\AppData\Roaming\Ethereum Wallet\ and not in c:\Users\username\AppData\Roaming\Ethereum\ where Ethereum Wallet / Mist stores them (If I select Mist or Ethereum Wallet and open save account, it opens c:\Users\username\AppData\Roaming\Ethereum\)

Then for the other two accounts I get: Cannot find keyfile for address: address Looking at the files I see the one which can be exported (copied) has the filename starting with UTC--YYYY-MM-DDT...... The other keyfiles file name looks more like the address and does not start with UTC-- ....

If I rename the files so they start as the other one with UTC--2016-01-04T14-26-18.559644500Z--address I can finally also export them. As I was not sure if manual renaming and using the same UTC is recommended here I checked and found I can import my keys and export them as new JSON files with an actual UTC file name.

almindor commented 7 years ago

Hmm interesting, seems your setup got pretty mixed up from Mist/Ethereum wallet.

I wonder if they changed the filename for accounts. Geth def. still uses the UTC--<timestamp>--<address> format even for newly created ones.

The other thing that makes me a bit nervous is how your datafolder is supposedly c:\Users\username\AppData\Roaming\Ethereum\ but your keys are only visible under c:\Users\username\AppData\Roaming\Ethereum Wallet\ correct?

Your datadir in etherwall/settings/geth points to c:\Users\username\AppData\Roaming\Ethereum\ ?

UGatgithub commented 7 years ago

No Geth data directory in Etherwall is C:/Users/username/AppData/Roaming/Ethereum Wallet/ I am willing to remove Etherwall and reimport the accounts as I agree there is something strange here. Also I get now this whenever I try to export an account. export error

almindor commented 7 years ago

Ouch, ok yeah, probably best but MAKE SURE TO BACKUP BOTH KEYSTORE CONTENTS!!! Go over your active accounts (those that have anything in them) and make sure you have the proper keystore file backed up for each before doing any cleanup.

Any keystore you find if it has files in it, make proper backups. Etherwall stores it's config inside regexp in windows, you might have to wipe that too if you want to go from defaults. I have an option planned to "reset to defaults" but it needs more work due exactly because of keystore files.

UGatgithub commented 7 years ago

OK, I guess the regexp storage is the reason why the accounts are still there even if I reinstall Etherwall and removed the keystore folder. I have backups of all private and public keys and the keystore files so there I should not get any issue.

almindor commented 7 years ago

Well the regexp storage does keep the addresses, but not the actual keys. It should get cleared tho if Geth reports the account missing.

e.g. if you had address A but then deleted it's keyfile from the keystore folder Etherwall (2.0.2+) should detect that and remove it from it's list.

UGatgithub commented 7 years ago

Is there more in regedit then this Computer\HKEY_CURRENT_USER\Software\Etherdyne and Computer\HKEY_USERS\.....\Software\Etherdyne ?

almindor commented 7 years ago

No that should be it.

UGatgithub commented 7 years ago

I exported them as backup before deleting. Then I removed Etherwall 2.0.3 and installed and started 2.0.4 with c:\Users\username\AppData\Roaming\Ethereum\ as data directory. Etherwall found the original keystore files and imported them as expected. Following that I tried and reimported the new Json files starting with UTC for the same accounts that I had downloaded via myetherwallet.com earlier today. Everything went smooth so I am able to export the UTC files now. I have one wallet contract, can that also be exported?

almindor commented 7 years ago

What do you mean by wallet contract? If you deployed a contract that's something akin to a wallet (e.g. multisig or such) then that's on the network.

You just need to keep the account that's used to authenticate on that contract (e.g. the deployer etc. it depends on the contract code).