Skip to content

Commit

Permalink
Payments: fix failed logic for display on Activity
Browse files Browse the repository at this point in the history
  • Loading branch information
kaloudis committed Jun 28, 2024
1 parent f9cf3eb commit 77bcc7c
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions models/Payment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export default class Payment extends BaseModel {
bolt: string;
status: string;
payment_request: string;
failure_reason?: string;
// c-lightning
id?: string;
destination?: string;
Expand Down Expand Up @@ -133,18 +134,19 @@ export default class Payment extends BaseModel {
}

@computed public get isFailed(): boolean {
if (!this.isIncomplete) return false;
if (!this.htlcs) return false;
let isFailed = false;
for (const htlc of this.htlcs) {
if (
htlc.status === 'FAILED' ||
htlc.status === lnrpc.HTLCAttempt.HTLCStatus.FAILED
) {
isFailed = true;
break;
if (this.htlcs) {
for (const htlc of this.htlcs) {
if (
htlc.status === 'FAILED' ||
htlc.status === lnrpc.HTLCAttempt.HTLCStatus.FAILED
) {
isFailed = true;
break;
}
}
}
if (this.failure_reason) isFailed = true;
return isFailed;
}

Expand Down

0 comments on commit 77bcc7c

Please sign in to comment.