Skip to content

Commit

Permalink
Merge pull request #1409 from SnowCait/auth-on-nwc
Browse files Browse the repository at this point in the history
AUTH on NWC
  • Loading branch information
SnowCait authored Sep 3, 2024
2 parents 8b59f4f + 05539d2 commit 5061602
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions web/src/lib/Zap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { get } from 'svelte/store';
import { _ } from 'svelte-i18n';
import { nip04 } from 'nostr-tools';
import { createRxForwardReq, createRxNostr } from 'rx-nostr';
import { seckeySigner } from 'rx-nostr-crypto';
import type { Event } from 'nostr-typedef';
import { makeNwcRequestEvent, parseConnectionString } from '$lib/nostr-tools/nip47';
import { verificationClient } from './timelines/MainTimeline';
Expand All @@ -12,17 +13,22 @@ export async function zapWithWalletConnect(uri: string, invoice: string): Promis
relay: walletRelay,
secret: walletSeckey
} = parseConnectionString(uri);
console.debug('[NWC info]', walletRelay, walletPubkey);
const event = await makeNwcRequestEvent(walletPubkey, walletSeckey, invoice);
console.debug('[NWC event]', event);

const nwcRxNostr = createRxNostr({ verifier: verificationClient.verifier });
const nwcRxNostr = createRxNostr({
verifier: verificationClient.verifier,
signer: seckeySigner(walletSeckey)
});
nwcRxNostr.setDefaultRelays([walletRelay]);

try {
const walletEvent = await new Promise<Event | null>((resolve, reject) => {
const nwcRxReq = createRxForwardReq();
nwcRxNostr.use(nwcRxReq).subscribe({
next: (packet) => {
console.log('[NWC]', packet);
console.log('[NWC success]', packet);
resolve(packet.event);
},
complete: () => {
Expand Down

0 comments on commit 5061602

Please sign in to comment.