|
2 | 2 | # Distributed under the MIT software license, see the accompanying |
3 | 3 | # file LICENCE or http://www.opensource.org/licenses/mit-license.php |
4 | 4 |
|
5 | | -from typing import TYPE_CHECKING |
| 5 | +from typing import TYPE_CHECKING, Optional |
6 | 6 |
|
7 | 7 | from . import util |
8 | 8 | from .util import TxMinedInfo, BelowDustLimit |
@@ -88,13 +88,13 @@ def add_channel(self, chan: 'AbstractChannel') -> None: |
88 | 88 | if chan.need_to_subscribe(): |
89 | 89 | self.add_callback(address, callback) |
90 | 90 |
|
91 | | - def unwatch_channel(self, address, funding_outpoint): |
| 91 | + def unwatch_channel(self, address: str, funding_outpoint: str) -> None: |
92 | 92 | self.logger.info(f'unwatching {funding_outpoint}') |
93 | 93 | self.remove_callback(address) |
94 | 94 |
|
95 | 95 | @ignore_exceptions |
96 | 96 | @log_exceptions |
97 | | - async def check_onchain_situation(self, address, funding_outpoint): |
| 97 | + async def check_onchain_situation(self, address: str, funding_outpoint: str) -> None: |
98 | 98 | # early return if address has not been added yet |
99 | 99 | if not self.adb.is_mine(address): |
100 | 100 | return |
@@ -142,17 +142,18 @@ async def update_channel_state( |
142 | 142 | self._pending_force_closes.discard(chan) |
143 | 143 | await self.lnworker.handle_onchain_state(chan) |
144 | 144 |
|
145 | | - async def sweep_commitment_transaction(self, funding_outpoint, closing_tx) -> bool: |
| 145 | + async def sweep_commitment_transaction(self, funding_outpoint: str, closing_tx: Transaction) -> bool: |
146 | 146 | """This function is called when a channel was closed. In this case |
147 | 147 | we need to check for redeemable outputs of the commitment transaction |
148 | 148 | or spenders down the line (HTLC-timeout/success transactions). |
149 | 149 |
|
150 | 150 | Returns whether we should continue to monitor. |
151 | 151 |
|
152 | | - Side-effécts: |
| 152 | + Side-effects: |
153 | 153 | - sets defaults labels |
154 | 154 | - populates wallet._accounting_addresses |
155 | 155 | """ |
| 156 | + assert closing_tx |
156 | 157 | chan = self.lnworker.channel_by_txo(funding_outpoint) |
157 | 158 | if not chan: |
158 | 159 | return False |
@@ -188,7 +189,8 @@ async def sweep_commitment_transaction(self, funding_outpoint, closing_tx) -> bo |
188 | 189 | self.maybe_add_accounting_address(spender_txid, sweep_info) |
189 | 190 | else: |
190 | 191 | keep_watching |= was_added |
191 | | - self.maybe_add_pending_forceclose(chan, spender_txid, is_local_ctx, sweep_info, was_added) |
| 192 | + self.maybe_add_pending_forceclose( |
| 193 | + chan=chan, spender_txid=spender_txid, is_local_ctx=is_local_ctx, sweep_info=sweep_info, was_added=was_added) |
192 | 194 | return keep_watching |
193 | 195 |
|
194 | 196 | def get_pending_force_closes(self): |
@@ -242,7 +244,15 @@ def maybe_add_accounting_address(self, spender_txid: str, sweep_info: 'SweepInfo |
242 | 244 | txout = prev_tx.outputs()[int(prev_index)] |
243 | 245 | self.lnworker.wallet._accounting_addresses.add(txout.address) |
244 | 246 |
|
245 | | - def maybe_add_pending_forceclose(self, chan, spender_txid, is_local_ctx, sweep_info, was_added): |
| 247 | + def maybe_add_pending_forceclose( |
| 248 | + self, |
| 249 | + *, |
| 250 | + chan: 'AbstractChannel', |
| 251 | + spender_txid: Optional[str], |
| 252 | + is_local_ctx: bool, |
| 253 | + sweep_info: 'SweepInfo', |
| 254 | + was_added: bool, |
| 255 | + ): |
246 | 256 | """ we are waiting for ctx to be confirmed and there are received htlcs """ |
247 | 257 | if was_added and is_local_ctx and sweep_info.name == 'received-htlc' and chan.has_anchors(): |
248 | 258 | tx_mined_status = self.adb.get_tx_height(spender_txid) |
|
0 commit comments