|
3 | 3 | from typing import List, Optional, Union
|
4 | 4 |
|
5 | 5 | from deepdiff import DeepDiff
|
| 6 | +from fastapi import HTTPException |
6 | 7 | from fastapi.param_functions import Query
|
| 8 | +from loguru import logger |
7 | 9 | from pydantic import BaseModel, validator
|
8 | 10 | from pydantic.types import conint
|
9 | 11 |
|
@@ -1318,10 +1320,13 @@ class LnInfo(BaseModel):
|
1318 | 1320 | ..., description="The SHA1 commit hash that the daemon is compiled with."
|
1319 | 1321 | )
|
1320 | 1322 |
|
1321 |
| - identity_pubkey: str = Query("The identity pubkey of the current node.") |
| 1323 | + identity_pubkey: str = Query( |
| 1324 | + ..., description="The identity pubkey of the current node." |
| 1325 | + ) |
1322 | 1326 |
|
1323 | 1327 | identity_uri: str = Query(
|
1324 |
| - "The complete URI (pubkey@physicaladdress:port) the current node." |
| 1328 | + ..., |
| 1329 | + description="The complete URI (pubkey@physicaladdress:port) the current node.", |
1325 | 1330 | )
|
1326 | 1331 |
|
1327 | 1332 | alias: str = Query(..., description="The alias of the node.")
|
@@ -1431,14 +1436,25 @@ def from_cln_jrpc(cls, implementation, i) -> "LnInfo":
|
1431 | 1436 | # _features.append(FeaturesEntry.from_cln_json(i["our_features"][k], k))
|
1432 | 1437 |
|
1433 | 1438 | _uris = []
|
1434 |
| - for b in i["binding"]: |
1435 |
| - _uris.append(f"{b['address']}:{b['port']}") |
| 1439 | + pubkey = i["id"] |
| 1440 | + if "binding" in i: |
| 1441 | + for b in i["binding"]: |
| 1442 | + _uris.append(f"{pubkey}@{b['address']}:{b['port']}") |
| 1443 | + |
| 1444 | + if "address" in i: |
| 1445 | + for b in i["address"]: |
| 1446 | + _uris.append(f"{pubkey}@{b['address']}:{b['port']}") |
| 1447 | + |
| 1448 | + uri = "" |
| 1449 | + if len(_uris) > 0: |
| 1450 | + uri = _uris[0] |
1436 | 1451 |
|
1437 | 1452 | return LnInfo(
|
1438 | 1453 | implementation=implementation,
|
1439 | 1454 | version=i["version"],
|
1440 | 1455 | commit_hash=i["version"].split("-")[-1],
|
1441 |
| - identity_pubkey=i["id"], |
| 1456 | + identity_pubkey=pubkey, |
| 1457 | + identity_uri=uri, |
1442 | 1458 | alias=i["alias"],
|
1443 | 1459 | color=i["color"],
|
1444 | 1460 | num_pending_channels=i["num_pending_channels"],
|
@@ -1514,6 +1530,7 @@ class LightningInfoLite(BaseModel):
|
1514 | 1530 | )
|
1515 | 1531 |
|
1516 | 1532 | @classmethod
|
| 1533 | + @logger.catch(exclude=(HTTPException,)) |
1517 | 1534 | def from_lninfo(cls, info: LnInfo):
|
1518 | 1535 | return cls(
|
1519 | 1536 | implementation=info.implementation,
|
|
0 commit comments