fix: lndrest nodemanager get_channel (flaky ci decoy) (#2877)
This commit is contained in:
+18
-3
@@ -220,10 +220,21 @@ class LndRestNode(Node):
|
||||
|
||||
async def get_channel(self, channel_id: str) -> Optional[NodeChannel]:
|
||||
channel_info = await self.get(f"/v1/graph/edge/{channel_id}")
|
||||
peer_id = channel_info["node2_pub"]
|
||||
info = await self.get("/v1/getinfo")
|
||||
if info["identity_pubkey"] == channel_info["node1_pub"]:
|
||||
my_node_key = "node1"
|
||||
peer_node_key = "node2"
|
||||
else:
|
||||
my_node_key = "node2"
|
||||
peer_node_key = "node1"
|
||||
peer_id = channel_info[f"{peer_node_key}_pub"]
|
||||
peer_b64 = _encode_urlsafe_bytes(peer_id)
|
||||
channels = await self.get(f"/v1/channels?peer={peer_b64}")
|
||||
if "error" in channel_info and "error" in channels:
|
||||
logger.debug("LND get_channel", channels)
|
||||
return None
|
||||
if len(channels["channels"]) == 0:
|
||||
logger.debug(f"LND get_channel no channels founds with id {peer_b64}")
|
||||
return None
|
||||
for channel in channels["channels"]:
|
||||
if channel["chan_id"] == channel_id:
|
||||
@@ -238,8 +249,12 @@ class LndRestNode(Node):
|
||||
if channel["active"]
|
||||
else ChannelState.INACTIVE
|
||||
),
|
||||
fee_ppm=channel_info["node1_policy"]["fee_rate_milli_msat"],
|
||||
fee_base_msat=channel_info["node1_policy"]["fee_base_msat"],
|
||||
fee_ppm=channel_info[f"{my_node_key}_policy"][
|
||||
"fee_rate_milli_msat"
|
||||
],
|
||||
fee_base_msat=channel_info[f"{my_node_key}_policy"][
|
||||
"fee_base_msat"
|
||||
],
|
||||
point=_parse_channel_point(channel["channel_point"]),
|
||||
balance=ChannelBalance(
|
||||
local_msat=msat(channel["local_balance"]),
|
||||
|
||||
Reference in New Issue
Block a user