Skip to content
This repository was archived by the owner on Aug 8, 2018. It is now read-only.

Use the new eth-keyfile module, fixes #292 #293

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions pyethapp/accounts.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -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

Expand Down
7 changes: 5 additions & 2 deletions pyethapp/tests/test_accounts.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand All @@ -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()
Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,4 @@ tinyrpc[gevent,httpclient,jsonext,websocket,wsgi]
pycryptodome==3.4.6
future
https://github.com/ethereum/serpent/tarball/develop
eth-keyfile