From b49255d5ea8d49c8d17ecc62baf6b7440bfa70b1 Mon Sep 17 00:00:00 2001 From: Roland Bewick Date: Sun, 1 Sep 2024 14:04:25 +0700 Subject: [PATCH] feat: pass lud16 in URL --- src/NWCClient.test.ts | 3 ++- src/NWCClient.ts | 5 +++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/NWCClient.test.ts b/src/NWCClient.test.ts index 9a081db..c63dd2f 100644 --- a/src/NWCClient.test.ts +++ b/src/NWCClient.test.ts @@ -3,7 +3,7 @@ import { NWCClient } from "./NWCClient"; // this has no funds on it, I think ;-) const exampleNwcUrl = - "nostr+walletconnect://69effe7b49a6dd5cf525bd0905917a5005ffe480b58eeb8e861418cf3ae760d9?relay=wss://relay.getalby.com/v1&secret=e839faf78693765b3833027fefa5a305c78f6965d0a5d2e47a3fcb25aa7cc45b"; + "nostr+walletconnect://69effe7b49a6dd5cf525bd0905917a5005ffe480b58eeb8e861418cf3ae760d9?relay=wss://relay.getalby.com/v1&secret=e839faf78693765b3833027fefa5a305c78f6965d0a5d2e47a3fcb25aa7cc45b&lud16=hello@getalby.com"; describe("parseWalletConnectUrl", () => { test("standard protocol", () => { @@ -15,6 +15,7 @@ describe("parseWalletConnectUrl", () => { "e839faf78693765b3833027fefa5a305c78f6965d0a5d2e47a3fcb25aa7cc45b", ); expect(parsed.relayUrl).toBe("wss://relay.getalby.com/v1"); + expect(parsed.lud16).toBe("hello@getalby.com"); }); test("protocol without double slash", () => { const parsed = NWCClient.parseWalletConnectUrl( diff --git a/src/NWCClient.ts b/src/NWCClient.ts index efa10b6..d292c2f 100644 --- a/src/NWCClient.ts +++ b/src/NWCClient.ts @@ -152,6 +152,7 @@ export interface NWCOptions { relayUrl: string; walletPubkey: string; secret?: string; + lud16?: string; } export class Nip47Error extends Error { @@ -227,6 +228,10 @@ export class NWCClient { if (secret) { options.secret = secret; } + const lud16 = url.searchParams.get("lud16"); + if (lud16) { + options.lud16 = lud16; + } return options; }