@@ -99,6 +99,7 @@ async def check_onchain_situation(self, address: str, funding_outpoint: str) ->
9999 if not self .adb .is_mine (address ):
100100 return
101101 # inspect_tx_candidate might have added new addresses, in which case we return early
102+ # note: maybe we should wait until adb.is_up_to_date... (?)
102103 funding_txid = funding_outpoint .split (':' )[0 ]
103104 funding_height = self .adb .get_tx_height (funding_txid )
104105 closing_txid = self .adb .get_spender (funding_outpoint )
@@ -159,7 +160,9 @@ async def sweep_commitment_transaction(self, funding_outpoint: str, closing_tx:
159160 return False
160161 # detect who closed and get information about how to claim outputs
161162 is_local_ctx , sweep_info_dict = chan .get_ctx_sweep_info (closing_tx )
162- keep_watching = False if sweep_info_dict else not self .adb .is_deeply_mined (closing_tx .txid ())
163+ # note: we need to keep watching *at least* until the closing tx is deeply mined,
164+ # possibly longer if there are TXOs to sweep
165+ keep_watching = not self .adb .is_deeply_mined (closing_tx .txid ())
163166 # create and broadcast transactions
164167 for prevout , sweep_info in sweep_info_dict .items ():
165168 prev_txid , prev_index = prevout .split (':' )
@@ -170,7 +173,7 @@ async def sweep_commitment_transaction(self, funding_outpoint: str, closing_tx:
170173 self .logger .info (f'prevout does not exist for { name } : { prevout } ' )
171174 continue
172175 was_added = self .maybe_redeem (sweep_info )
173- spender_txid = self .adb .get_spender (prevout )
176+ spender_txid = self .adb .get_spender (prevout ) # note: LOCAL spenders don't count
174177 spender_tx = self .adb .get_transaction (spender_txid ) if spender_txid else None
175178 if spender_tx :
176179 # the spender might be the remote, revoked or not
0 commit comments