57
57
fee_for_htlc_output , offered_htlc_trim_threshold_sat ,
58
58
received_htlc_trim_threshold_sat , make_commitment_output_to_remote_address , FIXED_ANCHOR_SAT ,
59
59
ChannelType , LNProtocolWarning , ctx_has_anchors )
60
- from .lnsweep import txs_our_ctx , txs_their_ctx
61
- from .lnsweep import txs_their_htlctx_justice , SweepInfo
62
- from .lnsweep import tx_their_ctx_to_remote_backup
60
+ from .lnsweep import sweep_our_ctx , sweep_their_ctx
61
+ from .lnsweep import sweep_their_htlctx_justice , sweep_our_htlctx , SweepInfo
62
+ from .lnsweep import sweep_their_ctx_to_remote_backup
63
63
from .lnhtlc import HTLCManager
64
64
from .lnmsg import encode_msg , decode_msg
65
65
from .address_synchronizer import TX_HEIGHT_LOCAL
@@ -285,10 +285,10 @@ def delete_closing_height(self):
285
285
self .storage .pop ('closing_height' , None )
286
286
287
287
def create_sweeptxs_for_our_ctx (self , ctx : Transaction ) -> Optional [Dict [str , SweepInfo ]]:
288
- return txs_our_ctx (chan = self , ctx = ctx , sweep_address = self . get_sweep_address () )
288
+ return sweep_our_ctx (chan = self , ctx = ctx )
289
289
290
290
def create_sweeptxs_for_their_ctx (self , ctx : Transaction ) -> Optional [Dict [str , SweepInfo ]]:
291
- return txs_their_ctx (chan = self , ctx = ctx , sweep_address = self . get_sweep_address () )
291
+ return sweep_their_ctx (chan = self , ctx = ctx )
292
292
293
293
def is_backup (self ) -> bool :
294
294
return False
@@ -315,8 +315,8 @@ def sweep_ctx(self, ctx: Transaction) -> Dict[str, SweepInfo]:
315
315
self .logger .info (f'not sure who closed.' )
316
316
return self ._sweep_info [txid ]
317
317
318
- def maybe_sweep_revoked_htlc (self , ctx : Transaction , htlc_tx : Transaction ) -> Optional [SweepInfo ]:
319
- return None
318
+ def maybe_sweep_htlcs (self , ctx : Transaction , htlc_tx : Transaction ) -> Optional [SweepInfo ]:
319
+ return {}
320
320
321
321
def extract_preimage_from_htlc_txin (self , txin : TxInput ) -> None :
322
322
return
@@ -595,15 +595,15 @@ def is_backup(self):
595
595
return True
596
596
597
597
def create_sweeptxs_for_their_ctx (self , ctx ):
598
- return tx_their_ctx_to_remote_backup (chan = self , ctx = ctx , sweep_address = self . get_sweep_address () )
598
+ return sweep_their_ctx_to_remote_backup (chan = self , ctx = ctx )
599
599
600
600
def create_sweeptxs_for_our_ctx (self , ctx ):
601
601
if self .is_imported :
602
- return txs_our_ctx (chan = self , ctx = ctx , sweep_address = self . get_sweep_address () )
602
+ return sweep_our_ctx (chan = self , ctx = ctx )
603
603
else :
604
604
return
605
605
606
- def maybe_sweep_revoked_htlcs (self , ctx : Transaction , htlc_tx : Transaction ) -> Dict [int , SweepInfo ]:
606
+ def maybe_sweep_htlcs (self , ctx : Transaction , htlc_tx : Transaction ) -> Dict [int , SweepInfo ]:
607
607
return {}
608
608
609
609
def extract_preimage_from_htlc_txin (self , txin : TxInput ) -> None :
@@ -1491,9 +1491,9 @@ def get_oldest_unrevoked_commitment(self, subject: HTLCOwner) -> PartialTransact
1491
1491
return self .get_commitment (subject , ctn = ctn )
1492
1492
1493
1493
def create_sweeptxs_for_watchtower (self , ctn : int ) -> List [Transaction ]:
1494
- from .lnsweep import txs_their_ctx_watchtower
1494
+ from .lnsweep import sweep_their_ctx_watchtower
1495
1495
secret , ctx = self .get_secret_and_commitment (REMOTE , ctn = ctn )
1496
- return txs_their_ctx_watchtower (self , ctx , secret , self .get_sweep_address ())
1496
+ return sweep_their_ctx_watchtower (self , ctx , secret , self .get_sweep_address ())
1497
1497
1498
1498
def get_oldest_unrevoked_ctn (self , subject : HTLCOwner ) -> int :
1499
1499
return self .hm .ctn_oldest_unrevoked (subject )
@@ -1726,9 +1726,12 @@ def get_close_options(self) -> Sequence[ChanCloseOption]:
1726
1726
assert not (self .get_state () == ChannelState .WE_ARE_TOXIC and ChanCloseOption .LOCAL_FCLOSE in ret ), "local force-close unsafe if we are toxic"
1727
1727
return ret
1728
1728
1729
- def maybe_sweep_revoked_htlcs (self , ctx : Transaction , htlc_tx : Transaction ) -> Dict [int , SweepInfo ]:
1729
+ def maybe_sweep_htlcs (self , ctx : Transaction , htlc_tx : Transaction ) -> Dict [int , SweepInfo ]:
1730
1730
# look at the output address, check if it matches
1731
- return txs_their_htlctx_justice (self , ctx , htlc_tx , self .get_sweep_address ())
1731
+ d = sweep_their_htlctx_justice (self , ctx , htlc_tx )
1732
+ d2 = sweep_our_htlctx (self , ctx , htlc_tx )
1733
+ d .update (d2 )
1734
+ return d
1732
1735
1733
1736
def has_pending_changes (self , subject : HTLCOwner ) -> bool :
1734
1737
next_htlcs = self .hm .get_htlcs_in_next_ctx (subject )
0 commit comments