Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: ln-info delivers wrong identity_uri #202 #210

Merged
merged 2 commits into from
May 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion app/apps/impl/raspiblitz.py
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ async def run_bonus_script(self, app_id: str, params: str):
"id": app_id,
"mode": mode,
"result": "fail",
"details": "install script did not ran thru",
"details": "install script threw an error",
},
)
# nothing above consider success
Expand Down Expand Up @@ -304,6 +304,9 @@ async def run_bonus_script(self, app_id: str, params: str):
"details": stdoutData["result"],
},
)
await broadcast_sse_msg(
SSE.INSTALLED_APP_STATUS, [updatedAppData]
)
else:
logging.error(f"FAIL - {app_id} was not installed")
logging.debug(f"updatedAppData: {updatedAppData}")
Expand All @@ -317,8 +320,15 @@ async def run_bonus_script(self, app_id: str, params: str):
"details": "install was not effective",
},
)
await broadcast_sse_msg(
SSE.INSTALLED_APP_STATUS, [updatedAppData]
)

elif mode == "off":
await broadcast_sse_msg(
SSE.INSTALL_APP,
{"id": app_id, "mode": mode, "result": "win"},
)
await broadcast_sse_msg(SSE.INSTALLED_APP_STATUS, [updatedAppData])

if not updatedAppData["installed"]:
Expand Down
27 changes: 22 additions & 5 deletions app/lightning/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
from typing import List, Optional, Union

from deepdiff import DeepDiff
from fastapi import HTTPException
from fastapi.param_functions import Query
from loguru import logger
from pydantic import BaseModel, validator
from pydantic.types import conint

Expand Down Expand Up @@ -1318,10 +1320,13 @@ class LnInfo(BaseModel):
..., description="The SHA1 commit hash that the daemon is compiled with."
)

identity_pubkey: str = Query("The identity pubkey of the current node.")
identity_pubkey: str = Query(
..., description="The identity pubkey of the current node."
)

identity_uri: str = Query(
"The complete URI (pubkey@physicaladdress:port) the current node."
...,
description="The complete URI (pubkey@physicaladdress:port) the current node.",
)

alias: str = Query(..., description="The alias of the node.")
Expand Down Expand Up @@ -1431,14 +1436,25 @@ def from_cln_jrpc(cls, implementation, i) -> "LnInfo":
# _features.append(FeaturesEntry.from_cln_json(i["our_features"][k], k))

_uris = []
for b in i["binding"]:
_uris.append(f"{b['address']}:{b['port']}")
pubkey = i["id"]
if "binding" in i:
for b in i["binding"]:
_uris.append(f"{pubkey}@{b['address']}:{b['port']}")

if "address" in i:
for b in i["address"]:
_uris.append(f"{pubkey}@{b['address']}:{b['port']}")

uri = ""
if len(_uris) > 0:
uri = _uris[0]

return LnInfo(
implementation=implementation,
version=i["version"],
commit_hash=i["version"].split("-")[-1],
identity_pubkey=i["id"],
identity_pubkey=pubkey,
identity_uri=uri,
alias=i["alias"],
color=i["color"],
num_pending_channels=i["num_pending_channels"],
Expand Down Expand Up @@ -1514,6 +1530,7 @@ class LightningInfoLite(BaseModel):
)

@classmethod
@logger.catch(exclude=(HTTPException,))
def from_lninfo(cls, info: LnInfo):
return cls(
implementation=info.implementation,
Expand Down