electrum

Electrum Bitcoin wallet
git clone https://git.parazyd.org/electrum
Log | Files | Refs | Submodules

commit 5a819611c8e5492d08ca8a97b3810009e823b560
parent 6ac15962dc2629729ab9d28b8cdd7991c7f07268
Author: ThomasV <thomasv@electrum.org>
Date:   Fri, 25 May 2018 11:08:48 +0200

qt: fix password passed to open_channel, cleanup

Diffstat:
Melectrum/gui/qt/main_window.py | 4++++
Mgui/qt/lightning_channels_list.py | 21+++++++++------------
Mlib/lnbase.py | 6+-----
3 files changed, 14 insertions(+), 17 deletions(-)

diff --git a/electrum/gui/qt/main_window.py b/electrum/gui/qt/main_window.py @@ -1582,6 +1582,10 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, Logger): 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()) diff --git a/gui/qt/lightning_channels_list.py b/gui/qt/lightning_channels_list.py @@ -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) diff --git a/lib/lnbase.py b/lib/lnbase.py @@ -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: