diff --git a/CHANGELOG b/CHANGELOG index 20769b5..b0e2880 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,7 +1,8 @@ * 0.1.1 - Create key table only if not exist * 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 - Introduce signer, transaction, keystore packages - Add test for keystore and signer diff --git a/LICENSE b/LICENSE.txt similarity index 100% rename from LICENSE rename to LICENSE.txt diff --git a/README.md b/README.md index 7707859..d299d2e 100644 --- a/README.md +++ b/README.md @@ -16,13 +16,17 @@ This package is written because at the time no good solution seemed to exist for 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` -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 @@ -45,7 +49,9 @@ The classes and packages provided are: ## 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 diff --git a/crypto_dev_signer/eth/web3ext/middleware.py b/crypto_dev_signer/eth/web3ext/middleware.py index a58f3e6..aa47423 100644 --- a/crypto_dev_signer/eth/web3ext/middleware.py +++ b/crypto_dev_signer/eth/web3ext/middleware.py @@ -55,9 +55,9 @@ class PlatformMiddleware: if self.re_personal.match(method) != None: 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 - # 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) ipc_provider_workaround = s.connect(self.ipcaddr) @@ -74,6 +74,7 @@ class PlatformMiddleware: #return str(json.dumps(jr)) return jr + # TODO: DRY elif method == 'eth_signTransaction': params = PlatformMiddleware._translate_params(suspect_params) s = socket.socket(family=socket.AF_UNIX, type=socket.SOCK_STREAM, proto=0) diff --git a/scripts/crypto-dev-daemon b/scripts/crypto-dev-daemon index 67faff4..a8ca9fc 100755 --- a/scripts/crypto-dev-daemon +++ b/scripts/crypto-dev-daemon @@ -20,6 +20,14 @@ signer = None chainId = 8995 +class MissingSecretError(BaseException): + + def __init__(self, message): + super(MissingSecretError, self).__init__(message) + + pass + + def personal_new_account(p): password = p if p.__class__.__name__ != 'str': @@ -134,7 +142,12 @@ def start_server(): def init(): 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) kw = { 'symmetric_key': secret, diff --git a/setup.py b/setup.py index 1086102..5e6ded3 100644 --- a/setup.py +++ b/setup.py @@ -17,4 +17,6 @@ setup( scripts = [ 'scripts/crypto-dev-daemon', ], + data_files = [('', ['LICENSE.txt'])], + url='https://gitlab.com/nolash/crypto-dev-signer', )