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.
This commit is contained in:
@@ -64,7 +64,7 @@ if TYPE_CHECKING:
|
|||||||
class channel_states(IntEnum):
|
class channel_states(IntEnum):
|
||||||
PREOPENING = 0 # Initial negotiation. Channel will not be reestablished
|
PREOPENING = 0 # Initial negotiation. Channel will not be reestablished
|
||||||
OPENING = 1 # Channel will be reestablished. (per BOLT2)
|
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.
|
# - Non-funding node: has sent the funding_signed message.
|
||||||
FUNDED = 2 # Funding tx was mined (requires min_depth and tx verification)
|
FUNDED = 2 # Funding tx was mined (requires min_depth and tx verification)
|
||||||
OPEN = 3 # both parties have sent funding_locked
|
OPEN = 3 # both parties have sent funding_locked
|
||||||
|
|||||||
@@ -605,6 +605,8 @@ class Peer(Logger):
|
|||||||
remote_sig = payload['signature']
|
remote_sig = payload['signature']
|
||||||
chan.receive_new_commitment(remote_sig, [])
|
chan.receive_new_commitment(remote_sig, [])
|
||||||
chan.open_with_first_pcp(remote_per_commitment_point, 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
|
return chan, funding_tx
|
||||||
|
|
||||||
def create_channel_storage(self, channel_id, outpoint, local_config, remote_config, constraints):
|
def create_channel_storage(self, channel_id, outpoint, local_config, remote_config, constraints):
|
||||||
|
|||||||
@@ -684,9 +684,6 @@ class LNWallet(LNWorker):
|
|||||||
await self.force_close_channel(chan.channel_id)
|
await self.force_close_channel(chan.channel_id)
|
||||||
return
|
return
|
||||||
|
|
||||||
if chan.get_state() == channel_states.PREOPENING:
|
|
||||||
chan.set_state(channel_states.OPENING)
|
|
||||||
|
|
||||||
if chan.get_state() == channel_states.OPENING:
|
if chan.get_state() == channel_states.OPENING:
|
||||||
if chan.short_channel_id is None:
|
if chan.short_channel_id is None:
|
||||||
self.save_short_chan_id(chan)
|
self.save_short_chan_id(chan)
|
||||||
@@ -775,14 +772,11 @@ class LNWallet(LNWorker):
|
|||||||
funding_sat=funding_sat,
|
funding_sat=funding_sat,
|
||||||
push_msat=push_sat * 1000,
|
push_msat=push_sat * 1000,
|
||||||
temp_channel_id=os.urandom(32))
|
temp_channel_id=os.urandom(32))
|
||||||
self.add_new_channel(chan)
|
|
||||||
self.network.trigger_callback('channels_updated', self.wallet)
|
self.network.trigger_callback('channels_updated', self.wallet)
|
||||||
self.wallet.add_transaction(funding_tx) # save tx as local into the wallet
|
self.wallet.add_transaction(funding_tx) # save tx as local into the wallet
|
||||||
self.wallet.set_label(funding_tx.txid(), _('Open channel'))
|
self.wallet.set_label(funding_tx.txid(), _('Open channel'))
|
||||||
if funding_tx.is_complete():
|
if funding_tx.is_complete():
|
||||||
# TODO make more robust (timeout low? server returns error?)
|
await self.network.try_broadcasting(funding_tx, 'open_channel')
|
||||||
await asyncio.wait_for(self.network.broadcast_transaction(funding_tx), LN_P2P_NETWORK_TIMEOUT)
|
|
||||||
chan.set_state(channel_states.OPENING)
|
|
||||||
return chan, funding_tx
|
return chan, funding_tx
|
||||||
|
|
||||||
def add_channel(self, chan):
|
def add_channel(self, chan):
|
||||||
|
|||||||
Reference in New Issue
Block a user