@@ -191,6 +191,7 @@ class AbstractChannel(Logger, ABC):
191
191
short_channel_id : Optional [ShortChannelID ] = None
192
192
funding_outpoint : Outpoint
193
193
node_id : bytes # note that it might not be the full 33 bytes; for OCB it is only the prefix
194
+ should_request_force_close : bool = False
194
195
_state : ChannelState
195
196
196
197
def set_short_channel_id (self , short_id : ShortChannelID ) -> None :
@@ -398,13 +399,20 @@ def update_funded_state(self, *, funding_txid: str, funding_height: TxMinedInfo)
398
399
if funding_height .conf > 0 :
399
400
self .set_short_channel_id (ShortChannelID .from_components (
400
401
funding_height .height , funding_height .txpos , self .funding_outpoint .output_index ))
401
- if self .is_zeroconf ():
402
- # remove zeroconf flag as we are now confirmed, this is to prevent an electrum server causing
403
- # us to remove a channel later in update_unfunded_state by omitting its funding tx
404
- self .remove_zeroconf_flag ()
405
402
if self .get_state () == ChannelState .OPENING :
406
403
if self .is_funding_tx_mined (funding_height ):
407
404
self .set_state (ChannelState .FUNDED )
405
+ elif self .is_zeroconf () and funding_height .conf >= 3 and not self .should_request_force_close :
406
+ if not self .is_funding_tx_mined (funding_height ):
407
+ # funding tx is invalid (invalid amount or address) we need to get rid of the channel again
408
+ self .should_request_force_close = True
409
+ if self .lnworker and self .node_id in self .lnworker .peers :
410
+ # reconnect to trigger force close request
411
+ self .lnworker .peers [self .node_id ].close_and_cleanup ()
412
+ else :
413
+ # remove zeroconf flag as we are now confirmed, this is to prevent an electrum server causing
414
+ # us to remove a channel later in update_unfunded_state by omitting its funding tx
415
+ self .remove_zeroconf_flag ()
408
416
409
417
def update_closed_state (self , * , funding_txid : str , funding_height : TxMinedInfo ,
410
418
closing_txid : str , closing_height : TxMinedInfo , keep_watching : bool ) -> None :
@@ -775,7 +783,6 @@ def __init__(self, state: 'StoredDict', *, name=None, lnworker=None, initial_fee
775
783
self .revocation_store = RevocationStore (state ["revocation_store" ])
776
784
self ._can_send_ctx_updates = True # type: bool
777
785
self ._receive_fail_reasons = {} # type: Dict[int, (bytes, OnionRoutingFailure)]
778
- self .should_request_force_close = False
779
786
self .unconfirmed_closing_txid = None # not a state, only for GUI
780
787
self .sent_channel_ready = False # no need to persist this, because channel_ready is re-sent in channel_reestablish
781
788
self .sent_announcement_signatures = False
0 commit comments