Skip to content

Commit

Permalink
Skip invoice paid twice error in NWC
Browse files Browse the repository at this point in the history
  • Loading branch information
benthecarman committed Jan 10, 2024
1 parent e23d3e8 commit a051545
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions src/components/PendingNwc.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,20 @@ export function PendingNwc() {
await state.mutiny_wallet?.approve_invoice(item.id);
await vibrateSuccess();
} catch (e) {
setError(eify(e));
console.error(e);
const err = eify(e);
// If we've already paid this invoice, just ignore the error
// we just want to remove it from the list and continue
if (err.message === "An invoice must not get payed twice.") {
// wrap in try/catch so we don't crash if the invoice is already gone
try {
await state.mutiny_wallet?.deny_invoice(item.id);
} catch (_e) {
// do nothing
}
} else {
setError(err);
console.error(e);
}
} finally {
setPaying("");
refetch();
Expand Down

0 comments on commit a051545

Please sign in to comment.