Commit graph

17 commits

Author SHA1 Message Date
fusion44
340d862102
chore(api): remove SSE transport and unused SSE stream endpoints
Replaced by the /ws WebSocket channel. Deletes the SSE connection manager,
the vendored sse_starlette, and the unused /bitcoin/block-sub and
/system/hardware-info-sub streaming endpoints. Also removes the
test_block_sub_error.py regression test, which exclusively covered the
now-deleted handle_block_sub per-request generator (handle_block_sub_redis,
which broadcasts over /ws, is retained and unaffected).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-12 18:41:18 +02:00
fusion44
a98e9372b0
refactor(api): Event enum + broadcast_msg over WebSocket
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-12 18:41:18 +02:00
fusion44
6444769dc4
fix(bitcoind): guard block-sub handlers against errored RPC replies
Same #277 root cause in the block-subscription path: Bitcoin Core 28+
uses strict JSON-RPC 2.0, so an errored getblock/getbestblockhash reply
has no 'result' key. handle_block_sub and handle_block_sub_redis accessed
r['result'] unguarded, so a transient RPC error would raise
KeyError: 'result' and kill the block stream / block-update task.

Skip and log the block when the reply has no result instead of crashing.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-08 14:33:59 +02:00
fusion44
3980ce0c6b
fix(bitcoind): handle JSON-RPC errors returned with HTTP 200
Bitcoin Core returns the -28 warmup error ('Loading block index',
'Verifying blocks', 'Starting network threads') as an HTTP 200 response
with a JSON-RPC error body. _process_response only classified errors on
the non-200 path and passed a 200 body through unchanged, so the result
had an 'error' key but no 'status' key. Callers doing
'raise HTTPException(result["status"], ...)' then crashed with
KeyError: 'status' instead of HTTPException(425), so the startup
warmup-retry loop in initialize_bitcoin_repo never engaged and the API
(and login) failed while bitcoind was still warming up.

Same root cause, different -28 warmup message.

Fixes #287
Fixes #285

Normalize any JSON-RPC error to an {error, status} dict regardless of the
HTTP status, mapping the warmup messages to 425 TOO_EARLY as before.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-08 13:30:04 +02:00
fusion44
868457ffa5
fix(api): replace deprecated asyncio.get_event_loop()
get_event_loop() is deprecated on Python 3.11+ when there is no running
loop and is slated to change behaviour further.

- SSEManager.setup() ran at import time (app.api.utils) via
  get_event_loop(); this only worked because uvicorn imports the app
  inside its loop and would break when imported without a running loop
  (e.g. a Celery worker). Start the broadcast consumer lazily from
  within a running loop instead.
- everywhere else the pattern was get_event_loop().create_task(x)
  inside a coroutine; replace with asyncio.create_task(x).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-03 22:34:44 +02:00
fusion44
824fa62c4d chore: small fixes and updates
- formatting
- small fix in a bitcoind model
- update the fake blitz scripts
- remove some dead code (app status sub)
2025-05-06 09:16:46 +02:00
fusion44
751687e60b chore: run ruff format and isort 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
62d3f3da9b
fix: code changes for pydantic 2.4 2024-03-10 07:57:38 +01:00
fusion44
b7e9ae29fb
fix: adapt code to recent dependeny upgrades 2024-02-24 15:30:32 +01:00
fusion44
67b72dc755
feat: improve get-raw-tx endpoint error handling 2024-02-24 07:59:44 +01:00
pre-commit-ci[bot]
9bd14d161a
[pre-commit.ci] pre-commit autoupdate (#240)
* [pre-commit.ci] pre-commit autoupdate

updates:
- [github.com/psf/black: 23.12.1 → 24.2.0](https://github.com/psf/black/compare/23.12.1...24.2.0)
- [github.com/astral-sh/ruff-pre-commit: v0.1.14 → v0.2.1](https://github.com/astral-sh/ruff-pre-commit/compare/v0.1.14...v0.2.1)

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2024-02-18 12:11:15 +01:00
fusion44
adf472ac8b feat: implement Ruff as a linter; fix given errors 2023-06-25 07:17:00 +02:00
fusion44
71ad84e704
feat: improve logging and error handling 2023-04-21 22:58:29 +02:00
pre-commit-ci[bot]
3d1dfd919c
[pre-commit.ci] pre-commit autoupdate (#187)
* [pre-commit.ci] pre-commit autoupdate

updates:
- [github.com/psf/black: 22.12.0 → 23.1.0](https://github.com/psf/black/compare/22.12.0...23.1.0)

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2023-02-11 13:47:34 +01:00
fusion44
d9ea422e91
feat: get raw transaction data from bitcoin core 2022-11-01 20:46:08 +01:00
fusion44
ba453e7bdb
refactor: switch to domain driven directory layout 2022-10-03 20:22:00 +02:00