Skip to content

Commit

Permalink
feat: pass lud16 in URL
Browse files Browse the repository at this point in the history
  • Loading branch information
rolznz committed Sep 1, 2024
1 parent 1cd2a46 commit b49255d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/NWCClient.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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&[email protected]";

describe("parseWalletConnectUrl", () => {
test("standard protocol", () => {
Expand All @@ -15,6 +15,7 @@ describe("parseWalletConnectUrl", () => {
"e839faf78693765b3833027fefa5a305c78f6965d0a5d2e47a3fcb25aa7cc45b",
);
expect(parsed.relayUrl).toBe("wss://relay.getalby.com/v1");
expect(parsed.lud16).toBe("[email protected]");
});
test("protocol without double slash", () => {
const parsed = NWCClient.parseWalletConnectUrl(
Expand Down
5 changes: 5 additions & 0 deletions src/NWCClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ export interface NWCOptions {
relayUrl: string;
walletPubkey: string;
secret?: string;
lud16?: string;
}

export class Nip47Error extends Error {
Expand Down Expand Up @@ -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;
}

Expand Down

0 comments on commit b49255d

Please sign in to comment.