From a051545d2d58f62f3e34aa034961d5eeeb52db95 Mon Sep 17 00:00:00 2001 From: benthecarman Date: Thu, 4 Jan 2024 21:01:59 -0600 Subject: [PATCH] Skip invoice paid twice error in NWC --- src/components/PendingNwc.tsx | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/components/PendingNwc.tsx b/src/components/PendingNwc.tsx index e1a0980..7bacd41 100644 --- a/src/components/PendingNwc.tsx +++ b/src/components/PendingNwc.tsx @@ -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();