Skip to content

Commit 09af778

Browse files
authored
Merge pull request #10327 from f321x/followup_10303
swaps: followup 10303
2 parents 41d391a + 3d0ba33 commit 09af778

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

electrum/submarine_swaps.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@
4242
from .lnaddr import lndecode
4343
from .json_db import StoredObject, stored_in
4444
from . import constants
45-
from .address_synchronizer import TX_HEIGHT_LOCAL, TX_HEIGHT_FUTURE
45+
from .address_synchronizer import (TX_HEIGHT_LOCAL, TX_HEIGHT_FUTURE, TX_HEIGHT_UNCONFIRMED,
46+
TX_HEIGHT_UNCONF_PARENT)
4647
from .fee_policy import FeePolicy
4748
from .invoices import Invoice, PR_PAID
4849
from .lnonion import OnionRoutingFailure, OnionFailureCode
@@ -553,9 +554,9 @@ async def _claim_to_output(self, swap: SwapData, claim_txin: PartialTxInput):
553554
assert swap.claim_to_output, swap
554555
txout = PartialTxOutput.from_address_and_value(swap.claim_to_output[0], swap.claim_to_output[1])
555556
tx = PartialTransaction.from_io([claim_txin], [txout])
556-
can_be_broadcast = self.wallet.adb.get_tx_height(swap.funding_txid).height() > 0
557-
already_broadcast = self.wallet.adb.get_tx_height(tx.txid()).height() >= 0
558-
self.logger.debug(f"_claim_to_output: {can_be_broadcast=} {already_broadcast=}")
557+
funding_tx_confirmed = self.wallet.adb.get_tx_height(swap.funding_txid).height() > TX_HEIGHT_UNCONFIRMED
558+
already_broadcast = self.wallet.adb.get_tx_height(tx.txid()).height() >= TX_HEIGHT_UNCONF_PARENT
559+
self.logger.debug(f"_claim_to_output: {funding_tx_confirmed=} {already_broadcast=}")
559560

560561
# add tx to db so it can be shown as future tx
561562
if not self.wallet.adb.get_transaction(tx.txid()):
@@ -572,7 +573,7 @@ async def _claim_to_output(self, swap: SwapData, claim_txin: PartialTxInput):
572573
if not already_broadcast and self.wallet.adb.future_tx.get(tx.txid(), 0) < wanted_height:
573574
self.wallet.adb.set_future_tx(tx.txid(), wanted_height=wanted_height)
574575

575-
if can_be_broadcast and not already_broadcast:
576+
if funding_tx_confirmed and not already_broadcast:
576577
tx = self.wallet.sign_transaction(tx, password=None, ignore_warnings=True)
577578
assert tx and tx.is_complete(), tx
578579
try:

0 commit comments

Comments
 (0)