-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathringtools.py
More file actions
141 lines (123 loc) · 3.68 KB
/
ringtools.py
File metadata and controls
141 lines (123 loc) · 3.68 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
import argparse
import sys
from clightning import CLightning
from lnd import Lnd
from output import Output
from status import Status
from utils import is_umbrel
from checkring import CheckRing
class RingTools:
def __init__(self, arguments):
if (arguments.client == 'cl'):
self.client = CLightning(arguments.clrpc)
else:
self.client = Lnd(arguments.lnddir, arguments.grpc)
self.output = Output(self.client)
self.arguments = arguments
def start(self):
if self.arguments.function == "status":
Status(self.client,
self.output,
self.arguments.channels_file,
self.arguments.loop,
self.arguments.show_fees).run()
elif self.arguments.function == "check":
CheckRing(self.client,
self.output,
self.arguments.pubkeys_file,
self.arguments.write_channels,
self.arguments.show_fees,
self.arguments.channels_file
).run()
pass
def main():
argument_parser = get_argument_parser()
arguments = argument_parser.parse_args()
return RingTools(arguments).start()
def get_argument_parser():
parser = argparse.ArgumentParser()
# This is needed for the cert and macaroon of LND
parser.add_argument(
dest="function",
choices=['status', 'check'],
help="Choose which function of the RingTools you would "
"like to use",
default="help",
)
parser.add_argument(
"--client",
choices=['lnd', 'cl'],
default="lnd",
dest="client",
help="(default: lnd) Which client to use",
)
#If nodeos is Umbrel use the default umbrel lnd location
lnd_dir = "~/.lnd"
if is_umbrel():
lnd_dir = "~/umbrel/lnd"
parser.add_argument(
"--lnddir",
default=lnd_dir,
dest="lnddir",
help="(default ~/.lnd or ~/umbrel/lnd/ when default umbrel installation) lnd directory",
)
parser.add_argument(
"--grpc",
default="localhost:10009",
dest="grpc",
help="(default localhost:10009) lnd gRPC endpoint",
)
parser.add_argument(
"--clrpc",
default="~/.lightning/bitcoin/lightning-rpc",
dest="clrpc",
help="(default ~/.lightning/bitcoin/lightning-rpc) C-Lightning unix-socket",
)
status_group = parser.add_argument_group(
"status",
"Get the current status of all channels",
)
check_group = parser.add_argument_group(
"check",
"Check if channels are open with pubkey list",
)
check_group.add_argument(
"-pubkeys-file",
"-pk",
default="./pubkeys.txt",
dest="pubkeys_file",
help="(default ./pubkeys.txt) pubkeys file"
)
check_group.add_argument(
'-w',
'--write-channels',
action="store_true",
dest="write_channels",
help="(default False) Write channels.txt"
)
status_group.add_argument(
"-channels-file",
"-c",
default="./channels.txt",
dest="channels_file",
help="(default ./channels.txt) channels file"
)
status_group.add_argument(
"-l",
"--loop",
action="store_true",
dest="loop",
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
success = main()
if success:
sys.exit(0)
sys.exit(1)