Skip to content
This repository was archived by the owner on May 23, 2023. It is now read-only.

Commit dd9986c

Browse files
vubvub
authored andcommitted
Merge branch 'develop' of github.com:ethereum/pyethereum into develop
2 parents fb7b763 + eba8ab2 commit dd9986c

File tree

4 files changed

+29
-6
lines changed

4 files changed

+29
-6
lines changed

ethereum/chain.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -284,11 +284,7 @@ def add_block(self, block, forward_pending_transactions=True):
284284
_log.debug('invalid uncles')
285285
return False
286286

287-
if not len(block.nonce) == 8:
288-
_log.debug('nonce not set')
289-
return False
290-
elif not block.header.check_pow(nonce=block.nonce) and\
291-
not block.is_genesis():
287+
elif not block.header.check_pow() and not block.is_genesis():
292288
_log.debug('invalid nonce')
293289
return False
294290

ethereum/keys.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,32 @@ def make_keystore_json(priv, pw, kdf="pbkdf2", cipher="aes-128-ctr"):
155155
}
156156

157157

158+
def check_keystore_json(jsondata):
159+
"""Check if ``jsondata`` has the structure of a keystore file version 3.
160+
161+
Note that this test is not complete, e.g. it doesn't check key derivation or cipher parameters.
162+
163+
:param jsondata: dictionary containing the data from the json file
164+
:returns: `True` if the data appears to be valid, otherwise `False`
165+
"""
166+
if 'crypto' not in jsondata and 'Crypto' not in jsondata:
167+
return False
168+
if 'version' not in jsondata:
169+
return False
170+
if jsondata['version'] != 3:
171+
return False
172+
crypto = jsondata.get('crypto', jsondata.get('Crypto'))
173+
if 'cipher' not in crypto:
174+
return False
175+
if 'ciphertext' not in crypto:
176+
return False
177+
if 'kdf' not in crypto:
178+
return False
179+
if 'mac' not in crypto:
180+
return False
181+
return True
182+
183+
158184
def decode_keystore_json(jsondata, pw):
159185
# Get KDF function and parameters
160186
if "crypto" in jsondata:

ethereum/tests/test_keys.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ def gen_func(filename, testname, testdata):
1313

1414
def do_test_key(filename, testname=None, testdata=None, limit=99999999):
1515
logger.debug('running test:%r in %r' % (testname, filename))
16+
assert keys.check_keystore_json(testdata["json"])
1617
privkey = keys.decode_keystore_json(testdata["json"], testdata["password"])
1718
assert utils.encode_hex(privkey) == utils.to_string(testdata["priv"])
1819

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,6 @@ def run_tests(self):
5151
install_requires=install_requires,
5252
tests_require=tests_require,
5353
entry_points=dict(console_scripts=console_scripts),
54-
version='1.0.0',
54+
version='1.0.1',
5555
cmdclass=cmdclass
5656
)

0 commit comments

Comments
 (0)