tSet channel state to OPENING as soon as we receive 'funding_signed', instead of when the funding transaction has been broadcast, because we have no reliable way to know when it will be broadcast. - electrum - Electrum Bitcoin wallet
 (HTM) git clone https://git.parazyd.org/electrum
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) Submodules
       ---
 (DIR) commit 34400c0710b2cb2b167e20a49643826565ef36b6
 (DIR) parent d04b8c05e2ed320148a781eee757ab2cada45188
 (HTM) Author: ThomasV <thomasv@electrum.org>
       Date:   Thu, 27 Feb 2020 15:22:22 +0100
       
       Set channel state to OPENING as soon as we receive 'funding_signed',
       instead of when the funding transaction has been broadcast, because
       we have no reliable way to know when it will be broadcast.
       
       Diffstat:
         M electrum/lnchannel.py               |       2 +-
         M electrum/lnpeer.py                  |       2 ++
         M electrum/lnworker.py                |       8 +-------
       
       3 files changed, 4 insertions(+), 8 deletions(-)
       ---
 (DIR) diff --git a/electrum/lnchannel.py b/electrum/lnchannel.py
       t@@ -64,7 +64,7 @@ if TYPE_CHECKING:
        class channel_states(IntEnum):
            PREOPENING      = 0 # Initial negotiation. Channel will not be reestablished
            OPENING         = 1 # Channel will be reestablished. (per BOLT2)
       -                        #  - Funding node: has broadcast the funding tx.
       +                        #  - Funding node: has received funding_signed (can broadcast the funding tx)
                                #  - Non-funding node: has sent the funding_signed message.
            FUNDED          = 2 # Funding tx was mined (requires min_depth and tx verification)
            OPEN            = 3 # both parties have sent funding_locked
 (DIR) diff --git a/electrum/lnpeer.py b/electrum/lnpeer.py
       t@@ -605,6 +605,8 @@ class Peer(Logger):
                remote_sig = payload['signature']
                chan.receive_new_commitment(remote_sig, [])
                chan.open_with_first_pcp(remote_per_commitment_point, remote_sig)
       +        chan.set_state(channel_states.OPENING)
       +        self.lnworker.add_new_channel(chan)
                return chan, funding_tx
        
            def create_channel_storage(self, channel_id, outpoint, local_config, remote_config, constraints):
 (DIR) diff --git a/electrum/lnworker.py b/electrum/lnworker.py
       t@@ -684,9 +684,6 @@ class LNWallet(LNWorker):
                    await self.force_close_channel(chan.channel_id)
                    return
        
       -        if chan.get_state() == channel_states.PREOPENING:
       -            chan.set_state(channel_states.OPENING)
       -
                if chan.get_state() == channel_states.OPENING:
                    if chan.short_channel_id is None:
                        self.save_short_chan_id(chan)
       t@@ -775,14 +772,11 @@ class LNWallet(LNWorker):
                    funding_sat=funding_sat,
                    push_msat=push_sat * 1000,
                    temp_channel_id=os.urandom(32))
       -        self.add_new_channel(chan)
                self.network.trigger_callback('channels_updated', self.wallet)
                self.wallet.add_transaction(funding_tx)  # save tx as local into the wallet
                self.wallet.set_label(funding_tx.txid(), _('Open channel'))
                if funding_tx.is_complete():
       -            # TODO make more robust (timeout low? server returns error?)
       -            await asyncio.wait_for(self.network.broadcast_transaction(funding_tx), LN_P2P_NETWORK_TIMEOUT)
       -            chan.set_state(channel_states.OPENING)
       +            await self.network.try_broadcasting(funding_tx, 'open_channel')
                return chan, funding_tx
        
            def add_channel(self, chan):