fix: removed removed optional lnurl from tags of payment zap request

This commit is contained in:
daniyal 2024-08-13 18:13:30 +05:00
parent 51bd5a4d5e
commit ff737e5486
2 changed files with 1 additions and 15 deletions

View File

@ -1,7 +1,5 @@
import { Invoice } from '@getalby/lightning-tools' import { Invoice } from '@getalby/lightning-tools'
import axios, { AxiosInstance } from 'axios' import axios, { AxiosInstance } from 'axios'
import { bech32 } from 'bech32'
import { Buffer } from 'buffer'
import { Filter, kinds } from 'nostr-tools' import { Filter, kinds } from 'nostr-tools'
import { requestProvider, SendPaymentResponse, WebLNProvider } from 'webln' import { requestProvider, SendPaymentResponse, WebLNProvider } from 'webln'
import { import {
@ -79,17 +77,10 @@ export class ZapController {
throw `Amount '${amount}' is not within minSendable and maxSendable values '${minSendable}-${maxSendable}'.` throw `Amount '${amount}' is not within minSendable and maxSendable values '${minSendable}-${maxSendable}'.`
} }
// encode lnurl into bech32 using lnurl prefix
const lnurlBech32 = bech32.encode(
'lnurl',
bech32.toWords(Buffer.from(lnurl, 'utf8'))
)
// generate zap request // generate zap request
const zapRequest = await this.createZapRequest( const zapRequest = await this.createZapRequest(
amount, amount,
content, content,
lnurlBech32,
recipientPubKey, recipientPubKey,
senderPubkey, senderPubkey,
eventId, eventId,
@ -122,7 +113,7 @@ export class ZapController {
// send zap request as GET request to callback url received from the lnurl pay endpoint // send zap request as GET request to callback url received from the lnurl pay endpoint
const { data } = await this.httpClient.get( const { data } = await this.httpClient.get(
`${callback}?amount=${amount}&nostr=${encodedEvent}&lnurl=${lnurlBech32}` `${callback}?amount=${amount}&nostr=${encodedEvent}`
) )
// data object of the response should contain payment request // data object of the response should contain payment request
@ -271,7 +262,6 @@ export class ZapController {
* Constructs zap request object. * Constructs zap request object.
* @param amount - request amount (sats). * @param amount - request amount (sats).
* @param content - comment. * @param content - comment.
* @param lnurl - lnurl pay endpoint.
* @param recipientPubKey - pubKey of the recipient. * @param recipientPubKey - pubKey of the recipient.
* @param senderPubkey - pubKey of of the sender. * @param senderPubkey - pubKey of of the sender.
* @param eventId - event id, if zapping an event. * @param eventId - event id, if zapping an event.
@ -281,7 +271,6 @@ export class ZapController {
private async createZapRequest( private async createZapRequest(
amount: number, amount: number,
content = '', content = '',
lnurl: string,
recipientPubKey: string, recipientPubKey: string,
senderPubkey: string, senderPubkey: string,
eventId?: string, eventId?: string,
@ -297,7 +286,6 @@ export class ZapController {
tags: [ tags: [
['relays', `${this.appRelay}`], ['relays', `${this.appRelay}`],
['amount', `${amount}`], ['amount', `${amount}`],
['lnurl', lnurl],
['p', recipientHexKey] ['p', recipientHexKey]
], ],
pubkey: senderPubkey, pubkey: senderPubkey,

View File

@ -7,7 +7,6 @@ export interface LnurlResponse {
minSendable: number minSendable: number
maxSendable: number maxSendable: number
commentAllowed: number commentAllowed: number
payerData: { [key: string]: { [key: string]: boolean } }
tag: string tag: string
nostrPubkey: string nostrPubkey: string
allowsNostr: boolean allowsNostr: boolean
@ -20,7 +19,6 @@ export const isLnurlResponse = (obj: any): obj is LnurlResponse =>
'minSendable' in obj && 'minSendable' in obj &&
'maxSendable' in obj && 'maxSendable' in obj &&
'commentAllowed' in obj && 'commentAllowed' in obj &&
'payerData' in obj &&
'tag' in obj && 'tag' in obj &&
'nostrPubkey' in obj && 'nostrPubkey' in obj &&
'allowsNostr' in obj 'allowsNostr' in obj