From ec24841f4ad6cd71ccca42dec18bad0c07d81a64 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 16 Sep 2024 11:19:05 +0000 Subject: [PATCH 1/3] Bump @types/eccrypto from 1.1.3 to 1.1.6 Bumps [@types/eccrypto](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/eccrypto) from 1.1.3 to 1.1.6. - [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases) - [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/eccrypto) --- updated-dependencies: - dependency-name: "@types/eccrypto" dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- package-lock.json | 8 ++++---- package.json | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/package-lock.json b/package-lock.json index 258d3a06..dda95d2c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -52,7 +52,7 @@ "@types/chai": "^4.3.4", "@types/chai-string": "^1.4.5", "@types/cors": "^2.8.17", - "@types/eccrypto": "^1.1.3", + "@types/eccrypto": "^1.1.6", "@types/jsonwebtoken": "^9.0.6", "@types/lodash": "^4.14.182", "@types/node": "^16.11.10", @@ -567,9 +567,9 @@ } }, "node_modules/@types/eccrypto": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/@types/eccrypto/-/eccrypto-1.1.3.tgz", - "integrity": "sha512-3O0qER6JMYReqVbcQTGmXeMHdw3O+rVps63tlo5g5zoB3altJS8yzSvboSivwVWeYO9o5jSATu7P0UIqYZPgow==", + "version": "1.1.6", + "resolved": "https://registry.npmjs.org/@types/eccrypto/-/eccrypto-1.1.6.tgz", + "integrity": "sha512-rsmcX5LdDZ3xN2W3al6+YR+XNmiQWlXSwVhsU184QOwNQNJ83YpwvAt8a7cT7y3RpVWkKWmXoIFdanI/z38rNQ==", "dev": true, "dependencies": { "@types/expect": "^1.20.4", diff --git a/package.json b/package.json index d2123f6f..4538fb19 100644 --- a/package.json +++ b/package.json @@ -68,7 +68,7 @@ "@types/chai": "^4.3.4", "@types/chai-string": "^1.4.5", "@types/cors": "^2.8.17", - "@types/eccrypto": "^1.1.3", + "@types/eccrypto": "^1.1.6", "@types/jsonwebtoken": "^9.0.6", "@types/lodash": "^4.14.182", "@types/node": "^16.11.10", From d3212974809efb2d171a20f9722a5fa6ff1da8a9 Mon Sep 17 00:00:00 2001 From: boufni95 Date: Tue, 1 Oct 2024 15:00:26 +0000 Subject: [PATCH 2/3] pending payment from hash --- src/services/lnd/lnd.ts | 21 ++++++++++++++++++++- src/services/main/paymentManager.ts | 23 +++++------------------ 2 files changed, 25 insertions(+), 19 deletions(-) diff --git a/src/services/lnd/lnd.ts b/src/services/lnd/lnd.ts index 2d445d07..0cf25ba9 100644 --- a/src/services/lnd/lnd.ts +++ b/src/services/lnd/lnd.ts @@ -14,7 +14,7 @@ import { AddInvoiceReq } from './addInvoiceReq.js'; import { PayInvoiceReq } from './payInvoiceReq.js'; import { SendCoinsReq } from './sendCoinsReq.js'; import { LndSettings, AddressPaidCb, InvoicePaidCb, NodeInfo, Invoice, DecodedInvoice, PaidInvoice, NewBlockCb, HtlcCb, BalanceInfo } from './settings.js'; -import { getLogger } from '../helpers/logger.js'; +import { ERROR, getLogger } from '../helpers/logger.js'; import { HtlcEvent_EventType } from '../../../proto/lnd/router.js'; import { LiquidityProvider, LiquidityRequest } from '../main/liquidityProvider.js'; import { Utils } from '../helpers/utilsWrapper.js'; @@ -464,6 +464,25 @@ export default class { return res.response } + async GetPaymentFromHash(paymentHash: string): Promise { + const abortController = new AbortController() + const stream = this.router.trackPaymentV2({ + paymentHash: Buffer.from(paymentHash, 'hex'), + noInflightUpdates: false + }, { abort: abortController.signal }) + return new Promise((res, rej) => { + stream.responses.onError(error => { + this.log(ERROR, "error with trackPaymentV2", error.message) + rej(null) + }) + stream.responses.onMessage(payment => { + abortController.abort() + res(payment) + }) + }) + + } + async ListPeers() { const res = await this.lightning.listPeers({ latestError: true }, DeadLineMetadata()) return res.response diff --git a/src/services/main/paymentManager.ts b/src/services/main/paymentManager.ts index 4e0723c0..b6e30a72 100644 --- a/src/services/main/paymentManager.ts +++ b/src/services/main/paymentManager.ts @@ -6,7 +6,7 @@ import { MainSettings } from './settings.js' import { InboundOptionals, defaultInvoiceExpiry } from '../storage/paymentStorage.js' import LND from '../lnd/lnd.js' import { Application } from '../storage/entity/Application.js' -import { getLogger, PubLogger } from '../helpers/logger.js' +import { ERROR, getLogger, PubLogger } from '../helpers/logger.js' import { UserReceivingAddress } from '../storage/entity/UserReceivingAddress.js' import { AddressPaidCb, InvoicePaidCb, PaidInvoice } from '../lnd/settings.js' import { UserReceivingInvoice, ZapInfo } from '../storage/entity/UserReceivingInvoice.js' @@ -124,23 +124,10 @@ export default class { } checkPendingLndPayment = async (log: PubLogger, p: UserInvoicePayment) => { - if (p.paymentIndex === 0 || p.paymentIndex === -1) { - log("found a pending payment with no payment index, skipping", p.serial_id) - //const fullAmount = p.paid_amount + p.service_fees + p.routing_fees - //log("found a pending payment with no payment index, refunding", fullAmount, "sats to user", p.user.user_id) - //await this.storage.txQueue.PushToQueue({ - // dbTx: true, description: "refund failed pending payment", exec: async tx => { - // await this.storage.userStorage.IncrementUserBalance(p.user.user_id, fullAmount, "payment_refund:" + p.invoice, tx) - // await this.storage.paymentStorage.UpdateExternalPayment(p.serial_id, 0, 0, false) - // } - //}) - return - } - console.log({ p }) - const paymentRes = await this.lnd.GetPayment(p.paymentIndex) - const payment = paymentRes.payments[0] - if (!payment || Number(payment.paymentIndex) !== p.paymentIndex) { - log("lnd payment not found for pending payment", p.serial_id, "with index", p.paymentIndex) + const decoded = await this.lnd.DecodeInvoice(p.invoice) + const payment = await this.lnd.GetPaymentFromHash(decoded.paymentHash) + if (!payment || payment.paymentHash !== decoded.paymentHash) { + log(ERROR, "lnd payment not found for pending payment hash ", decoded.paymentHash) return } From 499f3e622bced6deb832bfd2e719bc0ba4640ce2 Mon Sep 17 00:00:00 2001 From: "Justin (shocknet)" <34176400+shocknet-justin@users.noreply.github.com> Date: Wed, 2 Oct 2024 15:43:22 -0400 Subject: [PATCH 3/3] Update dependabot.yml --- .github/dependabot.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 5f0889ce..9a3fe1e8 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -9,3 +9,4 @@ updates: directory: "/" # Location of package manifests schedule: interval: "weekly" + branch: "test"