Commit Graph

158 Commits

Author SHA1 Message Date
dni ⚡
c8147bd83f
[FEAT] add extension functionality to lnbits-cli (#1963)
* [FEAT] add extension functionality to lnbits-cli

WIP

draft cli commands for vlad :)

* add extension list command

* [feat] lnbits-cli add install, uninstall and upgrade

* feat: load settings from DB

* refactor: simplify settings loading

* feat: show current version if installed

* feat: add mor emessages

* feat: basic DB install

* feat: add extension

* feat: do not install if the server is up

* feat: add logic for uninstall

* refactor: prepare for upgrade

* feat: check extension before upgrade

* refactor: stuff

* fix: have a default value

* feat: use the API logic

* feat: use pi methods for un-install

* refactor: extract _select_release

* feat: add flags

* feat: check if extension already up to date

* refactor: use `_run_async`

* feat: install all extensions

* feat: install online

* fix: api install

* fix: API upgrade & install

* feat: add API uninstall

* failed typo

* typo running

* url duplication

* [fix] provide short-options too (same as upgrade command)

Co-authored-by: Pavol Rusnak <pavol@rusnak.io>

* make black

* fix: fail if .superuser file not found; add `--admin-user` option

* fix: ambiguous use of `logger.debug`

- register_new_ext_routes must not be None
- `logger.debug` was used because it allowed any arguments, but that was a bad idea
- now an explicit empty `_do_nothing(*_)` function is used

* fix: load settings

* doc: updated `--source-repo`

* chore: rename `upgrade` to `update`

* refactor: use `@annotation` for making commands async

* fix: code checks

---------

Co-authored-by: Vlad Stan <stan.v.vlad@gmail.com>
Co-authored-by: Pavol Rusnak <pavol@rusnak.io>
2023-10-25 14:03:00 +02:00
callebtc
b2384c10cc
Refactor: Calculate invoice expiry outside of the crud (#1849)
* expiry before crud
* using Bolt11 as argument instead of payment_request
* fix missing expiry

---------

Co-authored-by: dni  <office@dnilabs.com>
2023-10-10 12:03:24 +02:00
dni ⚡
5b16f54857
[FEAT] cleanup GET /wallet endpoint, add wallet api routes (#1932)
* [FEAT] cleanup GET /wallet endpoint, add wallet api route
this removes the functionalitiy to create accounts and wallets via
the GET /wallet endpoint in generic.py

it add endpoints inside the api.py for it and the frontend is modified to use the api endpoints

this also simplifies for the `feat/login` for the route.

* remove stale generic tests and add api tests

* bug wrong endpoint create account

* vlad nitpick

* added checkif deleted is 404

* reload after renaming wallet

* another iteration with vlad

* create new wallet if it none exist

* fix delete refresh

* formatting
2023-09-25 14:06:00 +01:00
dni ⚡
1646b087cf
adding bolt11 lib and removing bolt11.py from the codebase (#1817)
* add latest bolt11 lib

decode exception handling for create_payment
fix json response for decode
bugfix hexing description hash
improvement on bolt11 lib
update to bolt11 2.0.1
fix clnrest
* bolt 2.0.4
* refactor core/crud.py

* catch bolt11 erxception clnrest
2023-09-25 12:06:54 +02:00
dni ⚡
a8082f798f
[CHORE] update dependencies, unsafe pip packages, fastapi (#1609)
* d

* middleware needs to be initialised before startup

runs on python3.11

update secp256k1

update psycopg

* update fastapi to v0.103

* fix webpush

* bump dependencies

* ruff issue

* lock versions

* bump versions

---------

Co-authored-by: jacksn <jkranawetter05@gmail.com>
2023-09-25 10:54:02 +01:00
Arc
3260acbcc7
Revert "do not show deleted wallets (#1942)" (#1947)
This reverts commit 1ee2d53069.
2023-09-18 19:41:35 +01:00
Tiago Vasconcelos
1ee2d53069
do not show deleted wallets (#1942)
* do not show deleted wallets

* rename parameter for clarity
2023-09-18 19:21:20 +01:00
jackstar12
4c16675b3b
Fix payments chart (#1851)
* feat: payment history endpoint

* test payment history

* use new endpoint in frontend

* refactor tests
2023-09-12 13:38:30 +01:00
dni ⚡
fee40d7321
[REFACTOR] core/__init__ to not have circular import issues (#1876)
* F541 fix

remove unused workflow and combine linters into one

add lnbits/static to ruff ignore
remote setupnode

ignore upgrades for mypy

ignore F401 for __init__ files

unused noqa

ignore upgrades for black

F821: undefine name

disabled and logged webhook_listener for opennode and lnpay because they are obvisouly not working

E402: module level import not at top of file

fixup

revert breaking changes wait for PR #1876

https://github.com/lnbits/lnbits/pull/1876

E721 fixes, only popped up for python3.9 not 3.10

[REFACTOR] core/__init__ to not have circular import issues

WIP

add db for backwards compat

fix pyright

make mypy happy again

pyright did not catch those, i think mypy got confused with relative imports. maybe we should use absolute ones everywhere

E402: module level import not at top of file

dont forget to add core_app

rebase on ruff pr

f

remo

format

* fix clnrest

* ignore E402 in conftest

* refactoring issues

---------

Co-authored-by: jacksn <jkranawetter05@gmail.com>
2023-09-12 11:25:05 +01:00
dni ⚡
f19d59d429
[BUG] self payments for the same wallet (#1914)
* [BUG] self payments for fakewallet

make it possible to pay to yourself on fakewallet

f

* bugfix selfpayments for fakewallet

* delete by wallet and fix previous_payment check (#1919)

---------

Co-authored-by: callebtc <93376500+callebtc@users.noreply.github.com>
2023-09-12 11:23:23 +01:00
dni ⚡
bda054415a
[FEAT] improve update_admin_settings (#1903)
* [FEAT] improve update_admin_settings

while working on the push notification pr i found it very hard just to update
2 settings inside the db, so i improved upon update_admin_settings.
now you just need to provide a dict with key/values you want to update inside db.

also debugging the endpoints for update_settings i found despite the type of `EditableSettings`
fastapi did in fact pass a dict.

* t

* use `EditableSettings` as param in update_settings

* fix settings model validation

we previously overrode the pydantic validation with our own method

* make `LnbitsSettings` a `BaseModel` and only add `BaseSettings` later

this allows us to instantiate `EditableSettings` without the environment values being loaded in

* add test

* forbid extra fields in update api

* fixup

* add test

* test datadir

* move UpdateSettings

* fix compat

* fixup webpush

---------

Co-authored-by: jacksn <jkranawetter05@gmail.com>
2023-09-12 10:59:32 +01:00
schneimi
fb98576431
[FEAT] Push notification integration into core (#1393)
* push notification integration into core

added missing component

fixed bell working on all pages
- made pubkey global template env var
- had to move `get_push_notification_pubkey` to `helpers.py` because of circular reference with `tasks.py`

formay

trying to fix mypy

added py-vapid to requirements

Trying to fix stub mypy issue

* removed key files

* webpush key pair is saved in db `webpush_settings`

* removed lnaddress extension changes

* support for multi user account subscriptions, subscriptions are stored user based

fixed syntax error

fixed syntax error

removed unused line

* fixed subscribed user storage with local storage, no get request required

* method is singular now

* cleanup unsubscribed or expired push subscriptions

fixed flake8 errors

fixed poetry errors

* updating to latest lnbits

formatting, rebase error

fix

* remove unused?

* revert

* relock

* remove

* do not create settings table use adminsettings

mypy

fix

* cleanup old code

* catch case when client tries to recreate existing webpush subscription e.g. on cleared local storage

* show notification bell on user related pages only

* use local storage with one key like array, some refactoring

* fixed crud import

* fixed too long line

* removed unused imports

* ruff

* make webpush editable

* fixed privkey encoding

* fix ruff

* fix migration

---------

Co-authored-by: schneimi <admin@schneimi.de>
Co-authored-by: schneimi <dev@schneimi.de>
Co-authored-by: dni  <office@dnilabs.com>
2023-09-11 14:48:49 +01:00
Tiago Vasconcelos
576e20d0cd
Add deleted flag wallet (#1826)
* add deleted flag on wallets

set deleted on delete wallet

2 twelves

format

fail on create invoice

make deleted check on SQL query

nazi flake8

add_test

boom... it works and passes!!

* add app fixture

vlad's recommendations

add deleted

* Add deleted flag to Wallet

* restore crud

* do not check for wallet in services.py

* add deleted flag on wallets

set deleted on delete wallet

2 twelves

format

fail on create invoice

make deleted check on SQL query

nazi flake8

add_test

boom... it works and passes!!

* add app fixture

vlad's recommendations

* add deleted

* error checks

---------

Co-authored-by: callebtc <93376500+callebtc@users.noreply.github.com>
2023-09-11 14:06:31 +01:00
jackstar12
2623e9247a
track fiat value of payments (#1789)
* save fiat_amounts on payment creation

* show fiat amount in frontend

* add lnbits_default_accounting_currency

* extract fiat calculation logic into service

* move all currency conversions to calc_fiat_amounts

move all conversion logic into create_invoice so extensions can benefit aswell

* show user-defined and wallet-defined currency in frontend

* remove sat from fiat units

* make bundle

* improve tests

* debug log
2023-08-28 11:00:59 +01:00
dni ⚡
4e6f229db2
[CHORE] string formatting default length 88 (#1887)
* [CHORE] string formatting default length 88

uses blacks default off 88 and enabled autostringformatting

* formatting

* nitpicks jackstar

fix
2023-08-24 10:26:09 +01:00
dni ⚡
2ab18544c3
[BUG] use WalletType for get_wallet_for_key fn (#1896) 2023-08-24 08:26:34 +02:00
dni ⚡
c4da1dfdce
[REFACTOR] WalletType into enum (#1888)
* [REFACTOR] WalletType into enum

- move wallettype models from decorators.py into models.py
- use enum instead of int
- use HTTPStatus for consistency

* Update lnbits/core/models.py

Co-authored-by: jackstar12 <62219658+jackstar12@users.noreply.github.com>

* use dataclass

---------

Co-authored-by: jackstar12 <62219658+jackstar12@users.noreply.github.com>
2023-08-23 12:41:22 +02:00
dni ⚡
355806608b
[CHORE] E722 bare exception fix (#1871)
* [CHORE] E722 bare exception fix
remove all bare exceptions from codebase and change it in `.flake8`
2023-08-16 12:17:54 +02:00
Arc
7e1f43933d
Adds security tools, such as a rate limiter, IP block/allow, server logs (#1606)
* added ratelimiter
* Adds server logs to admin ui
* Added IP allow/ban list
* fixed remove ips
* Split rate limit number and unit
* security tab and background tasks for killswitch
* fix test for auditor api

---------

Co-authored-by: dni  <office@dnilabs.com>
2023-06-20 11:26:33 +02:00
Tiago Vasconcelos
758a4ecaf6
Fix user label across lnbits (#1771)
* check for super user on get_user
* remove unecessary assingments
2023-06-20 08:41:57 +02:00
Vlad Stan
8c0e7725de
Add option to drop extension db at un-install time or later (#1746)
* chore: remove un-used file
* feat: allow extension DB clean-up
* feat: i18n and bundle update
* chore: code format
* fix: button color
* chore: delete temp file
* chore: fix merge conflicts
* chore: add extra log
* chore: bump CACHE_VERSION to `37`
2023-06-15 16:22:18 +02:00
Tiago Vasconcelos
eab19280d5
fix "boolean" query for sqlite (#1727)
use false
2023-05-24 12:14:21 +02:00
callebtc
e39241a9e9
Fix: get_payments crud default Filter values. (#1703)
* get_payments: deafult values for filter

* lololololoolol
2023-05-11 18:36:20 +02:00
callebtc
b6223f0e6d get_payments: deafult values for filter 2023-05-11 18:29:08 +02:00
dni ⚡
d8ccb4dcd8
fix old payments endpoint for lndhub (#1698)
* fix old payments endpoint for lndhub

* fixup tests
2023-05-10 11:47:04 +02:00
Vlad Stan
67d8b67ee5
Create super user account if it does not exist (#1688)
* fix: temp create account for `super_user_id` if missing

* chore: remove dumb import

* refactor: move logic outside `crud`

* feat: add uuid4 conversion

* fix: require valid string in .env file

* fix: update the `settings.super_user` value in case or normalisation for UUID4

* fix: allow long super_user

* chore: code format

* fix: add UI redirect with the normalized user

* fix: normalize `super_user` up one level

* fix: should normalize user in non-ui mode also
2023-05-09 09:22:19 +01:00
Vlad Stan
132d8a9320
fix: rename bool super_user to is_super_user (#1690) 2023-05-09 09:20:51 +01:00
jackstar12
c0f66989cb
Serverside Pagination for payments (#1613)
* initial backend support

* implement payments pagination on frontend

* implement search for payments api

* fix pyright issues

* sqlite support for searching

* backwards compatability

* formatting, small fixes

* small optimization

* fix sorting issue, add error handling

* GET payments test

* filter by dates, use List instead of list

* fix sqlite

* update bundle

* test old payments endpoint aswell

* refactor for easier review

* optimise test

* revert unnecessary change

---------

Co-authored-by: dni  <office@dnilabs.com>
2023-05-09 09:18:53 +01:00
Arc
91b28ebf83
Merge pull request #1612 from lnbits/fix_admin_ext_access
Fix admin ext access
2023-04-20 09:46:18 +01:00
Vlad Stan
0d14d2b56e fix: remove admin extensions for non admin users 2023-04-05 19:40:16 +03:00
dni ⚡
2a1a0f3a2f
fix pyright issues 2023-04-04 07:49:13 +02:00
dni ⚡
5dbd9a9192
add some assert description 2023-04-04 07:35:20 +02:00
Pavol Rusnak
0607cb1d6e
fix pyright lnbits/core
Co-authored-by: dni  <office@dnilabs.com>
2023-04-04 07:34:37 +02:00
calle
58c3b05e29
fix internal payment check (#1604) 2023-04-03 15:15:34 +02:00
dni ⚡
8ce84ce592
FEAT: Filters for GET requests, add it to GET /payments (#1557)
* feat filters, add them to GET payments

* add limit and offset to filters (#1563)

* add limit and offset to filters
* move filters example to parse_filters doc string

* black

* add openapi docs

* remove example commentC

* improve typing and make nested filter possible in openapi

* typo in fn name

* readd Type

---------

Co-authored-by: jackstar12 <62219658+jackstar12@users.noreply.github.com>
Co-authored-by: calle <93376500+callebtc@users.noreply.github.com>
2023-04-03 14:55:49 +02:00
dni ⚡
fe9e821af5
BUG: proper exception for already paid internal invoices (#1593)
* BUG: proper exception for paid interal invoices

* test should now fail, because we pay invoice twice, and should also work in regtest

* sorting

* unpack check_internal

* introduce another crud fn for checking internal paid payment

* rename

---------

Co-authored-by: callebtc <93376500+callebtc@users.noreply.github.com>
2023-04-03 14:44:17 +02:00
Pavol Rusnak
bc36e6bc4c
fix flake8 F541 (f-string is missing placeholders) 2023-01-30 11:46:44 +00:00
Pavol Rusnak
86e8a3a315
fix flake8 E711 (comparison-to-none) 2023-01-30 11:46:44 +00:00
Pavol Rusnak
d29fcca6aa
fix pylint W0612 (unused-variable) 2023-01-30 11:46:43 +00:00
Vlad Stan
6276a7a4db fix: icon missing after extension install 2023-01-26 12:30:42 +02:00
Vlad Stan
dd3fc7c2bb fix: merge errors 2023-01-25 09:56:05 +02:00
Vlad Stan
9cca87f738
Merge branch 'main' into extension_install_02 2023-01-25 09:50:54 +02:00
ben
c0c4c86808 Added wallet authentication to creat, get and delete tinyurls 2023-01-24 21:26:18 +00:00
ben
7322d27aa3 changed to shortuuid as suggested by Vlad 2023-01-24 20:27:20 +00:00
ben
caadeb77e2 format 2023-01-24 13:32:21 +00:00
ben
274615f0b3 Man, broken 2023-01-24 13:27:30 +00:00
ben
0d0817044c Pissy python and its tuples 2023-01-24 11:03:46 +00:00
Vlad Stan
fa5d824eea refactor: remove redundant changes 2023-01-20 15:59:44 +02:00
Vlad Stan
730017ed62 fix: import after renaming 2023-01-20 10:06:32 +02:00
Vlad Stan
5bcb8cb349 fix: deactivate on upgrade 2023-01-18 17:38:51 +02:00