change tests and nips to use the new api.

This commit is contained in:
fiatjaf
2023-12-19 13:49:03 -03:00
parent 1908e1ee0d
commit fe87529646
32 changed files with 151 additions and 163 deletions

View File

@@ -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)
}