From 1c8a57d700e2bc302f85359d498de6a5e5edc68a Mon Sep 17 00:00:00 2001 From: benthecarman Date: Sat, 13 Jan 2024 13:28:04 +0000 Subject: [PATCH] Handle expired invoices --- src/i18n/en/translations.ts | 1 + src/routes/Send.tsx | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/src/i18n/en/translations.ts b/src/i18n/en/translations.ts index bd09e4fa..61786379 100644 --- a/src/i18n/en/translations.ts +++ b/src/i18n/en/translations.ts @@ -137,6 +137,7 @@ export default { error_clipboard: "Clipboard not supported", error_keysend: "Keysend failed", error_LNURL: "LNURL Pay failed", + error_expired: "Invoice is expired", payment_pending: "Payment pending", payment_pending_description: "It's taking a while, but it's possible this payment may still go through. Please check 'Activity' for the current status.", diff --git a/src/routes/Send.tsx b/src/routes/Send.tsx index d9a7c532..f12ab626 100644 --- a/src/routes/Send.tsx +++ b/src/routes/Send.tsx @@ -446,6 +446,11 @@ export function Send() { state.mutiny_wallet ?.decode_invoice(source.invoice!) .then((invoice) => { + if (invoice.expire <= Date.now() / 1000) { + navigate("/search"); + throw new Error(i18n.t("send.error_expired")); + } + if (invoice?.amount_sats) { setAmountSats(invoice.amount_sats); setIsAmtEditable(false);