diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index a25fd79..d27518c 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -46,6 +46,10 @@ if rcode == 0: rcode, message = self.check_end_time(end_time, start_time, block_height) ``` +## Dev requirements +In order to contrubite you will need to install additional dependencies. They can be found at `requirements-dev.txt`. Install them by running: + + pip install -r requirements-dev.txt ## Code Documentation Code should be, at least, documented using docstrings. We use the [Sphinx Google Style](https://www.sphinx-doc.org/en/master/usage/extensions/example_google.html#example-google) for documenting functions. diff --git a/DEPENDENCIES.md b/DEPENDENCIES.md new file mode 100644 index 0000000..bb849db --- /dev/null +++ b/DEPENDENCIES.md @@ -0,0 +1,86 @@ +# Dependencies + +`teos` has both system-wide and Python dependencies. This document walks you through how to satisfy them. + +## System-wide dependencies + +`teos` has the following system-wide dependencies: + +- `python3` +- `pip3` + +### Checking if the dependencies are already satisfied + +Most UNIX systems ship with `python3` already installed, whereas OSX systems tend to ship with `python2`. In order to check our python version we should run: + + python --version + +For what we will get something like: + + Python 2.X.X + +Or + + Python 3.X.X + +It is also likely that, if `python3` is installed in our system, the `python` alias is not set to it but instead to `python2`. In order to check so, we can run: + + python3 --version + +If `python3` is installed but the `python` alias is not set to it, we should either set it, or use `python3` to run `teos`. + +Regarding `pip`, we can check what version is installed in our system (if any) by running: + + pip --version + +For what we will get something like: + + pip X.X.X from /usr/local/lib/python2.X/dist-packages/pip (python 2.X) + +Or + + pip X.X.X from /usr/local/lib/python3.X/dist-packages/pip (python 3.X) + +A similar thing to the `python` alias applies to the `pip` alias. We can check if pip3 is install by running: + + pip3 --version + +And, if it happens to be installed, change the alias to `pip3`, or use `pip3` instead of `pip`. + + +### Installing the dependencies + +`python3` ca be downloaded from the [Python official website](https://www.python.org/downloads/) or installed using a package manager, depending on your distribution. Examples for both UNIX-like and OSX systems are provided. + +#### Ubuntu + +`python3` can be installed using `apt` as follows: + + sudo apt-get update + sudo apt-get install python3 + +and for `pip3`: + + sudo apt-get install python3-pip + pip install --upgrade pip==9.0.3 + +#### OSX + +`python3` can be installed using `Homebrew` as follows: + + brew install python3 + +`pip3` will be installed alongside `python3` in this case. + +## Python dependencies + +`teos` has the following dependencies (which can be satisfied by using `pip install -r requirements.txt`): + +- `zmq` +- `flask` +- `cryptography` +- `coincurve` +- `pyzbase32` +- `requests` +- `plyvel` + diff --git a/INSTALL.md b/INSTALL.md new file mode 100644 index 0000000..a0593a8 --- /dev/null +++ b/INSTALL.md @@ -0,0 +1,35 @@ +# Install + +`teos` has some dependencies that can be satisfied by following [DEPENDENCIES.md](DEPENDENCIES.md). If your system already satisfies the dependencies, you can skip that part. + +There are two ways of running `teos`: adding the library to the `PYTHONPATH` env variable, or running it as a module. + +## Modifying `PYTHONPATH` +In order to run `teos`, you should set your `PYTHONPATH` env variable to include the **outer** teos folder. You can do so by running: + + export PYTHONPATH=$PYTHONPATH: + +For example, for user alice running a UNIX system and having `teos` in her home folder, she would run: + + export PYTHONPATH=$PYTHONPATH:/home/alice/teos/ + +You should also include the command in your `.bashrc` to avoid having to run it every time you open a new terminal. You can do it by running: + + echo 'export PYTHONPATH=$PYTHONPATH:' >> ~/.bashrc + +Once the `PYTHONPATH` is set, you should be able to run `teos` straightaway. Try it by running: + + cd /teos/ + python teosd.py + +## Running `teos` as a module +Python code can be also run as a module, to do so you need to use `python -m`. From the **outer** teos directory run: + + python -m teos.teosd + +Notice that if you run `teos` as a module, you'll need to replace all the calls from `python teosd.py` to `python -m teos.teosd` + +## Modify configuration parameters +If you'd like to modify some of the configuration defaults (such as the user directory, where the logs will be stored) you can do so in the config file located at: + + /teos/conf.py diff --git a/README.md b/README.md new file mode 100644 index 0000000..22ff8b2 --- /dev/null +++ b/README.md @@ -0,0 +1,34 @@ +# The Eye of Satoshi (TEOS) + +The Eye of Satoshi is a Lightning watchtower compliant with [BOLT13](https://github.com/sr-gi/bolt13), written in Python 3. + +TEOS consists in three main modules: + +- `teos`: including the tower's main functionality (server-side) +- `cli`: including a reference command line interface (client-side) +- `common`: including shared functionality between `teos` and `cli`. + +Additionally, tests for every module can be found at `tests`. + + +### Running TEOS +In order to run `teos` you will need to create a configuration file (follow [INSTALL.md](INSTALL.md)) and run `teosd.py`. Currently you will also need a set of keys (to sign appointments) stored in your data directory. + +You can use `generate_keys.py` to generate those keys. + +### Interacting with a TEOS instance +You can interact with a `teos` instance (either run by yourself or someone else) by using `teos_cli` under `cli`. + +Since `teos_cli` works independently of `teos`, you will need a separate configuration file for this (follow [cli/INSTALL.md](cli/INSTALL.md)) and a different set of keys. You can use `generate_keys.py` to generate those keys. + +Notice that `teos_cli` is a simple way to interact with `teos`, but ideally that should be part of your wallet functionality (therefore why they are independent entities). `teos_cli` can be used as an example for how to send data to a [BOLT13](https://github.com/sr-gi/bolt13) compliant watchtower. + +## Dependencies +Refer to [DEPENDENCIES.md](DEPENDENCIES.md) + +## Installation + +Refer to [INSTALL.md](INSTALL.md) + +## Contributing +Refer to [CONTRIBUTING.md](CONTRIBUTING.md) \ No newline at end of file diff --git a/cli/requirements-dev.txt b/cli/requirements-dev.txt deleted file mode 100644 index f8c47f0..0000000 --- a/cli/requirements-dev.txt +++ /dev/null @@ -1,3 +0,0 @@ -responses -pytest -black \ No newline at end of file diff --git a/teos/requirements-dev.txt b/requirements-dev.txt similarity index 77% rename from teos/requirements-dev.txt rename to requirements-dev.txt index 10481e4..8a51da8 100644 --- a/teos/requirements-dev.txt +++ b/requirements-dev.txt @@ -1,3 +1,4 @@ pytest black +responses bitcoind_mock===0.0.4 diff --git a/teos/requirements.txt b/requirements.txt similarity index 100% rename from teos/requirements.txt rename to requirements.txt