Electron-Cash / Electron-Cash

Electron Cash; Bitcoin Cash thin client
MIT License
364 stars 191 forks source link

Electron Cash silently crashes on non-English characters in the wallet path #173

Closed andy-red closed 7 years ago

andy-red commented 7 years ago

It seems that Electron Cash does not support some non-English characters in the directories in the wallet path. I am observing this problem in the Windows 7 Prof. 64-bit and Windows 10 Prof. 64-bit systems. When a directory with such character happens to be in the path, the application crashes after entering the correct wallet password.

This is serious, considering that a default Windows path (C:\Users\\AppData\Roaming\ElectronCash\wallets) contains a Windows username, which quite probably may contain national characters in non-English Windows systems.

How to reproduce the issue:

  1. Create a test directory with the Polish 'ł' character (0xc582 UTF-8, see https://en.wikipedia.org/wiki/%C5%81#Computer_usage if needed). E.g.: C:\tmp\ała
  2. Copy a correct wallet file to the C:\tmp\ała directory.
  3. Run a verbose version of the Electron Cash from the Windows command line ('cmd') using the '-w C:\tmp\ała' switch.
  4. See the error:
    File "C:\Users\andy\AppData\Local\Temp\_MEI53282\gui\qt\main_window.py", line 193, in __init__
    self.load_wallet(wallet)
    File "C:\Users\andy\AppData\Local\Temp\_MEI53282\gui\qt\main_window.py", line 320, in load_wallet
    self.update_recently_visited(wallet.storage.path)
    File "C:\Users\andy\AppData\Local\Temp\_MEI53282\gui\qt\main_window.py", line 402, in update_recently_visited
    filename = filename.decode('utf8')
    File "Z:\home\ubuntu\gitwork\electrum\contrib\build-wine\build\deterministic\out00-PYZ.pyz\encodings.utf_8", line 16,
    in decode
    UnicodeDecodeError: 'utf8' codec can't decode byte 0xb3 in position 8: invalid start byte
    # clear __builtin__._
    # clear sys.path
    # clear sys.argv
kenman345 commented 7 years ago

Can you please clarify your test scenario. In the error, you have three lines in a file within a C drive listed, but then the last file mentioned is following a path that indicates using ubuntu and wine.

In order to properly fix this issue, it would be best to understand this scenario to make sure it is fixed not just how we can reproduce but also how you originally found it.

andy-red commented 7 years ago

The error occurs in my Windows systems and no actual Ubuntu, Wine, Z: drive or '\home\ubuntu\' directory is involved or even present in the system. I guess that this strange Ubuntu path is hardcoded in the Electron Cash itself. Which might be a cause of this issue.

kenman345 commented 7 years ago

Would you download the revision in this branch? I think it might work but have yet to confirm. Still getting my PC set up for Python development.

https://github.com/kenman345/electrum/tree/unicode_fix