From 824fa62c4dfff02ad607d8fdabe4923ef36907dc Mon Sep 17 00:00:00 2001 From: fusion44 Date: Tue, 1 Apr 2025 20:51:57 +0200 Subject: [PATCH] chore: small fixes and updates - formatting - small fix in a bitcoind model - update the fake blitz scripts - remove some dead code (app status sub) --- README.md | 2 +- app/api/config.py | 2 +- app/apps/impl/apps_base.py | 4 ---- app/apps/impl/native_python.py | 3 --- app/apps/impl/raspiblitz.py | 19 ------------------- app/bitcoind/models.py | 10 ++++------ app/server.py | 1 - .../config.scripts/bonus.albyhub.sh | 2 +- .../config.scripts/bonus.jam.sh | 2 +- .../config.scripts/bonus.lnbits.sh | 2 +- .../config.scripts/bonus.rtl.sh | 4 ++++ scripts/sync_to_blitz.sh | 2 +- 12 files changed, 14 insertions(+), 39 deletions(-) diff --git a/README.md b/README.md index 294d5ba..866accb 100644 --- a/README.md +++ b/README.md @@ -39,7 +39,7 @@ This software is still considered BETA and may contain bugs. Don't expose it to Create a `.env` file with your `bitcoind` and `lnd` configuration. See the `.env_sample` file for all configuration options. The `.env` file is expected to be at the project root folder by default. -To use a custom path, set the `BAPI_ENV_PATH` env variable to the `.env` file path. +To use a custom path, set the `BAPI_ENV_PATH` env variable to the `.env` file path. ### Dependencies diff --git a/app/api/config.py b/app/api/config.py index 9439815..fda9dfe 100644 --- a/app/api/config.py +++ b/app/api/config.py @@ -17,7 +17,7 @@ def config( option: str, default: Any | Undefined = Undefined(), cast: Any | Undefined = Undefined(), -): +) -> Any: if _config is None: _setup_config() logger.trace("Configuration was not initialized => calling setup_config()") diff --git a/app/apps/impl/apps_base.py b/app/apps/impl/apps_base.py index ac4c91c..2ca6ea5 100644 --- a/app/apps/impl/apps_base.py +++ b/app/apps/impl/apps_base.py @@ -18,10 +18,6 @@ class AppsBase: async def get_app_status_advanced(self, app_id: str) -> Result[AppStatus, Report]: raise NotImplementedError() - @abstractmethod - async def get_app_status_sub(self): - raise NotImplementedError() - @abstractmethod async def install_app_sub(self, app_id: str): raise NotImplementedError() diff --git a/app/apps/impl/native_python.py b/app/apps/impl/native_python.py index ed76c49..a5a94df 100644 --- a/app/apps/impl/native_python.py +++ b/app/apps/impl/native_python.py @@ -24,9 +24,6 @@ class NativePythonApps(AppsBase): async def get_app_status_advanced(self, app_id: str) -> Result[AppStatus, Report]: raise _NotImplemented() - async def get_app_status_sub(self): - raise _NotImplemented() - async def install_app_sub(self, app_id: str): raise _NotImplemented() diff --git a/app/apps/impl/raspiblitz.py b/app/apps/impl/raspiblitz.py index e90422a..8ee7116 100644 --- a/app/apps/impl/raspiblitz.py +++ b/app/apps/impl/raspiblitz.py @@ -250,25 +250,6 @@ class RaspiBlitzApps(AppsBase): ) ) - async def get_app_status_sub(self): - switch = True - while True: - status = "online" if switch else "offline" - app_list = [ - # Specter is deactivated for now because it uses its own self signed - # HTTPS cert that makes trouble in Chrome on last test - # also see: app/constants.py where specter is deactivated - # {"id": "specter", "name": "Specter Desktop", "status": status}, - {"id": "sphinx", "name": "Sphinx Chat", "status": status}, - {"id": "btc-pay", "name": "BTCPay Server", "status": status}, - {"id": "rtl", "name": "Ride the Lightning", "status": status}, - {"id": "bos", "name": "Balance of Satoshis", "status": status}, - ] - i = random.randint(1, len(app_list)) - yield json.dumps(app_list[i - 1]) - await asyncio.sleep(4) - switch = not switch - async def install_app_sub(self, app_id: str): if app_id not in available_app_ids: raise HTTPException( diff --git a/app/bitcoind/models.py b/app/bitcoind/models.py index 90a0e67..d3e7f68 100644 --- a/app/bitcoind/models.py +++ b/app/bitcoind/models.py @@ -5,8 +5,6 @@ from typing import List, Optional, Union from fastapi import Query from pydantic.main import BaseModel -from loguru import logger - class FeeEstimationMode(str, Enum): CONSERVATIVE = "conservative" @@ -157,7 +155,7 @@ class NetworkInfo(BaseModel): local_addresses: List[BtcLocalAddress] = Query( [], description="List of local addresses" ) - warnings: List[str] = Query(None, description="Any network and blockchain warnings") + warnings: str = Query("", description="Any network and blockchain warnings") @classmethod def from_rpc(cls, r): @@ -177,7 +175,7 @@ class NetworkInfo(BaseModel): relay_fee=r["relayfee"], incremental_fee=r["incrementalfee"], local_addresses=[BtcLocalAddress.from_rpc(n) for n in r["localaddresses"]], - warnings=r["warnings"], + warnings="" if "warnings" not in r else str(r["warnings"]), ) @@ -371,7 +369,7 @@ class BlockchainInfo(BaseModel): "enabled)" ), ) - warnings: List[str] = Query(..., description="Any network and blockchain warnings") + warnings: str = Query("", description="Any network and blockchain warnings") softforks: List[SoftFork] = Query(..., description="Status of softforks") @classmethod @@ -401,7 +399,7 @@ class BlockchainInfo(BaseModel): prune_target_size=( None if "prune_target_size" not in r else int(r["prune_target_size"]) ), - warnings=r["warnings"], + warnings="" if "warnings" not in r else str(r["warnings"]), softforks=softforks, ) diff --git a/app/server.py b/app/server.py index cb09f53..6f5f109 100644 --- a/app/server.py +++ b/app/server.py @@ -5,7 +5,6 @@ from app.api.config import config import click # isort:skip - @click.command() @click.option("--port", default="5000", help="Port to run Blitz API on") @click.option("--host", default="127.0.0.1", help="Host to run Blitz API on") diff --git a/scripts/fake_blitz_scripts/config.scripts/bonus.albyhub.sh b/scripts/fake_blitz_scripts/config.scripts/bonus.albyhub.sh index d94c56a..ca62b49 100755 --- a/scripts/fake_blitz_scripts/config.scripts/bonus.albyhub.sh +++ b/scripts/fake_blitz_scripts/config.scripts/bonus.albyhub.sh @@ -8,7 +8,7 @@ if [ "$1" = "status" ]; then sleep 2s echo "appID='albyhub'" echo "version='${VERSION}'" - echo "installed=1" + echo "installed=0" echo "localIP='192.168.1.18'" echo "toraddress='toraddress'" echo "fingerprint='fingerprint'" diff --git a/scripts/fake_blitz_scripts/config.scripts/bonus.jam.sh b/scripts/fake_blitz_scripts/config.scripts/bonus.jam.sh index 210f1ab..cb4d2f2 100755 --- a/scripts/fake_blitz_scripts/config.scripts/bonus.jam.sh +++ b/scripts/fake_blitz_scripts/config.scripts/bonus.jam.sh @@ -8,7 +8,7 @@ REPO=joinmarket-webui/jam if [ "$1" = "status" ]; then sleep 2s echo "version='${WEBUI_VERSION}'" - echo "installed='1'" + echo "installed='0'" echo "localIP='192.168.1.18'" echo "httpPort='7500'" echo "httpsPort='7501'" diff --git a/scripts/fake_blitz_scripts/config.scripts/bonus.lnbits.sh b/scripts/fake_blitz_scripts/config.scripts/bonus.lnbits.sh index 508850b..58ff44e 100644 --- a/scripts/fake_blitz_scripts/config.scripts/bonus.lnbits.sh +++ b/scripts/fake_blitz_scripts/config.scripts/bonus.lnbits.sh @@ -8,7 +8,7 @@ VERSION="${tag}" if [ "$1" = "status" ]; then sleep 2s echo "version='${VERSION}'" - echo "installed=1" + echo "installed=0" echo "localIP='192.168.1.18'" echo "httpPort='5000'" echo "httpsPort='5001'" diff --git a/scripts/fake_blitz_scripts/config.scripts/bonus.rtl.sh b/scripts/fake_blitz_scripts/config.scripts/bonus.rtl.sh index cf6d3aa..35d892b 100755 --- a/scripts/fake_blitz_scripts/config.scripts/bonus.rtl.sh +++ b/scripts/fake_blitz_scripts/config.scripts/bonus.rtl.sh @@ -4,6 +4,10 @@ RTLVERSION="v0.15.2" if [ "$1" = "status" ]; then + sleep 2s + # raise a fake error + echo "result='FAKE ERROR FOR TESTING'" >&2 + exit 1 # get LNTYPE and CHAIN parameters LNTYPE="$2" # lnd or cl diff --git a/scripts/sync_to_blitz.sh b/scripts/sync_to_blitz.sh index 9ea22c7..21999bb 100644 --- a/scripts/sync_to_blitz.sh +++ b/scripts/sync_to_blitz.sh @@ -72,7 +72,7 @@ fi # Needs sshpass installed echo "# syncing local code to: ${remote}" -sshpass -p "$passwordA" rsync -rvz --exclude .git/ -e "ssh -p ${sshPort}" $local $remote +sshpass -p "$passwordA" rsync -rvz --exclude .venv/ --exclude test_env_data/ --exclude .git/ -e "ssh -p ${sshPort}" $local $remote result=$? echo "result(${result})" if [ "$result" != "0" ]; then