mirror of
https://github.com/nbd-wtf/nostr-tools.git
synced 2025-12-08 16:28:49 +00:00
change tests and nips to use the new api.
This commit is contained in:
16
nip47.ts
16
nip47.ts
@@ -1,4 +1,4 @@
|
||||
import { finishEvent } from './event.ts'
|
||||
import { finalizeEvent } from './pure.ts'
|
||||
import { NWCWalletRequest } from './kinds.ts'
|
||||
import { encrypt } from './nip04.ts'
|
||||
|
||||
@@ -15,22 +15,14 @@ export function parseConnectionString(connectionString: string) {
|
||||
return { pubkey, relay, secret }
|
||||
}
|
||||
|
||||
export async function makeNwcRequestEvent({
|
||||
pubkey,
|
||||
secret,
|
||||
invoice,
|
||||
}: {
|
||||
pubkey: string
|
||||
secret: string
|
||||
invoice: string
|
||||
}) {
|
||||
export async function makeNwcRequestEvent(pubkey: string, secretKey: Uint8Array, invoice: string) {
|
||||
const content = {
|
||||
method: 'pay_invoice',
|
||||
params: {
|
||||
invoice,
|
||||
},
|
||||
}
|
||||
const encryptedContent = await encrypt(secret, pubkey, JSON.stringify(content))
|
||||
const encryptedContent = await encrypt(secretKey, pubkey, JSON.stringify(content))
|
||||
const eventTemplate = {
|
||||
kind: NWCWalletRequest,
|
||||
created_at: Math.round(Date.now() / 1000),
|
||||
@@ -38,5 +30,5 @@ export async function makeNwcRequestEvent({
|
||||
tags: [['p', pubkey]],
|
||||
}
|
||||
|
||||
return finishEvent(eventTemplate, secret)
|
||||
return finalizeEvent(eventTemplate, secretKey)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user