mirror of
https://github.com/fusion44/blitz_api.git
synced 2026-08-18 12:27:50 +02:00
remove ln_info_lite
This commit is contained in:
parent
408f432133
commit
cf4ab3963c
9 changed files with 0 additions and 155 deletions
|
|
@ -100,7 +100,6 @@ class SSE:
|
|||
BTC_INFO = "btc_info"
|
||||
|
||||
LN_INFO = "ln_info"
|
||||
LN_INFO_LITE = "ln_info_lite"
|
||||
LN_INVOICE_STATUS = "ln_invoice_status"
|
||||
LN_PAYMENT_STATUS = "ln_payment_status"
|
||||
LN_ONCHAIN_PAYMENT_STATUS = "ln_onchain_payment_status"
|
||||
|
|
|
|||
|
|
@ -9,7 +9,6 @@ from app.bitcoind.service import get_btc_info
|
|||
from app.lightning.service import (
|
||||
get_fee_revenue,
|
||||
get_ln_info,
|
||||
get_ln_info_lite,
|
||||
get_wallet_balance,
|
||||
)
|
||||
from app.system.service import get_hardware_info, get_system_info
|
||||
|
|
@ -36,7 +35,6 @@ async def get_full_client_warmup_data() -> List:
|
|||
get_system_info(),
|
||||
get_btc_info(),
|
||||
get_ln_info(),
|
||||
get_ln_info_lite(),
|
||||
get_fee_revenue(),
|
||||
get_wallet_balance(),
|
||||
get_app_status(),
|
||||
|
|
|
|||
|
|
@ -1608,50 +1608,6 @@ class LnInfo(BaseModel):
|
|||
)
|
||||
|
||||
|
||||
class LightningInfoLite(BaseModel):
|
||||
implementation: str = Query(
|
||||
..., description="Lightning software implementation (LND, c-lightning)"
|
||||
)
|
||||
version: str = Query(..., description="Version of the implementation")
|
||||
identity_pubkey: str = Query(
|
||||
..., description="The identity pubkey of the current node"
|
||||
)
|
||||
identity_uri: str = Query(..., description="The complete URI of the current node")
|
||||
num_pending_channels: int = Query(..., description="Number of pending channels")
|
||||
num_active_channels: int = Query(..., description="Number of active channels")
|
||||
num_inactive_channels: int = Query(..., description="Number of inactive channels")
|
||||
num_peers: int = Query(..., description="Number of peers")
|
||||
block_height: int = Query(
|
||||
..., description="The node's current view of the height of the best block"
|
||||
)
|
||||
synced_to_chain: bool | None = Query(
|
||||
None, description="Whether the wallet's view is synced to the main chain"
|
||||
)
|
||||
synced_to_graph: bool | None = Query(
|
||||
None,
|
||||
description=(
|
||||
"Whether we consider ourselves synced with " "the public channel graph."
|
||||
),
|
||||
)
|
||||
|
||||
@classmethod
|
||||
@logger.catch(exclude=(HTTPException,))
|
||||
def from_lninfo(cls, info: LnInfo):
|
||||
return cls(
|
||||
implementation=info.implementation,
|
||||
version=info.version,
|
||||
identity_pubkey=info.identity_pubkey,
|
||||
identity_uri=info.identity_uri,
|
||||
num_pending_channels=info.num_pending_channels,
|
||||
num_active_channels=info.num_active_channels,
|
||||
num_inactive_channels=info.num_inactive_channels,
|
||||
num_peers=info.num_peers,
|
||||
block_height=info.block_height,
|
||||
synced_to_chain=info.synced_to_chain,
|
||||
synced_to_graph=info.synced_to_graph,
|
||||
)
|
||||
|
||||
|
||||
class WalletBalance(BaseModel):
|
||||
onchain_confirmed_balance: int = Query(
|
||||
...,
|
||||
|
|
|
|||
|
|
@ -17,7 +17,6 @@ from app.lightning.models import (
|
|||
FeeRevenue,
|
||||
GenericTx,
|
||||
Invoice,
|
||||
LightningInfoLite,
|
||||
LnInfo,
|
||||
NewAddressInput,
|
||||
OnChainTransaction,
|
||||
|
|
@ -36,7 +35,6 @@ from app.lightning.service import (
|
|||
decode_pay_request,
|
||||
get_fee_revenue,
|
||||
get_ln_info,
|
||||
get_ln_info_lite,
|
||||
get_wallet_balance,
|
||||
list_all_tx,
|
||||
list_invoices,
|
||||
|
|
@ -471,27 +469,6 @@ async def get_info():
|
|||
raise HTTPException(status.HTTP_501_NOT_IMPLEMENTED, detail=r.args[0])
|
||||
|
||||
|
||||
@router.get(
|
||||
"/get-info-lite",
|
||||
name=f"{_PREFIX}.get-info-lite",
|
||||
summary=(
|
||||
"Get lightweight current lightning info. "
|
||||
"Less verbose version of /lightning/get-info"
|
||||
),
|
||||
dependencies=[Depends(JWTBearer())],
|
||||
status_code=status.HTTP_200_OK,
|
||||
response_model=LightningInfoLite,
|
||||
responses=responses,
|
||||
)
|
||||
async def get_ln_info_lite_path():
|
||||
try:
|
||||
return await get_ln_info_lite()
|
||||
except HTTPException:
|
||||
raise
|
||||
except NotImplementedError as r:
|
||||
raise HTTPException(status.HTTP_501_NOT_IMPLEMENTED, detail=r.args[0])
|
||||
|
||||
|
||||
@router.get(
|
||||
"/decode-pay-req",
|
||||
name=f"{_PREFIX}.decode-pay-req",
|
||||
|
|
|
|||
|
|
@ -13,7 +13,6 @@ from app.lightning.models import (
|
|||
GenericTx,
|
||||
InitLnRepoUpdate,
|
||||
Invoice,
|
||||
LightningInfoLite,
|
||||
LnInfo,
|
||||
NewAddressInput,
|
||||
OnChainTransaction,
|
||||
|
|
@ -73,11 +72,6 @@ async def initialize_ln_repo() -> AsyncGenerator[InitLnRepoUpdate, None]:
|
|||
yield u
|
||||
|
||||
|
||||
async def get_ln_info_lite() -> LightningInfoLite:
|
||||
ln_info = await ln.get_ln_info()
|
||||
return LightningInfoLite.from_lninfo(ln_info)
|
||||
|
||||
|
||||
async def get_wallet_balance():
|
||||
return await ln.get_wallet_balance()
|
||||
|
||||
|
|
@ -223,12 +217,6 @@ async def _handle_info_listener():
|
|||
await broadcast_sse_msg(SSE.LN_INFO, info.model_dump())
|
||||
last_info = info
|
||||
|
||||
info_lite = LightningInfoLite.from_lninfo(info)
|
||||
|
||||
if last_info_lite != info_lite:
|
||||
await broadcast_sse_msg(SSE.LN_INFO_LITE, info_lite.model_dump())
|
||||
last_info_lite = info_lite
|
||||
|
||||
await asyncio.sleep(GATHER_INFO_INTERVALL)
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -312,7 +312,6 @@ async def warmup_new_connections():
|
|||
_handle(id, SSE.SYSTEM_INFO, res[0]),
|
||||
_handle(id, SSE.BTC_INFO, res[1]),
|
||||
_handle(id, SSE.LN_INFO, res[2]),
|
||||
_handle(id, SSE.LN_INFO_LITE, res[3]),
|
||||
_handle(id, SSE.LN_FEE_REVENUE, res[4]),
|
||||
_handle(id, SSE.WALLET_BALANCE, res[5]),
|
||||
_handle(id, SSE.INSTALLED_APP_STATUS, res[6]),
|
||||
|
|
|
|||
29
openapi.json
29
openapi.json
|
|
@ -1327,35 +1327,6 @@
|
|||
]
|
||||
}
|
||||
},
|
||||
"/lightning/get-info-lite": {
|
||||
"get": {
|
||||
"tags": [
|
||||
"Lightning"
|
||||
],
|
||||
"summary": "Get lightweight current lightning info. Less verbose version of /lightning/get-info",
|
||||
"operationId": "lightning_get_info_lite_lightning_get_info_lite_get",
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "Successful Response",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/LightningInfoLite"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"423": {
|
||||
"description": "LND only: Wallet is locked. Unlock via /lightning/unlock-wallet."
|
||||
}
|
||||
},
|
||||
"security": [
|
||||
{
|
||||
"JWTBearer": []
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"/lightning/decode-pay-req": {
|
||||
"get": {
|
||||
"tags": [
|
||||
|
|
|
|||
|
|
@ -1,9 +1,6 @@
|
|||
from starlette.testclient import TestClient
|
||||
|
||||
from app.main import app
|
||||
from app.models.lightning import LightningInfoLite
|
||||
from app.routers import lightning
|
||||
from tests.routers.test_lightning_utils import get_valid_lightning_info_lite
|
||||
from tests.routers.utils import call_route
|
||||
from tests.utils import monkeypatch_auth
|
||||
|
||||
|
|
@ -28,31 +25,7 @@ def test_route_authentications_latest():
|
|||
call_route(test_client, f"{prefix}/send-coins", params=p, method="p")
|
||||
p = {"pay_req": "1337"}
|
||||
call_route(test_client, f"{prefix}/send-payment", params=p, method="p")
|
||||
call_route(test_client, f"{prefix}/get-info-lite")
|
||||
call_route(test_client, f"{prefix}/get-info")
|
||||
call_route(test_client, f"{prefix}/decode-pay-req", params={"pay_req": ""})
|
||||
p = {"password": "1"}
|
||||
call_route(test_client, f"{prefix}/unlock-wallet", params=p, method="p")
|
||||
|
||||
|
||||
def test_get_ln_status(monkeypatch):
|
||||
prefix_latest = "/latest/lightning"
|
||||
prefix_v1 = "/v1/lightning"
|
||||
|
||||
monkeypatch_auth(monkeypatch)
|
||||
|
||||
async def mock_get_ln_info_lite() -> LightningInfoLite:
|
||||
return get_valid_lightning_info_lite()
|
||||
|
||||
monkeypatch.setattr(lightning, "get_ln_info_lite", mock_get_ln_info_lite)
|
||||
|
||||
response = test_client.get(f"{prefix_latest}/get-info-lite")
|
||||
|
||||
r_js = response.json()
|
||||
v_js = get_valid_lightning_info_lite().model_dump()
|
||||
assert r_js == v_js
|
||||
|
||||
response = test_client.get(f"{prefix_v1}/get-info-lite")
|
||||
r_js = response.json()
|
||||
v_js = get_valid_lightning_info_lite().model_dump()
|
||||
assert r_js == v_js
|
||||
|
|
|
|||
|
|
@ -1,16 +0,0 @@
|
|||
from app.models.lightning import LightningInfoLite
|
||||
|
||||
|
||||
def get_valid_lightning_info_lite() -> LightningInfoLite:
|
||||
return LightningInfoLite(
|
||||
implementation="LND",
|
||||
version="0.13.1",
|
||||
identity_pubkey="0246ad12eb40bcf26a0cd50757b15a58181d0ad0d78d5bc31e8058205321c3e632",
|
||||
num_pending_channels=1,
|
||||
num_active_channels=4,
|
||||
num_inactive_channels=2,
|
||||
num_peers=3,
|
||||
block_height=123456,
|
||||
synced_to_chain=True,
|
||||
synced_to_graph=True,
|
||||
)
|
||||
Loading…
Add table
Add a link
Reference in a new issue