electrum

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

commit 6e71340e526bf5bbc0807419ea641ffefd3ac933
parent 40fcf58fec376d6b6f9c301f2186093e93c553f8
Author: ThomasV <thomasv@electrum.org>
Date:   Fri,  8 Jun 2018 12:53:35 +0200

do not block GUI with open_channel

Diffstat:
Melectrum/commands.py | 3++-
Mgui/qt/channels_list.py | 6+++---
Mlib/lnbase.py | 1-
Mlib/lnworker.py | 3+--
Mlib/tests/test_lnbase.py | 4++--
5 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/electrum/commands.py b/electrum/commands.py @@ -766,7 +766,8 @@ class Commands: # lightning network commands @command('wpn') def open_channel(self, node_id, amount, channel_push=0, password=None): - self.wallet.lnworker.open_channel(node_id, satoshis(amount), satoshis(channel_push), password) + f = self.wallet.lnworker.open_channel(node_id, satoshis(amount), satoshis(channel_push), password) + return f.result() @command('wn') def reestablish_channel(self): diff --git a/gui/qt/channels_list.py b/gui/qt/channels_list.py @@ -26,10 +26,10 @@ class ChannelsList(MyTreeWidget): def create_menu(self, position): menu = QtWidgets.QMenu() - cur = self.currentItem() - print('ID', bh2u(cur.data(0, QtCore.Qt.UserRole))) + channel_id = self.currentItem().data(0, QtCore.Qt.UserRole) + print('ID', bh2u(channel_id)) def close(): - print("closechannel result", self.parent.wallet.lnworker.close_channel_from_other_thread(cur.di)) + self.parent.wallet.lnworker.close_channel(channel_id) menu.addAction(_("Close channel"), close) menu.exec_(self.viewport().mapToGlobal(position)) diff --git a/lib/lnbase.py b/lib/lnbase.py @@ -582,7 +582,6 @@ class Peer(PrintError): self.privkey = lnworker.privkey self.network = lnworker.network self.channel_db = lnworker.channel_db - self.path_finder = lnworker.path_finder self.channel_state = lnworker.channel_state self.read_buffer = b'' self.ping_time = 0 diff --git a/lib/lnworker.py b/lib/lnworker.py @@ -180,8 +180,7 @@ class LNWorker(PrintError): def open_channel(self, node_id, local_amt_sat, push_amt_sat, pw): coro = self._open_channel_coroutine(node_id, local_amt_sat, push_amt_sat, None if pw == "" else pw) - # FIXME this is blocking the GUI - return asyncio.run_coroutine_threadsafe(coro, self.network.asyncio_loop).result() + return asyncio.run_coroutine_threadsafe(coro, self.network.asyncio_loop) def pay(self, invoice): addr = lndecode(invoice, expected_hrp=constants.net.SEGWIT_HRP) diff --git a/lib/tests/test_lnbase.py b/lib/tests/test_lnbase.py @@ -5,8 +5,8 @@ import unittest from lib.util import bh2u, bfh from lib.lnbase import make_commitment, get_obscured_ctn, Peer, make_offered_htlc, make_received_htlc, make_htlc_tx from lib.lnbase import secret_to_pubkey, derive_pubkey, derive_privkey, derive_blinded_pubkey, overall_weight -from lib.lnbase import make_htlc_tx_output, make_htlc_tx_inputs, get_per_commitment_secret_from_seed -from lib.lnbase import make_htlc_tx_witness, OnionHopsDataSingle, new_onion_packet, OnionPerHop +from lib.lnbase import make_htlc_tx_output, make_htlc_tx_inputs, get_per_commitment_secret_from_seed, make_htlc_tx_witness +from lib.lnrouter import OnionHopsDataSingle, new_onion_packet, OnionPerHop from lib.lnbase import RevocationStore from lib.transaction import Transaction from lib import bitcoin