Skip to content

Commit f045b1c

Browse files
committed
Various updates
1 parent 4b2e6b3 commit f045b1c

8 files changed

+50
-18
lines changed

auto_policy.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,5 +62,8 @@ def update(self):
6262
base_fee_msat=int(self.policy3['base_fee']),
6363
fee_rate=float(self.policy3['fee_rate']),
6464
time_lock_delta=int(sc.default_time_lock_delta))
65+
66+
lightning_channel.Channels.read_channels()
6567
UpdateScheduler.trigger('channel_info_widget')
68+
6669
print('auto_policy exit: ' + str(datetime.now()))

balance_info_widget.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ def __init__(self):
164164
self.formLayout_5.setWidget(0, QtWidgets.QFormLayout.FieldRole, self.ratio_label)
165165

166166
# register the balance info widget update function, don't start a timer, but run it once
167-
UpdateScheduler.register('balance_info_widget', self.update, start=False, immediate=True)
167+
UpdateScheduler.register('balance_info_widget', self.update, start=True, immediate=True)
168168
self.show()
169169

170170
def update(self):

channel_info_widget.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -527,6 +527,7 @@ def update(self, channel_id=None):
527527
return
528528

529529
self.forwarding_events = FwdingEvents()
530+
x = self.forwarding_events.total_amt_forwarded()
530531
channel = lightning_channel.Channels.channel_index[self.channel_id][0]
531532
if channel.channel_state == lightning_channel.Channel.ChannelState.ACTIVE:
532533
self.reconnect_push_button.hide()
@@ -579,7 +580,6 @@ def update(self, channel_id=None):
579580
except urllib.error.URLError:
580581
self.date_created_label.setText('Unable to determine')
581582

582-
583583
def reconnect_channel(self, event):
584584
try:
585585
channel = lightning_channel.Channels.channel_index[self.channel_id][0]

conductor.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,8 @@
2929
from PyQt5 import QtCore, QtWidgets, QtGui
3030

3131
# TODO 2: Add some basic exception handling
32-
# TODO 3: Add channel policy update window - global, node, based on ratio local and remote balance
3332
# TODO 4: Add overview of inactive channels - toggle between node colours and green (active) red (inactive) nodes
34-
# TODO 5: Add auto refresh every hour
35-
# TODO 6: Add auto close after certain period of inactivity
33+
# TODO 6: Add auto close channel after certain period of inactivity
3634

3735

3836
class MainWindow(QtWidgets.QMainWindow):

config/conductor.conf

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,15 @@ policy1_fee_rate = 0.000001
2626
# in the case below if the local balance is between 4 times smaller and 4 times larger
2727
# policy 2 will be set (2500 msat)
2828
policy2_perc = 0.25
29-
policy2_base_fee = 2500
30-
policy2_fee_rate = 0.000001
29+
policy2_base_fee = 1000
30+
policy2_fee_rate = 0.002500
3131

3232
#else
3333
# in all other cases policy three will be used (5000 msat)
3434
# so if if the local balance is more than 4 times smaller in this case
3535
policy3_perc = 0
36-
policy3_base_fee = 5000
37-
policy3_fee_rate = 0.000001
36+
policy3_base_fee = 1000
37+
policy3_fee_rate = 0.005
3838

3939
# the automatic policy update is run from the start and run every 2 hours when option is set to True
4040
auto_policy = True

lightning/fwding_event.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,3 +57,16 @@ def get_date_last_forward(self, chan_id):
5757
and timestamp < forwarding_event.timestamp:
5858
timestamp = forwarding_event.timestamp
5959
return timestamp
60+
61+
def total_amt_forwarded(self):
62+
tot_amt_fwd = 0
63+
for fwe in self.forwarding_events:
64+
tot_amt_fwd += fwe.amt_in
65+
return tot_amt_fwd
66+
67+
def total_fees_received(self):
68+
tot_fees_received = 0
69+
for fwe in self.forwarding_events:
70+
tot_fees_received += fwe.amt_in
71+
tot_fees_received -= fwe.amt_out
72+
return tot_fees_received

lightning/lightning_channel.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616

1717
import ipaddress
18+
from datetime import datetime
1819
from utils.block_explorer import get_block_data
1920
from lightning import lndAL
2021
from lightning.fee_report import FeeReport
@@ -102,17 +103,20 @@ def __init__(self, channel):
102103
super(Channel, self).__init__(channel)
103104
self.channel_type = "channel"
104105
self.chan_id = channel.chan_id
106+
self._creation_date = None
105107

106108
def update_channel(self, channel):
107109
self.chan_id = channel.chan_id
108110

109111
@property
110112
def creation_date(self):
111-
channel_id_bytes = hex(self.chan_id)[2:]
112-
while len(channel_id_bytes) < 16:
113-
channel_id_bytes = '0' + channel_id_bytes
114-
data = get_block_data(int(channel_id_bytes[:6], 16))
115-
return data['timestamp']
113+
if self._creation_date is None:
114+
channel_id_bytes = hex(self.chan_id)[2:]
115+
while len(channel_id_bytes) < 16:
116+
channel_id_bytes = '0' + channel_id_bytes
117+
data = get_block_data(int(channel_id_bytes[:6], 16))
118+
self._creation_date = data['timestamp']
119+
return self._creation_date
116120

117121
def __eq__(self, other):
118122
return self.chan_id == other.chan_id
@@ -253,12 +257,14 @@ def read_channels(mode=ReadMode.OPEN_ONLY):
253257
# reads the open and closed channels
254258
# re-creates the channel list with the current state
255259
# Also the routing policy is cleared
260+
print('read_channels entry: ' + str(datetime.now()))
256261
RoutingPolicy.clear_graph()
257262
Channels.channel_index = defaultdict(list)
258263
if mode == Channels.ReadMode.OPEN_ONLY or mode == Channels.ReadMode.BOTH:
259264
Channels._read_open_channels()
260265
if mode == Channels.ReadMode.CLOSED_ONLY or mode == Channels.ReadMode.BOTH:
261266
Channels._read_closed_channels()
267+
print('read_channels exit: ' + str(datetime.now()))
262268

263269
@staticmethod
264270
def _read_open_channels():

lightning/lndAL.py

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,19 @@ class LightningException(Exception):
3737
debug_error_string = "{"created":"@1543505526.607347974","description":"Error received from peer","file":"src/core/lib/surface/call.cc","file_line":1017,"grpc_message":"unknown service lnrpc.Lightning","grpc_status":12}"
3838
3939
grpc._channel._Rendezvous: <_Rendezvous of RPC that terminated with:
40-
status = StatusCode.UNAVAILABLE
41-
details = "Connect Failed"
42-
debug_error_string = "{"created":"@1543670679.735250331","description":"Failed to create subchannel","file":"src/core/ext/filters/client_channel/client_channel.cc","file_line":2721,"referenced_errors":[{"created":"@1543670679.735240549","description":"Pick Cancelled","file":"src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc","file_line":241,"referenced_errors":[{"created":"@1543670679.735022159","description":"Connect Failed","file":"src/core/ext/filters/client_channel/subchannel.cc","file_line":689,"grpc_status":14,"referenced_errors":[{"created":"@1543670679.734841131","description":"Handshake read failed","file":"src/core/lib/security/transport/security_handshaker.cc","file_line":321,"referenced_errors":[{"created":"@1543670679.734745641","description":"FD Shutdown","file":"src/core/lib/iomgr/lockfree_event.cc","file_line":194,"referenced_errors":[{"created":"@1543670679.734720568","description":"Handshake timed out","file":"src/core/lib/channel/handshaker.cc","file_line":290}]}]}]}]}]}"
40+
status = StatusCode.UNKNOWN
41+
details = "peer 0321ad07ca4a3e590830ea835844820ea08b0e8d2e7dbdc32aa98e801ab9fd862e is not online"
42+
debug_error_string = "{"created":"@1547324967.579864705","description":"Error received from peer","file":"src/core/lib/surface/call.cc","file_line":1017,"grpc_message":"peer 0321ad07ca4a3e590830ea835844820ea08b0e8d2e7dbdc32aa98e801ab9fd862e is not online","grpc_status":2}"
43+
44+
grpc._channel._Rendezvous: <_Rendezvous of RPC that terminated with:
45+
status = StatusCode.UNKNOWN
46+
details = "not enough witness outputs to create funding transaction, need 0.01 BTC only have 0.00004855 BTC available"
47+
debug_error_string = "{"created":"@1547325316.221901640","description":"Error received from peer","file":"src/core/lib/surface/call.cc","file_line":1017,"grpc_message":"not enough witness outputs to create funding transaction, need 0.01 BTC only have 0.00004855 BTC available","grpc_status":2}"
48+
49+
grpc._channel._Rendezvous: <_Rendezvous of RPC that terminated with:
50+
status = StatusCode.UNKNOWN
51+
details = "no policy for outgoing channel 613822157507592192 "
52+
debug_error_string = "{"created":"@1547327609.724794018","description":"Error received from peer","file":"src/core/lib/surface/call.cc","file_line":1017,"grpc_message":"no policy for outgoing channel 613822157507592192 ","grpc_status":2}"
4353
4454
'''
4555
pass
@@ -52,7 +62,9 @@ def get_rpc_data():
5262
os.environ['GRPC_SSL_CIPHER_SUITES'] = 'HIGH+ECDSA'
5363
cert = open(system_config.tls_cert_directory + '/tls.cert', 'rb').read()
5464
ssl_creds = grpc.ssl_channel_credentials(cert)
55-
channel = grpc.secure_channel(system_config.lnd_rpc_address + ':' + system_config.lnd_rpc_port, ssl_creds)
65+
channel = grpc.secure_channel(system_config.lnd_rpc_address + ':' + system_config.lnd_rpc_port, ssl_creds,
66+
options=[('grpc.max_send_message_length', 8000000),
67+
('grpc.max_receive_message_length', 8000000)])
5668
LndAL._stub = lnrpc.LightningStub(channel)
5769

5870
@staticmethod

0 commit comments

Comments
 (0)