Skip to content

Commit

Permalink
Merge pull request #244 from getAlby/chore/nwc-client-lud16
Browse files Browse the repository at this point in the history
chore: add lud16 property to nwc client
  • Loading branch information
rolznz authored Sep 1, 2024
2 parents a7085cd + 08205d0 commit 9b5b65c
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/NWCClient.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,17 @@ describe("parseWalletConnectUrl", () => {
expect(parsed.relayUrl).toBe("wss://relay.getalby.com/v1");
});
});

describe("NWCClient", () => {
test("standard protocol", () => {
const nwcClient = new NWCClient({ nostrWalletConnectUrl: exampleNwcUrl });
expect(nwcClient.walletPubkey).toBe(
"69effe7b49a6dd5cf525bd0905917a5005ffe480b58eeb8e861418cf3ae760d9",
);
expect(nwcClient.secret).toBe(
"e839faf78693765b3833027fefa5a305c78f6965d0a5d2e47a3fcb25aa7cc45b",
);
expect(nwcClient.lud16).toBe("hello@getalby.com");
expect(nwcClient.options.lud16).toBe("hello@getalby.com");
});
});
2 changes: 2 additions & 0 deletions src/NWCClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,7 @@ export class NWCClient {
relay: Relay;
relayUrl: string;
secret: string | undefined;
lud16: string | undefined;
walletPubkey: string;
options: NWCOptions;

Expand Down Expand Up @@ -264,6 +265,7 @@ export class NWCClient {
: this.options.secret
) as string;
}
this.lud16 = this.options.lud16;
this.walletPubkey = (
this.options.walletPubkey.toLowerCase().startsWith("npub")
? nip19.decode(this.options.walletPubkey).data
Expand Down

0 comments on commit 9b5b65c

Please sign in to comment.