Skip to content

Commit 879dcb3

Browse files
committed
add dust_override to SweepInfo
We might want to set this value independently from is_anchor.
1 parent 41378e1 commit 879dcb3

File tree

4 files changed

+15
-1
lines changed

4 files changed

+15
-1
lines changed

electrum/lnsweep.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ class SweepInfo(NamedTuple):
4343
txin: PartialTxInput
4444
txout: Optional[PartialTxOutput] # only for first-stage htlc tx
4545
can_be_batched: bool # todo: this could be more fine-grained
46+
dust_override: bool
4647

4748
def is_anchor(self):
4849
return self.name in ['local_anchor', 'remote_anchor']
@@ -260,6 +261,7 @@ def justice_txin(output_idx):
260261
txin=txin,
261262
txout=None,
262263
can_be_batched=False,
264+
dust_override=False,
263265
)
264266
return index_to_sweepinfo
265267

@@ -337,6 +339,7 @@ def sweep_our_ctx(
337339
txin=txin,
338340
txout=None,
339341
can_be_batched=True,
342+
dust_override=True,
340343
)
341344

342345
# to_local
@@ -358,6 +361,7 @@ def sweep_our_ctx(
358361
txin=txin,
359362
txout=None,
360363
can_be_batched=True,
364+
dust_override=False,
361365
)
362366
we_breached = ctn < chan.get_oldest_unrevoked_ctn(LOCAL)
363367
if we_breached:
@@ -398,6 +402,7 @@ def txs_htlc(
398402
# - in particular, it would be safe to batch htlcs where
399403
# htlc_direction, htlc.payment_hash, htlc.cltv_abs
400404
# all match. That is, MPP htlcs for the same payment.
405+
dust_override=False,
401406
)
402407
else:
403408
# second-stage
@@ -420,6 +425,7 @@ def txs_htlc(
420425
# this is safe to batch, we are the only ones who can spend
421426
# (assuming we did not broadcast a revoked state)
422427
can_be_batched=True,
428+
dust_override=False,
423429
)
424430

425431
# offered HTLCs, in our ctx --> "timeout"
@@ -557,6 +563,7 @@ def sweep_their_ctx_to_remote_backup(
557563
txin=txin,
558564
txout=None,
559565
can_be_batched=True,
566+
dust_override=True,
560567
)
561568

562569
# to_remote
@@ -577,6 +584,7 @@ def sweep_their_ctx_to_remote_backup(
577584
txin=txin,
578585
txout=None,
579586
can_be_batched=True,
587+
dust_override=False,
580588
)
581589
return txs
582590

@@ -634,6 +642,7 @@ def sweep_their_ctx(
634642
txin=txin,
635643
txout=None,
636644
can_be_batched=True,
645+
dust_override=True,
637646
)
638647

639648
# to_local is handled by lnwatcher
@@ -646,6 +655,7 @@ def sweep_their_ctx(
646655
txin=txin,
647656
txout=None,
648657
can_be_batched=False,
658+
dust_override=False,
649659
)
650660

651661
# to_remote
@@ -676,6 +686,7 @@ def sweep_their_ctx(
676686
txin=txin,
677687
txout=None,
678688
can_be_batched=True,
689+
dust_override=False,
679690
)
680691

681692
# HTLCs
@@ -715,6 +726,7 @@ def tx_htlc(
715726
txout=None,
716727
can_be_batched=False, # both parties can spend
717728
# (still, in some cases we could batch, see comment in sweep_our_ctx)
729+
dust_override=False,
718730
)
719731
# received HTLCs, in their ctx --> "timeout"
720732
# offered HTLCs, in their ctx --> "success"

electrum/submarine_swaps.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -529,6 +529,7 @@ async def _claim_swap(self, swap: SwapData) -> None:
529529
txout=None,
530530
name=name,
531531
can_be_batched=can_be_batched,
532+
dust_override=False,
532533
)
533534
try:
534535
self.wallet.txbatcher.add_sweep_input('swaps', sweep_info)

electrum/txbatcher.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ def add_payment_output(self, output: 'PartialTxOutput') -> None:
265265

266266
def is_dust(self, sweep_info: SweepInfo) -> bool:
267267
"""Can raise NoDynamicFeeEstimates."""
268-
if sweep_info.is_anchor():
268+
if sweep_info.dust_override:
269269
return False
270270
if sweep_info.txout is not None:
271271
return False

tests/test_txbatcher.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ def is_connected(self):
8686
txout=None,
8787
name='swap claim',
8888
can_be_batched=True,
89+
dust_override=False,
8990
)
9091

9192

0 commit comments

Comments
 (0)