Skip to content
This repository has been archived by the owner on May 13, 2022. It is now read-only.

Commit

Permalink
Restructure project, make requirements explicit
Browse files Browse the repository at this point in the history
The microraiden python package was moved one level up to the
root directory. The setup.py for microraiden now resides in the
root directory.
Parsing of a requirements-file in setup.py was replaced by an
explicit list of version fixes, as needed for setuptools 'install_requires'.
Only deployment/development specific packages that are not neccessarily
needed for installation should be specified in requirements files.

Also, there where install-scripts added in the Makefile for easy
user installation.
  • Loading branch information
ezdac committed Feb 16, 2018
1 parent 10489d6 commit 87c8124
Show file tree
Hide file tree
Showing 130 changed files with 331 additions and 327 deletions.
File renamed without changes.
86 changes: 86 additions & 0 deletions .gitignore
Expand Up @@ -6,3 +6,89 @@ __pycache__
build/docs/
docs/api/
.cache

# ignore private keys
*.pem

# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]

# C extensions
*.so

# Distribution / packaging
.Python
env/
devenv/
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
*.egg-info/
.installed.cfg
*.egg

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*,cover

# hypothesis
.hypothesis

# Pyenv
.python-version

# Translations
*.mo
*.pot

# Django stuff:
*.log

# Sphinx documentation
docs/_build/

# PyBuilder
target/

# truffle related
truffle/.babel.json
truffle/environments/development/contracts/
truffle/.bash_history

# never check in .static-abi.json files
*.static-abi.json

# ignore node_modules
node_modules/
package-lock.json

# never check in the smoketest_config.json
smoketest_config.json

# ignore tag files
tags
1 change: 0 additions & 1 deletion microraiden/MANIFEST.in → MANIFEST.in
@@ -1,2 +1 @@
include requirements-dev.txt
include requirements.txt
39 changes: 32 additions & 7 deletions Makefile
Expand Up @@ -3,20 +3,45 @@
DOCS_SRC := docs
BUILD_DIR := build
DOCS_BUILD_DIR := $(BUILD_DIR)/docs
DATADIR:=microraiden/data

all: docs microraiden
all: docs webui flake8

docs: apidocs
install:
pip install .

dev_install:
pip install -e . -r requirements-dev.txt

docs: pydocs jsdocs

pydocs: apidocs
sphinx-build -b html $(DOCS_SRC) $(DOCS_BUILD_DIR)

apidocs:
sphinx-apidoc -o $(DOCS_SRC)/api microraiden/microraiden/
sphinx-apidoc -o $(DOCS_SRC)/api microraiden/

microraiden:
make -C microraiden
jsdocs:
cd microraiden/webui/microraiden/ && npm run docs

clean:
make -C microraiden clean
rm -rf $(BUILD_DIR)
python setup.py clean --all
rm -vrf $(BUILD_DIR) ./dist ./*.pyc ./*.tgz ./*.egg-info

mrproper: clean

bandit:
bandit -s B101 -r microraiden/

pylint:
pylint microraiden/

ssl_cert:
openssl req -x509 -newkey rsa:4096 -nodes -out $(DATADIR)/cert.pem -keyout $(DATADIR)/key.pem -days 365

flake8:
flake8 microraiden/

webui:
python setup.py compile_webui

113 changes: 113 additions & 0 deletions README.md
Expand Up @@ -110,3 +110,116 @@ python -m microraiden.examples.demo_proxy --private-key <private_key_file> start

* Go to the paywalled resource pages:
- http://localhost:5000/teapot


# µRaiden

## Installation

### Using `virtualenv`

Run the following commands from the repository root directory.

```bash
virtualenv -p python3 env
. env/bin/activate
pip install -e microraiden
```

#### Using microraiden in pip's _editable_ mode
Because of `gevent` you will need to install microraiden's requirements first.
```bash
virtualenv -p python3 env
. env/bin/activate
git clone git@github.com:raiden-network/microraiden.git
cd microraiden/microraiden
pip install -r requirements-dev.txt
pip install -e .
```

### Using a global `pip3` installation

```bash
sudo pip3 install -e microraiden
```

## Execution

### HTTP Proxy
There are several examples that demonstrate how to serve custom content. To try them, run one of the following commands from the `microraiden` directory:
```bash
python3 -m microraiden.examples.demo_proxy --private-key <private_key_file> start
```
or
```bash
python3 -m microraiden.examples.wikipaydia --private-key <private_key_file> --private-key-password-file <password_file> start
```
By default, the web server listens on `0.0.0.0:5000`. The private key file should be in the JSON format produced by Geth/Parity and must be readable and writable only by the owner to be accepted (`-rw-------`). A ``--private-key-password-file`` option can be specified, containing the password for the private key in the first line of the file. If it's not provided, the password will be prompted interactively.
An Ethereum node RPC interface is expected to respond on http://localhost:8545. Alternatively, you can use [Infura infrastructure](https://infura.io/) as a RPC provider.
### M2M Client
```bash
python3 -m microraiden.examples.m2m_client --key-path <path to private key file> --key-password-path <password file>
```

## Library usage

### Client
The µRaiden client backend used by the M2M sample client can be used as a standalone library. After installation, import the following class:
```python
from microraiden import Client

client = Client('<hex-encoded private key>')
```

Alternatively you can specify a path to a JSON private key, optionally specifying a file containing the password. If it's not provided, it'll be prompted interactively.
```python
client = Client(key_path='<path to private key file>', key_password_file='<path to password file>')
```

This client object allows interaction with the blockchain and offline-signing of transactions and Raiden balance proofs.

An example lifecycle of a `Client` object could look like this:

```python
from microraiden import Client

receiver = '0xb6b79519c91edbb5a0fc95f190741ad0c4b1bb4d'
privkey = '0x55e58f57ec2177ea681ee461c6d2740060fd03109036e7e6b26dcf0d16a28169'

# 'with' statement to cleanly release the client's file lock in the end.
with Client(privkey) as client:

channel = client.get_suitable_channel(receiver, 10)
channel.create_transfer(3)
channel.create_transfer(4)

print(
'Current balance proof:\n'
'From: {}\n'
'To: {}\n'
'Channel opened at block: #{}\n' # used to uniquely identify this channel
'Balance: {}\n' # total: 7
'Signature: {}\n' # valid signature for a balance of 7 on this channel
.format(
channel.sender, channel.receiver, channel.block, channel.balance, channel.balance_sig
)
)

channel.topup(5) # total deposit: 15

channel.create_transfer(5) # total balance: 12

channel.close()

# Wait for settlement period to end.

channel.settle()

# Instead of requesting a close and waiting for the settlement period to end, you can also perform
# a cooperative close, provided that you have a receiver-signed balance proof that matches your
# current channel balance.

channel.close_cooperatively(closing_sig)
```

The values required for a valid balance proof required by the receiver end are printed above. Make sure to let them know.
2 changes: 2 additions & 0 deletions contracts/Makefile
@@ -0,0 +1,2 @@
install:
pip install -r requirements.txt
85 changes: 0 additions & 85 deletions microraiden/.gitignore

This file was deleted.

27 changes: 0 additions & 27 deletions microraiden/Makefile

This file was deleted.

0 comments on commit 87c8124

Please sign in to comment.