mirror of
https://github.com/getAlby/hub.git
synced 2026-08-13 12:33:39 +02:00
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:
parent
3318128b41
commit
968a8a1486
2 changed files with 17 additions and 11 deletions
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue