Browse Source

do not block GUI with open_channel

dependabot/pip/contrib/deterministic-build/ecdsa-0.13.3
ThomasV 7 years ago
parent
commit
6e71340e52
  1. 3
      electrum/commands.py
  2. 6
      gui/qt/channels_list.py
  3. 1
      lib/lnbase.py
  4. 3
      lib/lnworker.py
  5. 4
      lib/tests/test_lnbase.py

3
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):

6
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))

1
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

3
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)

4
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

Loading…
Cancel
Save