From 879dcb3224336f3b572420d8f5ccd000de2681ac Mon Sep 17 00:00:00 2001 From: ThomasV Date: Mon, 3 Nov 2025 13:36:37 +0100 Subject: [PATCH] add dust_override to SweepInfo We might want to set this value independently from is_anchor. --- electrum/lnsweep.py | 12 ++++++++++++ electrum/submarine_swaps.py | 1 + electrum/txbatcher.py | 2 +- tests/test_txbatcher.py | 1 + 4 files changed, 15 insertions(+), 1 deletion(-) diff --git a/electrum/lnsweep.py b/electrum/lnsweep.py index f63064162..014c87ad4 100644 --- a/electrum/lnsweep.py +++ b/electrum/lnsweep.py @@ -43,6 +43,7 @@ class SweepInfo(NamedTuple): txin: PartialTxInput txout: Optional[PartialTxOutput] # only for first-stage htlc tx can_be_batched: bool # todo: this could be more fine-grained + dust_override: bool def is_anchor(self): return self.name in ['local_anchor', 'remote_anchor'] @@ -260,6 +261,7 @@ def sweep_their_htlctx_justice( txin=txin, txout=None, can_be_batched=False, + dust_override=False, ) return index_to_sweepinfo @@ -337,6 +339,7 @@ def sweep_our_ctx( txin=txin, txout=None, can_be_batched=True, + dust_override=True, ) # to_local @@ -358,6 +361,7 @@ def sweep_our_ctx( txin=txin, txout=None, can_be_batched=True, + dust_override=False, ) we_breached = ctn < chan.get_oldest_unrevoked_ctn(LOCAL) if we_breached: @@ -398,6 +402,7 @@ def sweep_our_ctx( # - in particular, it would be safe to batch htlcs where # htlc_direction, htlc.payment_hash, htlc.cltv_abs # all match. That is, MPP htlcs for the same payment. + dust_override=False, ) else: # second-stage @@ -420,6 +425,7 @@ def sweep_our_ctx( # this is safe to batch, we are the only ones who can spend # (assuming we did not broadcast a revoked state) can_be_batched=True, + dust_override=False, ) # offered HTLCs, in our ctx --> "timeout" @@ -557,6 +563,7 @@ def sweep_their_ctx_to_remote_backup( txin=txin, txout=None, can_be_batched=True, + dust_override=True, ) # to_remote @@ -577,6 +584,7 @@ def sweep_their_ctx_to_remote_backup( txin=txin, txout=None, can_be_batched=True, + dust_override=False, ) return txs @@ -634,6 +642,7 @@ def sweep_their_ctx( txin=txin, txout=None, can_be_batched=True, + dust_override=True, ) # to_local is handled by lnwatcher @@ -646,6 +655,7 @@ def sweep_their_ctx( txin=txin, txout=None, can_be_batched=False, + dust_override=False, ) # to_remote @@ -676,6 +686,7 @@ def sweep_their_ctx( txin=txin, txout=None, can_be_batched=True, + dust_override=False, ) # HTLCs @@ -715,6 +726,7 @@ def sweep_their_ctx( txout=None, can_be_batched=False, # both parties can spend # (still, in some cases we could batch, see comment in sweep_our_ctx) + dust_override=False, ) # received HTLCs, in their ctx --> "timeout" # offered HTLCs, in their ctx --> "success" diff --git a/electrum/submarine_swaps.py b/electrum/submarine_swaps.py index b0b623083..dfc5ebfe9 100644 --- a/electrum/submarine_swaps.py +++ b/electrum/submarine_swaps.py @@ -529,6 +529,7 @@ class SwapManager(Logger): txout=None, name=name, can_be_batched=can_be_batched, + dust_override=False, ) try: self.wallet.txbatcher.add_sweep_input('swaps', sweep_info) diff --git a/electrum/txbatcher.py b/electrum/txbatcher.py index 6451bfb33..bd0183201 100644 --- a/electrum/txbatcher.py +++ b/electrum/txbatcher.py @@ -265,7 +265,7 @@ class TxBatch(Logger): def is_dust(self, sweep_info: SweepInfo) -> bool: """Can raise NoDynamicFeeEstimates.""" - if sweep_info.is_anchor(): + if sweep_info.dust_override: return False if sweep_info.txout is not None: return False diff --git a/tests/test_txbatcher.py b/tests/test_txbatcher.py index 2afafe4ce..f038bb7e5 100644 --- a/tests/test_txbatcher.py +++ b/tests/test_txbatcher.py @@ -86,6 +86,7 @@ SWAP_SWEEP_INFO = SweepInfo( txout=None, name='swap claim', can_be_batched=True, + dust_override=False, )