Commit graph

20 commits

Author SHA1 Message Date
fusion44
a921686b4a
fix(lightning): clear error for undecodable/wrong-network invoices
Decoding a malformed or wrong-network invoice (e.g. a regtest lnbcrt...
invoice on a mainnet node) made each backend fail with a cryptic,
leaked error: LND with the Go 'strconv.ParseUint: parsing "rt500":
invalid syntax' surfaced as a 500, and CLN with 'Invalid bolt11: ...'.

Add a shared helper raise_for_pay_req_decode_error() in lightning/utils
that recognizes the decode-failure signatures of both backends and
raises one clear 400 pointing at the likely cause (malformed or wrong
network). Wire LND (lnd_grpc), CLN gRPC and CLN JSON-RPC through it so
they behave identically; genuine backend errors still return 500.

Fixes #225

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
8646d966dc
fix(lnd): return a retryable status while the RPC server starts up
While LND is up but its RPC server is 'in the process of starting up, but
not yet ready to accept calls', every LND method returned a bare 500 -
the caller (e.g. the WebUI polling list-all-tx) got a generic server
error with no useful signal.

_check_if_locked only mapped the 'wallet locked' case; generalize it to
_check_transient_ln_error and also map the startup message to
425 TOO_EARLY (matching how bitcoind warmup is reported), with a clear
'try again shortly' detail. This covers all LND methods that share the
same error-handling path.

Fixes #247

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-11 10:02:20 +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
e564d18d2b
chore: clean up imports; add better LND error logging 2026-02-03 11:05:19 +01: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
b08e53b599
fix(lnd): catch when pay requests can't be decoded
refs #247
2024-03-10 21:16:26 +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
adf472ac8b feat: implement Ruff as a linter; fix given errors 2023-06-25 07:17:00 +02:00
fusion44
e290de8933
feat: proper error handling resolving peer aliases
Implementations sometimes don't find aliases in the gossip, even if
they are openeing a channel to the pubkey. In this case an empty
string will be returned and the problem logged in debug mode.

refs #199
2023-05-01 20:48:10 +02:00
fusion44
71ad84e704
feat: improve logging and error handling 2023-04-21 22:58:29 +02:00
fusion44
eca87a5019
feat: improve logging for lnd and cln grpc 2023-04-03 20:17:48 +02:00
fusion44
b3262c5a38
fix: increase gRPC max receive message size
refs #125
2023-04-03 18:49:48 +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
2435b1c57f
feat: improve logging and remove print statements 2022-12-18 20:55:48 +01:00
fusion44
86442dde89
feat: implement send all onchain funds flag
refs #139
2022-11-28 19:07:25 +01:00
fusion44
a448dbda8d
fix: more import path fixes 2022-10-09 20:16:49 +02:00
fusion44
4908f99999
fix: import problems and typos 2022-10-04 19:23:09 +02:00
fusion44
ba453e7bdb
refactor: switch to domain driven directory layout 2022-10-03 20:22:00 +02:00
Renamed from app/repositories/ln_impl/lnd_grpc.py (Browse further)