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 axios, { AxiosInstance } from 'axios'
import { bech32 } from 'bech32'
import { Buffer } from 'buffer'
import { Filter, kinds } from 'nostr-tools'
import { requestProvider, SendPaymentResponse, WebLNProvider } from 'webln'
import {
@ -79,17 +77,10 @@ export class ZapController {
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
const zapRequest = await this.createZapRequest(
amount,
content,
lnurlBech32,
recipientPubKey,
senderPubkey,
eventId,
@ -122,7 +113,7 @@ export class ZapController {
// send zap request as GET request to callback url received from the lnurl pay endpoint
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
@ -271,7 +262,6 @@ export class ZapController {
* Constructs zap request object.
* @param amount - request amount (sats).
* @param content - comment.
* @param lnurl - lnurl pay endpoint.
* @param recipientPubKey - pubKey of the recipient.
* @param senderPubkey - pubKey of of the sender.
* @param eventId - event id, if zapping an event.
@ -281,7 +271,6 @@ export class ZapController {
private async createZapRequest(
amount: number,
content = '',
lnurl: string,
recipientPubKey: string,
senderPubkey: string,
eventId?: string,
@ -297,7 +286,6 @@ export class ZapController {
tags: [
['relays', `${this.appRelay}`],
['amount', `${amount}`],
['lnurl', lnurl],
['p', recipientHexKey]
],
pubkey: senderPubkey,

View File

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