fix: ignore swap out payment timeout (#1517)

* fix: ignore swap out payment timeout

* chore: add comment to explain timeout in lnd

---------

Co-authored-by: im-adithya <imadithyavardhan@gmail.com>
This commit is contained in:
Roland 2025-07-21 21:18:02 +07:00 committed by GitHub
parent 3318128b41
commit 968a8a1486
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 17 additions and 11 deletions

View file

@ -442,6 +442,10 @@ func (svc *LNDService) SendPaymentSync(ctx context.Context, payReq string, amoun
}
if resp.Status != lnrpc.Payment_SUCCEEDED {
// In LND, timeout error only happens when there are more routes to try
// but we ran out of time in contrast to LDK where the payment is initiated
// and might still succeed after receiving timeout error
// See https://github.com/lightningnetwork/lnd/issues/4269#issuecomment-626279140
failureReasonMessage := resp.FailureReason.String()
logger.Logger.WithFields(logrus.Fields{
"bolt11": payReq,

View file

@ -1088,18 +1088,20 @@ func (svc *swapsService) startSwapOutListener(swap *db.Swap) {
"swap_id": swap.SwapId,
}
sendPaymentTimeout := int64(3600)
holdInvoicePayment, err := svc.transactionsService.SendPaymentSync(svc.ctx, swap.Invoice, nil, metadata, svc.lnClient, nil, nil, &sendPaymentTimeout)
logger.Logger.WithField("swapId", swap.SwapId).Info("Initiating swap invoice payment")
_, err = svc.transactionsService.SendPaymentSync(svc.ctx, swap.Invoice, nil, metadata, svc.lnClient, nil, nil, &sendPaymentTimeout)
if err != nil {
logger.Logger.WithError(err).WithFields(logrus.Fields{
"swapId": swap.SwapId,
}).Error("Error paying the swap invoice")
paymentErrorCh <- err
return
}
logger.Logger.WithField("swapId", swap.SwapId).Info("Initiated swap invoice payment")
if holdInvoicePayment.PaymentHash != swap.PaymentHash {
paymentErrorCh <- errors.New("swap hold payment hash mismatch")
return
if errors.Is(err, lnclient.NewTimeoutError()) {
logger.Logger.WithFields(logrus.Fields{
"swapId": swap.SwapId,
}).Info("Ignoring payment timeout while swapping out")
} else {
logger.Logger.WithError(err).WithFields(logrus.Fields{
"swapId": swap.SwapId,
}).Error("Error paying the swap invoice")
paymentErrorCh <- err
return
}
}
}()
case boltz.TransactionMempool: