From 28ac62e751bb8cc70d240e2e460c9b50d11fc0d2 Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Mon, 3 Feb 2025 20:57:19 -0800 Subject: fix bip21 parse without amount --- src/lib/bip21.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'src/lib') diff --git a/src/lib/bip21.ts b/src/lib/bip21.ts index 2642afab..4689246e 100644 --- a/src/lib/bip21.ts +++ b/src/lib/bip21.ts @@ -19,9 +19,11 @@ export function decode(uri, allowedSchemes = ["bitcoin", "liquidnetwork"]) { const query = queryStart === -1 ? "" : uri.slice(queryStart + 1); const options = Object.fromEntries(new URLSearchParams(query)); - const n = Number(options?.amount); - if (!Number.isFinite(n)) throw new Error("Invalid amount"); - if (n < 0) throw new Error("Invalid amount"); + if (options.amount) { + const n = Number(options.amount); + if (!Number.isFinite(n)) throw new Error("Invalid amount"); + if (n < 0) throw new Error("Invalid amount"); + } return { scheme: urnScheme, address, options }; } -- cgit v1.2.3