Add option to show if channel is disabled

This commit is contained in:
Sebastian Andersson 2023-03-18 18:56:02 +01:00
parent bd90bb3a40
commit 35955cc070
3 changed files with 48 additions and 0 deletions

View file

@ -59,6 +59,7 @@ class ClnClient:
int(info[0]["htlc_minimum_msat"]),
int(info[0]["htlc_maximum_msat"]),
)
node1_disabled = not info[0]["active"]
if len(info) > 1:
node2_fee = (
int(info[1]["base_fee_millisatoshi"]),
@ -68,12 +69,15 @@ class ClnClient:
int(info[1]["htlc_minimum_msat"]),
int(info[1]["htlc_maximum_msat"]),
)
node2_disabled = not info[1]["active"]
if info[0]["source"] != self.local_pubkey:
assert info[1]["source"] == self.local_pubkey
fee_remote = node1_fee
fee_local = node2_fee
htlc_remote = node1_htlc
htlc_local = node2_htlc
disabled_remote = node1_disabled
disabled_local = node2_disabled
if len(info) > 1:
if info[1]["source"] != self.local_pubkey:
assert info[0]["source"] == self.local_pubkey
@ -81,21 +85,29 @@ class ClnClient:
fee_remote = node2_fee
htlc_local = node1_htlc
htlc_remote = node2_htlc
disabled_local = node1_disabled
disabled_remote = node2_disabled
else:
fee_local = node1_fee
fee_remote = 0, 0
htlc_local = node1_htlc
htlc_remote = None, None
disabled_local = node1_disabled
disabled_remote = None
else:
fee_local = 0, 0
fee_remote = 0, 0
htlc_local = None, None
htlc_remote = None, None
disabled_local = None
disabled_remote = None
chan.local_base_fee, chan.local_fee_rate = fee_local
chan.remote_base_fee, chan.remote_fee_rate = fee_remote
chan.local_min_htlc, chan.local_max_htlc = htlc_local
chan.remote_min_htlc, chan.remote_max_htlc = htlc_remote
chan.local_disabled = disabled_local
chan.remote_disabled = disabled_remote
chan.local_alias = self.local_alias
listnode = self._run("listnodes", chan.remote_node_id)
if len(listnode["nodes"]) > 0:

View file

@ -70,6 +70,7 @@ class LndClient(abc.ABC):
int(node1_policy["min_htlc"]),
int(node1_policy["max_htlc_msat"]),
)
node1_disabled = node1_policy["disabled"]
node2_fee = (
int(node2_policy["fee_base_msat"]),
int(node2_policy["fee_rate_milli_msat"]),
@ -78,27 +79,35 @@ class LndClient(abc.ABC):
int(node2_policy["min_htlc"]),
int(node2_policy["max_htlc_msat"]),
)
node2_disabled = node2_policy["disabled"]
if info["node1_pub"] != self.local_pubkey:
assert info["node2_pub"] == self.local_pubkey
fee_remote = node1_fee
fee_local = node2_fee
htlc_remote = node1_htlc
htlc_local = node2_htlc
disabled_remote = node1_disabled
disabled_local = node2_disabled
if info["node2_pub"] != self.local_pubkey:
assert info["node1_pub"] == self.local_pubkey
fee_local = node1_fee
fee_remote = node2_fee
htlc_local = node1_htlc
htlc_remote = node2_htlc
disabled_local = node1_disabled
disabled_remote = node2_disabled
chan.local_base_fee, chan.local_fee_rate = fee_local
chan.remote_base_fee, chan.remote_fee_rate = fee_remote
chan.local_min_htlc, chan.local_max_htlc = htlc_local
chan.remote_min_htlc, chan.remote_max_htlc = htlc_remote
chan.local_disabled = disabled_local
chan.remote_disabled = disabled_remote
except:
chan.local_base_fee, chan.local_fee_rate = None, None
chan.remote_base_fee, chan.remote_fee_rate = None, None
chan.local_min_htlc, chan.local_max_htlc = None, None
chan.remote_min_htlc, chan.remote_max_htlc = None, None
chan.local_disabled, chan.remote_disabled = None, None
chan.local_alias = self.local_alias
chan.remote_alias = self.getnodeinfo(chan.remote_node_id)["node"]["alias"]
chan.last_forward = 0

27
suez.py
View file

@ -29,6 +29,13 @@ def _resolve_htlc(htlc_msat):
return "{:,}".format(htlc_sat)
def _resolve_disabled(c):
local = "y" if c.local_disabled else "n" if c.local_disabled is not None else "-"
remote = "y" if c.remote_disabled else "n" if c.remote_disabled is not None else "-"
res = "[bright_blue]{}[/bright_blue]|[bright_yellow]{}[/bright_yellow]"
return res.format(local, remote)
def info_box(ln, score):
grid = Table.grid()
grid.add_column(style="bold")
@ -58,11 +65,14 @@ def channel_table(
show_chan_ids,
show_forwarding_stats,
show_minmax_htlc,
show_disabled,
):
table = Table(box=box.SIMPLE)
table.add_column("\ninbound", justify="right", style="bright_red")
table.add_column("\nratio", justify="center")
table.add_column("\noutbound", justify="right", style="green")
if show_disabled:
table.add_column("is\ndisabled", justify="right")
if show_minmax_htlc:
table.add_column("local\nmin_htlc\n(sat)", justify="right", style="bright_blue")
table.add_column("local\nmax_htlc\n(sat)", justify="right", style="bright_blue")
@ -130,6 +140,10 @@ def channel_table(
bar,
"{:,}".format(c.local_balance),
]
if show_disabled:
columns += [
_resolve_disabled(c),
]
if show_minmax_htlc:
columns += [
_resolve_htlc(c.local_min_htlc),
@ -180,6 +194,10 @@ def channel_table(
None,
"" * 6,
]
if show_disabled:
columns += [
None,
]
if show_minmax_htlc:
columns += [
None,
@ -204,6 +222,10 @@ def channel_table(
None,
"{:,}".format(total_local),
]
if show_disabled:
columns += [
None,
]
if show_minmax_htlc:
columns += [
None,
@ -258,6 +280,7 @@ def channel_table(
help="Show forwarding counts and success percentages (CLN)",
)
@click.option("--show-minmax-htlc", is_flag=True, help="Show min and max htlc.")
@click.option("--show-disabled", is_flag=True, help="Show if channel is disabled.")
@click.option(
"--channels",
default="all",
@ -276,6 +299,7 @@ def suez(
show_chan_ids,
show_forwarding_stats,
show_minmax_htlc,
show_disabled,
channels,
):
clients = {
@ -315,6 +339,7 @@ def suez(
show_chan_ids,
show_forwarding_stats,
show_minmax_htlc,
show_disabled,
)
public_info = channelcount_info_box(len(public_channels), "public")
console.print(public_table)
@ -328,6 +353,7 @@ def suez(
show_chan_ids,
show_forwarding_stats,
show_minmax_htlc,
show_disabled,
)
private_info = channelcount_info_box(len(private_channels), "private")
console.print(private_table)
@ -350,5 +376,6 @@ def suez(
show_chan_ids,
show_forwarding_stats,
show_minmax_htlc,
show_disabled,
)
console.print(table)