diff --git a/electrumx_rpc.py b/electrumx_rpc.py index 2ce4dee..03e25c1 100755 --- a/electrumx_rpc.py +++ b/electrumx_rpc.py @@ -43,14 +43,16 @@ def main(): parser = argparse.ArgumentParser('Send electrumx an RPC command' ) parser.add_argument('-p', '--port', metavar='port_num', type=int, help='RPC port number') - parser.add_argument('command', nargs='*', default=[], + parser.add_argument('command', nargs=1, default=[], help='command to send') + parser.add_argument('param', nargs='*', default=[], + help='params to send') args = parser.parse_args() if args.port is None: args.port = int(environ.get('ELECTRUMX_RPC_PORT', 8000)) - payload = {'method': args.command[0], 'params': args.command[1:]} + payload = {'method': args.command[0], 'params': args.param} loop = asyncio.get_event_loop() proto_factory = partial(RPCClient, loop) @@ -60,7 +62,7 @@ def main(): protocol.send(payload) loop.run_forever() except OSError: - print('error connecting - is ElectrumX running?') + print('error connecting - is ElectrumX catching up or not running?') finally: loop.close() diff --git a/server_main.py b/electrumx_server.py similarity index 100% rename from server_main.py rename to electrumx_server.py diff --git a/lib/__init__.py b/lib/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/samples/scripts/NOTES b/samples/scripts/NOTES index e56c4ec..4b86bde 100644 --- a/samples/scripts/NOTES +++ b/samples/scripts/NOTES @@ -2,7 +2,8 @@ The following environment variables are required: DB_DIRECTORY - path to the database directory (if relative, to `run` script) USERNAME - the username the server will run as if using `run` script -SERVER_MAIN - path to the server_main.py script (if relative, to `run` script) +ELECTRUMX - path to the electrumx_server.py script (if relative, + to `run` script) DAEMON_URL - the URL used to connect to the daemon. Should be of the form http://username:password@hostname:port/ Alternatively you can specify DAEMON_USERNAME, DAEMON_PASSWORD, diff --git a/samples/scripts/env/ELECTRUMX b/samples/scripts/env/ELECTRUMX new file mode 100644 index 0000000..3de0637 --- /dev/null +++ b/samples/scripts/env/ELECTRUMX @@ -0,0 +1 @@ +/path/to/electrumx_server.py diff --git a/samples/scripts/env/SERVER_MAIN b/samples/scripts/env/SERVER_MAIN deleted file mode 100644 index 6aee931..0000000 --- a/samples/scripts/env/SERVER_MAIN +++ /dev/null @@ -1 +0,0 @@ -/path/to/repos/electrumx/server_main.py diff --git a/samples/systemd-unit b/samples/systemd-unit index 94b7d47..46107f3 100644 --- a/samples/systemd-unit +++ b/samples/systemd-unit @@ -4,7 +4,7 @@ After=network.target [Service] EnvironmentFile=/etc/electrumx.conf -ExecStart=/home/electrumx/electrumx/server_main.py +ExecStart=/usr/local/bin/electrumx_server.py User=electrumx [Install] diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..827e807 --- /dev/null +++ b/setup.py @@ -0,0 +1,24 @@ +import setuptools +from server.version import VERSION + + +setuptools.setup( + name='electrumx', + version=VERSION.split()[-1], + scripts=['electrumx_server.py', 'electrumx_rpc.py'], + python_requires='>=3.5', + install_requires=['plyvel', 'aiohttp >= 1'], + packages=setuptools.find_packages(), + description='ElectrumX Server', + author='Neil Booth', + author_email='kyuupichan@gmail.com', + license='MIT Licence', + url='https://github.com/kyuupichan/electrumx/', + long_description='Server implementation for the Electrum wallet', + classifiers=[ + 'Development Status :: 3 - Alpha', + 'Topic :: Internet', + 'License :: OSI Approved :: MIT License', + 'Operating System :: Unix', + ], +)