From fa87c8d27318cf4cc5b2bcedd8916e9d5a97d9e9 Mon Sep 17 00:00:00 2001 From: Jean Demeusy Date: Thu, 11 Jan 2024 22:58:23 +0100 Subject: [PATCH] Fix address retrieval and funding in low balance channels --- ct-app/core/core.py | 9 ++++++++- ct-app/core/node.py | 6 ++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/ct-app/core/core.py b/ct-app/core/core.py index 32621f14..a7486e35 100644 --- a/ct-app/core/core.py +++ b/ct-app/core/core.py @@ -99,6 +99,12 @@ def subgraph_safes_balance_url(self, subgraph: SubgraphType) -> str: async def _retrieve_address(self): addresses = await self.api.get_address("all") + if not addresses: + self.warning("No address retrieved from node.") + return + if "hopr" not in addresses or "native" not in addresses: + self.warning("Invalid address retrieved from node.") + return self.address = Address(addresses["hopr"], addresses["native"]) @flagguard @@ -343,7 +349,8 @@ async def distribute_rewards(self): async def get_fundings(self): from_address = self.params.subgraph.from_address ct_safe_addresses = { - (await node.api.node_info()).node_safe for node in self.network_nodes + getattr(await node.api.node_info(), "node_safe", None) + for node in self.network_nodes } transactions = [] diff --git a/ct-app/core/node.py b/ct-app/core/node.py index 917a9e13..d402d638 100644 --- a/ct-app/core/node.py +++ b/ct-app/core/node.py @@ -245,7 +245,9 @@ async def fund_channels(self): ] low_balances = [ - c for c in out_opens if int(c.balance)/1e18 <= self.params.channel.min_balance + c + for c in out_opens + if int(c.balance) / 1e18 <= self.params.channel.min_balance ] self.debug(f"Low balance channels: {len(low_balances)}") @@ -255,7 +257,7 @@ async def fund_channels(self): for channel in low_balances: if channel.destination_peer_id in peer_ids: ok = await self.api.fund_channel( - channel.channel_id, self.params.channel.funding_amount*1e18 + channel.channel_id, self.params.channel.funding_amount * 1e18 ) if ok: self.debug(f"Funded channel {channel.channel_id}")