Skip to content

Commit ad980aa

Browse files
authored
Merge pull request #438 from getAlby/fix/bip21-lightning-parsing
fix: bip21 lightning param parsing without address
2 parents 613dc04 + 2b8258f commit ad980aa

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

lib/initiatePaymentFlow.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ export async function initiatePaymentFlow(
1515

1616
try {
1717
if (text.startsWith("bitcoin:")) {
18-
const universalUrl = text.replace("bitcoin:", "http://");
19-
const url = new URL(universalUrl);
20-
const lightningParam = url.searchParams.get("lightning");
18+
const bip21 = text.slice("bitcoin:".length);
19+
const query = bip21.includes("?") ? bip21.split("?")[1] : "";
20+
const lightningParam = new URLSearchParams(query).get("lightning");
2121
if (!lightningParam) {
2222
throw new Error("No lightning param found in bitcoin payment link");
2323
}

0 commit comments

Comments
 (0)