Use keyapi for address generation in import key in dictkeystore

This commit is contained in:
nolash
2021-01-09 20:25:47 +01:00
parent 0afacff6c6
commit e1e585776d
11 changed files with 93 additions and 7 deletions

View File

@@ -5,3 +5,4 @@ from eth_keys.backends import NativeECCBackend
keyapi = KeyAPI(NativeECCBackend)
from .postgres import ReferenceKeystore
from .dict import DictKeystore

View File

@@ -1,6 +1,9 @@
# standard imports
import os
# third-party imports
import eth_keyfile
# local imports
from . import keyapi
@@ -25,6 +28,11 @@ class Keystore:
raise NotImplementedError
def insert_key(self, pk, password=None):
raise NotImplementedError
def import_keystore_data(self, keystore_content, password=''):
#private_key = w3.eth.account.decrypt(keystore_content, password)
private_key = eth_keyfile.decode_keyfile_json(keystore_content, password.encode('utf-8'))
return self.import_raw_key(private_key, password)
def import_keystore_file(self, keystore_file, password=''):
keystore_content = eth_keyfile.load_keyfile(keystore_file)
return self.import_keystore_data(keystore_content, password)