mirror of
https://github.com/LBRYFoundation/LBRY-Vault.git
synced 2025-08-27 23:41:35 +00:00
qt: fix password passed to open_channel, cleanup
This commit is contained in:
parent
9ff68501e3
commit
86972cc9e2
3 changed files with 14 additions and 17 deletions
|
@ -1490,6 +1490,10 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, PrintError):
|
|||
return func(self, *args, **kwargs)
|
||||
return request_password
|
||||
|
||||
@protected
|
||||
def protect(self, func, args, password):
|
||||
return func(*args, password)
|
||||
|
||||
def is_send_fee_frozen(self):
|
||||
return self.fee_e.isVisible() and self.fee_e.isModified() \
|
||||
and (self.fee_e.text() or self.fee_e.hasFocus())
|
||||
|
|
|
@ -33,21 +33,19 @@ def addChannelRow(new):
|
|||
datatable.move_to_end(new["chan_id"], last=False)
|
||||
return made
|
||||
|
||||
|
||||
class LightningChannelsList(QtWidgets.QWidget):
|
||||
update_rows = QtCore.pyqtSignal(dict)
|
||||
update_single_row = QtCore.pyqtSignal(dict)
|
||||
|
||||
def clickHandler(self, nodeIdInput, local_amt_inp, push_amt_inp, lnworker):
|
||||
nodeId = nodeIdInput.text()
|
||||
print("creating channel with connstr {}".format(nodeId))
|
||||
def open_channel(self, nodeIdInput, local_amt_inp, push_amt_inp, password):
|
||||
node_id = str(nodeIdInput.text())
|
||||
print("creating channel with {}".format(node_id))
|
||||
local_amt = int(local_amt_inp.text())
|
||||
try:
|
||||
push_amt = int(push_amt_inp.text())
|
||||
except ValueError:
|
||||
push_amt = 0
|
||||
push_amt = int(push_amt_inp.text())
|
||||
assert local_amt >= 200000
|
||||
assert local_amt >= push_amt
|
||||
obj = lnworker.open_channel_from_other_thread(node_id=str(nodeId), local_amt=local_amt, push_amt=push_amt, emit_function=self.update_rows.emit, get_password=self.main_window.password_dialog)
|
||||
obj = self.lnworker.open_channel_from_other_thread(node_id, local_amt, push_amt, self.update_rows.emit, password)
|
||||
|
||||
@QtCore.pyqtSlot(dict)
|
||||
def do_update_single_row(self, new):
|
||||
|
@ -95,11 +93,10 @@ class LightningChannelsList(QtWidgets.QWidget):
|
|||
self._tv.customContextMenuRequested.connect(self.create_menu)
|
||||
|
||||
nodeid_inp = QtWidgets.QLineEdit(self)
|
||||
local_amt_inp = QtWidgets.QLineEdit(self)
|
||||
push_amt_inp = QtWidgets.QLineEdit(self)
|
||||
|
||||
local_amt_inp = QtWidgets.QLineEdit(self, text='200000')
|
||||
push_amt_inp = QtWidgets.QLineEdit(self, text='0')
|
||||
button = QtWidgets.QPushButton('Open channel', self)
|
||||
button.clicked.connect(lambda: self.clickHandler(nodeid_inp, local_amt_inp, push_amt_inp, lnworker))
|
||||
button.clicked.connect(lambda: self.main_window.protect(self.open_channel, (nodeid_inp, local_amt_inp, push_amt_inp)))
|
||||
|
||||
l=QtWidgets.QVBoxLayout(self)
|
||||
h=QtWidgets.QGridLayout(self)
|
||||
|
|
|
@ -1394,11 +1394,7 @@ class LNWorker:
|
|||
coro = peer.channel_establishment_flow(self.wallet, self.config, password, amount, push_msat, temp_channel_id=os.urandom(32))
|
||||
return asyncio.run_coroutine_threadsafe(coro, self.network.asyncio_loop)
|
||||
|
||||
def open_channel_from_other_thread(self, node_id, local_amt, push_amt, emit_function, get_password):
|
||||
pw = get_password()
|
||||
if pw is None:
|
||||
# user pressed cancel
|
||||
return
|
||||
def open_channel_from_other_thread(self, node_id, local_amt, push_amt, emit_function, pw):
|
||||
# TODO this could race on peers
|
||||
peer = self.peers.get(node_id)
|
||||
if peer is None:
|
||||
|
|
Loading…
Add table
Reference in a new issue