No description
Find a file
2022-07-23 15:12:20 +02:00
.github/workflows chore: exclude lnd grpc files from code scanning 2021-08-14 13:08:34 +02:00
.vscode chore: format source using the pre_commit command 2022-03-20 17:20:56 +01:00
app fix[CLN]: return onchain funds in sat not msat 2022-07-23 14:48:34 +02:00
docker feat: implement simple docker compose dev env 2022-03-20 19:55:52 +01:00
scripts correct file ownership after make sync 2022-06-30 12:48:58 +02:00
tests chore: format source using the pre_commit command 2022-03-20 17:20:56 +01:00
.coveragerc test: Add testing dependencies and first tests 2021-10-02 12:00:44 +02:00
.env_sample refactor: remove CLN socket impl; code cleanup 2022-06-12 08:06:55 +02:00
.gitignore feat: implement simple docker compose dev env 2022-03-20 19:55:52 +01:00
.pre-commit-config.yaml [pre-commit.ci] pre-commit autoupdate 2022-07-10 16:46:49 +02:00
.wakatime-project chore: fix wakatime EOL 2022-07-23 15:12:20 +02:00
LICENSE Create LICENSE 2021-09-23 21:03:34 +02:00
Makefile chore: dep update; update version to 0.5.0 2022-05-28 12:38:10 +02:00
poetry.lock chore: lock dependencies to latest versions 2022-07-23 15:07:32 +02:00
pyproject.toml chore: lock dependencies to latest versions 2022-07-23 15:07:32 +02:00
README.md refactor: remove CLN socket impl; code cleanup 2022-06-12 08:06:55 +02:00
requirements.txt fix: install for python 3.9 and add hash 2022-06-18 22:45:56 +01:00

blitz_api

pre-commit

Configuration

Create a .env file with your bitcoind and lnd configuration. See the .env_sample file for all configuration options.

Dependencies

Installation

⚠️ To setup a development environment for BlitzAPI skip to the Development section.

Linux / macOS

make install

or

python -m pip install -r requirements.txt

Windows

py -m pip install -r requirements.txt

Run the application

Linux / macOS

make run

or

python -m uvicorn app.main:app --reload

Windows

py -m uvicorn app.main:app --reload

Development

It is recommended to have python-poetry installed.

From within the blitz_api folder open a poetry shell via:

poetry shell

(To exit the poetry shell use: exit)

Development (RaspiBlitz Remote)

Create a file /script/sync_to_blitz.personal.sh (will be ignored by github) the SSH connection data to your RaspiBlitz.

localIP="192.168.178.61" sshPort="22" passwordA=""

Then you can run always make sync_to_blitz to copy your latest code over to your RaspiBlitz. The script automatically restarts the backend API with the new code on your RaspiBlitz and shows you the logs.

To test the backend API then call the SwaggerUI: http://[LOCALIP]/api/v1/docs - to call protected endpoints run the /system/login endpoint first with HTTP POST body:

{
  "password": "[PASSWORDA]"
}

and then copy the JWT Auth string returned to Authorize in the top section of the SwaggerUI.

You can also now test the RaspiBlitz WebUI against the API by running it locally on your dev laptop when you configure it to use the backend API of your RaspiBlitz.

Installation

poetry install
pre-commit install

or

make install_dev

If python dependencies have been changed it's necessary to freeze all requirements to requirements.txt:

poetry export -f requirements.txt --output requirements.txt

This will skip all dev dependencies by default.
This step is required to avoid having to install poetry for final deployment.

Testing

Make sure to include tests for important pieces of submitted code.

Run the tests with pytest

make test

Run tests and generate a coverage

make coverage

This will run tests and generate a coverage html file in this folder: ./htmlcov

Before you commit

This project uses pre-commit to keep the source code structured. Please make sure to run either make pre_commit or pre-commit run --all-files. The CI pipeline will reject pull requests that fail this step. This step helps to ensures that the source code is formatted consistently and pull requests are as tidy as possible.

Swagger

Once the API is running swagger docs can be found here:

http://127.0.0.1:8000/latest/docs

Useful cURL commands to test the API

curl -N http://127.0.0.1:8000/sse/subscribe
curl -N http://127.0.0.1:8000/v1/bitcoin/getblockchaininfo
curl -X POST -N http://127.0.0.1:8000/v1/setup/type/1
curl --header "Content-Type: application/json" \
  --request POST \
  --data '{"password":"12345678"}' \
  http://127.0.0.1:8000/system/login

Acknowledgements

Integrated Libraries: