Merge remote-tracking branch 'nolash/master' into lash/table-when-not-exist

This commit is contained in:
nolash 2020-09-19 14:26:32 +02:00
commit a54627801a
6 changed files with 31 additions and 8 deletions

View File

@ -1,7 +1,8 @@
* 0.1.1 * 0.1.1
- Create key table only if not exist - Create key table only if not exist
* 0.1.0 * 0.1.0
- Add web3 ext middleware capturing signer requests - Package wrap with setup.py
- Fix hex prefix bug in tx serialization
* 0.0.1 * 0.0.1
- Introduce signer, transaction, keystore packages - Introduce signer, transaction, keystore packages
- Add test for keystore and signer - Add test for keystore and signer

View File

@ -16,13 +16,17 @@ This package is written because at the time no good solution seemed to exist for
Two scripts are currently available: Two scripts are currently available:
### `server.py` ### `crypto-dev-daemon.py`
An Unix socket IPC server implementing the `web3.eth.personal` namespace of the web3 `json-rpc` "standard." An Unix socket IPC server implementing the following web3 json-rpc methods:
* web3.eth.personal.newAccount
* web3.eth.personal.signTransaction
* web3.eth.signTransaction
### `web3_middleware.py` ### `web3_middleware.py`
Demonstrates use of the IPC server as middleware for handling calls to the `personal_*` methods. Demonstrates use of the IPC server as middleware for handling calls to the web3 json-rpc methods provided by the daemon.
### Classes ### Classes
@ -45,7 +49,9 @@ The classes and packages provided are:
## VERSION ## VERSION
This software is 0.0.1 alpha state and very brittle. This software is in alpha state and very brittle.
Current version is 0.1.0
## LICENSE ## LICENSE

View File

@ -55,9 +55,9 @@ class PlatformMiddleware:
if self.re_personal.match(method) != None: if self.re_personal.match(method) != None:
params = PlatformMiddleware._translate_params(suspect_params) params = PlatformMiddleware._translate_params(suspect_params)
# multiple providers is broken in web3.py 5.12.0 # multiple providers is removed in web3.py 5.12.0
# https://github.com/ethereum/web3.py/issues/1701 # https://github.com/ethereum/web3.py/issues/1701
# hack workaround # thus we need a workaround to use the same web3 instance
s = socket.socket(family=socket.AF_UNIX, type=socket.SOCK_STREAM, proto=0) s = socket.socket(family=socket.AF_UNIX, type=socket.SOCK_STREAM, proto=0)
ipc_provider_workaround = s.connect(self.ipcaddr) ipc_provider_workaround = s.connect(self.ipcaddr)
@ -74,6 +74,7 @@ class PlatformMiddleware:
#return str(json.dumps(jr)) #return str(json.dumps(jr))
return jr return jr
# TODO: DRY
elif method == 'eth_signTransaction': elif method == 'eth_signTransaction':
params = PlatformMiddleware._translate_params(suspect_params) params = PlatformMiddleware._translate_params(suspect_params)
s = socket.socket(family=socket.AF_UNIX, type=socket.SOCK_STREAM, proto=0) s = socket.socket(family=socket.AF_UNIX, type=socket.SOCK_STREAM, proto=0)

View File

@ -20,6 +20,14 @@ signer = None
chainId = 8995 chainId = 8995
class MissingSecretError(BaseException):
def __init__(self, message):
super(MissingSecretError, self).__init__(message)
pass
def personal_new_account(p): def personal_new_account(p):
password = p password = p
if p.__class__.__name__ != 'str': if p.__class__.__name__ != 'str':
@ -134,7 +142,12 @@ def start_server():
def init(): def init():
global db, signer global db, signer
secret_hex = os.environ.get('SIGNER_SECRET') secret_hex = ''
try:
secret_hex = os.environ['SIGNER_SECRET']
except KeyError as e:
raise MissingSecretError('please set the SIGNER_SECRET environment variable to a valid hex value')
secret = bytes.fromhex(secret_hex) secret = bytes.fromhex(secret_hex)
kw = { kw = {
'symmetric_key': secret, 'symmetric_key': secret,

View File

@ -17,4 +17,6 @@ setup(
scripts = [ scripts = [
'scripts/crypto-dev-daemon', 'scripts/crypto-dev-daemon',
], ],
data_files = [('', ['LICENSE.txt'])],
url='https://gitlab.com/nolash/crypto-dev-signer',
) )