From d105925c73cda05b80f451fa184b960e52813f86 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Francisco=20Calder=C3=B3n?= Date: Thu, 29 Aug 2024 11:01:32 -0300 Subject: [PATCH] Revert "Remove the lightning prefix from the lnInvoice (#572)" (#576) This reverts commit 5ae85c690f8389364e17adc3798821d01a3efd0f. --- bot/commands.js | 4 +--- bot/validations.ts | 9 ++------- util/valitationUtils.ts | 11 ----------- 3 files changed, 3 insertions(+), 21 deletions(-) delete mode 100644 util/valitationUtils.ts diff --git a/bot/commands.js b/bot/commands.js index 099aa3cc..98d09b65 100644 --- a/bot/commands.js +++ b/bot/commands.js @@ -21,7 +21,6 @@ const OrderEvents = require('./modules/events/orders'); const { resolvLightningAddress } = require('../lnurl/lnurl-pay'); const { logger } = require('../logger'); -const { removeLightningPrefix } = require('../util/valitationUtils'); const waitPayment = async (ctx, bot, buyer, seller, order, buyerInvoice) => { try { @@ -33,8 +32,7 @@ const waitPayment = async (ctx, bot, buyer, seller, order, buyerInvoice) => { return; } - // ISSUE: 542 - order.buyer_invoice = removeLightningPrefix(buyerInvoice); + order.buyer_invoice = buyerInvoice; // We need the i18n context to send the message with the correct language const i18nCtx = await getUserI18nContext(seller); // If the buyer is the creator, at this moment the seller already paid the hold invoice diff --git a/bot/validations.ts b/bot/validations.ts index 28a0a55c..36e1734a 100644 --- a/bot/validations.ts +++ b/bot/validations.ts @@ -12,7 +12,6 @@ import { Order, User, Community } from '../models'; import { isIso4217, isDisputeSolver } from '../util'; const { existLightningAddress } = require('../lnurl/lnurl-pay'); import { logger } from '../logger'; -import { removeLightningPrefix } from '../util/valitationUtils'; // We look in database if the telegram user exists, // if not, it creates a new user @@ -327,9 +326,7 @@ const validateLightningAddress = async (lightningAddress: string) => { const validateInvoice = async (ctx: MainContext, lnInvoice: string) => { try { - // ISSUE: 542 - const checkedPrefixlnInvoice = removeLightningPrefix(lnInvoice); - const invoice = parsePaymentRequest({ request: checkedPrefixlnInvoice }); + const invoice = parsePaymentRequest({ request: lnInvoice }); const latestDate = new Date( Date.now() + Number(process.env.INVOICE_EXPIRATION_WINDOW) ); @@ -369,9 +366,7 @@ const validateInvoice = async (ctx: MainContext, lnInvoice: string) => { const isValidInvoice = async (ctx: MainContext, lnInvoice: string) => { try { - // ISSUE: 542 - const checkedPrefixlnInvoice = removeLightningPrefix(lnInvoice); - const invoice = parsePaymentRequest({ request: checkedPrefixlnInvoice }); + const invoice = parsePaymentRequest({ request: lnInvoice }); const latestDate = new Date( Date.now() + Number(process.env.INVOICE_EXPIRATION_WINDOW) ).toISOString(); diff --git a/util/valitationUtils.ts b/util/valitationUtils.ts deleted file mode 100644 index 39e887ae..00000000 --- a/util/valitationUtils.ts +++ /dev/null @@ -1,11 +0,0 @@ -export const removeLightningPrefix = (invoice: string): string => { - const prefix = 'lightning:'; - - // Check if the invoice starts with the prefix - if (invoice.startsWith(prefix)) { - return invoice.substring(prefix.length); - } - - // Return the invoice as is if no prefix is found - return invoice; -};