From ade165aed16e09fd22463cb71e800a630208ab8b Mon Sep 17 00:00:00 2001 From: boufni95 Date: Thu, 18 Dec 2025 21:22:59 +0000 Subject: [PATCH] fix --- src/services/lnd/lnd.ts | 6 +++--- src/services/main/paymentManager.ts | 2 +- src/tests/liquidityProvider.spec.ts | 2 +- src/tests/testBase.ts | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/services/lnd/lnd.ts b/src/services/lnd/lnd.ts index e3a5fe2f..07cd8750 100644 --- a/src/services/lnd/lnd.ts +++ b/src/services/lnd/lnd.ts @@ -425,7 +425,7 @@ export default class { const r = res.response return { local: r.localBalance ? Number(r.localBalance.sat) : 0, remote: r.remoteBalance ? Number(r.remoteBalance.sat) : 0 } } - async PayInvoice(invoice: string, amount: number, feeLimit: number, decodedAmount: number, { useProvider, from }: TxActionOptions, paymentIndexCb?: (index: number) => void): Promise { + async PayInvoice(invoice: string, amount: number, { routingFeeLimit, serviceFee }: { routingFeeLimit: number, serviceFee: number }, decodedAmount: number, { useProvider, from }: TxActionOptions, paymentIndexCb?: (index: number) => void): Promise { // console.log("Paying invoice") if (this.outgoingOpsLocked) { this.log("outgoing ops locked, rejecting payment request") @@ -434,14 +434,14 @@ export default class { // Force use of provider when bypass is enabled const mustUseProvider = this.liquidProvider.getSettings().useOnlyLiquidityProvider || useProvider if (mustUseProvider) { - const res = await this.liquidProvider.PayInvoice(invoice, decodedAmount, from, feeLimit) + const res = await this.liquidProvider.PayInvoice(invoice, decodedAmount, from, serviceFee) const providerDst = this.liquidProvider.GetProviderDestination() return { feeSat: res.service_fee, valueSat: res.amount_paid, paymentPreimage: res.preimage, providerDst } } await this.Health() try { const abortController = new AbortController() - const req = PayInvoiceReq(invoice, amount, feeLimit) + const req = PayInvoiceReq(invoice, amount, routingFeeLimit) const stream = this.router.sendPaymentV2(req, { abort: abortController.signal }) return new Promise((res, rej) => { stream.responses.onError(error => { diff --git a/src/services/main/paymentManager.ts b/src/services/main/paymentManager.ts index e902078c..d2e9c5b3 100644 --- a/src/services/main/paymentManager.ts +++ b/src/services/main/paymentManager.ts @@ -383,7 +383,7 @@ export default class { const op = this.newInvoicePaymentOperation({ invoice, opId, amount: payAmount, networkFee: 0, serviceFee: serviceFee, confirmed: false }) optionals.ack?.(op) try { - const payment = await this.lnd.PayInvoice(invoice, amountForLnd, routingFeeLimit, payAmount, { useProvider: use === 'provider', from: 'user' }, index => { + const payment = await this.lnd.PayInvoice(invoice, amountForLnd, { routingFeeLimit, serviceFee }, payAmount, { useProvider: use === 'provider', from: 'user' }, index => { this.storage.paymentStorage.SetExternalPaymentIndex(pendingPayment.serial_id, index) }) await this.storage.paymentStorage.UpdateExternalPayment(pendingPayment.serial_id, payment.feeSat, serviceFee, true, payment.providerDst) diff --git a/src/tests/liquidityProvider.spec.ts b/src/tests/liquidityProvider.spec.ts index ad3685b7..460969da 100644 --- a/src/tests/liquidityProvider.spec.ts +++ b/src/tests/liquidityProvider.spec.ts @@ -23,7 +23,7 @@ const testInboundPaymentFromProvider = async (T: TestBase, bootstrapped: Main, b T.d("starting testInboundPaymentFromProvider") const invoiceRes = await bootstrapped.appUserManager.NewInvoice({ app_id: bUser.appId, user_id: bUser.userId, app_user_id: bUser.appUserIdentifier }, { amountSats: 3000, memo: "liquidityTest" }) - await T.externalAccessToOtherLnd.PayInvoice(invoiceRes.invoice, 0, 100, 3000, { from: 'system', useProvider: false }) + await T.externalAccessToOtherLnd.PayInvoice(invoiceRes.invoice, 0, { routingFeeLimit: 100, serviceFee: 100 }, 3000, { from: 'system', useProvider: false }) await new Promise((resolve) => setTimeout(resolve, 200)) const userBalance = await bootstrapped.appUserManager.GetUserInfo({ app_id: bUser.appId, user_id: bUser.userId, app_user_id: bUser.appUserIdentifier }) T.expect(userBalance.balance).to.equal(3000) diff --git a/src/tests/testBase.ts b/src/tests/testBase.ts index 9719e15e..791bb6ce 100644 --- a/src/tests/testBase.ts +++ b/src/tests/testBase.ts @@ -121,7 +121,7 @@ export const teardown = async (T: TestBase) => { export const safelySetUserBalance = async (T: TestBase, user: TestUserData, amount: number) => { const app = await T.main.storage.applicationStorage.GetApplication(user.appId) const invoice = await T.main.paymentManager.NewInvoice(user.userId, { amountSats: amount, memo: "test" }, { linkedApplication: app, expiry: defaultInvoiceExpiry }) - await T.externalAccessToOtherLnd.PayInvoice(invoice.invoice, 0, 100, amount, { from: 'system', useProvider: false }) + await T.externalAccessToOtherLnd.PayInvoice(invoice.invoice, 0, { routingFeeLimit: 100, serviceFee: 100 }, amount, { from: 'system', useProvider: false }) const u = await T.main.storage.userStorage.GetUser(user.userId) expect(u.balance_sats).to.be.equal(amount) T.d(`user ${user.appUserIdentifier} balance is now ${amount}`)