tkivy: fix open_channel (API was changed) - electrum - Electrum Bitcoin wallet HTML git clone https://git.parazyd.org/electrum DIR Log DIR Files DIR Refs DIR Submodules --- DIR commit ddeb176b3da0c4fcbb6cf2b8d85dd319e2a2bf56 DIR parent 557987d4ebfca40902e741254734f13e9150f1d9 HTML Author: SomberNight <somber.night@protonmail.com> Date: Sat, 23 Nov 2019 20:50:30 +0100 kivy: fix open_channel (API was changed) Diffstat: M electrum/gui/kivy/uix/dialogs/ligh… | 4 ++++ M electrum/gui/qt/main_window.py | 4 +++- M electrum/lnworker.py | 8 +++++--- 3 files changed, 12 insertions(+), 4 deletions(-) --- DIR diff --git a/electrum/gui/kivy/uix/dialogs/lightning_open_channel.py b/electrum/gui/kivy/uix/dialogs/lightning_open_channel.py t@@ -133,6 +133,7 @@ class LightningOpenChannelDialog(Factory.Popup): def on_qr(self, conn_str): self.pubkey = conn_str + # FIXME "max" button in amount_dialog should enforce LN_MAX_FUNDING_SAT def open_channel(self): if not self.pubkey or not self.amount: self.app.show_info(_('All fields must be filled out')) t@@ -145,8 +146,11 @@ class LightningOpenChannelDialog(Factory.Popup): self.dismiss() def do_open_channel(self, conn_str, amount, password): + coins = self.app.wallet.get_spendable_coins(None, nonlocal_only=True) + funding_tx = self.app.wallet.lnworker.mktx_for_open_channel(coins=coins, funding_sat=amount) try: chan, funding_tx = self.app.wallet.lnworker.open_channel(connect_str=conn_str, + funding_tx=funding_tx, funding_sat=amount, push_amt_sat=0, password=password) DIR diff --git a/electrum/gui/qt/main_window.py b/electrum/gui/qt/main_window.py t@@ -1618,7 +1618,9 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, Logger): def mktx_for_open_channel(self, funding_sat): coins = self.get_coins(nonlocal_only=True) - make_tx = partial(self.wallet.lnworker.mktx_for_open_channel, coins, funding_sat) + make_tx = lambda fee_est: self.wallet.lnworker.mktx_for_open_channel(coins=coins, + funding_sat=funding_sat, + fee_est=fee_est) return make_tx def open_channel(self, connect_str, funding_sat, push_amt): DIR diff --git a/electrum/lnworker.py b/electrum/lnworker.py t@@ -53,7 +53,7 @@ from .lnutil import (Outpoint, LNPeerAddr, UpdateAddHtlc, Direction, LnLocalFeatures, format_short_channel_id, ShortChannelID) from .lnutil import ln_dummy_address -from .transaction import PartialTxOutput, PartialTransaction +from .transaction import PartialTxOutput, PartialTransaction, PartialTxInput from .lnonion import OnionFailureCode from .lnmsg import decode_msg from .i18n import _ t@@ -848,7 +848,8 @@ class LNWallet(LNWorker): peer = await self._add_peer(host, port, node_id) return peer - def mktx_for_open_channel(self, coins, funding_sat, fee_est): + def mktx_for_open_channel(self, *, coins: Sequence[PartialTxInput], funding_sat: int, + fee_est=None) -> PartialTransaction: dummy_address = ln_dummy_address() outputs = [PartialTxOutput.from_address_and_value(dummy_address, funding_sat)] tx = self.wallet.make_unsigned_transaction( t@@ -861,7 +862,8 @@ class LNWallet(LNWorker): def open_channel(self, *, connect_str: str, funding_tx: PartialTransaction, funding_sat: int, push_amt_sat: int, password: str = None, timeout: Optional[int] = 20) -> Tuple[Channel, PartialTransaction]: - assert funding_sat <= LN_MAX_FUNDING_SAT + if funding_sat > LN_MAX_FUNDING_SAT: + raise Exception(_("Requested channel capacity is over protocol allowed maximum.")) coro = self._open_channel_coroutine(connect_str=connect_str, funding_tx=funding_tx, funding_sat=funding_sat, push_sat=push_amt_sat, password=password) fut = asyncio.run_coroutine_threadsafe(coro, self.network.asyncio_loop)