steemit / steem-python

The official Python (3) library for the Steem Blockchain.
https://steem.io
MIT License
153 stars 98 forks source link

TypeError when importing accounts in steempy Python 2.7 #181

Closed cyon1c closed 6 years ago

cyon1c commented 6 years ago

In Python 2.7, the steempy cli will crash when calling importaccount with the below stack trace.

Traceback (most recent call last):
  File "/Users/jw/.local/share/virtualenvs/steem-python-Y0u0V5gr/bin/steempy", line 11, in <module>
    sys.exit(legacyentry())
  File "/Users/jw/.local/share/virtualenvs/steem-python-Y0u0V5gr/lib/python2.7/site-packages/steem/cli.py", line 1153, in legacyentry
    steem.commit.wallet.addPrivateKey(active_privkey)
  File "/Users/jw/.local/share/virtualenvs/steem-python-Y0u0V5gr/lib/python2.7/site-packages/steem/wallet.py", line 218, in addPrivateKey
    self.keyStorage.add(self.encrypt_wif(wif), pub)
  File "/Users/jw/.local/share/virtualenvs/steem-python-Y0u0V5gr/lib/python2.7/site-packages/steem/wallet.py", line 158, in encrypt_wif
    bip38.encrypt(PrivateKey(wif), self.masterpassword), "encwif")
  File "/Users/jw/.local/share/virtualenvs/steem-python-Y0u0V5gr/lib/python2.7/site-packages/steembase/bip38.py", line 59, in encrypt
    key = scrypt.hash(passphrase, salt, 16384, 8, 8)
  File "/Users/jw/.local/share/virtualenvs/steem-python-Y0u0V5gr/lib/python2.7/site-packages/scrypt/scrypt.py", line 215, in hash
    password = _ensure_bytes(password)
  File "/Users/jw/.local/share/virtualenvs/steem-python-Y0u0V5gr/lib/python2.7/site-packages/scrypt/scrypt.py", line 93, in _ensure_bytes
    raise TypeError('can not encrypt/decrypt unicode objects')
TypeError: can not encrypt/decrypt unicode objects

This appears to happen due to the handling of the user prompted input and the way it is being sanitized.

roadscape commented 6 years ago

@cyon1c was this addressed? IIRC there was another utf fix since this issue was created.

jeffignacio commented 6 years ago

I'm running into the same issue.

cyon1c commented 6 years ago

@jeffignacio is it possible for you to use Python 3.6? This issue only exists in Python 2.7.