|
|
|
@ -279,7 +279,7 @@ class SwapManager(Logger): |
|
|
|
if not self.lnwatcher.adb.is_up_to_date(): |
|
|
|
if not self.lnwatcher.adb.is_up_to_date(): |
|
|
|
return |
|
|
|
return |
|
|
|
current_height = self.network.get_local_height() |
|
|
|
current_height = self.network.get_local_height() |
|
|
|
delta = current_height - swap.locktime |
|
|
|
remaining_time = swap.locktime - current_height |
|
|
|
txos = self.lnwatcher.adb.get_addr_outputs(swap.lockup_address) |
|
|
|
txos = self.lnwatcher.adb.get_addr_outputs(swap.lockup_address) |
|
|
|
|
|
|
|
|
|
|
|
for txin in txos.values(): |
|
|
|
for txin in txos.values(): |
|
|
|
@ -292,7 +292,7 @@ class SwapManager(Logger): |
|
|
|
txin = None |
|
|
|
txin = None |
|
|
|
# if it is a normal swap, we might have double spent the funding tx |
|
|
|
# if it is a normal swap, we might have double spent the funding tx |
|
|
|
# in that case we need to fail the HTLCs |
|
|
|
# in that case we need to fail the HTLCs |
|
|
|
if delta >= 0: |
|
|
|
if remaining_time <= 0: |
|
|
|
self._fail_swap(swap, 'expired') |
|
|
|
self._fail_swap(swap, 'expired') |
|
|
|
|
|
|
|
|
|
|
|
if txin: |
|
|
|
if txin: |
|
|
|
@ -341,7 +341,7 @@ class SwapManager(Logger): |
|
|
|
if spent_height > 0: |
|
|
|
if spent_height > 0: |
|
|
|
self._fail_swap(swap, 'refund tx confirmed') |
|
|
|
self._fail_swap(swap, 'refund tx confirmed') |
|
|
|
return |
|
|
|
return |
|
|
|
if delta < 0: |
|
|
|
if remaining_time > 0: |
|
|
|
# too early for refund |
|
|
|
# too early for refund |
|
|
|
return |
|
|
|
return |
|
|
|
else: |
|
|
|
else: |
|
|
|
@ -351,10 +351,10 @@ class SwapManager(Logger): |
|
|
|
if funding_height.conf <= 0: |
|
|
|
if funding_height.conf <= 0: |
|
|
|
return |
|
|
|
return |
|
|
|
key = swap.payment_hash.hex() |
|
|
|
key = swap.payment_hash.hex() |
|
|
|
if -delta <= MIN_LOCKTIME_DELTA: |
|
|
|
if remaining_time <= MIN_LOCKTIME_DELTA: |
|
|
|
if key in self.invoices_to_pay: |
|
|
|
if key in self.invoices_to_pay: |
|
|
|
# fixme: should consider cltv of ln payment |
|
|
|
# fixme: should consider cltv of ln payment |
|
|
|
self.logger.info(f'locktime too close {key} {delta}') |
|
|
|
self.logger.info(f'locktime too close {key} {remaining_time}') |
|
|
|
self.invoices_to_pay.pop(key, None) |
|
|
|
self.invoices_to_pay.pop(key, None) |
|
|
|
return |
|
|
|
return |
|
|
|
if key not in self.invoices_to_pay: |
|
|
|
if key not in self.invoices_to_pay: |
|
|
|
|