Skip to content

Commit

Permalink
fix: always watch temporarily failed xpay payments
Browse files Browse the repository at this point in the history
  • Loading branch information
michael1011 committed Feb 2, 2025
1 parent 9c92159 commit 984761c
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 18 deletions.
6 changes: 1 addition & 5 deletions lib/lightning/PendingPaymentTracker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -230,11 +230,7 @@ class PendingPaymentTracker {
this.lightningTrackers[lightningClient.type].isPermanentError(e);

// CLN xpay does throw errors while the payment is still pending
if (
lightningClient.type === NodeType.CLN &&
!isPermanentError &&
ClnPendingPaymentTracker.shouldBeWatched(e)
) {
if (lightningClient.type === NodeType.CLN && !isPermanentError) {
this.lightningTrackers[lightningClient.type].watchPayment(
lightningClient,
swap.invoice!,
Expand Down
14 changes: 1 addition & 13 deletions lib/lightning/paymentTrackers/ClnPendingPaymentTracker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,6 @@ class ClnPendingPaymentTracker extends NodePendingPendingTracker {
);
}

public static shouldBeWatched = (error: unknown) => {
const msg = formatError(error);
return (
(msg.includes('Failed after') && msg.includes('attempts')) ||
msg.includes('xpay') ||
msg === 'Connection dropped'
);
};

public stop = () => {
clearInterval(this.checkInterval as unknown as number);
};
Expand All @@ -52,10 +43,7 @@ class ClnPendingPaymentTracker extends NodePendingPendingTracker {
.then((result) => this.handleSucceededPayment(preimageHash, result))
.catch((error) => {
// CLN xpay throws errors while the payment is still pending
if (
!this.isPermanentError(error) &&
ClnPendingPaymentTracker.shouldBeWatched(error)
) {
if (!this.isPermanentError(error)) {
this.watchPayment(client, invoice, preimageHash);
} else {
this.handleFailedPayment(client, preimageHash, error);
Expand Down

0 comments on commit 984761c

Please sign in to comment.