mirror of
https://github.com/StijnBTC/Ringtools.git
synced 2025-02-28 07:54:09 +01:00
Fee output added to overview when using -f flag
This commit is contained in:
parent
4c92ebb47a
commit
eeee55b19d
3 changed files with 33 additions and 13 deletions
|
@ -2,6 +2,8 @@ import os
|
||||||
import sys
|
import sys
|
||||||
from yachalk import chalk
|
from yachalk import chalk
|
||||||
|
|
||||||
|
ALIAS_LENGTH = 32
|
||||||
|
|
||||||
|
|
||||||
class Output:
|
class Output:
|
||||||
def __init__(self, lnd):
|
def __init__(self, lnd):
|
||||||
|
@ -26,8 +28,11 @@ def format_error(error):
|
||||||
return chalk.red(error)
|
return chalk.red(error)
|
||||||
|
|
||||||
|
|
||||||
def format_channel(channel_id, node1_alias, node2_alias, chanDisabled):
|
def format_channel(channel, node1_alias, node2_alias, chanDisabled, show_fees):
|
||||||
text = f'{channel_id:<18} {format_alias(node1_alias):<32} {format_alias(node2_alias):<32}'
|
text = f'{channel.channel_id:<18} {format_alias(node1_alias):<40} {format_alias(node2_alias):<40}'
|
||||||
|
if show_fees:
|
||||||
|
text += f'base {channel.node1_policy.fee_base_msat:<5} rate {channel.node1_policy.fee_rate_milli_msat:<5} '\
|
||||||
|
f'base {channel.node2_policy.fee_base_msat:<5} rate {channel.node2_policy.fee_rate_milli_msat:<5} '
|
||||||
if chanDisabled:
|
if chanDisabled:
|
||||||
return chalk.bg_red(text)
|
return chalk.bg_red(text)
|
||||||
else:
|
else:
|
||||||
|
|
24
ringtools.py
24
ringtools.py
|
@ -13,9 +13,12 @@ class RingTools:
|
||||||
self.arguments = arguments
|
self.arguments = arguments
|
||||||
|
|
||||||
def start(self):
|
def start(self):
|
||||||
print(self.arguments.function)
|
|
||||||
if self.arguments.function == "status":
|
if self.arguments.function == "status":
|
||||||
Status(self.lnd, self.output, self.arguments.channels_file, self.arguments.loop).run()
|
Status(self.lnd,
|
||||||
|
self.output,
|
||||||
|
self.arguments.channels_file,
|
||||||
|
self.arguments.loop,
|
||||||
|
self.arguments.show_fees).run()
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
@ -28,6 +31,13 @@ def main():
|
||||||
def get_argument_parser():
|
def get_argument_parser():
|
||||||
parser = argparse.ArgumentParser()
|
parser = argparse.ArgumentParser()
|
||||||
# This is needed for the cert and macaroon of LND
|
# This is needed for the cert and macaroon of LND
|
||||||
|
parser.add_argument(
|
||||||
|
dest="function",
|
||||||
|
choices=['status'],
|
||||||
|
help="Choose which function of the RingTools you would "
|
||||||
|
"like to use",
|
||||||
|
default="help",
|
||||||
|
)
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"--lnddir",
|
"--lnddir",
|
||||||
default="~/.lnd",
|
default="~/.lnd",
|
||||||
|
@ -40,14 +50,13 @@ def get_argument_parser():
|
||||||
dest="grpc",
|
dest="grpc",
|
||||||
help="(default localhost:10009) lnd gRPC endpoint",
|
help="(default localhost:10009) lnd gRPC endpoint",
|
||||||
)
|
)
|
||||||
parser.add_argument(dest="function", choices=['status'])
|
|
||||||
status_group = parser.add_argument_group(
|
status_group = parser.add_argument_group(
|
||||||
"status",
|
"status",
|
||||||
"Get the current status of all channels",
|
"Get the current status of all channels",
|
||||||
)
|
)
|
||||||
status_group.add_argument(
|
status_group.add_argument(
|
||||||
"-channels-file",
|
"-channels-file",
|
||||||
"-f",
|
"-c",
|
||||||
default="./channels.txt",
|
default="./channels.txt",
|
||||||
dest="channels_file",
|
dest="channels_file",
|
||||||
help="(default ./channels.txt) channels file"
|
help="(default ./channels.txt) channels file"
|
||||||
|
@ -59,6 +68,13 @@ def get_argument_parser():
|
||||||
dest="loop",
|
dest="loop",
|
||||||
help="(default False) Keeps checking channel status"
|
help="(default False) Keeps checking channel status"
|
||||||
)
|
)
|
||||||
|
status_group.add_argument(
|
||||||
|
'-f',
|
||||||
|
'--show-fees',
|
||||||
|
action="store_true",
|
||||||
|
dest="show_fees",
|
||||||
|
help="(default False) Shows fees in status screen"
|
||||||
|
)
|
||||||
return parser
|
return parser
|
||||||
|
|
||||||
|
|
||||||
|
|
13
status.py
13
status.py
|
@ -1,19 +1,18 @@
|
||||||
import os
|
import os
|
||||||
import re
|
|
||||||
from time import sleep
|
from time import sleep
|
||||||
|
|
||||||
from output import format_error, Output, format_alias, clear_screen, format_channel
|
from output import format_error, clear_screen, format_channel
|
||||||
|
|
||||||
LOOP_SLEEP_TIME = 10
|
LOOP_SLEEP_TIME = 10
|
||||||
|
|
||||||
|
|
||||||
class Status:
|
class Status:
|
||||||
def __init__(self, lnd, output, channels_file, keep_loop):
|
def __init__(self, lnd, output, channels_file, keep_loop, show_fees):
|
||||||
self.lnd = lnd
|
self.lnd = lnd
|
||||||
self.output = output
|
self.output = output
|
||||||
self.channels_file = channels_file
|
self.channels_file = channels_file
|
||||||
self.keep_loop = keep_loop
|
self.keep_loop = keep_loop
|
||||||
print(channels_file)
|
self.show_fees = show_fees
|
||||||
|
|
||||||
def read_file(self, file):
|
def read_file(self, file):
|
||||||
if not os.path.isfile(file):
|
if not os.path.isfile(file):
|
||||||
|
@ -41,10 +40,10 @@ class Status:
|
||||||
node1 = self.lnd.get_node(response.node1_pub)
|
node1 = self.lnd.get_node(response.node1_pub)
|
||||||
node2 = self.lnd.get_node(response.node2_pub)
|
node2 = self.lnd.get_node(response.node2_pub)
|
||||||
disabled = response.node1_policy.disabled or response.node2_policy.disabled
|
disabled = response.node1_policy.disabled or response.node2_policy.disabled
|
||||||
self.print_channel(response.channel_id, node1.alias, node2.alias, disabled)
|
self.print_channel(response, node1.alias, node2.alias, disabled)
|
||||||
|
|
||||||
def print_channel(self, channel_id, node1_alias, node2_alias, chan_disabled):
|
def print_channel(self, channel, node1_alias, node2_alias, chan_disabled):
|
||||||
self.output.print_line(format_channel(channel_id, node1_alias, node2_alias, chan_disabled))
|
self.output.print_line(format_channel(channel, node1_alias, node2_alias, chan_disabled, self.show_fees))
|
||||||
|
|
||||||
def handle_error(self, error):
|
def handle_error(self, error):
|
||||||
self.output.print_line(format_error(error))
|
self.output.print_line(format_error(error))
|
||||||
|
|
Loading…
Add table
Reference in a new issue