aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2025-02-03 20:57:19 -0800
committerAdam Soltys <[email protected]>2025-02-03 20:57:19 -0800
commit28ac62e751bb8cc70d240e2e460c9b50d11fc0d2 (patch)
tree880e40f9dfb0ab712f736fcd804d6aa2d0de8e63 /src
parent0fecfc762a11f0a5a96a398ca2e55574c0a72d6a (diff)
downloadcoinos-ui-28ac62e751bb8cc70d240e2e460c9b50d11fc0d2.tar.gz
coinos-ui-28ac62e751bb8cc70d240e2e460c9b50d11fc0d2.zip
fix bip21 parse without amount
Diffstat (limited to 'src')
-rw-r--r--src/lib/bip21.ts8
1 files changed, 5 insertions, 3 deletions
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 };
}