Updates READMEs with the new config file apporach

This commit is contained in:
Sergi Delgado Segura
2020-03-23 17:12:23 +01:00
parent d21e947e05
commit d2fbcf61e3
4 changed files with 112 additions and 41 deletions

View File

@@ -5,14 +5,14 @@
There are two ways of running `teos`: running it as a module or adding the library to the `PYTHONPATH` env variable. There are two ways of running `teos`: running it as a module or adding the library to the `PYTHONPATH` env variable.
## Running `teos` as a Module ## Running `teos` as a Module
The easiest way to run `teos` is as a module. To do so you need to use `python -m`. From the teos parent directory run: The **easiest** way to run `teos` is as a module. To do so you need to use `python -m`. From the teos parent directory run:
python -m teos.teosd python -m teos.teosd -h
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` 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`
## Modifying `PYTHONPATH` ## Modifying `PYTHONPATH`
Alternatively, you can add `teos` to your `PYTHONPATH`. You can do so by running: **Alternatively**, you can add `teos` to your `PYTHONPATH` by running:
export PYTHONPATH=$PYTHONPATH:<absolute_path_to_teos_parent> export PYTHONPATH=$PYTHONPATH:<absolute_path_to_teos_parent>
@@ -24,7 +24,14 @@ You should also include the command in your `.bashrc` to avoid having to run it
echo 'export PYTHONPATH=$PYTHONPATH:<absolute_path_to_teos_parent>' >> ~/.bashrc echo 'export PYTHONPATH=$PYTHONPATH:<absolute_path_to_teos_parent>' >> ~/.bashrc
## Modify Configuration Parameters Once the `PYTHONPATH` is set, you should be able to run `teos` straightaway. Try it by running:
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:
<absolute_path_to_teos_parent>/teos/conf.py cd <absolute_path_to_cli_parent>/teos
python teosd.py -h
## Modify Configuration Parameters
If you'd like to modify some of the configuration defaults (such as the bitcoind rpcuser and password) you can do so in the config file located at:
<data_dir>/.teos/teos.conf
`<data_dir>` defaults to your home directory (`~`).

View File

@@ -14,34 +14,95 @@ The Eye of Satoshi is a Lightning watchtower compliant with [BOLT13](https://git
Additionally, tests for every module can be found at `tests`. Additionally, tests for every module can be found at `tests`.
By default, `teos` will run on `regtest`. In order to run it on another network you need to change your `bitcoin.conf` (to run in the proper network) and your `conf.py` to match the network name and rpc port: ## Dependencies
Refer to [DEPENDENCIES.md](DEPENDENCIES.md)
## Installation
Refer to [INSTALL.md](INSTALL.md)
## Running TEOS
You can run `teos` buy running `teosd.py` under `teos`:
``` ```
BTC_RPC_PORT = 18443 python -m teos.teosd
BTC_NETWORK = "regtest"
``` ```
### Running TEOS `teos` comes with a default configuration that can be found at [teos/\_\_init\_\_.py](teos/__init__.py).
You can run `teos` buy running `teosd.py` under `teos`.
`teos` comes with a default configuration file (check [conf.py](teos/conf.py)). The configuration file include, amongst others, where your data folder is placed, what network it connects to, etc. The configuration includes, amongst others, where your data folder is placed, what network it connects to, etc.
To run `teos` you need a set of keys (to sign appointments) stored in your data directory. You can follow [generate keys](#generate-keys) to generate them. To run `teos` you need a set of keys (to sign appointments) stored in your data directory. You can follow [generate keys](#generate-keys) to generate them.
### Interacting with a TEOS Instance
### Configuration file and command line parameters
To change the configuration defaults you can:
- Define a configuration file following the template (check [teos/template.conf](teos/template.conf)) and place it in the `data_dir` (that defaults to `~/.teos/`)
and / or
- Add some global options when running the daemon (run `teosd.py -h` for more info).
## Running TEOS in another network
By default, `teos` runs on `mainnet`. In order to run it on another network you need to change the network parameter in the configuration file or pass the network parameter as a command line option. Notice that if teos does not find a `bitcoind` node running in the same network that it is set to run, it will refuse to run.
### Modifiying the configuration file
The configuration file options to change the network where `teos` will run are the `btc_rpc_port` and the `btc_network` under the `bitcoind` section:
```
[bitcoind]
btc_rpc_user = "user"
btc_rpc_passwd = "passwd"
btc_rpc_connect = "localhost"
btc_rpc_port = 8332
btc_network = "mainnet"
```
For regtest, it should look like:
```
[bitcoind]
btc_rpc_user = "user"
btc_rpc_passwd = "passwd"
btc_rpc_connect = "localhost"
btc_rpc_port = 18443
btc_network = "regtest"
```
### Passing command line options to `teosd`
Some configuration options can also be passed as options when running `teosd`. We can, for instance, pick the network as follows:
```
python -m teos.teosd --btcnetwork=regtest --btcrpcport=18443
```
## 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`. 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`, it uses a different configuration file (check [cli/conf.py](cli/conf.py)). Since `teos_cli` works independently of `teos`, it uses a different configuration. The defaults can be found at [cli/\_\_init\_\_.py](cli/__init__.py). The same approach as with `teosd` is followed:
`teos_cli` also needs an independent set of keys (that can be generated following [generate keys](#generate-keys)) as well as the public key of the tower instance (`teos_pk.der`). The same data directory can be used for both if you are running things locally. - A config file (`~/.teos_cli/teos_cli.conf`) can be set to change the defaults.
- Some options ca also be changed via command line.
- The configuration file template can be found at [cli/template.conf](cli/template.conf))
`teos_cli` needs an independent set of keys and, top of that, a copy of tower's the public key (`teos_pk.der`). Check [generate keys](#generate-keys) for more on how to set this.
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. 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.
### Generate Keys ## Generate Keys
In order to generate a pair of keys for `teos` (or `teos_cli`) you can use `generate_keys.py`. In order to generate a pair of keys for `teos` (or `teos_cli`) you can use `generate_keys.py`.
The script generates a set of keys (`teos_sk.der` and `teos_pk.der`) in the current directory, by default. The name and output directory can be changed using `-n` and `-d` respectively. The script generates and stores a set of keys on disk (by default it outputs them in the current directory and names them `teos_sk.der` and `teos_pk.der`). The name and output directory can be changed using `-n` and `-d` respectively.
The following command will generate a set of keys for `teos` and store it in the default data directory (`~/.teos`): The following command will generate a set of keys for `teos` and store it in the default data directory (`~/.teos`):
``` ```
@@ -59,12 +120,5 @@ Notice that `cli` needs a copy of the tower public key, so you should make a cop
cp ~./teos/teos_pk.der ~./teos_cli/teos_pk.der cp ~./teos/teos_pk.der ~./teos_cli/teos_pk.der
``` ```
## Dependencies
Refer to [DEPENDENCIES.md](DEPENDENCIES.md)
## Installation
Refer to [INSTALL.md](INSTALL.md)
## Contributing ## Contributing
Refer to [CONTRIBUTING.md](CONTRIBUTING.md) Refer to [CONTRIBUTING.md](CONTRIBUTING.md)

View File

@@ -2,16 +2,23 @@
`teos_cli` 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. `teos_cli` 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_cli`: adding the library to the `PYTHONPATH` env variable, or running it as a module. There are two ways of running `teos_cli`: running it as a module or adding the library to the PYTHONPATH env variable.
## Running `teos_cli` as a module
The **easiest** way to run `teos_cli` is as a module. To do so you need to use `python -m`. From `cli` **parent** directory run:
python -m cli.teos_cli -h
Notice that if you run `teos_cli` as a module, you'll need to replace all the calls from `python teos_cli.py <argument>` to `python -m cli.teos_cli <argument>`
## Modifying `PYTHONPATH` ## Modifying `PYTHONPATH`
In order to run `teos_cli`, you should set your `PYTHONPATH` env variable to include the folder that contains the `cli` folder. You can do so by running: **Alternatively**, you can add `teos_cli` to your `PYTHONPATH` by running:
export PYTHONPATH=$PYTHONPATH:<absolute_path_to_cli_parent> export PYTHONPATH=$PYTHONPATH:<absolute_path_to_cli_parent>
For example, for user alice running a UNIX system and having `cli` in her home folder, she would run: For example, for user alice running a UNIX system and having `python-teos` in her home folder, she would run:
export PYTHONPATH=$PYTHONPATH:/home/alice/ export PYTHONPATH=$PYTHONPATH:/home/alice/python-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: 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:
@@ -22,14 +29,10 @@ Once the `PYTHONPATH` is set, you should be able to run `teos_cli` straightaway.
cd <absolute_path_to_cli_parent>/cli cd <absolute_path_to_cli_parent>/cli
python teos_cli.py -h python teos_cli.py -h
## Running `teos_cli` as a module
Python code can be also run as a module, to do so you need to use `python -m`. From `cli` **parent** directory run:
python -m cli.teos_cli -h
Notice that if you run `teos_cli` as a module, you'll need to replace all the calls from `python teos_cli.py <argument>` to `python -m cli.teos_cli <argument>`
## Modify configuration parameters ## Modify configuration parameters
If you'd like to modify some of the configuration defaults (such as the user directory, where the logs and appointment receipts will be stored) you can do so in the config file located at: If you'd like to modify some of the configuration defaults (such as the user directory, where the logs and appointment receipts will be stored) you can do so in the config file located at:
<absolute_path_to_cli_parent>/cli/conf.py <data_dir>/.teos_cli/teos_cli.conf
`<data_dir>` defaults to your home directory (`~`).

View File

@@ -15,8 +15,8 @@ Refer to [INSTALL.md](INSTALL.md)
#### Global options #### Global options
- `-s, --server`: API server where to send the requests. Defaults to https://teos.pisa.watch (modifiable in conf.py) - `-s, --server`: API server where to send the requests. Defaults to 'localhost' (modifiable in conf file).
- `-p, --port` : API port where to send the requests. Defaults to 443 (modifiable in conf.py) - `-p, --port` : API port where to send the requests. Defaults to '9814' (modifiable in conf file).
- `-h --help`: shows a list of commands or help for a specific command. - `-h --help`: shows a list of commands or help for a specific command.
#### Commands #### Commands
@@ -68,7 +68,7 @@ if `-f, --file` **is** specified, then the command expects a path to a json file
### get_appointment ### get_appointment
This command is used to get information about an specific appointment from the Eye of Satoshi. This command is used to get information about a specific appointment from the Eye of Satoshi.
**Appointment can be in three states:** **Appointment can be in three states:**
@@ -146,8 +146,15 @@ or
If you wish to read about the underlying API, and how to write your own tool to interact with it, refer to [tEOS-API.md](TEOS-API.md). If you wish to read about the underlying API, and how to write your own tool to interact with it, refer to [tEOS-API.md](TEOS-API.md).
## Are you reckless? Try me on mainnet ## Try our live instance
Would you like to try me on `mainnet` instead of `testnet`? Add `-s https://mainnet.teos.pisa.watch` to your calls, for example:
By default, `teos_cli` will connect to your local instance (running on localhost). There are also a couple of live instances running, one for mainet and one for testnet:
- testnet endpoint = `teos.pisa.watch`
- mainnet endpoint = `teosmainnet.pisa.watch`
### Connecting to the mainnet instance
Add `-s https://teosmainnet.pisa.watch` to your calls, for example:
``` ```
python teos_cli.py -s https://teosmainnet.pisa.watch add_appointment -f dummy_appointment_data.json python teos_cli.py -s https://teosmainnet.pisa.watch add_appointment -f dummy_appointment_data.json
@@ -155,4 +162,4 @@ python teos_cli.py -s https://teosmainnet.pisa.watch add_appointment -f dummy_ap
You can also change the config file to avoid specifying the server every time: You can also change the config file to avoid specifying the server every time:
`DEFAULT_TEOS_API_SERVER = "https://teosmainnet.pisa.watch"` `TEOS_SERVER = "https://teosmainnet.pisa.watch"`