electrum

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

commit 1323bd4f9cbf5e87b5d6eb03216d8fc6e331954b
parent 01ed5e7345ba2c0960b2cea6aa2aed2a942a2495
Author: ThomasV <thomasv@electrum.org>
Date:   Mon, 15 Feb 2021 16:47:42 +0100

open_channel_coroutine: do not timeout on sign_transaction. fixes #7027

Diffstat:
Melectrum/lnpeer.py | 7+++----
Melectrum/lnworker.py | 25+++++++++++++------------
2 files changed, 16 insertions(+), 16 deletions(-)

diff --git a/electrum/lnpeer.py b/electrum/lnpeer.py @@ -563,7 +563,6 @@ class Peer(Logger): @temporarily_reserve_funding_tx_change_address async def channel_establishment_flow( self, *, - password: Optional[str], funding_tx: 'PartialTransaction', funding_sat: int, push_msat: int, @@ -578,6 +577,7 @@ class Peer(Logger): Channel configurations are initialized in this method. """ + # will raise if init fails await asyncio.wait_for(self.initialized, LN_P2P_NETWORK_TIMEOUT) feerate = self.lnworker.current_feerate_per_kw() @@ -675,9 +675,8 @@ class Peer(Logger): funding_tx.outputs().remove(dummy_output) funding_tx.add_outputs([funding_output]) funding_tx.set_rbf(False) - self.lnworker.wallet.sign_transaction(funding_tx, password) - if not funding_tx.is_complete() and not funding_tx.is_segwit(): - raise Exception('Funding transaction is not complete') + if not funding_tx.is_segwit(): + raise Exception('Funding transaction is not segwit') funding_txid = funding_tx.txid() assert funding_txid funding_index = funding_tx.outputs().index(funding_output) diff --git a/electrum/lnworker.py b/electrum/lnworker.py @@ -861,20 +861,21 @@ class LNWallet(LNWorker): await self.network.try_broadcasting(force_close_tx, 'force-close') @log_exceptions - async def _open_channel_coroutine(self, *, connect_str: str, funding_tx: PartialTransaction, - funding_sat: int, push_sat: int, - password: Optional[str]) -> Tuple[Channel, PartialTransaction]: + async def _open_channel_coroutine( + self, *, connect_str: str, + funding_tx: PartialTransaction, + funding_sat: int, push_sat: int, + password: Optional[str]) -> Tuple[Channel, PartialTransaction]: peer = await self.add_peer(connect_str) - # will raise if init fails - await asyncio.wait_for(peer.initialized, LN_P2P_NETWORK_TIMEOUT) - chan, funding_tx = await peer.channel_establishment_flow( - password=password, + coro = peer.channel_establishment_flow( funding_tx=funding_tx, funding_sat=funding_sat, push_msat=push_sat * 1000, temp_channel_id=os.urandom(32)) + chan, funding_tx = await asyncio.wait_for(coro, LN_P2P_NETWORK_TIMEOUT) util.trigger_callback('channels_updated', self.wallet) self.wallet.add_transaction(funding_tx) # save tx as local into the wallet + self.wallet.sign_transaction(funding_tx, password) self.wallet.set_label(funding_tx.txid(), _('Open channel')) if funding_tx.is_complete(): await self.network.try_broadcasting(funding_tx, 'open_channel') @@ -911,15 +912,15 @@ class LNWallet(LNWorker): return tx 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]: + funding_sat: int, push_amt_sat: int, password: str = None) -> Tuple[Channel, PartialTransaction]: 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) + 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) try: - chan, funding_tx = fut.result(timeout=timeout) + chan, funding_tx = fut.result() except concurrent.futures.TimeoutError: raise Exception(_("open_channel timed out")) # at this point the channel opening was successful