Commit graph

45 commits

Author SHA1 Message Date
fusion44
bdeac676c0
feat: add SQLite database support
Preparations for creating a transaction index.

refs #30
2023-04-05 22:11: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
bd06a3cc6f
feat: improve logging by using loguru package 2022-12-18 20:55:31 +01:00
fusion44
b0226dab01
fix: crash when ln node type is an empty string
fixes #169
2022-12-01 18:51:03 +01:00
fusion44
cebbdfb0d1
fix: BOOTSTRAPPING_AFTER_UNLOCK event handling
fixes #166
2022-11-26 14:03:52 +01:00
Christoph Stenglein
2053f0ea3b
remove some unused imports, send correct message on warmup 2022-10-22 14:17:13 +02:00
fusion44
3ce6c1e549
refactor: port changes from #152 2022-10-22 11:08:54 +02:00
fusion44
fe65568f55
Revert "chore: merge changes from main"
This reverts commit e3f0350c72, reversing
changes made to a448dbda8d.
2022-10-19 21:32:47 +02:00
fusion44
e3f0350c72
chore: merge changes from main 2022-10-19 21:19:43 +02:00
fusion44
beba4332e7
fix: null access crash when no token was supplied
fixes #158
2022-10-18 19:54:14 +02:00
fusion44
4393132d1c
fix: properly check token on sse requests 2022-10-17 22:11:17 +02:00
Christoph Stenglein
32c7c4a23c
feat: allow cookie & JWT auth for sse/subscribe (#152)
* return cookie on login and check cookie in sse/subscribe

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

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

* allow cookie & JWT auth for sse/subscribe

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

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

* return token object on login to preserve compatibility

* remove unused import

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2022-10-16 21:58:23 +02:00
fusion44
ba453e7bdb
refactor: switch to domain driven directory layout 2022-10-03 20:22:00 +02:00
fusion44
e1d5e23db7
refactor: setup implementation decoupling 2022-10-03 19:04:44 +02:00
fusion44
52edecd0c9
refactor: app implementation decoupling 2022-09-10 22:14:37 +02:00
fusion44
6098c70eee
refactor: send_sse_message to broadcast_sse_msg 2022-09-10 15:52:11 +02:00
fusion44
69d8032900
refactor: sse code into dedicated SSEManager class 2022-09-10 15:48:03 +02:00
fusion44
49bdbab66d
refactor: use a Queue instead of Redis for SSE
refs #60
2022-09-10 13:53:09 +02:00
fusion44
f282e3af8d
fix: add missing imports 2022-07-25 18:07:35 +02:00
fusion44
f940551409
feat: add JWT token auth to SSE endpoint 2022-07-24 21:26:29 +02:00
/rootzoll
67a9242301
fix bitcoin-only Warumup info (#114) 2022-06-16 15:30:14 +02:00
/rootzoll
cb71b26431
fix setup block (#113) 2022-06-14 14:44:55 +02:00
fusion44
c08e604d55
feat: send warmup data as available
When neither BTC nor LN is running:
send hardware_info

When BTC is running and LN is not:
send hardware_info and btc_info

When both are running:
send the full package

This code doesn't keep track of which connection has received
which data already, so it may send data twice data to the client
when the startup state changes. Especially the hardware info
is rather data intensive. This is OK for now, to keep the code simple.

closes #110
2022-06-12 07:59:40 +02:00
fusion44
eb87b0501b
refactor: send warmup data to SSE clients
refs #97
2022-06-10 19:45:55 +02:00
fusion44
4f33bdfc79
fix: send a disabled msg when ln_node is "none"
refs #97
2022-06-08 20:39:12 +02:00
fusion44
493d8039fa
refactor: improve startup procedure
During startup the API will try to connect to Bitcoin Core and the
Lightning Node. If it can't connect it will check every "n" seconds
(currently 2s) and connect when available. A new SSE event
called "system_startup_info" is introduced. This event contains
all startup status information during the startup procedure.

The old wallet_locked event is obsolete.

Sample:
--------------------------
event: system_startup_info
data: {"bitcoin": "offline", "bitcoin_msg": "", "lightning": "offline", "lightning_msg": "Unable to connect to LND daemon, waiting..."}
--------------------------
event: system_startup_info
data: {"bitcoin": "done", "bitcoin_msg": "", "lightning": "offline", "lightning_msg": "Unable to connect to LND daemon, waiting..."}
--------------------------
event: system_startup_info
data: {"bitcoin": "done", "bitcoin_msg": "", "lightning": "locked", "lightning_msg": "Wallet locked, unlock it to enable full RPC access"}
--------------------------
event: system_startup_info
data: {"bitcoin": "done", "bitcoin_msg": "", "lightning": "done", "lightning_msg": ""}
--------------------------
event: system_startup_info
data: {"bitcoin": "done", "bitcoin_msg": "", "lightning": "bootstraping", "lightning_msg": "RPC not yet available"}
--------------------------

refs #97
2022-06-06 19:29:21 +02:00
fusion44
887d44be44
chores: remove unused health messages; Fix typos
closes remove confusing "health" message in system_info #95
2022-06-04 14:46:03 +02:00
/rootzoll
ce7f82c106
Installapps (#78)
Adding functionallity for setup & installing additional apps ... run with the latest raspiblitz dev scripts.
2022-05-05 13:27:59 +02:00
fusion44
85d2de19e4
chore: fix some naming issues 2022-03-23 21:03:50 +01:00
fusion44
b1dc854dd2
refactor: use app.utils.redis_get() everywhere 2022-03-19 12:36:03 +01:00
fusion44
9665d694b7
feat: check defer starting LN and Bitcoin handlers
This really applies only to RaspiBlitz. Depending on the current
setup step there still isn't a Bitcoin Deamon or Lightning Node running.
We must defer the registration of all those handlers until later when
everything is properly setup.

Since there is a final reboot after the setup there is no need to
check in the background whether setup is finished. The API server
is restartet anyway.

refs #71
2022-03-19 09:29:09 +01:00
Stefan Stammberger
927bffa701
fix: add fee data to SSE warmup package 2022-01-22 20:47:28 +01:00
Stefan Stammberger
20e0457a73
feat: send a wallet_locked_status SSE message
When someone connects to the SSE endpoint and the wallet is
locked a message with event name `wallet_lock_status` type is sent:
```js
// only sent when a new SSE connection is established and the wallet is
//  locked at the same time
event: wallet_lock_status
data: {"locked": true}
```
When the wallet is unlocked either through SSH or the API, another
event is sent:
```js
// sent always when a new connection is established when the wallet
// is unlocked, or it is sent when the wallet was unlocked after
// connection was established
event: wallet_lock_status
data: {"locked": false}
```

It is always the first thing the client receives. After the unlock
event, the usual warmup data is sent.

refs #34
2021-11-30 19:57:17 +01:00
Stefan Stammberger
8e32b68786
feat: listen for external unlocks via command line
refs #34
2021-11-30 17:18:42 +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
782464b61d
feat: implement handling of locked wallets
* new endpoint: /lightning/unlock-wallet
* ln endpoints return HTTP_423_LOCKED status if wallet is locked
* bootup sequence defers ln listeners setup if wallet is locked

refs #34
2021-11-24 11:12:10 +01:00
Stefan Stammberger
58af4f56d5
feat: send full LnInfo when a new client connects 2021-11-18 19:50:04 +01:00
Stefan Stammberger
6ca9b97b87
fix: problems with included external packages
* Add proper licensing information
* Move sse_starlette to the externals folder
2021-11-18 11:30:48 +01:00
Stefan Stammberger
f9aae93ce9
fix: install problem due to include from git repo
fixes #40
2021-11-18 08:31:46 +01:00
Stefan Stammberger
3f8860999b
fix: sse message composition 2021-10-27 19:23:21 +02:00
Stefan Stammberger
6ad707e3ea
fix: SSE message JSON encoding
fixes #23, #24, #25
2021-10-12 21:36:15 +02:00
Stefan Stammberger
27463dfbfe
feat: Send warmup data to new SSE clients
closes #9
2021-10-05 19:36:09 +02:00
Christoph Stenglein
2ab56ca774
only allow localhst:3000 since other ports are not needed 2021-10-04 17:36:56 +02:00
Christoph Stenglein
c7cd337bf8
add CORS headers to responses 2021-10-04 17:30:01 +02:00
Stefan Stammberger
8ce482d6a8
refactor: move main.py file into the "app" package
This is in preparation to adding testing functionalities.

Also applied some formatting and removed unused imports to main.py
2021-10-02 10:01:17 +02:00
Renamed from main.py (Browse further)