diff --git a/nip57.test.ts b/nip57.test.ts index 465ff2c..a5608ac 100644 --- a/nip57.test.ts +++ b/nip57.test.ts @@ -242,10 +242,11 @@ describe('validateZapRequest', () => { }) describe('makeZapReceipt', () => { - test('returns a valid Zap receipt with a preimage', () => { - const privateKey = generateSecretKey() - const publicKey = getPublicKey(privateKey) + const privateKey = generateSecretKey() + const publicKey = getPublicKey(privateKey) + const target = 'efeb5d6e74ce6ffea6cae4094a9f29c26b5c56d7b44fae9f490f3410fd708c45' + test('returns a valid Zap receipt with a preimage', () => { const zapRequest = JSON.stringify( finalizeEvent( { @@ -253,7 +254,7 @@ describe('makeZapReceipt', () => { created_at: Date.now() / 1000, content: 'content', tags: [ - ['p', publicKey], + ['p', target], ['amount', '100'], ['relays', 'relay1', 'relay2'], ], @@ -274,16 +275,14 @@ describe('makeZapReceipt', () => { expect.arrayContaining([ ['bolt11', bolt11], ['description', zapRequest], - ['p', publicKey], + ['p', target], + ['P', publicKey], ['preimage', preimage], ]), ) }) test('returns a valid Zap receipt without a preimage', () => { - const privateKey = generateSecretKey() - const publicKey = getPublicKey(privateKey) - const zapRequest = JSON.stringify( finalizeEvent( { @@ -291,7 +290,7 @@ describe('makeZapReceipt', () => { created_at: Date.now() / 1000, content: 'content', tags: [ - ['p', publicKey], + ['p', target], ['amount', '100'], ['relays', 'relay1', 'relay2'], ], @@ -311,7 +310,8 @@ describe('makeZapReceipt', () => { expect.arrayContaining([ ['bolt11', bolt11], ['description', zapRequest], - ['p', publicKey], + ['p', target], + ['P', publicKey], ]), ) expect(JSON.stringify(result.tags)).not.toContain('preimage') diff --git a/nip57.ts b/nip57.ts index 0770007..b8c9a2e 100644 --- a/nip57.ts +++ b/nip57.ts @@ -119,7 +119,7 @@ export function makeZapReceipt({ kind: 9735, created_at: Math.round(paidAt.getTime() / 1000), content: '', - tags: [...tagsFromZapRequest, ['bolt11', bolt11], ['description', zapRequest]], + tags: [...tagsFromZapRequest, ['P', zr.pubkey], ['bolt11', bolt11], ['description', zapRequest]], } if (preimage) { diff --git a/package.json b/package.json index 5e0938f..3d8a9f1 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "type": "module", "name": "nostr-tools", - "version": "2.1.1", + "version": "2.1.2", "description": "Tools for making a Nostr client.", "repository": { "type": "git",