diff --git a/pyethapp/accounts.py b/pyethapp/accounts.py index c8789b4f..0adf2ec6 100644 --- a/pyethapp/accounts.py +++ b/pyethapp/accounts.py @@ -2,6 +2,7 @@ from builtins import object import json import os +import eth_keyfile from random import SystemRandom import shutil from uuid import UUID @@ -74,7 +75,7 @@ def new(cls, password, key=None, uuid=None, path=None): if not is_string(password): password = to_string(password) - keystore = keys.make_keystore_json(key, password) + keystore = eth_keyfile.create_keyfile_json(key, password) keystore['id'] = uuid return Account(keystore, password, path) @@ -121,7 +122,9 @@ def unlock(self, password): account is locked) """ if self.locked: - self._privkey = keys.decode_keystore_json(self.keystore, password) + if not is_string(password): + password = to_string(password) + self._privkey = eth_keyfile.decode_keyfile_json(self.keystore, password) self.locked = False self.address # get address such that it stays accessible after a subsequent lock diff --git a/pyethapp/tests/test_accounts.py b/pyethapp/tests/test_accounts.py index 3c0f8a3f..561f04a4 100644 --- a/pyethapp/tests/test_accounts.py +++ b/pyethapp/tests/test_accounts.py @@ -3,7 +3,7 @@ from past.utils import old_div import json from uuid import uuid4 -import ethereum.tools.keys +import eth_keyfile.keyfile from ethereum.tools.keys import privtoaddr from ethereum.transactions import Transaction from ethereum.utils import ( @@ -14,7 +14,10 @@ import pytest # reduce key derivation iterations -ethereum.tools.keys.PBKDF2_CONSTANTS['c'] = 100 +def get_default_work_factor_for_kdf(kdf): + return 100 +eth_keyfile.keyfile.get_default_work_factor_for_kdf = \ + get_default_work_factor_for_kdf @pytest.fixture() diff --git a/requirements.txt b/requirements.txt index 17065682..2f638c9b 100644 --- a/requirements.txt +++ b/requirements.txt @@ -22,3 +22,4 @@ tinyrpc[gevent,httpclient,jsonext,websocket,wsgi] pycryptodome==3.4.6 future https://github.com/ethereum/serpent/tarball/develop +eth-keyfile