diff --git a/.dockerignore b/.dockerignore index 005f64cc..edbbf189 100644 --- a/.dockerignore +++ b/.dockerignore @@ -4,7 +4,6 @@ docker docs tests venv -tools lnbits/static/css/* lnbits/static/bundle.js diff --git a/.env.example b/.env.example index 11ae45d8..26358af4 100644 --- a/.env.example +++ b/.env.example @@ -66,6 +66,9 @@ LNBITS_BACKEND_WALLET_CLASS=VoidWallet # VoidWallet is just a fallback that works without any actual Lightning capabilities, # just so you can see the UI before dealing with this file. +# Invoice expiry for LND, CLN, Eclair, LNbits funding sources +LIGHTNING_INVOICE_EXPIRY=600 + # Set one of these blocks depending on the wallet kind you chose above: # ClicheWallet diff --git a/.github/workflows/regtest.yml b/.github/workflows/regtest.yml index 57b7e1f4..eb2630db 100644 --- a/.github/workflows/regtest.yml +++ b/.github/workflows/regtest.yml @@ -134,6 +134,49 @@ jobs: uses: codecov/codecov-action@v3 with: file: ./coverage.xml + LNbitsWallet: + runs-on: ubuntu-latest + strategy: + matrix: + python-version: ["3.9"] + poetry-version: ["1.3.1"] + steps: + - uses: actions/checkout@v2 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python-version }} + - name: Set up Poetry ${{ matrix.poetry-version }} + uses: abatilo/actions-poetry@v2 + with: + poetry-version: ${{ matrix.poetry-version }} + - name: Setup Regtest + run: | + docker build -t lnbitsdocker/lnbits-legend . + git clone https://github.com/lnbits/legend-regtest-enviroment.git docker + cd docker + chmod +x ./tests + ./tests + sudo chmod -R a+rwx . + docker exec lnbits-legend-lnbits-1 /bin/bash -c "poetry run python tools/create_fake_admin.py" + - name: Install dependencies + run: | + poetry install + - name: Run tests + env: + PYTHONUNBUFFERED: 1 + PORT: 5123 + LNBITS_DATA_FOLDER: ./data + LNBITS_BACKEND_WALLET_CLASS: LNbitsWallet + LNBITS_ENDPOINT: http://localhost:5001 + LNBITS_KEY: "d08a3313322a4514af75d488bcc27eee" + run: | + sudo chmod -R a+rwx . && rm -rf ./data && mkdir -p ./data + make test-real-wallet + - name: Upload coverage to Codecov + uses: codecov/codecov-action@v3 + with: + file: ./coverage.xml EclairWallet: runs-on: ubuntu-latest strategy: @@ -176,4 +219,4 @@ jobs: - name: Upload coverage to Codecov uses: codecov/codecov-action@v3 with: - file: ./coverage.xml + file: ./coverage.xml \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index cc3a14bd..a7a3be9f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -13,7 +13,7 @@ RUN mkdir -p lnbits/data COPY . . RUN poetry config virtualenvs.create false -RUN poetry install --only main --no-root +RUN poetry install --only main RUN poetry run python build.py ENV LNBITS_PORT="5000" diff --git a/docs/guide/installation.md b/docs/guide/installation.md index 52ce6420..43e7e388 100644 --- a/docs/guide/installation.md +++ b/docs/guide/installation.md @@ -26,8 +26,8 @@ sudo apt install python3.9 python3.9-distutils curl -sSL https://install.python-poetry.org | python3 - # Once the above poetry install is completed, use the installation path printed to terminal and replace in the following command -export PATH="/home/user/.local/bin:$PATH" -# Next command, you can exchange with python3.10 or newer versions. +export PATH="/home/user/.local/bin:$PATH" +# Next command, you can exchange with python3.10 or newer versions. # Identify your version with python3 --version and specify in the next line # command is only needed when your default python is not ^3.9 or ^3.10 poetry env use python3.9 @@ -36,7 +36,7 @@ poetry install --only main mkdir data cp .env.example .env # set funding source amongst other options -nano .env +nano .env ``` #### Running the server @@ -45,7 +45,7 @@ nano .env poetry run lnbits # To change port/host pass 'poetry run lnbits --port 9000 --host 0.0.0.0' # adding --debug in the start-up command above to help your troubleshooting and generate a more verbose output -# Note that you have to add the line DEBUG=true in your .env file, too. +# Note that you have to add the line DEBUG=true in your .env file, too. ``` #### Updating the server @@ -58,7 +58,7 @@ poetry install --only main # Start LNbits with `poetry run lnbits` ``` -## Option 2: Nix +## Option 2: Nix > note: currently not supported while we make some architectural changes on the path to leave beta @@ -105,22 +105,30 @@ If you want to host LNbits on the internet, run with the option `--host 0.0.0.0` ## Option 4: Docker +use latest version from docker hub +```sh +docker pull lnbitsdocker/lnbits-legend +wget https://raw.githubusercontent.com/lnbits/lnbits/main/.env.example -O .env +mkdir data +docker run --detach --publish 5000:5000 --name lnbits --volume ${PWD}/.env:/app/.env --volume ${PWD}/data/:/app/data lnbitsdocker/lnbits-legend +``` +build the image yourself ```sh git clone https://github.com/lnbits/lnbits.git cd lnbits -docker build -t lnbits . +docker build -t lnbitsdocker/lnbits-legend . cp .env.example .env mkdir data -docker run --detach --publish 5000:5000 --name lnbits-legend --volume ${PWD}/.env:/app/.env --volume ${PWD}/data/:/app/data lnbits-legend +docker run --detach --publish 5000:5000 --name lnbits --volume ${PWD}/.env:/app/.env --volume ${PWD}/data/:/app/data lnbitsdocker/lnbits-legend ``` ## Option 5: Fly.io Fly.io is a docker container hosting platform that has a generous free tier. You can host LNbits for free on Fly.io for personal use. -First, sign up for an account at [Fly.io](https://fly.io) (no credit card required). +First, sign up for an account at [Fly.io](https://fly.io) (no credit card required). -Then, install the Fly.io CLI onto your device [here](https://fly.io/docs/getting-started/installing-flyctl/). +Then, install the Fly.io CLI onto your device [here](https://fly.io/docs/getting-started/installing-flyctl/). After install is complete, the command will output a command you should copy/paste/run to get `fly` into your `$PATH`. Something like: @@ -145,7 +153,7 @@ fly launch You'll be prompted to enter an app name, region, postgres (choose no), deploy now (choose no). -You'll now find a file in the directory called `fly.toml`. Open that file and modify/add the following settings. +You'll now find a file in the directory called `fly.toml`. Open that file and modify/add the following settings. Note: Be sure to replace `${PUT_YOUR_LNBITS_ENV_VARS_HERE}` with all relevant environment variables in `.env` or `.env.example`. Environment variable strings should be quoted here, so if in `.env` you have `LNBITS_ENDPOINT=https://legend.lnbits.com` in `fly.toml` you should have `LNBITS_ENDPOINT="https://legend.lnbits.com"`. @@ -169,7 +177,7 @@ kill_timeout = 30 LNBITS_FORCE_HTTPS=true FORWARDED_ALLOW_IPS="*" LNBITS_DATA_FOLDER="/data" - + ${PUT_YOUR_LNBITS_ENV_VARS_HERE} ... diff --git a/lnbits/core/services.py b/lnbits/core/services.py index d7c6f5f3..17d43644 100644 --- a/lnbits/core/services.py +++ b/lnbits/core/services.py @@ -65,6 +65,7 @@ async def create_invoice( memo: str, description_hash: Optional[bytes] = None, unhashed_description: Optional[bytes] = None, + expiry: Optional[int] = None, extra: Optional[Dict] = None, webhook: Optional[str] = None, internal: Optional[bool] = False, @@ -80,6 +81,7 @@ async def create_invoice( memo=invoice_memo, description_hash=description_hash, unhashed_description=unhashed_description, + expiry=expiry or settings.lightning_invoice_expiry, ) if not ok: raise InvoiceFailure(error_message or "unexpected backend error.") diff --git a/lnbits/core/templates/admin/_tab_funding.html b/lnbits/core/templates/admin/_tab_funding.html index 3887e151..35349e38 100644 --- a/lnbits/core/templates/admin/_tab_funding.html +++ b/lnbits/core/templates/admin/_tab_funding.html @@ -16,7 +16,7 @@
Active Funding (Requires server restart)
@@ -30,28 +30,40 @@Fee reserve
-Invoice Expiry
+Fee reserve
+TopUp a wallet
+