From 57f733ebb5844fc6e511eb61eb9b1823ebf3ff1a Mon Sep 17 00:00:00 2001 From: /rootzoll Date: Wed, 18 May 2022 00:14:35 +0200 Subject: [PATCH] Adding identity_uri to /lightning/get-info (#89) --- app/models/lightning.py | 5 ++++- app/repositories/lightning.py | 11 +++++++++-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/app/models/lightning.py b/app/models/lightning.py index 5b5a8ae..d7517b7 100644 --- a/app/models/lightning.py +++ b/app/models/lightning.py @@ -950,7 +950,10 @@ class LnInfo(BaseModel): commit_hash: str # The identity pubkey of the current node. - identity_pubkey: str + identity_pubkey: str = Query("the nodes pubkey") + + # The complete URI (pubkey@physicaladdress:port) the current node. + identity_uri: str = Query("the nodes complete URI") # If applicable, the alias of the current node, e.g. "bob" alias: str diff --git a/app/repositories/lightning.py b/app/repositories/lightning.py index cf5c07a..a84f939 100644 --- a/app/repositories/lightning.py +++ b/app/repositories/lightning.py @@ -6,6 +6,8 @@ from decouple import config from fastapi import status from fastapi.exceptions import HTTPException +from app.models.system import APIPlatform + from app.models.lightning import ( FeeRevenue, GenericTx, @@ -20,7 +22,7 @@ from app.models.lightning import ( SendCoinsResponse, Channel, ) -from app.utils import SSE, lightning_config, send_sse_message +from app.utils import SSE, lightning_config, send_sse_message, redis_get if lightning_config.ln_node == "lnd": from app.repositories.ln_impl.lnd import ( @@ -76,6 +78,8 @@ ENABLE_FWD_NOTIFICATIONS = config( FWD_GATHER_INTERVAL = config("forwards_gather_interval", default=2.0, cast=float) +PLATFORM = config("platform", cast=str) + if FWD_GATHER_INTERVAL < 0.3: raise RuntimeError("forwards_gather_interval cannot be less than 0.3 seconds") @@ -178,7 +182,10 @@ async def channel_close(channel_id: int, force_close: bool) -> str: async def get_ln_info() -> LnInfo: - return await get_ln_info_impl() + ln_info = await get_ln_info_impl() + if PLATFORM == APIPlatform.RASPIBLITZ: + ln_info.identity_uri = await redis_get("ln_default_address") + return ln_info async def unlock_wallet(password: str) -> bool: