chores: remove unused health messages; Fix typos

closes remove confusing "health" message in system_info #95
This commit is contained in:
fusion44 2022-06-04 14:46:03 +02:00
parent 762b79fde2
commit 887d44be44
No known key found for this signature in database
GPG key ID: 645FA807E935D9D5
16 changed files with 41 additions and 119 deletions

View file

@ -177,13 +177,13 @@ register_handlers_finished = False
async def check_defer_register_handlers():
"""
Special case for RaspiBlitz: Depending on the current setup step
there still isn't a Bitcoin Deamon or Lightning Node running.
there still isn't a Bitcoin Daemon 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.
is restarted anyway.
"""
platform = APIPlatform.get_current()
@ -198,7 +198,7 @@ async def check_defer_register_handlers():
await register_all_handlers(redis_plugin.redis)
else:
logging.warning(
f"Setup not finished. Defering handler startup. Current phase: '{setup_phase}'"
f"Setup not finished. Deferring handler startup. Current phase: '{setup_phase}'"
)

View file

@ -22,7 +22,9 @@ class BlockRpcFunc(str, Enum):
elif func == "rawblock":
return cls.RAWBLOCK
else:
raise ArgumentError("Function name must either be 'hasblock' or 'rawblock'")
raise ArgumentError(
"Function name must either be 'hashblock' or 'rawblock'"
)
class BtcNetwork(BaseModel):

View file

@ -17,54 +17,6 @@ class LoginInput(BaseModel):
] = None
class HealthMessagePriority(str, Enum):
INFO = "info" # FYI, can normally be ignored.
WARNING = (
"warning" # Potential problem might occur, user interaction possibly required.
)
ERROR = "error" # Something bad happened. User interaction deinitely required.
class HealthMessage(BaseModel):
id: int = Query(
None,
description="""ID of the message.
Idea behind the ID is that messages can be replacable on the client.
To prevent spamming the user with multiple messages, message with ID 25 will be replaced with never data of ID 25
""",
example="""
```{
id: 25,
level: "warning",
message: "HDD is 89.3% full"
}```
""",
)
level: HealthMessagePriority = Query(
HealthMessagePriority.INFO,
description="""Priority level of the message. For more info see `message`.
`INFO`: FYI, can normally be ignored.\n
`WARNING`: Potential problem might occur, user interaction possibly required.\n
`ERROR`: Something bad happened. User interaction definitely required.
If there are multiple messages with different priorities, the most severe level will be shown.
""",
)
message: str = Query(..., description="Detailed message description")
class HealthState(str, Enum):
# All systems work nominally
GOOD = "good"
# Some event requires users attention (Software update, HDD nearly full)
ATTENTION_REQUIRED = "attention_required"
# An error happened which prevents the node from working properly
# (Hardware failure, DB corruption, Internet connection not available, ...)
STOPPED = "stopped"
class APIPlatform(str, Enum):
RASPIBLITZ = "raspiblitz"
NATIVE_PYTHON = "native_python"
@ -97,12 +49,6 @@ class SystemInfo(BaseModel):
api_version: str = Query(
..., description="Version of the API software on this system."
)
health: HealthState = Query(
..., description="General health state of the Raspiblitz"
)
health_messages: List[HealthMessage] = Query(
[], description="List of all messages regarding node health."
)
tor_web_ui: str = Query("", description="WebUI TOR address")
tor_api: str = Query("", description="API TOR address")
lan_web_ui: str = Query("", description="WebUI LAN address")

View file

@ -114,7 +114,7 @@ async def get_app_status_sub():
while True:
status = "online" if switch else "offline"
app_list = [
# Specter is deactivated for now because it uses its own selfsigned HTTPS cert that makes trouble in chome on last test
# 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},
@ -168,7 +168,7 @@ async def uninstall_app_sub(app_id: str, delete_data: bool):
async def run_bonus_script(app_id: str, params: str):
# to satisfy CodeQL: test again against pedefined array and dont use 'user value'
# to satisfy CodeQL: test again against predefined array and don't use 'user value'
tested_app_id = ""
for id in available_app_ids:
if id == app_id:
@ -201,7 +201,7 @@ async def run_bonus_script(app_id: str, params: str):
logFileName = f"/var/cache/raspiblitz/temp/install.{app_id}.log"
logging.info(f"WRITING LONG FILE: {logFileName}")
with open(logFileName, "w", encoding="utf-8") as f:
f.write(f"API triggred script: {cmd}\n")
f.write(f"API triggered script: {cmd}\n")
f.write(f"###### STDOUT #######\n")
if stdout:
f.write(stdout.decode())

View file

@ -46,7 +46,7 @@ async def estimate_fee(
status.HTTP_500_INTERNAL_SERVER_ERROR, detail=errors[0 : len(errors) - 1]
)
# returned in BTC by Bitcoincoin Core => convert to msat
# returned in BTC by Bitcoin Core => convert to msat
rate_btc = result["result"]["feerate"]
return rate_btc * 100000000

View file

@ -57,9 +57,9 @@ async def get_wallet_balance():
async def list_all_tx(
successfull_only: bool, index_offset: int, max_tx: int, reversed: bool
successful_only: bool, index_offset: int, max_tx: int, reversed: bool
) -> List[GenericTx]:
return await ln.list_all_tx_impl(successfull_only, index_offset, max_tx, reversed)
return await ln.list_all_tx_impl(successful_only, index_offset, max_tx, reversed)
async def list_invoices(
@ -189,10 +189,10 @@ async def register_lightning_listener():
"""
Unable to connect to LND. Possible reasons:
* Node is not reachable (ports, network down, ...)
* Maccaroon is not correct
* Macaroon is not correct
* IP is not included in LND tls certificate
Add tlsextraip=192.168.1.xxx to lnd.conf and restart LND.
This will recreate the TLS certificate. The .env must be adpted accordingly.
This will recreate the TLS certificate. The .env must be adapted accordingly.
* TLS certificate is wrong. (settings changed, ...)
To Debug gRPC problems uncomment the following line in app.utils.LightningConfig._init():

View file

@ -121,7 +121,7 @@ memo_cache = {}
async def list_all_tx_impl(
successfull_only: bool, index_offset: int, max_tx: int, reversed: bool
successful_only: bool, index_offset: int, max_tx: int, reversed: bool
) -> List[GenericTx]:
list_invoice_req = ln.ListinvoicesRequest()
list_payments_req = ln.ListpaysRequest()
@ -138,14 +138,14 @@ async def list_all_tx_impl(
tx = []
for invoice in res[0].invoices:
i = GenericTx.from_cln_grpc_invoice(invoice)
if successfull_only and i.status == TxStatus.SUCCEEDED:
if successful_only and i.status == TxStatus.SUCCEEDED:
tx.append(i)
continue
tx.append(i)
for transaction in res[1]:
t = GenericTx.from_cln_grpc_onchain_tx(transaction, res[3].block_height)
if successfull_only and t.status == TxStatus.SUCCEEDED:
if successful_only and t.status == TxStatus.SUCCEEDED:
tx.append(t)
continue
@ -162,7 +162,7 @@ async def list_all_tx_impl(
memo_cache[pay.bolt11] = pr.description
p = GenericTx.from_cln_grpc_payment(pay, comment)
if successfull_only and p.status == TxStatus.SUCCEEDED:
if successful_only and p.status == TxStatus.SUCCEEDED:
tx.append(p)
continue
@ -511,7 +511,7 @@ async def listen_forward_events() -> ForwardSuccessEvent:
interval = config("gather_ln_info_interval", default=2, cast=float)
# make sure we know how many forewards we have
# make sure we know how many forwards we have
# we need to calculate the difference between each iteration
# status=1 == "settled"
req = ln.ListforwardsRequest(status=1)

View file

@ -140,7 +140,7 @@ def _get_block_time(block_height: int) -> tuple:
async def list_all_tx_impl(
successfull_only: bool, index_offset: int, max_tx: int, reversed: bool
successful_only: bool, index_offset: int, max_tx: int, reversed: bool
) -> List[GenericTx]:
@force_async
def _list_invoices():
@ -420,7 +420,7 @@ async def listen_forward_events() -> ForwardSuccessEvent:
# repository.
interval - 0.1
# make sure we know how many forewards we have
# make sure we know how many forwards we have
# we need to calculate the difference between each iteration
res = lncfg.cln_sock.listforwards(status="settled")
num_fwd_last_poll = len(res["forwards"])

View file

@ -458,7 +458,7 @@ async def channel_open_impl(
target_conf=target_confs,
)
async for response in lncfg.lnd_stub.OpenChannel(r):
# TODO: this is still some bytestring that needs correct convertion to a string txid (ok OK for now)
# TODO: this is still some bytestring that needs correct conversion to a string txid (ok OK for now)
return str(response.chan_pending.txid.hex())
except grpc.aio._call.AioRpcError as error:
@ -467,12 +467,12 @@ async def channel_open_impl(
)
async def peer_resolve_alias(nodepub: str) -> str:
async def peer_resolve_alias(node_pub: str) -> str:
# get fresh list of peers and their aliases
try:
request = ln.NodeInfoRequest(pub_key=nodepub, include_channels=False)
request = ln.NodeInfoRequest(pub_key=node_pub, include_channels=False)
response = await lncfg.lnd_stub.GetNodeInfo(request)
return str(response.node.alias)
@ -528,7 +528,7 @@ async def channel_close_impl(channel_id: int, force_close: bool) -> str:
target_conf=6,
)
async for response in lncfg.lnd_stub.CloseChannel(request):
# TODO: this is still some bytestring that needs correct convertion to a string txid (ok OK for now)
# TODO: this is still some bytestring that needs correct conversion to a string txid (ok OK for now)
return str(response.close_pending.txid.hex())
except grpc.aio._call.AioRpcError as error:

View file

@ -70,7 +70,7 @@ async def password_change(type: str, old_password: str, new_password: str):
if not type in ["a", "b", "c"]:
raise HTTPException(status.HTTP_400_BAD_REQUEST, detail="unknown password type")
# check password formattings
# check password formatting
if not password_valid(old_password):
raise HTTPException(
status.HTTP_400_BAD_REQUEST, detail="old password format invalid"
@ -93,13 +93,13 @@ async def password_change(type: str, old_password: str, new_password: str):
)
# second set new password
scriptcall = (
script_call = (
f'/home/admin/config.scripts/blitz.passwords.sh set {type} "{new_password}"'
)
if type == "c":
# will set password c of both lnd & core lightning if installed/activated
scriptcall = f'/home/admin/config.scripts/blitz.passwords.sh set c "{old_password}" "{new_password}"'
result = await call_script(scriptcall)
script_call = f'/home/admin/config.scripts/blitz.passwords.sh set c "{old_password}" "{new_password}"'
result = await call_script(script_call)
data = parse_key_value_text(result)
print(str(data))
if "error" in data.keys() and len(data["error"]) > 0:

View file

@ -3,14 +3,7 @@ import logging
from decouple import config
from app.constants import API_VERSION
from app.models.system import (
APIPlatform,
ConnectionInfo,
HealthMessage,
HealthMessagePriority,
HealthState,
SystemInfo,
)
from app.models.system import APIPlatform, ConnectionInfo, SystemInfo
from app.repositories.lightning import get_ln_info
@ -33,12 +26,6 @@ async def get_system_info_impl() -> SystemInfo:
platform=APIPlatform.NATIVE_PYTHON,
platform_version=version,
api_version=API_VERSION,
health=HealthState.ATTENTION_REQUIRED,
health_messages=[
HealthMessage(
id=25, level=HealthMessagePriority.WARNING, message="HDD 85% full"
)
],
tor_web_ui=tor_api_docs,
tor_api=tor_api,
lan_web_ui=lan_api_docs,

View file

@ -5,14 +5,7 @@ import os
from decouple import config
from app.constants import API_VERSION
from app.models.system import (
APIPlatform,
ConnectionInfo,
HealthMessage,
HealthMessagePriority,
HealthState,
SystemInfo,
)
from app.models.system import APIPlatform, ConnectionInfo, SystemInfo
from app.repositories.lightning import get_ln_info
from app.utils import (
SSE,
@ -36,12 +29,6 @@ async def get_system_info_impl() -> SystemInfo:
platform=APIPlatform.RASPIBLITZ,
platform_version=await redis_get("raspiBlitzVersion"),
api_version=API_VERSION,
health=HealthState.ATTENTION_REQUIRED,
health_messages=[
HealthMessage(
id=25, level=HealthMessagePriority.WARNING, message="HDD 85% full"
)
],
tor_web_ui=tor,
tor_api=f"{tor}/api",
lan_web_ui=f"http://{lan}/",

View file

@ -129,7 +129,7 @@ async def get_fee_revenue_path() -> FeeRevenue:
responses=responses,
)
async def list_all_tx_path(
successfull_only: bool = Query(
successful_only: bool = Query(
False,
description="If set, only successful transaction will be returned in the response.",
),
@ -147,7 +147,7 @@ async def list_all_tx_path(
),
):
try:
return await list_all_tx(successfull_only, index_offset, max_tx, reversed)
return await list_all_tx(successful_only, index_offset, max_tx, reversed)
except HTTPException as r:
raise
except NotImplementedError as r:

View file

@ -218,7 +218,7 @@ async def setup_start_done(data: StartDoneData):
# hostname=[string]
# passwordA=[string]
# passwordB=[string]
# passwordC=[string] (might be empty of no lightning was choosen)
# passwordC=[string] (might be empty of no lightning was chosen)
# lndrescue=[path] (might be used later if lnd rescue file upload is offered)
# clrescue=[path] (might be used later if c-lightning rescue file upload is offered)
# seedWords= (might be used later if we offer recover from seed words)
@ -249,10 +249,10 @@ async def setup_final_info():
)
return HTTPException(status.HTTP_405_METHOD_NOT_ALLOWED)
resultlines = []
with open(setupFilePath, "r") as setupfile:
resultlines = setupfile.readlines()
data = parse_key_value_lines(resultlines)
result_lines = []
with open(setupFilePath, "r") as setup_file:
result_lines = setup_file.readlines()
data = parse_key_value_lines(result_lines)
try:
seedwordsNEW = data["seedwordsNEW"]
except:
@ -283,7 +283,7 @@ async def get_shutdown():
setupPhase = await redis_get("setupPhase")
state = await redis_get("state")
if setupPhase == "done":
logging.warning(f"can only be called when node is not setuped yet")
logging.warning(f"can only be called when the nodes is not finalized yet")
return HTTPException(status.status.HTTP_405_METHOD_NOT_ALLOWED)
if state != "waitsetup":
logging.warning(f"can only be called when nodes awaits setup")

View file

@ -122,7 +122,7 @@ async def hw_info() -> map:
@router.get(
"/connection-info",
name=f"{_PREFIX}.connection-info",
summary="Get credential information to connect externbal apps.",
summary="Get credential information to connect external apps.",
response_description="Returns a JSON string with credential information.",
response_model=ConnectionInfo,
dependencies=[Depends(JWTBearer())],

View file

@ -279,7 +279,7 @@ class _PushID(object):
def __init__(self):
# Timestamp of last push, used to prevent local collisions if you
# pushtwice in one ms.
# push twice in one ms.
self.last_push_time = 0
# We generate 72-bits of randomness which get turned into 12