Browse Source

guis: reintroduce suggest button

patch-4
bitromortac 4 years ago
parent
commit
085056532c
No known key found for this signature in database GPG Key ID: 1965063FC13BEBE2
  1. 17
      electrum/gui/kivy/uix/dialogs/lightning_open_channel.py
  2. 22
      electrum/gui/qt/channels_list.py

17
electrum/gui/kivy/uix/dialogs/lightning_open_channel.py

@ -71,6 +71,11 @@ Builder.load_string('''
size_hint: 0.5, None
height: '48dp'
on_release: app.scan_qr(on_complete=s.on_qr)
Button:
text: _('Suggest')
size_hint: 1, None
height: '48dp'
on_release: s.suggest_node()
Button:
text: _('Clear')
size_hint: 1, None
@ -97,6 +102,18 @@ class LightningOpenChannelDialog(Factory.Popup, Logger):
d = LabelDialog(_('IP/port in format:\n[host]:[port]'), self.ipport, callback)
d.open()
def suggest_node(self):
self.app.wallet.network.start_gossip()
suggested = self.app.wallet.lnworker.lnrater.suggest_peer()
_, _, percent = self.app.wallet.network.lngossip.get_sync_progress_estimate()
if suggested:
self.pubkey = suggested.hex()
else:
if percent is None:
percent = "??"
self.pubkey = f"Please wait, graph is updating ({percent}% / 30% done)."
def __init__(self, app, lnaddr=None, msg=None):
Factory.Popup.__init__(self)
Logger.__init__(self)

22
electrum/gui/qt/channels_list.py

@ -356,8 +356,20 @@ class ChannelsList(MyTreeView):
max_button = EnterButton(_("Max"), spend_max)
max_button.setFixedWidth(100)
max_button.setCheckable(True)
suggest_button = QPushButton(d, text=_('Suggest Peer'))
def on_suggest():
self.parent.wallet.network.start_gossip()
nodeid = bh2u(lnworker.lnrater.suggest_peer() or b'')
if not nodeid:
remote_nodeid.setText(
"Please wait until the graph is synchronized to 30%.")
else:
remote_nodeid.setText(nodeid)
remote_nodeid.repaint() # macOS hack for #6269
suggest_button.clicked.connect(on_suggest)
clear_button = QPushButton(d, text=_('Clear'))
clear_button.setFixedWidth(100)
def on_clear():
amount_e.setText('')
amount_e.setFrozen(False)
@ -367,16 +379,16 @@ class ChannelsList(MyTreeView):
max_button.setChecked(False)
max_button.repaint() # macOS hack for #6269
clear_button.clicked.connect(on_clear)
h = QGridLayout()
h.addWidget(QLabel(_('Your Node ID')), 0, 0)
h.addWidget(local_nodeid, 0, 1, 1, 4)
h.addWidget(local_nodeid, 0, 1, 1, 3)
h.addWidget(QLabel(_('Remote Node ID')), 1, 0)
h.addWidget(remote_nodeid, 1, 1, 1, 4)
h.addWidget(remote_nodeid, 1, 1, 1, 3)
h.addWidget(suggest_button, 2, 1)
h.addWidget(clear_button, 2, 2)
h.addWidget(QLabel('Amount'), 3, 0)
h.addWidget(amount_e, 3, 1)
h.addWidget(max_button, 3, 2)
h.addWidget(clear_button, 3, 3)
vbox.addLayout(h)
ok_button = OkButton(d)
ok_button.setDefault(True)

Loading…
Cancel
Save