tnew network API: use broadcast_transaction with run_from_other_thread - electrum - Electrum Bitcoin wallet HTML git clone https://git.parazyd.org/electrum DIR Log DIR Files DIR Refs DIR Submodules --- DIR commit 139f773c2e199f9b5c71f3450811acfa81918d13 DIR parent 1a7b06b69092fb4955e4cd91f99224b1c1eb6f70 HTML Author: Janus <ysangkok@gmail.com> Date: Tue, 2 Oct 2018 21:13:17 +0200 new network API: use broadcast_transaction with run_from_other_thread Diffstat: M electrum/gui/qt/channels_list.py | 4 +++- M electrum/lnworker.py | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) --- DIR diff --git a/electrum/gui/qt/channels_list.py b/electrum/gui/qt/channels_list.py t@@ -34,7 +34,9 @@ class ChannelsList(MyTreeWidget): channel_id = self.currentItem().data(0, QtCore.Qt.UserRole) print('ID', bh2u(channel_id)) def close(): - suc, msg = self.parent.wallet.lnworker.close_channel(channel_id) + netw = self.parent.network + coro = self.parent.wallet.lnworker.close_channel(channel_id) + suc, msg = netw.run_from_another_thread(coro) if not suc: self.main_window.show_error('Force-close failed:\n{}'.format(msg)) menu.addAction(_("Force-close channel"), close) DIR diff --git a/electrum/lnworker.py b/electrum/lnworker.py t@@ -252,7 +252,7 @@ class LNWorker(PrintError): # we output the funding_outpoint instead of the channel_id because lnd uses channel_point (funding outpoint) to identify channels return [(chan.funding_outpoint.to_str(), chan.get_state()) for channel_id, chan in self.channels.items()] - def close_channel(self, chan_id): + async def close_channel(self, chan_id): chan = self.channels[chan_id] # local_commitment always gives back the next expected local_commitment, # but in this case, we want the current one. So substract one ctn number t@@ -266,7 +266,7 @@ class LNWorker(PrintError): none_idx = tx._inputs[0]["signatures"].index(None) tx.add_signature_to_txin(0, none_idx, bh2u(remote_sig)) assert tx.is_complete() - return self.network.broadcast_transaction_from_non_network_thread(tx) + return await self.network.broadcast_transaction(tx) def _get_next_peers_to_try(self) -> Sequence[LNPeerAddr]: now = time.time()