mirror of
https://github.com/LBRYFoundation/LBRY-Vault.git
synced 2025-08-28 07:51:27 +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 func(self, *args, **kwargs)
|
||||||
return request_password
|
return request_password
|
||||||
|
|
||||||
|
@protected
|
||||||
|
def protect(self, func, args, password):
|
||||||
|
return func(*args, password)
|
||||||
|
|
||||||
def is_send_fee_frozen(self):
|
def is_send_fee_frozen(self):
|
||||||
return self.fee_e.isVisible() and self.fee_e.isModified() \
|
return self.fee_e.isVisible() and self.fee_e.isModified() \
|
||||||
and (self.fee_e.text() or self.fee_e.hasFocus())
|
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)
|
datatable.move_to_end(new["chan_id"], last=False)
|
||||||
return made
|
return made
|
||||||
|
|
||||||
|
|
||||||
class LightningChannelsList(QtWidgets.QWidget):
|
class LightningChannelsList(QtWidgets.QWidget):
|
||||||
update_rows = QtCore.pyqtSignal(dict)
|
update_rows = QtCore.pyqtSignal(dict)
|
||||||
update_single_row = QtCore.pyqtSignal(dict)
|
update_single_row = QtCore.pyqtSignal(dict)
|
||||||
|
|
||||||
def clickHandler(self, nodeIdInput, local_amt_inp, push_amt_inp, lnworker):
|
def open_channel(self, nodeIdInput, local_amt_inp, push_amt_inp, password):
|
||||||
nodeId = nodeIdInput.text()
|
node_id = str(nodeIdInput.text())
|
||||||
print("creating channel with connstr {}".format(nodeId))
|
print("creating channel with {}".format(node_id))
|
||||||
local_amt = int(local_amt_inp.text())
|
local_amt = int(local_amt_inp.text())
|
||||||
try:
|
push_amt = int(push_amt_inp.text())
|
||||||
push_amt = int(push_amt_inp.text())
|
|
||||||
except ValueError:
|
|
||||||
push_amt = 0
|
|
||||||
assert local_amt >= 200000
|
assert local_amt >= 200000
|
||||||
assert local_amt >= push_amt
|
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)
|
@QtCore.pyqtSlot(dict)
|
||||||
def do_update_single_row(self, new):
|
def do_update_single_row(self, new):
|
||||||
|
@ -95,11 +93,10 @@ class LightningChannelsList(QtWidgets.QWidget):
|
||||||
self._tv.customContextMenuRequested.connect(self.create_menu)
|
self._tv.customContextMenuRequested.connect(self.create_menu)
|
||||||
|
|
||||||
nodeid_inp = QtWidgets.QLineEdit(self)
|
nodeid_inp = QtWidgets.QLineEdit(self)
|
||||||
local_amt_inp = QtWidgets.QLineEdit(self)
|
local_amt_inp = QtWidgets.QLineEdit(self, text='200000')
|
||||||
push_amt_inp = QtWidgets.QLineEdit(self)
|
push_amt_inp = QtWidgets.QLineEdit(self, text='0')
|
||||||
|
|
||||||
button = QtWidgets.QPushButton('Open channel', self)
|
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)
|
l=QtWidgets.QVBoxLayout(self)
|
||||||
h=QtWidgets.QGridLayout(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))
|
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)
|
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):
|
def open_channel_from_other_thread(self, node_id, local_amt, push_amt, emit_function, pw):
|
||||||
pw = get_password()
|
|
||||||
if pw is None:
|
|
||||||
# user pressed cancel
|
|
||||||
return
|
|
||||||
# TODO this could race on peers
|
# TODO this could race on peers
|
||||||
peer = self.peers.get(node_id)
|
peer = self.peers.get(node_id)
|
||||||
if peer is None:
|
if peer is None:
|
||||||
|
|
Loading…
Add table
Reference in a new issue