Commit graph

27 commits

Author SHA1 Message Date
fusion44
71e7cb5632
feat(api): add gated build_error_response for consistent errors
Introduces the flat ErrorMessage envelope builder with BAPI_SEND_REPORT /
BAPI_SEND_TRACE gating (report/trace off by default), plus the design
spec and implementation plan for the consistent-error-responses work.

Fixes #148
Fixes #123

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-12 18:41:18 +02:00
fusion44
dccaa17a8e
fix(auth): correct JWT expiry unit and use standard exp claim
sign_jwt added JWT_EXPIRY_TIME (seconds) to a milliseconds epoch and
stored it in a custom 'expires' claim, while register_cookie_updater
slept JWT_EXPIRY_TIME as seconds. With the code default (300) tokens
effectively expired almost immediately; with the sampled 3600000 the
cookie-refresh loop slept ~41 days, so the local .cookie held an
expired token nearly always. The custom claim also meant PyJWT never
validated expiry itself.

- issue standard 'iat'/'exp' claims (seconds) and let PyJWT validate,
  requiring 'exp' on decode
- derive the cookie refresh interval from the same unit, guarded
  against tiny/negative values
- default BAPI_JWT_EXPIRY_TIME to 3600s and fix .env_sample (was
  3600000 'milliseconds')

Existing tokens and the local .cookie are invalidated by this change;
clients re-login and the cookie regenerates at startup.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-03 20:35:34 +02:00
fusion44
4e038e8fc7 feat: fetch app status via a celery task
This is a feature that allows to fetch the app status via a celery
task which stores the result in the Redis database and notifies the API
of the change. The API sends a notification to connected clients via the
SSE mechanism.

Using a background task allows to avoid crashing the whole API if the
script call fails.

The by default the cache is refreshed every 30 minutes. This can be
changed by setting the `BAPI_APP_STATUS_UPDATE_INTERVAL_MIN` environment
variable.

refs #123
2025-05-06 09:16:46 +02:00
fusion44
25e4be8441 feat: make config loading more flexible
If the environment variable BAPI_ENV_PATH is set, the config system will
try to read configs from the given path instead of .env in pwd

If no file is found .env in pwd will be used as a fallback

Env variables will always override settings in .env files.
2025-03-23 17:43:39 +01:00
fusion44
d0d1380eea
feat: implement remote debugging on a remote machine (#207)
closes #206 

* feat: implement remote debugging on a RaspiBlitz
* docs: reverse the prep steps
* fix: ruff line length warning
2023-06-25 08:01:43 +02:00
fusion44
94179cc5da
feat: add CLN JSON-RPC implementation 2023-03-26 20:53:50 +02:00
fusion44
0fe94da897
feat: prepare for release 0.5.1beta 2023-02-05 21:24:31 +01:00
fusion44
bd06a3cc6f
feat: improve logging by using loguru package 2022-12-18 20:55:31 +01:00
fusion44
3865d89fd5
feat: configure node acces via file paths
closes #146
2022-09-10 07:43:16 +02:00
fusion44
268bcf5072 feat: add support for bitcoin regtest 2022-08-18 20:13:50 +02:00
fusion44
2f5ce09b56
refactor: remove CLN socket impl; code cleanup
This implementation isn't used and was very inefficient due to
py-lightning not supporting asyncio.

Some minor fixes and code formatting
2022-06-12 08:06:55 +02:00
/rootzoll
2962b522b7
Fix Update Setup (#107)
* #104 fix default value
* handle update state on setup
2022-06-06 15:36:30 +02:00
Christoph Stenglein
80282c318f
add correct expiry time definition and set to 60m (#104) 2022-06-06 09:42:52 +02:00
fusion44
762b79fde2
refactor: make running without LN explicit in .env 2022-06-04 14:16:19 +02:00
fusion44
de9a96e621
feat: implement Core Lightning gRPC backend (#98)
Some remaining issues with current implementation:

Some remaining issues with current implementation:

* Some calls require shell access to lightning-cli as some gRPC calls are not yet implemented
* Getting on-chain fund flows is not as nice as it is with LND and required access to the Core Lightning SQlite database
* With current API you can only get current outputs
* High probability of bugs arising

closes #45
2022-06-04 14:10:44 +02:00
fusion44
7d452be179
feat: implement "rawblock" zmq sub as a fallback
Lightning Polar only exposes "rawblock" and not "hashblock
=> make it configurable which one to use
2022-04-05 16:40:18 +02:00
fusion44
516550bd9f
chore: format source using the pre_commit command 2022-03-20 17:20:56 +01:00
Stefan Stammberger
233a41eb96
feat: implement forward success SSE notifications
refs #64
2022-01-15 14:27:08 +01:00
Stefan Stammberger
4157058a54
feat: implement get-system-info backends
Raspiblitz and native-python implementations should work.
Only feature still missing is system health related stuff.

refs #47
2021-12-25 16:53:42 +01:00
Stefan Stammberger
228ae2100a
feat: set raspiblitz as default platform
Rationale: No need to change RaspiBlitz install scripts
2021-12-18 13:27:47 +01:00
Stefan Stammberger
ab0a8f2575
feat: fetch hardware data via Redis
To keep Blitz API platform independent two code paths have been
implemented. A new "platform" .env variable must be set if running
on a raspiblitz to fetch hardware data from Redis. See the comments
in .env_sample for further explanation.
2021-12-15 21:11:46 +01:00
Stefan Stammberger
71f87e06d7
feat: implement local cookie authentication
This is only useful for application running directly on the Raspiblitz.
This will create a file in ~/.blitz_api/.cookie with a valid JWT token.
Local applications can use this to authenticate to the API without
having to ask for the password. This is similar to how Bitcoin Cores
cookie auth works.
2021-11-28 08:42:52 +01:00
Stefan Stammberger
43783549d1
feat: implement get a raw system logs endpoint
Not tested yet on a real Raspiblitz!

refs #18
2021-09-20 11:22:50 +02:00
Stefan Stammberger
2b03882907
refactor: rename "password_a" to "password" 2021-08-17 18:53:53 +02:00
Stefan Stammberger
7ecf29cef0
feat: enhancements to /system/login
* password_a must now be posted in the request body as a json object
* password is now read from the .env file instead of hardcoded
* password will be checked if it is min 8 chars
* one_time_password is not yet in use and optional
2021-08-17 18:34:05 +02:00
Stefan Stammberger
d4de6af895
fix: update .env_sample file with ln info interval 2021-08-02 21:02:55 +02:00
Stefan Stammberger
c33351d968
refactor: move some config vars to the .env file 2021-07-25 17:24:33 +02:00
Renamed from .env (Browse further)